View Full Version : multi-texture & reflection amount
08-01-2006, 08:37 AM
-diffuse texture on unit 0
-reflection cubemap on unit 1
-reflection amount (GLfloat)
How can I control the amount of reflection (no shaders)? If there is also a way to tint the reflection (color + amount as alpha) then I'm interested to hear about it.
Ps. It is sort of sad that one is not able to find something simple as this on the web, there should be a "Tips and tricks" or "Techniques" section on the Wiki.
08-01-2006, 01:08 PM
[...] there should be a "Tips and tricks" or "Techniques" section on the Wiki. So, then wait 'til someone will help you and write the wiki article yourself.
08-01-2006, 01:44 PM
Use ARB_texture_env_combine on unit 1.
08-01-2006, 01:53 PM
Make sure you modulate the reflection using Fresnel's equations based on the material properties.
There is a section in this book where I describe the use of Frenel's equations with sample code:
To do vertex alpha and tint in a single pass you should probably use a modulate on unit 0 with vertex color and alpha holding tint and reflection coefficient.
Then you can use a DECAL texenv on the second unit to blend between the result and the other texture.
You have some choices to make this work either put diffuse on unit 1 and reflection on unit 0, or use crossbar to select them as the source, but crossbar is another extension albeit almost universally available. You can also use interpolate combiner texenv and one_minus_alpha as arguments but there's no sense in making this more complex than it has to be.
08-01-2006, 07:28 PM
You should perhaps do things like this in a GLSL shader, it is relatively easy to do, and it will look better since you can modulate the alpha on a per pixel level instead of per vertex.
I put some fakeish fresnel term in my latest tutorial (http://www.flashbang.se/index.php?id=23) .
If you want to do it without using shaders the easiest thing would be to do it in two passes, one with the difuse and the second one with the alpha modulated reflection.
08-02-2006, 06:38 AM
@zeoverlord: I already have it working with (GLSL) shaders, but am adding this for compatibility with older cards.
@dorbie: I never thought of swapping the two textures, it makes sense. Allthough its rather hard to do in my case without breaking stuff I'll try what you suggested, thanks!
@moebi: I'm more than happy to contribute the solution to the Wiki (which unfortunately seems rather inactive).
* Swapping texture 0 and 1 requires me to re-write a lot of code. Any chance I can do this with GL_NV_texture_env_combine4? Pseudo code?
08-07-2006, 09:31 AM
Swapping texture 0 and 1 requires me to re-write a lot of code. Any chance I can do this with GL_NV_texture_env_combine4?
I'm not particulary interested in performance or complexity, since it acts as alternative to a shader render path.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.