This gives correct two-sided lighting for non-closed meshes, which may
be used for tree leaves and such.
virtual vec3 get_fragment_normal()
{
+ vec3 normal;
+ float sgn = (gl_FrontFacing ? 1.0 : -1.0);
if(use_normal_map)
- return normalize(world_tbn_matrix*(texture(normal_map, texcoord.xy).xyz*2.0-1.0));
+ return sgn*normalize(world_tbn_matrix*(texture(normal_map, texcoord.xy).xyz*2.0-1.0));
else
- return normalize(world_normal);
+ return sgn*normalize(world_normal);
}
virtual IncomingLight get_incoming_light(int index, vec3 world_pos)