[osg-users] blending with shader

David Heitbrink david-heitbrink at uiowa.edu
Tue Oct 11 15:23:41 PDT 2016

The function I posted was similar to a function I called from my shader I ran in my final pass. What you have is functionally the similar. 

As per the inout, this states the parameter into the function is both an input and an output. I set the version for my shader to something like 4.5 in compatibility mode. The function was called last in my shader.


As per your program I think you were are getting into trouble is here:

vec2 texCoord = vec2(gl_FragCoord.x/width, gl_FragCoord.y/height); 
vec4 sceneColor = texture2D(sceneTexture, texCoord); 
vec4 blendingColor = texture2D(blendTexture, texCoord);

Your texCoord, is basically the location on your display device. This is what you want to use to lookup your blending value. 

But you will want to use a separate coordinate for your scene color. You basically need the texture coordinate from your warping geometry. 

As per not setting a uniform for the sampler if I remember which I might be totally wrong about, the value of the uniform is going to default to 0, which in this case will default to texture unit 0, if the uniform is never set.

Also with texture attribute 0, I assume that's being used for your scene texture. So your scene texture and your blending texture must use different texture units.

Read this topic online here:

More information about the osg-users mailing list