Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Cubemap Problem (with pic)

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

I'm using a cubemap and the sides of my objects are only using the 'front' part of the map. This image shows what I mean:

cubemap.jpg

The camera is at the origin looking straight down the positive z-axis. Notice how the sides of the sphere and cubes are white, the color of the 'front' part of the map (which is at the bottom of the image for reference.)

Here is my shader code:


// pixel shader part
// passed view and normal are in world coordinates

float3 V=normalize(input.view);
float3 N=normalize(input.normal);
float3 R=-reflect(V,N);
float3 color=texCUBE(ReflectionMap,R).xyz;


Am I doing something wrong ? Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
Hidden
That's how it should work for a reflection. At the right side of the sphere, the normals will be close to (1, 0, 0). If your view vector is close to (0, 0, 1) (assuming +Z goes into the screen), then your reflection vector will be pointing in the direction of positive Z. Hence, you will sample the far side of the cube map.

Share this post


Link to post
looks correctly to me.

the side of the sphere is nearly 90degree to the view, it's nearly the same angle like e.g. a water plane would have in relation to the view. reflecting a ray on a plane that is nearly 90 degree to the view, will result in direction that just slightly changes -> still points to the white side of the cubemap.

if that's what confused you.

if you'd use the normal instead of the reflection vector, you'd just get the sides, if that's what you want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!