Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Projecting cubemaps


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Tessellator   Members   -  Reputation: 723

Like
0Likes
Like

Posted 22 August 2005 - 05:02 AM

Hi all, I've projected 2D textures in the past (for spot lights and such), mostly with the FFP, but it seemed reasonably easy to move that thinking into a vertex/pixel shader. What i'd like to do is project a cube map using the programmable pipeline, alhough I'm not quite sure what it is I'm supposed to pass to the texCUBEproj instruction (in HLSL). In 2D, i'd multiply the world space pos back into the projector space (with texture offsets and biases included), and pass that along to the tex2Dproj instruction. I think what's confusing me is the fact im dealing with 3d coordinates, with a fourth for the divide. Can anyone give me a little pointer, or post a link to some info regarding this? I've googled but turned up very little info. Any help would be massively appreciated. :) Many thanks, T

Sponsor:

#2 SimmerD   Crossbones+   -  Reputation: 1102

Like
0Likes
Like

Posted 22 August 2005 - 06:03 AM

There is no 4th for the divide with a cubemap.

just do :

float4 cube_space_pos = world_space_pos - cubemap_pos;

half4 color = TexCUBEProj( cube_space_pos.xyz );

#3 Cypher19   Members   -  Reputation: 768

Like
0Likes
Like

Posted 22 August 2005 - 07:08 AM

Edit: My mind a splode: SimmerD is...WRONG? http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/directx9_c_Oct_2004/directx/graphics/reference/highlevellanguageshaders/intrinsicfunctions/texcubeproj.asp



#4 Tessellator   Members   -  Reputation: 723

Like
0Likes
Like

Posted 22 August 2005 - 11:45 AM

I'm away from my home computer now so I can't give that a go, but I would think it would end up doing a divide by zero if in fact the docs are correct. I'll post back tomorrow once I've given it a go.

Edit: Just noticed the .xyz mask on the input, although the docs specify the input size as 4. Hopefully that'll work... as I said, I'll get back tomorrow. :)

Ta,
T

#5 Sneftel   Senior Moderators   -  Reputation: 1781

Like
0Likes
Like

Posted 22 August 2005 - 11:52 AM

I assume that TexCUBEProj() is merely there for completeness, as any cubetexture lookup for a vector should be equivalent to a lookup to the corresponding normalized vector.

#6 rept   Members   -  Reputation: 157

Like
0Likes
Like

Posted 22 August 2005 - 01:38 PM

If you need it for a point-light projector, then just simply transform the surface point into light-space, and use this 3-vector for a cubemap lookup (texCUBE), no need to use the *proj variant.

Anyway, projected cubemaps work pretty much the same way as their planar counterparts : xyz is divided by w, and the standard cubemapping process applies from here : greatest (absolute) component is selected (face index), rest is divided by its absolute value, biased, and looked up.

#7 Tessellator   Members   -  Reputation: 723

Like
0Likes
Like

Posted 22 August 2005 - 09:58 PM

Well, texCUBE seems to work fine as suggested, so cheers guys! :)
I now do (the equivelant of):

float4 projLightVal = texCUBE(cubeSampler, mul(vLightToTexelDir, c_matToLightSpace));

Ta muchly,
T




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS