浏览代码

Improvements to the depth gradient shader math.

/4.1
Todd Stinson 4 年前
当前提交
9c5ad6aa
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 24
      Assets/Shaders/EnvironmentDepthGradient.shader

24
Assets/Shaders/EnvironmentDepthGradient.shader


float cosrot = cos(angle);
float sinrot = sin(angle);
float2 tmp = float2(v.texcoord.x - 0.5f, 0.5f - v.texcoord.y);
float3x3 textureXformMatrix = float3x3(
float3(cosrot, -sinrot, 0.5f),
float3(sinrot, cosrot, 0.5f),
float3(0.0f, 0.0f, 1.0f)
);
float3 tmp = float3(v.texcoord.x - 0.5f, 0.5f - v.texcoord.y, 1.0f);
o.texcoord = float2(tmp.x * cosrot - tmp.y * sinrot + 0.5f, tmp.x * sinrot + tmp.y * cosrot + 0.5f);
o.texcoord = mul(textureXformMatrix, tmp).xy;
return o;
}

real4 K = half4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
real3 P = abs(frac(arg1.xxx + K.xyz) * 6.0 - K.www);
real4 K = real4(1.0h, 2.0h / 3.0h, 1.0h / 3.0h, 3.0h);
real3 P = abs(frac(arg1.xxx + K.xyz) * 6.0h - K.www);
return arg1.z * lerp(K.xxx, saturate(P - K.xxx), arg1.y);
}

float envDistance = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r;
real lerpFactor = (envDistance - _MinDistance) / (_MaxDistance - _MinDistance);
real hue = lerp(0.70f, -0.15f, saturate(lerpFactor));
if (hue < 0.0f)
real hue = lerp(0.70h, -0.15h, saturate(lerpFactor));
if (hue < 0.0h)
hue += 1.0f;
hue += 1.0h;
real3 color = real3(hue, 0.9, 0.6);
real3 color = real3(hue, 0.9h, 0.6h);
o.color = real4(HSVtoRGB(color), 1.0);
o.color = real4(HSVtoRGB(color), 1.0h);
return o;
}

正在加载...
取消
保存