HLSL - passing a texture

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
andrewdfrost
Posts: 13
Joined: Mon Feb 05, 2007 2:05 pm

HLSL - passing a texture

Post by andrewdfrost »

Hi Guys, I am new and this is my first post forgive my ignorance!

I developed an app that used MDX and effect files. In my original code I was passing a texture to the shader as a parameter. I am now trying to port it to use the Irrlicht engine (.NET version).

Whilst I have only been looking at Irrlicht for a few days, and I am still getting to grips with how it uses shaders, I cannot see an obvious way to pass a texture to a shader. The SetPixelShaderConstant and SetVertexShaderConstant methods only take floats.

I might just be being dumb, but any enlightenment very much appreciated.
TheC
Posts: 93
Joined: Fri May 05, 2006 7:50 am

Post by TheC »

Just apply the texture to the object and retrieve it like this:

sampler2D tex0 : register(s0);
sampler2D tex1 : register(s1);
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Re: HLSL - passing a texture

Post by sio2 »

andrewdfrost wrote:I might just be being dumb, but any enlightenment very much appreciated.
You don't set textures. Irrlicht has done it for you at the point when the shader is called.

There's some Irrlicht/shader stuff on my website: http://sio2.g0dsoft.com
andrewdfrost
Posts: 13
Joined: Mon Feb 05, 2007 2:05 pm

Post by andrewdfrost »

Thanks for that, but not being too experienced with HLSL, I don't suppose you could elaborate further:

My textures are created dynamically when the application starts up, do I retrieve the texture to set from the shader in OnSetConstants? If so how?

Cheers again.
andrewdfrost
Posts: 13
Joined: Mon Feb 05, 2007 2:05 pm

Post by andrewdfrost »

Cheers sio2, just picked up your post, I'll have a look at you stuff later today.
Post Reply