146 lines
3.8 KiB
Plaintext
146 lines
3.8 KiB
Plaintext
float4 g_fResolution : register(c0);
|
|
float3x3 g_mCubeMatrix : register(c40);
|
|
float g_fCubeWeight : register(c43);
|
|
float g_fOverlayFade : register(c50);
|
|
float4 g_fFadeColor : register(c51);
|
|
|
|
sampler2D randomSampler : register(s0);
|
|
sampler3D randomCubeSampler : register(s1);
|
|
sampler2D ditherSampler : register(s2);
|
|
sampler2D inputSampler : register(s3);
|
|
samplerCUBE inputCubeSampler : register(s4);
|
|
|
|
float4 rand_val(float4 r)
|
|
{
|
|
return r;
|
|
// float lr = dot(r, float4(10.f, 100.f, 1000.f, 1.f));
|
|
// return lr / 1111.f;
|
|
}
|
|
|
|
float4 noise(float2 t)
|
|
{
|
|
float4 r = tex2D(randomSampler, .03125f * t);
|
|
return rand_val(r)* 2.f - 1.f;
|
|
}
|
|
float4 noise_grad(float2 t, float2 dtX, float2 dtY)
|
|
{
|
|
float4 r = tex2Dgrad(randomSampler, .03125f * t, .0625f * dtX, .0625f * dtY);
|
|
return rand_val(r)* 2.f - 1.f;
|
|
}
|
|
|
|
float4 abs_noise(float2 t)
|
|
{
|
|
return abs( noise(t) );
|
|
}
|
|
float4 abs_noise_grad(float2 t, float2 dtX, float2 dtY)
|
|
{
|
|
return abs( noise_grad(t, dtX, dtY) );
|
|
}
|
|
|
|
float4 ps_perlin(float2 TexCoord : TEXCOORD0) : COLOR0
|
|
{
|
|
float2 t = 32 * TexCoord;
|
|
|
|
float4 fNoise = noise(t) / 2.0f;
|
|
fNoise += noise(2 * t) / 4.0f;
|
|
fNoise += noise(4 * t) / 8.0f;
|
|
fNoise += noise(8 * t) / 16.0f;
|
|
fNoise += noise(16 * t) / 32.0f;
|
|
fNoise += noise(32 * t) / 64.0f;
|
|
fNoise += noise(64 * t) / 128.0f;
|
|
fNoise += noise(128 * t) / 256.0f;
|
|
fNoise += noise(256 * t) / 512.0f;
|
|
fNoise += noise(512 * t) / 1024.0f;
|
|
|
|
return fNoise * 0.5f + 0.5f;
|
|
}
|
|
|
|
float4 ps_wave(float2 TexCoord : TEXCOORD0) : COLOR0
|
|
{
|
|
float4 fNoise = tex2D(inputSampler, TexCoord);
|
|
float4 fX = 0.5f * fNoise;
|
|
fX -= round(fX);
|
|
float4 fWave = 8.1688f * (1.0f - cos(fX));
|
|
return fNoise;
|
|
}
|
|
|
|
float4 ps_normal(float2 TexCoord : TEXCOORD0) : COLOR0
|
|
{
|
|
// Construct pixels
|
|
float3 vPixel = TexCoord.xyy;
|
|
vPixel.z = tex2D(inputSampler, vPixel.xy).r;
|
|
|
|
float3 vRightPixel = TexCoord.xyy;
|
|
vRightPixel.x += g_fResolution.z;
|
|
vRightPixel.z = tex2D(inputSampler, vRightPixel.xy).r;
|
|
|
|
float3 vBottomPixel = TexCoord.xyy;
|
|
vBottomPixel.y += g_fResolution.w;
|
|
vBottomPixel.z = tex2D(inputSampler, vBottomPixel.xy).r;
|
|
|
|
// Get change rates
|
|
float3 vRight = vRightPixel - vPixel;
|
|
float3 vDown = vBottomPixel - vPixel;
|
|
|
|
// Compute normal
|
|
float3 vNormal = cross(vRight, vDown);
|
|
vNormal.z = max(vNormal.z, 0.0f);
|
|
vNormal = normalize(vNormal);
|
|
|
|
// Encode & return
|
|
vNormal.xy = vNormal.xy * 0.5f + 0.5f;
|
|
return float4(saturate(vNormal), vPixel.z);
|
|
}
|
|
|
|
float4 ps_cube_blur(float2 TexCoord : TEXCOORD0) : COLOR0
|
|
{
|
|
float3 vCubeDir = float3(TexCoord * float2(2.0f, -2.0f) - float2(1.0f, -1.0f), 1.0f);
|
|
float3 vCubeCoord = mul(vCubeDir, transpose(g_mCubeMatrix));
|
|
return texCUBE(inputCubeSampler, vCubeCoord) * g_fCubeWeight;
|
|
}
|
|
|
|
bool flame(float2 o)
|
|
{
|
|
return (o.x < -0.52) && (pow(2 * (o.x + 0.52), 2.0) + pow(o.y - 0.33, 2.0) < 1) ||
|
|
(o.x >= -0.52 && o.x < 1.57 && o.y <= 1 - sin(3 * o.x) / 3 || o.x >= 1.57 && o.y < 1.33 - pow(o.x - 1.57, 2.0)) &&
|
|
(o.x >= -0.52 && o.y >= -0.01 + sin(1.5 * o.x - 0.9) / 1.5);
|
|
}
|
|
|
|
float4 ps_logo(float2 TexCoord : TEXCOORD0) : COLOR0
|
|
{
|
|
float4 fColor = 0.0f;
|
|
float2 o;
|
|
|
|
TexCoord.y = (TexCoord.y - 0.5f) * (g_fResolution.y * 16) / (g_fResolution.x * 9) + 0.5f;
|
|
|
|
TexCoord.y = 1.0f - TexCoord.y;
|
|
TexCoord *= float2(1024, 768);
|
|
|
|
// 4x sampling
|
|
for (float x = 0; x < 1/128.0; x += 1/256.0)
|
|
for (float y = 0; y < 1/128.0; y += 1/256.0)
|
|
{
|
|
o = (TexCoord.yx - float2(384.0f, 512.0f)) / 128.0f + float2(0.5f + y, 0.3f + x);
|
|
o.y *= (3.0f * 16) / (4.0f * 9);
|
|
o.x /= 1.1;
|
|
o.y *= 1.2;
|
|
fColor += flame(o) * float4(0, 0.5, 1, 1);
|
|
|
|
o.y /= -1.2;
|
|
o.x *= 1.1;
|
|
o += float2(0.2, 0.3);
|
|
fColor += flame(o) * float4(0, 0.75, 1, 1);
|
|
}
|
|
|
|
fColor /= 8.0f;
|
|
fColor *= g_fOverlayFade * length((o+float2(.4,0))*.8);
|
|
return fColor;
|
|
}
|
|
|
|
float4 ps_fade() : COLOR0
|
|
{
|
|
float4 fColor = g_fFadeColor;
|
|
fColor.xyz *= fColor.w;
|
|
return fColor;
|
|
}
|