Got blending between materials working with texture atlases.
This commit is contained in:
@ -4,11 +4,13 @@ struct v2f
|
||||
float4 Color : COLOR;
|
||||
float4 TexCoords : TEXCOORD0;
|
||||
float4 Normal : TEXCOORD1;
|
||||
float Alpha : TEXCOORD2;
|
||||
float2 Alpha : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 main(v2f IN, uniform sampler2D colourMap : TEXUNIT0) : COLOR
|
||||
{
|
||||
//return float4(IN.Alpha.y, 1.0f-IN.Alpha.y, 0.0f,1.0f);
|
||||
|
||||
float textureScalingFactor = 20.0f;
|
||||
float textureSize = 512.0f;
|
||||
float noOfTexturesPerDimension = 4.0;
|
||||
@ -25,7 +27,7 @@ float4 main(v2f IN, uniform sampler2D colourMap : TEXUNIT0) : COLOR
|
||||
IN.TexCoords /= noOfTexturesPerDimension;
|
||||
|
||||
//Next we compute the offset of the texture in the texture atlas
|
||||
float material = floor(IN.Alpha);
|
||||
float material = floor(IN.Alpha.x);
|
||||
float y = floor(material / noOfTexturesPerDimension);
|
||||
float x = fmod(material,noOfTexturesPerDimension);
|
||||
float2 offset = float2(x,y);
|
||||
@ -40,5 +42,5 @@ float4 main(v2f IN, uniform sampler2D colourMap : TEXUNIT0) : COLOR
|
||||
float3 colourMapValue = colourMapValueXY + colourMapValueYZ + colourMapValueXZ;
|
||||
|
||||
//Return the result
|
||||
return float4(colourMapValue*IN.Color.rgb,1.0);
|
||||
return float4(colourMapValue*IN.Color.rgb*IN.Alpha.y,IN.Alpha.y);
|
||||
}
|
@ -2,7 +2,7 @@ struct a2v
|
||||
{
|
||||
float4 Position : POSITION; //in object space
|
||||
float3 Normal : NORMAL;
|
||||
float Alpha : TEXCOORD0;
|
||||
float2 Alpha : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
@ -11,7 +11,7 @@ struct v2f
|
||||
float4 Color : COLOR;
|
||||
float4 TexCoords : TEXCOORD0;
|
||||
float4 Normal : TEXCOORD1;
|
||||
float Alpha : TEXCOORD2;
|
||||
float2 Alpha : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct light
|
||||
@ -94,6 +94,8 @@ v2f doWork(a2v IN, float4x4 world, float4x4 viewProj, float4 ambient, int iNoOfL
|
||||
OUT.Position = mul(viewProj, OUT.Position);
|
||||
|
||||
OUT.Alpha = IN.Alpha;
|
||||
|
||||
//OUT.Material = IN.Material;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
@ -2,6 +2,12 @@ material TextureAtlasMaterial
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0.0 0.0 0.0
|
||||
diffuse 0.0 0.0 0.0
|
||||
}
|
||||
|
||||
pass
|
||||
{
|
||||
vertex_program_ref TextureAtlasOneLightVertexProgram
|
||||
@ -23,6 +29,9 @@ material TextureAtlasMaterial
|
||||
texture texture_atlas.png
|
||||
filtering none
|
||||
}
|
||||
|
||||
depth_bias 1 1
|
||||
scene_blend add
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user