1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
sampler2D BaseSampler = sampler_state
{
MinFilter = Linear;
MagFilter = Linear;
WrapS = Repeat;
WrapT = Repeat;
};
sampler2D NormalSampler = sampler_state
{
MinFilter = Linear;
MagFilter = Linear;
WrapS = Repeat;
WrapT = Repeat;
};
void v_SimpleBumpMap
(
in float3 modelPosition : POSITION,
in float3 modelLightDirection : COLOR0,
in float2 modelBaseTCoord : TEXCOORD0,
in float2 modelNormalTCoord : TEXCOORD1,
out float4 clipPosition : POSITION,
out float3 vertexLightDirection : COLOR0,
out float2 vertexBaseTCoord : TEXCOORD0,
out float2 vertexNormalTCoord : TEXCOORD1,
uniform float4x4 PVWMatrix
)
{
// Transform the position from model space to clip space.
clipPosition = mul(PVWMatrix, float4(modelPosition,1.0f));
// Pass through the parameters.
vertexBaseTCoord = modelBaseTCoord;
vertexNormalTCoord = modelNormalTCoord;
vertexLightDirection = modelLightDirection;
}
void p_SimpleBumpMap
(
in float3 vertexLightDirection : COLOR0,
in float2 vertexBaseTCoord : TEXCOORD0,
in float2 vertexNormalTCoord : TEXCOORD1,
out float4 pixelColor : COLOR
)
{
float3 baseColor = tex2D(BaseSampler, vertexBaseTCoord).rgb;
float3 normalColor = tex2D(NormalSampler, vertexNormalTCoord).rgb;
// The lack of normalizations of the light and normal vectors
// allows this to compile for Shader Model 1 (ps_1_1).
float3 lightDirection = 2.0f*vertexLightDirection - 1.0f;
float3 normalDirection = 2.0f*normalColor - 1.0f;
float LdN = saturate(dot(lightDirection, normalDirection));
pixelColor.rgb = LdN*baseColor;
pixelColor.a = 1.0f;
}
|