diff --git a/shaders/texture_loading/glsl/texture.frag b/shaders/texture_loading/glsl/texture.frag index 6943e81..4b643fd 100644 --- a/shaders/texture_loading/glsl/texture.frag +++ b/shaders/texture_loading/glsl/texture.frag @@ -1,6 +1,7 @@ #version 450 layout (binding = 1) uniform sampler2D samplerColor; +layout (binding = 2) uniform sampler2D samplerColor_ex; layout (location = 0) in vec2 inUV; layout (location = 1) in vec3 inNormal; @@ -11,16 +12,27 @@ layout (location = 0) out vec4 outFragColor; void main() { vec4 color = texture(samplerColor, inUV); + vec4 color_ex = texture(samplerColor_ex, inUV); vec3 N = normalize(inNormal); vec4 textureColor = color; - if (textureColor.a < 0.1) { + + //if (textureColor.a < 0.1) + //{ //textureColor = vec4(0.2, 0.2, 0.2, 0.5); - discard; - } + // discard; + //} + + // 计算与 (0,0,1) 的点乘 + float ndot = dot(N, vec3(0.0, 0.0, -1.0)); + + // 保证结果 >= 0 + ndot = max(ndot, 0.0); - outFragColor = textureColor; + vec4 blendedColor = mix(color_ex, color, ndot); + + outFragColor = blendedColor; // outFragColor = vec4(1, 0, 0, 1); } \ No newline at end of file diff --git a/shaders/texture_loading/glsl/texture.frag.spv b/shaders/texture_loading/glsl/texture.frag.spv index dfcd420..6bbc39d 100644 Binary files a/shaders/texture_loading/glsl/texture.frag.spv and b/shaders/texture_loading/glsl/texture.frag.spv differ