如何解决从一个纹理到另一个纹理的平滑步进渐变过渡取决于另一个纹理的亮度
我希望能够根据另一个纹理 (texture2) 的颜色/亮度平滑地从一个纹理 (texture0) 过渡到另一个 (texture1)。
我可以使两个纹理重叠,但无法找到平滑步进纹理的解决方案。
vec4 texture0 = texture2D(text0,vec2(text0_texture_x,text0_texture_y));
vec4 texture1 = texture2D(text1,vec2(text1_texture_x,text1_texture_y));
vec4 texture2 = texture2D(text2,vec2(text2_texture_x,text2_texture_y));
if((texture2.r < 0.58 && texture2.r > 0.5) && (texture2.g < 0.58 && texture2.g > 0.5 ) && (texture2.b < 0.58 && texture2.b > 0.5)){
if(texture1.r > 1.0){
othertexture.a = 1.0;
}
else if(texture1.r <= 1.0){
othertexture.a = othertexture_data_transparency + 0.25;
}
othertexture.rgb *= othertexture.a;
texture0.rgb *= texture0.a;
vec4 texture0_final_color;
texture0_final_color.rgb = othertexture.rgb + (texture0.rgb * (1.0 - othertexture.a));
texture0_final_color.a = othertexture.a + (texture0.a * (1.0 - othertexture.a));
texture1.rgb *= texture1.a;
vec4 texture1_final_color;
texture1_final_color.rgb = othertexture.rgb + (texture1.rgb * (1.0 - othertexture.a));
texture1_final_color.a = othertexture.a + (texture1.a * (1.0 - othertexture.a));
// gl_FragColor = texture0_final_color*(1.0 - 0.1) + texture1_final_color*0.3;
gl_FragColor = (texture0_final_color*(1.0 - 0.4) + texture1_final_color*0.3);
// gl_FragColor = smoothstep(0.0,0.9,texture2);
}
else if(texture2.r < 0.5 && texture2.g < 0.5 && texture2.b < 0.5){
othertexture.a = othertexture_data_transparency;
othertexture.rgb *= othertexture.a;
texture0.rgb *= texture0.a;
vec4 texture0_final_color;
texture0_final_color.rgb = othertexture.rgb + (texture0.rgb * (1.0 - othertexture.a));
texture0_final_color.a = othertexture.a + (texture0.a * (1.0 - othertexture.a));
gl_FragColor = texture0_final_color;
}
else{
if(texture1.r > 1.0){
othertexture.a = 1.0;
}
else if(texture1.r <= 1.0){
othertexture.a = othertexture_data_transparency + 0.25;
}
othertexture.rgb *= othertexture.a;
texture1.rgb *= texture1.a;
vec4 texture1_final_color;
texture1_final_color.rgb = othertexture.rgb + (texture1.rgb * (1.0 - othertexture.a));
texture1_final_color.a = othertexture.a + (texture1.a * (1.0 - othertexture.a));
gl_FragColor = texture1_final_color;
}
}
是否有更好的阶梯梯度解决方案来平滑过渡两个着色器?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。