[SOVLED] HLSL coordinate tansforms

Started by
1 comment, last by brekehan 14 years, 11 months ago
say: Out.pos = mul( Position, g_mWorldViewProjection); so what is the corresponding coordinate in view space (UV?) pos.xy ? pos.xy / pos.w ? or should I do some transforms? float2 uv = sign( Out.pos ); uv = (float2(uv.x, -uv.y) + 1.0) * 0.5; and I wnat know when to /.w and when not? [Edited by - zinking on May 17, 2009 12:56:54 AM]
Advertisement
float2 uv = (float2(Position.x, -Position.y) + float2( 1.0f, 1.0f ) ) * 0.5f;

that's the answer, I've solved that.
A UV is not a "coordinate in view space"
It is a texture coordinate.

It does not have a set range either, like you are using in your calculation.
It does however map (0,0 to 1,1) to texture addresses.
There are different modes to map these coordinates.

Your choices if words are confusing.

Do you mean, "How do I programatically create my own texture coordinates, in a clamped addressing mode, given the vertex positions of a triangle?" or do you mean "What are the screenspace coordinates of a vertex given in world space?"

The latter would depend on your projection transform and viewport.

I don't follow what you are transforming and to where...

This topic is closed to new replies.

Advertisement