完成双贴图效果,修改闪退的bug,换成赴宴的贴图
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 70 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 82 KiB |
@@ -6,27 +6,28 @@ layout (binding = 2) uniform sampler2D samplerColor_ex;
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(samplerColor, inUV);
|
||||
vec4 color_ex = texture(samplerColor_ex, inUV);
|
||||
vec4 color = texture(samplerColor, inUV);
|
||||
vec4 color_ex = texture(samplerColor_ex, inUV);
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 N = normalize(inNormal);
|
||||
|
||||
// 计算与 (0,0,1) 的点乘
|
||||
float ndot = dot(N, vec3(0.0, 0.0, -1.0));
|
||||
|
||||
// 保证结果 >= 0
|
||||
// 保证结果 >= 0
|
||||
ndot = max(ndot, 0.0);
|
||||
|
||||
// 重新映射ndot值,让中间2/3部分进行融合
|
||||
// 当ndot在[0.166, 0.833]范围内时进行混合,两端保持不变
|
||||
float blendFactor;
|
||||
if (ndot < 0.166) {
|
||||
if (ndot < 0.266) {
|
||||
blendFactor = 0.0; // 完全使用color_ex
|
||||
} else if (ndot > 0.833) {
|
||||
} else if (ndot > 0.733) {
|
||||
blendFactor = 1.0; // 完全使用color
|
||||
} else {
|
||||
// 在中间2/3部分进行平滑过渡
|
||||
@@ -41,5 +42,7 @@ void main()
|
||||
|
||||
vec4 blendedColor = mix(color_ex, color, blendFactor);
|
||||
|
||||
outFragColor = blendedColor;
|
||||
outFragColor = blendedColor;
|
||||
|
||||
// outFragColor = vec4(1, 0, 0, 1);
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user