# [SOVLED] HLSL coordinate tansforms

This topic is 3495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites
float2 uv = (float2(Position.x, -Position.y) + float2( 1.0f, 1.0f ) ) * 0.5f;

that's the answer, I've solved that.

##### Share on other sites
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...

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633676
• Total Posts
3013279
×