Added arb imaging definitions (but we don't use it)
This commit is contained in:
parent
a9117ef399
commit
43be23e8fe
2 changed files with 87 additions and 0 deletions
41
cg/deluxe.cg
Normal file
41
cg/deluxe.cg
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
Cg code that does the delux-maps.
|
||||
|
||||
Deluxmaps:
|
||||
These are maps with a worldspace average to light vector, so you can simulate
|
||||
any lightsource with them, area, skys.... and have some level of bumpmapping.
|
||||
So the problem is we have to put this into tangent space per pixel and renormalize!
|
||||
*/
|
||||
/*
|
||||
struct myVertexOut {
|
||||
float4 tanVec : COLOR0;
|
||||
float4 binVec : COLOR1;
|
||||
float4 matColor : TEXCOORD0; //materials color map
|
||||
float4 matNorm : TEXCOORD1; //materials tangentspace normal map
|
||||
float4 luxColor : TEXCOORD2; //luxColor map (aka an ordinary lightmap)
|
||||
float4 deLuxVec : TEXCOORD3; //"to Light" map in worldspace.
|
||||
};*/
|
||||
/*
|
||||
float4 main(myVertexOut I,
|
||||
uniform sampler2D normalMap,
|
||||
uniform sampler2D intensityMap,
|
||||
uniform sampler2D colorMap) : COLOR
|
||||
{
|
||||
// Lookup the normal map
|
||||
float4 normal = 2 * (tex2D(normalMap, I.texCoord0.xy) - 0.5);
|
||||
|
||||
// Multiply
|
||||
// 3 X 2 matrix generated using lightDir and halfAngle with
|
||||
// scaled normal
|
||||
// followed by lookup in intensity map with the result.
|
||||
float2 intensCoord = float2(dot(I.lightDir.xyz, normal.xyz),
|
||||
dot(I.halfAngle.xyz, normal.xyz));
|
||||
float4 intensity = tex2D(intensityMap, intensCoord);
|
||||
|
||||
// Lookup color
|
||||
float4 color = tex2D(colorMap, I.texCoord3.xy);
|
||||
|
||||
// Blend/Modulate intensity with color
|
||||
return color * intensity;
|
||||
}
|
||||
*/
|
46
cg/deluxe1.cg
Normal file
46
cg/deluxe1.cg
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Geforce 4 deluxmaps, pass one
|
||||
* compile with "-profile fp20"
|
||||
*/
|
||||
|
||||
struct inputVertex {
|
||||
float4 norVec : COLOR0;
|
||||
float4 tanVec : TEXCOORD0;
|
||||
float4 binVec : TEXCOORD1;
|
||||
float4 deLuxCoord : TEXCOORD2;
|
||||
float4 texCoord : TEXCOORD3;
|
||||
};
|
||||
|
||||
float4 main(inputVertex I, uniform samplerCUBE tangentCube, uniform samplerCUBE binormalCube,
|
||||
uniform sampler2D deLuxMap, uniform sampler2D normalMap) : COLOR
|
||||
{
|
||||
//normal
|
||||
float3 normal = I.norVec.xyz;
|
||||
normal = normal + (normal/2)*(1-dot(normal,normal));//renormalize
|
||||
|
||||
//tangent
|
||||
float3 tangent = 2 * (texCUBE(tangentCube, I.tanVec.xyz).xyz - 0.5);
|
||||
|
||||
//binormal
|
||||
float3 binormal = 2 * (texCUBE(binormalCube, I.binVec.xyz).xyz - 0.5);
|
||||
|
||||
// Get the worldspace delux
|
||||
float3 wDelux = 2 * (tex2D(deLuxMap, I.deLuxCoord.xy).xyz - 0.5);
|
||||
|
||||
//Put into tangent space
|
||||
float3 tDelux;
|
||||
tDelux.x = dot(wDelux,tangent);
|
||||
tDelux.y = dot(wDelux,binormal);
|
||||
tDelux.z = dot(wDelux,normal);
|
||||
|
||||
tDelux = tDelux + (tDelux/2)*(1-dot(tDelux,tDelux));//renormalize
|
||||
|
||||
// Get the normal from normal map lookup
|
||||
float3 matNormal = 2 * (tex2D(normalMap, I.texCoord.xy).xyz - 0.5);
|
||||
|
||||
// normal . light vector
|
||||
float4 res;
|
||||
res = saturate(dot(tDelux.xyz, matNormal.xyz).x);
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in a new issue