25 lines
1.3 KiB
Plaintext
Executable File
25 lines
1.3 KiB
Plaintext
Executable File
// 官方版本的RampShadowID函数
|
|
float RampShadowID(float input, float useShadow2, float useShadow3, float useShadow4, float useShadow5,
|
|
float shadowValue1, float shadowValue2, float shadowValue3, float shadowValue4, float shadowValue5)
|
|
{
|
|
// 根据input值将模型分为5个区域
|
|
float v1 = step(0.6, input) * step(input, 0.8); // 0.6-0.8区域
|
|
float v2 = step(0.4, input) * step(input, 0.6); // 0.4-0.6区域
|
|
float v3 = step(0.2, input) * step(input, 0.4); // 0.2-0.4区域
|
|
float v4 = step(input, 0.2); // 0-0.2区域
|
|
|
|
// 根据开关控制是否使用不同材质的值
|
|
float blend12 = lerp(shadowValue1, shadowValue2, useShadow2);
|
|
float blend15 = lerp(shadowValue1, shadowValue5, useShadow5);
|
|
float blend13 = lerp(shadowValue1, shadowValue3, useShadow3);
|
|
float blend14 = lerp(shadowValue1, shadowValue4, useShadow4);
|
|
|
|
// 根据区域选择对应的材质值
|
|
float result = blend12; // 默认使用材质1或2
|
|
result = lerp(result, blend15, v1); // 0.6-0.8区域使用材质5
|
|
result = lerp(result, blend13, v2); // 0.4-0.6区域使用材质3
|
|
result = lerp(result, blend14, v3); // 0.2-0.4区域使用材质4
|
|
result = lerp(result, shadowValue1, v4); // 0-0.2区域使用材质1
|
|
|
|
return result;
|
|
} |