Page MenuHome

Fix GLSL shading for Backfaces in 3Dview and BGE
Closed, ResolvedPublicPATCH

Description

Hi,
When GLSL mode is able all faces in 3D view texture mode have backface and it's faces have a inverted solution for normals
witch make strange results in the shading of the object. This patch fix this problem inverting the normal of the fragment
if it's a backface. It works as well in BGE when backface culling in material is unchecked.
here is a example before and after the patch marge in trunk (blender 2.64)
http://www.pasteall.org/pic/38473

Cheers,
Vitor Balbio

Event Timeline

I haven't looked at the patch yet, but it looks like it is related to this bug report:
http://projects.blender.org/tracker/?group_id=9&atid=306&func=detail&aid=23382

Wow, that patch was a lot smaller than I was expecting. It looks good to me, but I'm assigning this to Brecht for final review/okay.

I just went and double checked, and gl_FrontFacing is still good for GL 3 (in other words, it's not deprecated).

I hope it can help and go to the trunk =)
About gl_FrontFacing it's in OpenGL 3.2 Quick Refence Card.
http://www.khronos.org/files/opengl-quick-reference-card.pdf

A fix like this is fine with me, but note there a 3 commentes about a negated normal in the shader, all cases should be fixed. I'm also not sure how this interacts with tangent space normal mapping, that should be checked as well.

Fixed bug with tangent space normal maps. I can't find any other bad implications for viewport and BGE, can someone confirm it's ok now?

A picture:
http://www.pasteall.org/pic/53992

and a .blend for test:
http://www.pasteall.org/blend/22274

Hope it's ok now =)

Fix committed to svn now, thanks for the patch! I started from your code but noticed normal maps still weren't quite displaying right, and Cycles GLSL also still had the issue. So I changed the patch to flip the normal earlier so it affects all functions and not just the two.

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Resolved.Jun 24 2013, 3:46 PM

Nice, i'm glad to help =)