Shadow through partial transparent objects

Hello. I’m sure the topic was raised here before like here Can't make transparent objects receive pssm shadows properly - #37 by nehon but I’m confused.

What I have are 3 objects with transparent “holes” in it and each of the 3 object should cast a shadow through the “holes”. I think I need to add the alpha discard threshold?

What are the PostShadow and PreShadow for?

Sorry for the noob-questions.

terrain-hole-shadow-example-1

Interesting. I fixed the texture coordinates on the west/east/south/north sides and the shadow is now there :slight_smile:

Correct texture coordinates are important for shadow? Ok, learned something.

terrain-hole-shadow-example-2

Texture coordinates shouldn’t affect shadows unless that shadows are passing through transparent parts of the texture… but even still, what’s visually displayed will be what’s used for shadows unless something else is very strange.

I suspect something else changed or there is another problem that only crops up randomly.

You were right. I changed the thickness of the layers from 0.5 to 1.0 and forget to adjust the y coordinate, so that actually the 2. layer was inside the 1. and the 3. inside the 2. I guess it wasn’t a shadow what I saw.

So, back to my original question. The 1. layer is casting a nice shadow into the hole. How can I get the 2. layer also cast a shadow onto the 3. layer?

It’s tough for us to debug your code from here. You may have to put together simple test case that illustrates the problem.

99% of the time the simple test case will work find and then you can work out what’s different. The other 1% of the time you have something to post that lets us help.

Edit: but just looking at your picture, the geometry looks flat. You may have to show multiple views to prove to us that it isn’t. And are the holes actual holes in the geometry or holes in your texture… if they are holes in your texture then render order becomes super important and maybe you need alpha discard.

…all things that seeing a simple test case would have shown us, too.

1 Like

To provide a test case I need to generalize it first. Currently, it’s integrated with resources loading and multiple maven modules, etc. I can do that tomorrow.

And are the holes actual holes in the geometry or holes in your texture…

Not holes in the geometry. Those are transparent patches in a texture.

I’m using terrain splatting like JMoney-Terrain. The terrain map is a 8x8 pixels texture that codes what kind of terrain texture the quad should use. Around is dirt texture, in the middle is transparent texture. Those are 3 terrains on top of teach other., each with their own 8x8 pixels texture map.

Shadows use the z-buffer. Your transparent textures don’t look transparent to the z-buffer if you haven’t set alpha discard.

1 Like