Game Development Community

How does a shader know which texture it's referencing?

by Greg G · in Torque Game Engine Advanced · 03/02/2009 (3:44 pm) · 1 replies

I have been trying to write a simple shader but I can't figure out how to tell the shader which texture to use.

I found many examples of shaders using a texture but I don't understand the logic behind the code.

For example:
Fragout main( ConnectData IN,
              uniform sampler2D diffuseMap      : register(S0),
              uniform sampler2D bumpMap         : register(S1),
	      uniform sampler2D height_map      : register(S2),
              uniform float4    ambient         : register(C2),
			  uniform sampler2D lightMap       : register(S3)

What exactly does S0, S1, S2, & C2 mean. How do I know that S0 corresponds to the diffuse texture?

#1
03/03/2009 (6:54 am)
S0 is the sampler - here's a good intro to pixel shaders:

http://www.flipcode.com/archives/Pixel_Shader_20_Example-A_Simple_Example_of_Using_Pixel_Shader_Version_20.shtml