To elaborate my question, I am explaining this with code:
Code:
import viz
viz.go()
viz.add('piazza.osgb')
# Add render texture using depth pixel format
img = viz.addRenderTexture()
# Use render node to render the scene to the depth texture
rn1 = viz.addRenderNode()
rn1.setRenderTexture(img)
rn1.setEuler(180,0,0)
rn2 = viz.addRenderNode()
rn2.setRenderTexture(img)
rn2.setEuler(180,0,0)
# Display depth texture on the screen
quad1 = viz.addTexQuad()
quad1.setScale(3,2)
quad1.setPosition(-2,2,6)
quad2 = viz.addTexQuad()
quad2.setScale(3,2)
quad2.setPosition(2,2,6)
# Use shader to display depth texture in linear range
fragSepia = """
uniform sampler2D InputTex;
void main()
{
vec4 color = texture2D(InputTex,gl_TexCoord[0].st);
gl_FragColor.r = dot(color.rgb, vec3(.393, .769, .189));
gl_FragColor.g = dot(color.rgb, vec3(.349, .686, .168));
gl_FragColor.b = dot(color.rgb, vec3(.272, .534, .131));
gl_FragColor.a = color.a;
}
"""
fragGray = """
uniform sampler2D InputTex;
void main()
{
vec4 color = texture2D(InputTex,gl_TexCoord[0].st);
float lum = 0.222*color.r + 0.707*color.g + 0.071*color.b;
gl_FragColor = vec4(lum,lum,lum,color.a);
}
"""
shader = viz.addShader(frag=fragSepia)
quad1.apply(viz.addUniformInt('InputTex',0))
quad1.apply(shader)
quad1.texture(img)
shader2 = viz.addShader(frag=fragGray)
quad2.apply(viz.addUniformInt('InputTex',0))
quad2.apply(shader2)
quad2.texture(img)
# Need to specify clip plane here and in shader
viz.clip(0.1,200)
This code gives me output as follow:
Left Side is Sepia Effect & Right Side is Gray Effect. I want to produce third effect i.e. 70% Sepia & 30% Gray. I am willing to use Multi-Passing & everything should be behind the screen & main window should have the final output.
Thanks!