TEXCOORDn in HLSL?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

TEXCOORDn in HLSL?

Post by Virror »

Trying to change my triplanar texturing shader to be able to use multiple texture using an simple texture atlas. My mesh is based on a volume of voxels were every voxel have a material value. Now i want to take this value into the shader and i have read that using TEXCOORD0 for this works very well, but i have no clue how to make TEXCOORD0 contain something? How do i set this from Irrlicht?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: TEXCOORDn in HLSL?

Post by Mel »

It all depends on the type of vertex you are passing to a shader. Irrlicht still doesn't support FVF's so, you have to adapt your code to what Irrlicht can offer. In this case, your best friend is the Tangents vertices, mainly because it is the largest, and thus, the one which has the most room for stuff.

The structure of a tanget vertex contains a vector which is the position, another with the normal, a 32 bit unsigned integer which has the color, a 2d vector containing the texture map coordinates and 2 more vectors containing the Binormal and the Tangent of the vertex. These are mapped as follow:

Position -> POSITION0: float4
Normal -> NORMAL0: float3
Color -> COLOR0: float4
UVcoordinates-> TEXCOORD0: float2
Tangent-> TEXCOORD1: float3
Binormal-> TEXCOORD2: float3

So, if you want to pass any data to a shader, you have to alter the vertex information manually, keeping in mind that if you wish the data to be ported correctly, you have to fit your data in the space and types the vertex has.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: TEXCOORDn in HLSL?

Post by mongoose7 »

But wouldn't you automatically get TEXCOORD0 just by loading a model with UV coords?
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: TEXCOORDn in HLSL?

Post by Virror »

Thanx Mel, just what i needed to know, i only have a 4-bit value i need to pass, so it should be easy to fit : )
trivtn
Posts: 132
Joined: Tue Jan 17, 2006 12:30 pm
Location: Viet Nam
Contact:

Re: TEXCOORDn in HLSL?

Post by trivtn »

Thanks Mel !
There's something is fantastic, there's nothing is absolute.
Post Reply