Shader texture lookup?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Shader texture lookup?

Post by jacmoe »

I have this hlsl pixel shader:

Code: Select all

sampler base_texture;

// Constants
float3  color;

float4 main(float2 uv : TEXCOORD0) : COLOR
{
  float4 Out;
  Out = tex2D(base_texture, uv); 
  Out.rgb *= color;

  return Out;
}
You are supposed to pass it a texture (sampler), I guess ...

Does Ogre support this?
I got my hands on a lot of atmospheric shader scripts (*drool*), but a lot of them do texture lookups ..
It must be a recent technique, because it complains about it not being supported under 2.0 - do you know which version it wants? 2.1 ?

:wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

Indeed it is! :)
nfz wrote:The first sampler variable defined is s0, the second is s1 and so on. The only time it doesn't work is if the sampler variable is not used in the shader or if you are combining fragmented HLSL shaders (similar to shader objects in GLSL) which Ogre doesnt support (yet).

To sum it up: the first sampler you define in your hlsl source corresponds to the first texture_unit in the pass of the technique in the material script and the second sampler defined refers to the second texture_unit and so on.
I found it here :wink:

I guess I should follow my own advice - the 'search' facility of this forum :oops:

Hopefully, this discovery will lead to Caelum2 :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.