Added normal based material.
This commit is contained in:
parent
4013e9143f
commit
2ec6e8fbda
10
media/materials/programs/NormalFragmentProgram.cg
Normal file
10
media/materials/programs/NormalFragmentProgram.cg
Normal 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);
|
||||
}
|
27
media/materials/programs/NormalVertexProgram.cg
Normal file
27
media/materials/programs/NormalVertexProgram.cg
Normal 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;
|
||||
}
|
@ -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
|
||||
}
|
18
media/materials/scripts/Normal.material
Normal file
18
media/materials/scripts/Normal.material
Normal 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
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user