Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shininess on Texture




On 20 Nov 2007, at 11:34, Lorenzo wrote:

Hi, I set specular to 1.0 and shininess to 128 and I get a nice effect on my
surface when I use a non-white surface color. Then I apply a texture and the
shining effect disappears. How to keep it?

This is because the shading model in standard OpenGL is done before texturing, so the texture overlays the specular highlight, which isn't what you naturally expect to happen.


effectively you get (diffuse + specular) * texture
when you want      (diffuse * texture) + specular

Three ways I know of getting around this.

1) Old School: Do 1 pass that has ambient and diffuse at normal, with texturing, but no specular. Do 2nd pass with zero ambient and diffuse, no texturing, but with specular. Blend it on so as to add the two images together.

2) Semi-Old School: OpenGL 1.2 Added GL_SEPARATE_SPECULAR_COLOR. Using this you can separate the specular colour out, and add it at a later stage in the pipeline

3) New School: Vertex shader that does the lighting calculations, but forwards the diffuse and specular colours separately to the fragment shader. Fragment shader that does diffuse * texture + specular. If you do this then you can do per-fragment lighting rather than per-vertex and it looks that much better.

Easiest on to get going is No. 2. I think it's just a glEnable() call to get it working. For number 3 take a look in the Orange book (I've never read it, but it must be in there)

Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >Shininess on Texture (From: Lorenzo <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.