port from perforce
This commit is contained in:
115
evoke-64k/ev10/cfg/_svn/text-base/pstarmac.txt.svn-base
Normal file
115
evoke-64k/ev10/cfg/_svn/text-base/pstarmac.txt.svn-base
Normal file
@@ -0,0 +1,115 @@
|
||||
float4 g_fResolution : register(c0);
|
||||
float3 g_vLightDir : register(c1);
|
||||
|
||||
sampler3D randomSampler : register(s0);
|
||||
sampler1D diffSampler : register(s2);
|
||||
sampler1D specSampler : register(s3);
|
||||
sampler2D shadowSampler : register(s4);
|
||||
sampler2D depthSampler : register(s5);
|
||||
|
||||
static float g_fTileHardness = .6f;
|
||||
static float g_fTileDepth = 8.f;
|
||||
static float g_fBumpDepth = .75f;
|
||||
static float g_fTexScale = 1.f;
|
||||
static float g_fSpecularPower = 0.5f;
|
||||
static float g_fSpecularHardness = 32.f;
|
||||
|
||||
struct psIn
|
||||
{
|
||||
float2 t : TEXCOORD0;
|
||||
float3 n : TEXCOORD1;
|
||||
float3 v : TEXCOORD2;
|
||||
float4 s : TEXCOORD3;
|
||||
float3 w : TEXCOORD4;
|
||||
};
|
||||
|
||||
float rand_val(float4 r)
|
||||
{
|
||||
float lr = dot(r, float4(10.f, 100.f, 1000.f, 1.f));
|
||||
return lr / 1111.f;
|
||||
}
|
||||
|
||||
float noise(float3 t)
|
||||
{
|
||||
float4 r = tex3D(randomSampler, .03125f * t);
|
||||
return rand_val(r)* 2.f - 1.f;
|
||||
}
|
||||
float noise_grad(float3 t, float3 dtX, float3 dtY)
|
||||
{
|
||||
float4 r = tex3Dgrad(randomSampler, .03125f * t, .0625f * dtX, .0625f * dtY);
|
||||
return rand_val(r)* 2.f - 1.f;
|
||||
}
|
||||
|
||||
float abs_noise(float3 t)
|
||||
{
|
||||
return abs( noise(t) );
|
||||
}
|
||||
float abs_noise_grad(float3 t, float3 dtX, float3 dtY)
|
||||
{
|
||||
return abs( noise_grad(t, dtX, dtY) );
|
||||
}
|
||||
|
||||
float4 ps_main(psIn i) : COLOR0
|
||||
{
|
||||
float3 t = i.w * g_fTexScale;
|
||||
|
||||
float3 pw = i.w.xxz; pw.y = 0.0f; // i.w - i.n * dot(i.w, i.n);
|
||||
float3 pt = pw * g_fTexScale + .5f;
|
||||
float3 tt = floor(pt);
|
||||
float3 dttX = ddx(pt);
|
||||
float3 dttY = ddy(pt);
|
||||
|
||||
// Texturing
|
||||
float3 fColor = 0.15f * saturate( dot(1.f, abs(dttX) + abs(dttY)) );
|
||||
fColor += abs_noise_grad(tt, dttX, dttY);
|
||||
fColor += abs_noise(2.f * t) / 8.f;
|
||||
fColor += noise(4.f * t) / 8.f;
|
||||
|
||||
float fDetail = noise(8.f * t) / 16.f;
|
||||
fDetail += noise(16.f * t) / 16.f;
|
||||
fDetail += noise(32.f * t) / 32.f;
|
||||
fDetail += noise(128.f * t) / 32.f;
|
||||
fDetail += noise(1024.f * t) / 32.f;
|
||||
|
||||
fColor += fDetail;
|
||||
|
||||
// Contrast
|
||||
fColor = 1.0f - saturate(fColor);
|
||||
fColor *= fColor;
|
||||
fColor = 1.0f - fColor;
|
||||
|
||||
// Super tile
|
||||
float3 tb = 2.f * frac(pt) - 1.f;
|
||||
float3 te = tb * tb; // ^2
|
||||
te *= te; // ^4
|
||||
te *= te; // ^8
|
||||
float tdd = saturate(1.f - 2.f * fwidth(pt));
|
||||
float td = saturate( dot(tdd, te) );
|
||||
float3 tc = 1.f - td;
|
||||
float3 ti = saturate(td - g_fTileHardness);
|
||||
|
||||
// Bump mapping
|
||||
float3 n = normalize(i.n + g_fBumpDepth * g_fTileDepth * ti * tb);
|
||||
|
||||
// Shadow (AA)
|
||||
float2 sc = i.s.xy / i.s.w;
|
||||
float aa = abs( tex2D(depthSampler, sc).x - i.s.z );
|
||||
float2 ddaa = float2(ddx(aa), ddy(aa));
|
||||
float2 aaetc = sign(-ddaa) * g_fResolution.zw;
|
||||
sc += aaetc * saturate(4.f * aa);
|
||||
float fShadow = 0.2f + 0.8f * (float)tex2D(shadowSampler, sc);
|
||||
|
||||
// Diffuse light
|
||||
fColor *= tex1D( diffSampler, fShadow * (0.5f + 0.5f * dot(n, -g_vLightDir)) ).xyz;
|
||||
|
||||
// Specular highlights
|
||||
float3 h = normalize( normalize(i.v) + -g_vLightDir );
|
||||
float s = 0.5f + 0.5f * dot(n, h);
|
||||
s *= saturate(1.f + g_fBumpDepth * fDetail);
|
||||
fColor += g_fSpecularPower * tex1D(specSampler, fShadow * s).xyz; // pow(s, g_fSpecularHardness)
|
||||
|
||||
// Tile borders
|
||||
fColor *= tc;
|
||||
|
||||
return float4(fColor, 1.0f);
|
||||
}
|
||||
Reference in New Issue
Block a user