Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, 7th_zorro, TedMar), 1,243 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Tangent and Bi-Normal #53434
08/27/05 15:50
08/27/05 15:50
Joined: Jan 2005
Posts: 72
Cairo, Egypt
Sanfir Offline OP
Junior Member
Sanfir  Offline OP
Junior Member

Joined: Jan 2005
Posts: 72
Cairo, Egypt
Hi,
I was wondering how to implement the Tangent and BiNormal in 3dgs, when I use these properties directly, I get a lot of errors. I know that the tangent is calculated through D3DXComputeTangent(), and the binormal is the dot product of the tangent and the normal, but how to get that working from c-script?


There are two ways to write an error free code, only the third one succeeds!! ramy.wassef@gmail.com
Re: Tangent and Bi-Normal [Re: Sanfir] #53435
08/30/05 08:53
08/30/05 08:53
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
for some reason tangent is caluculated into texcoord 1, not the actual tangent slot. so you must use texcoord1 for tangent. to generate the tangents, you need to add this flag to your material..
flags=tangent;

then to get the binormal you must do it manually in you shader code..and binormal is a *cross product* not a dot product.
if using HLSL, you do it like so:
struct VS_INPUT_STRUCT
{
float4 position: POSITION;
float3 tangent: TEXCOORD1;
float3 normal: NORMAL;
float2 texcoord0: TEXCOORD0;
};
......
binormal=cross(In.tangent, In.normal);


as a side note: this whole thing is wierd because using the compute tangent function is D3DX *should* give you the tangent in the tangent slot and the binormal in the binormal slot. At last that's what it claims to do. But in A6 the vertex format doesnt allow for this.,. why they dont change this i dont know. However, even wierder, in my dll when i have cloned a mesh to a new vertex format that should have tangent and binormal usage slots, D3DXMeshComputeTangentEX still doesnt give me the right tangent and binormal in the right slots. I actually do need ot use texcoord1 to make it work, and the binormal is never genertated correctly. Does anyone know what the deal is here?

Re: Tangent and Bi-Normal [Re: Matt_Aufderheide] #53436
08/30/05 14:42
08/30/05 14:42
Joined: Jan 2005
Posts: 72
Cairo, Egypt
Sanfir Offline OP
Junior Member
Sanfir  Offline OP
Junior Member

Joined: Jan 2005
Posts: 72
Cairo, Egypt
Thanks Matt that really helped


There are two ways to write an error free code, only the third one succeeds!! ramy.wassef@gmail.com
Re: Tangent and Bi-Normal [Re: Sanfir] #53437
09/02/05 13:00
09/02/05 13:00
Joined: Aug 2002
Posts: 44
Panama City, FL
S
Specterdragon Offline
Newbie
Specterdragon  Offline
Newbie
S

Joined: Aug 2002
Posts: 44
Panama City, FL
For me, I noticed there was issues with the tangent/bimormals, so I've been calculating them at runtime by hand. The results are good, but probably a little slow. And it isn't EXACTLY accurate (there's an issue reguarding the world up direction)... but at least doing it myself has the advantage that I know what the code is doing.

*shrug* Works for me at least.


Just thinking out loud, Specterdragon

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1