Bug 28577 - Incorrect specular highlights on backfaces
Summary: Incorrect specular highlights on backfaces
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 17:36 UTC by Tim Evans
Modified: 2010-06-21 16:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Test code that reproduces the problem (2.41 KB, text/plain)
2010-06-16 17:36 UTC, Tim Evans
Details
Patch against mesa-7.8.2 that fixes this problem (447 bytes, patch)
2010-06-17 19:42 UTC, Tim Evans
Details | Splinter Review

Description Tim Evans 2010-06-16 17:36:48 UTC
Created attachment 36323 [details]
Test code that reproduces the problem

When rendering faces with:
 * glLightModeli (GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
 * glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
 * glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
 * A infinite distance light.

The specular colour is applied incorrectly to backward faces. The faces show up as the correct colour when they don't have a specular highlight, but as full-intensity white when they have any specular.

Without separate specular the results are correct.

With local-viewer set to true, or with a non-infinite distance light, the results are better but still wrong. The specular highlight doesn't go to full white instantly but it's still brighter than it should be.

I'm attaching some simple code to reproduce the problem. It should show a red and green square rotating on a blue background. As the square rotates the correct specular highlight will show up on the red front face: a gradual lightening from red to pink then back to red again. The green back face instead goes instantly from green to white, then instantly back to green again.
Comment 1 Tim Evans 2010-06-16 17:41:11 UTC
In case it matters, I've reproduced this problem on Mesa 7.7.1 and 7.8.1, both on win32 with the GDI interface, compiled with Visual C++ 2008 with optimisation disabled. My machine is running Windows Vista 64.
Comment 2 Tim Evans 2010-06-17 19:42:28 UTC
Created attachment 36354 [details] [review]
Patch against mesa-7.8.2 that fixes this problem

In ss_tritmp.h, the backface specular values are copied into the vertex attrib array using SS_SPEC. SS_SPEC converts the values from float [0,1] to uint8 [0,255], but the vertex attrib array is float, and the values are used as if they were [0,1] later.  Changing the definition of SS_SPEC to COPY_4V fixes the problem for me.  Attaching a patch to that effect.
Comment 3 Brian Paul 2010-06-21 16:20:21 UTC
Thanks!  Patch committed to master with commit 1f9f650738ed5bc8e8d8eeb43234d2e969621d7f.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.