port from perforce
This commit is contained in:
46
aquarium/src/intro/shaders/shadow.hlsl
Normal file
46
aquarium/src/intro/shaders/shadow.hlsl
Normal file
@@ -0,0 +1,46 @@
|
||||
//[entrypoint(ps)]
|
||||
float ps_DrawDepth(in Hull h, out float d : SV_Depth) : SV_Target0
|
||||
{
|
||||
float3 rd;
|
||||
float t;
|
||||
d = 0;
|
||||
if (raymarch(h, 24, rd, t))
|
||||
{
|
||||
float3 p = h.world + t * rd;
|
||||
d = length(p - _c._e.xyz) / 500;
|
||||
return exp(80 * d);
|
||||
}
|
||||
discard;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float log_conv(float x0, float X, float y0, float Y)
|
||||
{
|
||||
return X + log(x0 + (y0 * exp(Y - X)));
|
||||
}
|
||||
|
||||
float blur(float2 uv, float2 dirAndSize)
|
||||
{
|
||||
const float coeff[7] = { 0.006, 0.061, 0.242, 0.382, 0.242, 0.061, 0.006 };
|
||||
float2 s = uv - 3 * dirAndSize.xy;
|
||||
float accum = 0;
|
||||
for (int i = 0; i < 7; ++i)
|
||||
accum += t2d4.Sample(s0, s + i * dirAndSize.xy).x * coeff[i];
|
||||
return accum;
|
||||
}
|
||||
|
||||
//[entrypoint(ps)]
|
||||
float ps_BlurH(in float2 uv : TEXCOORD) : SV_Target0
|
||||
{
|
||||
float w,h;
|
||||
t2d4.GetDimensions(w, h);
|
||||
return blur(uv, float2(1/w,0));
|
||||
}
|
||||
|
||||
//[entrypoint(ps)]
|
||||
float ps_BlurV(in float2 uv : TEXCOORD) : SV_Target0
|
||||
{
|
||||
float w,h;
|
||||
t2d4.GetDimensions(w, h);
|
||||
return blur(uv, float2(0,1/h));
|
||||
}
|
||||
Reference in New Issue
Block a user