HLSL Shaders - Tangent & Binormal

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
scippie
Posts: 26
Joined: Sat Oct 13, 2007 3:35 pm
Location: Belgium
Contact:

HLSL Shaders - Tangent & Binormal

Post by scippie »

I've been searching on a bug in my shaders for a really long time, only to find out that the problem was not my shader, but me thinking that the Vertex Shader's input tangent would be stored in the TANGENT register and the binormal in the BINORMAL register.

After much too long, I found this topic on this forum that states that I should use the TEXCOORD1 and TEXCOORD2 register in stead of TANGENT and BINORMAL. YES! That solved it!

But why??? Why??? Why does irrlicht use the TEXCOORD1 and TEXCOORD2 registers in stead of the obvious TANGENT and BINORMAL registers?

Yes, you might say that I should have read this forum earlier to find out about this, but you can't blame me for trusting irrlicht :oops:
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Re: HLSL Shaders - Tangent & Binormal

Post by sio2 »

scippie wrote: But why??? Why??? Why does irrlicht use the TEXCOORD1 and TEXCOORD2 TANGENT and BINORMAL registers?
On a very simplified level:
TANGENT and BINORMAL are semantics;
TEXCOORD1 and TEXCOORD2 are registers.

Post your HLSL code so we can see how your trying to do things...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Re: HLSL Shaders - Tangent & Binormal

Post by Saturn »

sio2 wrote:
scippie wrote: But why??? Why??? Why does irrlicht use the TEXCOORD1 and TEXCOORD2 TANGENT and BINORMAL registers?
On a very simplified level:
TANGENT and BINORMAL are semantics;
TEXCOORD1 and TEXCOORD2 are registers.
Not really. TANGENT, BINORMAL, TEXCOORDx are all semantics and registers are registers, input registers in this case.

As far as I understand the question, the problem is already solved, only it is asked why Irrlicht uses TEXCOORD semantics for tangents and binormals. Can't answer that one, sorry.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Because irrlicht doesn't use vertex attributes for some reason. (probably to save loading yet another extension if under opengl

Those aren't registers, think of registers (or call them temporary registers because it makes more sense) as temporary variables that you have total control of what goes in and out of them.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Re: HLSL Shaders - Tangent & Binormal

Post by sio2 »

Saturn wrote: Not really.
Yeah, I don't think I got my point over very well.

If you use tangent and binormal semantics then there needs some mapping for the shader to know where in the input vertex to pull the data. If you use texcoordn then I think the HLSL compiler can infer where to pull data from to fill the respective register. I'm guessing a bit on this as: a) I haven't seen the OP's code and b) the HLSL compiler sometimes needs a "nudge" (such as the need for :register(sn) sometimes for samplers).

Does Irrlicht use FVF codes or full vertex declarations?
scippie
Posts: 26
Joined: Sat Oct 13, 2007 3:35 pm
Location: Belgium
Contact:

Post by scippie »

Thanks. I didn't know that those were not real registers (the book I'm reading puts them next to TEXCOORDn and the like).

No, there is no problem to be solved with my shader as it works fine now.

I just got very strange looking results when I used TANGENT en BINORMAL but after a long search, I tried the obvious: "are the tangents and binormals that I receive in the shaders the same as the ones I have in my code?"... and they werent :). And that's why I thought: WHY? :)
Post Reply