Offline / Send Message
I'm using Shader Forge in Unity to make a shader for translucent cloth. But I can't figure out how to get shadows to show on the back side of the surface.

I did this a few years ago in a custom game engine. It worked great, but the shader was done under-the-hood, not exposed to me. http://wiki.polycount.com/wiki/Normal_map#Back_Lighting_Example

Shader is on the middle quad here. N dot L is working fine, at least for the front faces.

I tried inverting the normal, and now the backside of the quad is lit. But the shadow is not visible on the backfaces.

Also the unlit part of the shadow-casting long box is showing through the backfaces of the quad.

If I 1-minus the Light Attenuation, the shadow is merely inverted (shadows are white, lit parts are black). The shadow direction is not inverted.

## Replies

• Offline / Send Message
Sounds like I might need to rotate the Light Attenuation vector 180 degrees.

Apparently there's no node for rotating a vector...

... but maybe I can use the uv Rotator.
• Offline / Send Message
Nope, rotating it via Rotator doesn't seem to transform the shadowing direction, instead it just inverts the values again. I'm probably not using it right though, kind of shooting in the dark here.

• Offline / Send Message
Trying to understand how Dot Product works. Shader Forge documentation says:
If they point in the same direction, it outputs 1, if they are perpendicular to each other, it outputs 0, if they point in opposite directions, it outputs -1.
But that doesn't make sense if I draw it out as a diagram:

White = 1, black = 0, and I would think black also = -1. ??
• Offline / Send Message
ngon master
To flip the light direction, try multiplying it by -1. You could rotate a vector by multiplying it with an another vector. I'm not sure if this will result shadows on the back faces though.
• Offline / Send Message
Yeah tried flipping the light direction. I kind of knew it wouldn't work anyhow, since I still need the shadow-casting to come from the same direction as the light.

Multiplying one vector with another, interesting! I guess times -1?
• Offline / Send Message
(LightDir.Normal) + (LightDir. -Normal) I think.. Maybe?
This is basically transmittance I think. But Im not in front of a shader editor. I could check tomorrow
• Offline / Send Message
Hey that kind of makes sense. I'll try this out.
• Offline / Send Message
polycounter lvl 3
I'm not sure I'm right but I think Light Direction should be from the surface to the light.
The shader forge definition of a dot product is accurate.
• Offline / Send Message
null
Hi,I've been something in something like you recently.But there is no good way.I saw http://wiki.polycount.com/wiki/Normal_map#Back_Lighting_Example

I think he did not use the shader to make the backlight.But through the normal map to achieve,Or modify the vertex normals。I tried it and he should be able to work.But the backlight is only suitable for appearing on the Z axis。X or Y backlight can only be displayed in one direction, the other direction can not work.

• Offline / Send Message
That's my example too!

The backlight works from all angles. It is blending two materials... one is lit same direction as light and shows a regular leaf texture, the other material is lit the inverse direction (inverted normal map) and shows an under-leaf texture.

However, my original problem has to do with self-shadowing. I did not solve this in Unity.
• Offline / Send Message
triangle
Can't you just take the absolute value from the dot product node so the front and back shade the same?
• Offline / Send Message
triangle

this works. just tested it.
• Offline / Send Message
null

haha .Today solved some problems.Now the effect is not bad