4/06/2007

Adding texture

It's time to make use of a texture source in the shader. In order to use a texture source in a pixel shader, it should be first declared as a sampler.

.
.
.
texture diffuseTexture : DIFFUSE
<

string Uiname = "diffuse texture"
string ResourceName = "diffuse.dds"
>;

sampler diffuseTextureSampler = sampler_state
{

texture = {diffuseTexture};
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
.
.
.

float4 PS(vertexOutput IN) : COLOR
{
float3 N = normalize(IN.worldNormal);
float3 L = normalize(IN.lightVector);
float diff = saturate(dot(N,L));
float4 diffTexture = tex2D(diffuseTextureSampler, IN.texCoord.xy) ;
.
.
.



texture_added.fx

No comments:

Tag