从一个纹理到另一个纹理的平滑步进渐变过渡取决于另一个纹理的亮度

问题描述

我希望能够根据另一个纹理 (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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...