Added normal based material.

This commit is contained in:
David Williams 2008-01-16 20:56:54 +00:00
parent 4013e9143f
commit 2ec6e8fbda
5 changed files with 69 additions and 16 deletions

View File

@ -0,0 +1,10 @@
struct v2f
{
float4 Position : POSITION; //in projection space
float4 Normal : TEXCOORD0;
};
float4 main(v2f IN) : COLOR
{
return abs(IN.Normal);
}

View File

@ -0,0 +1,27 @@
struct a2v
{
float4 Position : POSITION; //in object space
float3 Normal : NORMAL;
float2 Alpha : TEXCOORD0;
};
struct v2f
{
float4 Position : POSITION; //in projection space
float4 Normal : TEXCOORD0;
};
v2f main(a2v IN, uniform float4x4 world, uniform float4x4 viewProj)
{
v2f OUT;
OUT.Position = mul(world, IN.Position);
IN.Normal = normalize(IN.Normal);
OUT.Normal = float4(IN.Normal,0.0);
OUT.Position = mul(viewProj, OUT.Position);
return OUT;
}

View File

@ -94,4 +94,18 @@ fragment_program TextureAtlasExperimentalFragmentProgram cg
source TextureAtlasExperimentalFragmentProgram.cg
entry_point main
profiles ps_1_1 arbfp1
}
vertex_program NormalVertexProgram cg
{
source NormalVertexProgram.cg
entry_point main
profiles vs_1_1 arbvp1
}
fragment_program NormalFragmentProgram cg
{
source NormalFragmentProgram.cg
entry_point main
profiles ps_1_1 arbfp1
}

View File

@ -0,0 +1,18 @@
material NormalMaterial
{
technique
{
pass
{
vertex_program_ref NormalVertexProgram
{
param_named_auto world world_matrix
param_named_auto viewProj viewproj_matrix
}
fragment_program_ref NormalFragmentProgram
{
}
}
}
}

View File

@ -520,22 +520,6 @@ namespace Ogre
const uchar material0 = vertMaterials[triTable[iCubeIndex][i ]];
const uchar material1 = vertMaterials[triTable[iCubeIndex][i+1]];
const uchar material2 = vertMaterials[triTable[iCubeIndex][i+2]];
/*if(surfacePatchMapResult.find(material0) == surfacePatchMapResult.end())
{
surfacePatchMapResult.insert(std::make_pair(material0,new IndexedSurfacePatch));
}
if(surfacePatchMapResult.find(material1) == surfacePatchMapResult.end())
{
surfacePatchMapResult.insert(std::make_pair(material1,new IndexedSurfacePatch));
}
if(surfacePatchMapResult.find(material2) == surfacePatchMapResult.end())
{
surfacePatchMapResult.insert(std::make_pair(material2,new IndexedSurfacePatch));
}*/
//float materialToUse = std::max(material0,std::max(material1,material2));
//If all the materials are the same, we just need one triangle for that material with all the alphas set high.