Roger James wrote:
I was assuming that because the lighting equation (blinn) has already been applied in the pipeline before textures are applied, that if we wanted to use a texture map to supply the ambient terms to that equation, then the lighting equation would have to be somehow re-implemented in a fragment shader. I did not think the the fixed functionality could be configured to handle it, especially the contributions from light sources. I am happy to be wrong in this.

Well, thinking about it more, in order to get it mathematically correct, you're probably right. However, fixed-function multitexturing can give a reasonable facsimile (especially with an ambient occlusion map in the ambient channel).

The "right" way to implement all of this is probably to write a COLLADA Blinn shader (as well as one for Phong, one for Lambert, etc.) and avoid fixed function altogether. Unfortunately, this leads to problems if users want to make use of their own shaders.


The transparency bit is the bit that needs fixing. We are just not handling transparent textures at the moment. I would really appreciate your input in this area, as I feel that I am just wandering about in the wilderness on it at the moment.

I don't really remember enough about how this works. I know there are issues and subtle differences regarding A_ONE and RGB_ZERO modes, and I thought I even heard the spec for this changed between 1.4 and 1.5 (I wrote my code for 1.4). I'll tell you what I did in my code, but I don't have time to research this further right now.

In my code, (which is probably technically wrong, but seems to work most of the time) I check the opaque setting on the transparent color. If it's A_ONE, I use the transparency value as the alpha on the material (the OpenGL material, that is). If it's RGB_ZERO, and transparency is specified as a color, I average the transparency color's RGB values and set the material's alpha to 1 minus the average (this is probably a best-effort kind of hack). If transparency is a texture (an alpha map), I ignore it, since it's not possible to support in fixed-function (at least I don't think it is).

Of course, none of this has anything to do with whether or not the diffuse texture has alpha. If the diffuse texture has an alpha channel, this needs to be honored as well. I check for this with a call to osg::Image::isImageTranslucent() on the image from the texture in question.

--"J"
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to