port from perforce
This commit is contained in:
112
evoke-64k/bp10/cfg/_svn/tmp/tempfile.2.tmp
Normal file
112
evoke-64k/bp10/cfg/_svn/tmp/tempfile.2.tmp
Normal file
@@ -0,0 +1,112 @@
|
||||
float3 g_vLightDir : register(c1);
|
||||
float g_fTime : register(c3);
|
||||
|
||||
sampler3D randomSampler : register(s0);
|
||||
sampler1D diffSampler : register(s2);
|
||||
sampler1D specSampler : register(s3);
|
||||
sampler2D shadowSampler : register(s4);
|
||||
|
||||
static float g_fVariation = .1f;
|
||||
static float g_fBumpDepth = .02f;
|
||||
static float g_fBumpFalloff = 256.f;
|
||||
static float g_fTexScale = 1.f;
|
||||
static float g_fSpecularPower = 0.2f;
|
||||
static float g_fSpecularHardness = 32.f;
|
||||
|
||||
struct psIn
|
||||
{
|
||||
float4 c : COLOR0;
|
||||
float2 t : TEXCOORD0;
|
||||
float3 n : TEXCOORD1;
|
||||
float3 v : TEXCOORD2;
|
||||
float4 s : TEXCOORD3_CENTROID;
|
||||
float3 w : TEXCOORD4;
|
||||
};
|
||||
|
||||
float3 hslToRgb(float3 color)
|
||||
{
|
||||
float3 result = 0;
|
||||
float h = color.r;
|
||||
float s = color.g;
|
||||
float l = color.b;
|
||||
float q,p;
|
||||
if (l < 0.5)
|
||||
q = l*(1+s);
|
||||
else if (l >= 0.5)
|
||||
q = l+s-(l*s);
|
||||
p=2*l-q;
|
||||
result.r=h+1.0/3.0;
|
||||
result.g=h;
|
||||
result.b=h-1.0/3.0;
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
if (result[j]<0) result[j] += 1;
|
||||
if (result[j]>1) result[j] -= 1;
|
||||
}
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (result[i]<1.0/6.0)
|
||||
result[i]=p+((q-p)*6*result[i]);
|
||||
else if (result[i]<0.5)
|
||||
result[i]=q;
|
||||
else if (result[i]<2.0/3.0)
|
||||
result[i]=p+((q-p)*6*(2.0/3.0-result[i]));
|
||||
else
|
||||
result[i]=p;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float noise(float3 t)
|
||||
{
|
||||
float4 r = tex3D(randomSampler, .03125f * t);
|
||||
float lr = dot(r, float4(1.f, 10.f, 100.f, 1000.f));
|
||||
return lr * 2.f / 1111.f - 1.f;
|
||||
}
|
||||
float abs_noise(float3 t) { return abs( noise(t) ); }
|
||||
|
||||
float4 ps_main(psIn i) : COLOR0
|
||||
{
|
||||
float3 t = i.w * g_fTexScale;
|
||||
|
||||
float3 fColor = i.c;
|
||||
|
||||
float fStruct = noise(t) / 2.f;
|
||||
fStruct += noise(4.f * t) / 4.f;
|
||||
fStruct += noise(8.f * t) / 8.f;
|
||||
fStruct += noise(16.f * t) / 16.f;
|
||||
fStruct += noise(32.f * t) / 32.f;
|
||||
|
||||
fColor *= (1.f - g_fVariation) + g_fVariation * fStruct;
|
||||
|
||||
float fDetail = noise(81.f * t) / 2.f;
|
||||
fDetail += noise(243.f * t) / 4.f;
|
||||
fDetail += noise(729.f * t) / 8.f;
|
||||
|
||||
// Bump mapping
|
||||
// float ddf = g_fBumpFalloff * dot(fwidth(i.w), 1.f);
|
||||
float3 pp = i.w + i.n * g_fBumpDepth * (fStruct + fDetail / 16.f); // (1.f + ddf)
|
||||
float3 ddppx = ddx(pp);
|
||||
float3 ddppy = ddy(pp);
|
||||
float3 n = normalize( cross(ddppx, ddppy) );
|
||||
|
||||
// Shadow
|
||||
float fShadow = 0.2f + 0.8f * (float)tex2Dproj(shadowSampler, i.s);
|
||||
|
||||
// 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 = saturate( dot(n, h) );
|
||||
fColor += g_fSpecularPower * tex1D(specSampler, fShadow * s).xyz;
|
||||
|
||||
//return float4(fColor, 1.f);
|
||||
|
||||
// calculate coloration (hypno toad commands you!)
|
||||
float4 plasmaVal = tex3D(randomSampler, g_fTime * 0.001 + t * 0.0025);
|
||||
float plasmaPower = saturate((i.w.z - 80) + g_fTime * 15 ) * plasmaVal.a;
|
||||
float3 plasmaColor = lerp(1, hslToRgb(1 + plasmaVal.rgb), plasmaPower);
|
||||
|
||||
return float4(fColor * plasmaColor, 1.f);
|
||||
}
|
||||
89
evoke-64k/bp10/cfg/_svn/tmp/tempfile.tmp
Normal file
89
evoke-64k/bp10/cfg/_svn/tmp/tempfile.tmp
Normal file
@@ -0,0 +1,89 @@
|
||||
float2 res : register(c0);
|
||||
|
||||
sampler2D colorSampler : register(s0);
|
||||
sampler2D depthSampler : register(s1);
|
||||
sampler2D blurSampler : register(s4);
|
||||
|
||||
// Tweakables
|
||||
static float g_fRadius = 0.005f;
|
||||
static float g_fLowRadiusScaling = 0.4f;
|
||||
static float g_fNearPlane = 1.0f;
|
||||
static float g_fFocalPlane = 8.0f;
|
||||
static float g_fFarPlane = 128.0f;
|
||||
static float g_fMaxDistBlur = 0.45f;
|
||||
|
||||
static const float2 vPoissonDisc[] = {
|
||||
float2(-0.326212f, -0.40581f),
|
||||
float2(-0.840144f, -0.07358f),
|
||||
float2(-0.695914f, 0.457137f),
|
||||
float2(-0.203345f, 0.620716f),
|
||||
float2(0.96234f, -0.194983f),
|
||||
float2(0.473434f, -0.480026f),
|
||||
float2(0.519456f, 0.767022f),
|
||||
float2(0.185461f, -0.893124f),
|
||||
float2(0.507431f, 0.064425f),
|
||||
float2(0.89642f, 0.412458f),
|
||||
float2(-0.32194f, -0.932615f),
|
||||
float2(-0.791559f, -0.59771f)
|
||||
};
|
||||
|
||||
float4 ps_blur_intensity(float2 TexCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// Sample pixel depth
|
||||
float fDepth = tex2D(depthSampler, TexCoord).x;
|
||||
|
||||
// Fix canvas depth
|
||||
fDepth += (fDepth < 0.001f) * g_fFarPlane;
|
||||
|
||||
float fIntensity;
|
||||
|
||||
// Close-up blur
|
||||
if(fDepth < g_fFocalPlane)
|
||||
fIntensity = (fDepth - g_fFocalPlane) / (g_fFocalPlane - g_fNearPlane);
|
||||
// Distance blur
|
||||
else
|
||||
fIntensity = min((fDepth - g_fFocalPlane) / (g_fFarPlane - g_fFocalPlane), g_fMaxDistBlur);
|
||||
|
||||
// Bias to valid range
|
||||
return float4(
|
||||
tex2D(colorSampler, TexCoord).xyz,
|
||||
0.5f + 0.5f * fIntensity);
|
||||
}
|
||||
|
||||
float4 ps_main(float2 TexCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// Center pixel depth
|
||||
float fDepth = tex2D(colorSampler, TexCoord).w;
|
||||
|
||||
// Scale sampling radius
|
||||
float fRadius = abs(2.0f * g_fRadius * fDepth - g_fRadius);
|
||||
float fLowRadius = fRadius * g_fLowRadiusScaling;
|
||||
|
||||
float4 fColor = 0.0f;
|
||||
float fAmount = 0.0f;
|
||||
|
||||
// Loop over samples
|
||||
for(int i = 0; i < 12; i++)
|
||||
{
|
||||
// Sample on poisson disc
|
||||
float2 fHighSampleTexCoord = TexCoord + fRadius * vPoissonDisc[i];
|
||||
float2 fLowSampleTexCoord = TexCoord + fLowRadius * vPoissonDisc[i];
|
||||
|
||||
// Sample blurred and unblurred texture
|
||||
float4 fHighSample = tex2D(colorSampler, fHighSampleTexCoord);
|
||||
float4 fLowSample = tex2D(blurSampler, fLowSampleTexCoord);
|
||||
|
||||
// Blend between blurred and unblurred texture
|
||||
float fSampleBlurIntensity = abs(2.0f * fHighSample.w - 1.0f);
|
||||
float4 fSample = lerp(fHighSample, fLowSample, fSampleBlurIntensity);
|
||||
|
||||
// Compute smart weight to avoid cross-edge leaking
|
||||
float fWeight = fSample.w < fDepth ? abs(2.0f * fSample.w - 1.0f) : 1.0f;
|
||||
|
||||
// Sum up
|
||||
fColor += fSample * fWeight;
|
||||
fAmount += fWeight;
|
||||
}
|
||||
|
||||
return fColor / fAmount;
|
||||
}
|
||||
Reference in New Issue
Block a user