www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on May 25, 2012, 01:35:03 pm
-
I have problem with objects without culling. I'm using shader for calculating per-pixel lighting. When I disable culling, normals are still same, so lighting is "bad" from other side. Is there any simple and fast solution? or is better to use two triangle for each side?
-
Is there any simple and fast solution? or is better to use two triangle for each side?
None that i know of. You could invert the normal in the shader, but i've no idea how to detect if this is needed.
-
OK, so I will copy triangles to both side, that will be the simplest solution for me
-
I solved the problem. For calculating dot product of normal and light direction is using max from dot and 0 for "dark to light" shading
max(dot(normal, lightVector), 0.0);
If you replace above mentioned by this one, lighting is good from both side... get "light - dark - light" shading
abs(dot(normal, lightVector));
EDIT: this of course not working in camera - plane - light case. In theory, it will probably needs camera-vertex dot and check it with normal-light dot...?