Reputation: 1232
I'm trying to combine two texture using shaders in opengl es 2.0
as you can see on the screen shot, I am trying to create a needle reflection on backward object using dynamic environment mapping. but, reflection of the needle looks semi transparent and it's blend with my environment map.
here is the my fragment shader;
varying highp vec4 R;
uniform samplerCube cube_map1;
uniform samplerCube cube_map2;
void main()
{
mediump vec3 output_color1;
mediump vec3 output_color2;
output_color1 = textureCube(cube_map1 , R.xyz).rgb;
output_color2 = textureCube(cube_map2 , R.xyz).rgb;
gl_FragColor = mix(vec4(output_color1,1.0),vec4(output_color2,1.0),0.5);
}
but, "mix" method cause a blending two textures.
I'm also checked Texture Combiners examples but it didn't help either.
is there any way to combine two textures without blend each other.
thanks.
Upvotes: 3
Views: 3465
Reputation: 818
Judging from the comments, my guess is you want to draw the needle on top of the landscape picture. I'd simply render it as an overlay but since you want to do it in a shader maybe this would work:
void main()
{
mediump vec3 output_color1;
mediump vec3 output_color2;
output_color1 = textureCube(cube_map1 , R.xyz).rgb;
output_color2 = textureCube(cube_map2 , R.xyz).rgb;
if ( length( output_color1 ) > 0.0 )
gl_FragColor = vec4(output_color1,1.0);
else
gl_FragColor = vec4(output_color2,1.0);
}
Upvotes: 1