Simle HLSL cubemap reflection

Started by
27 comments, last by GLForce 14 years, 12 months ago
In this picture:

It looks like perspective correction is not enabled.
Advertisement
Yeah, I'll look for that too. The cubemap stuff solved one of my problems (one I didin't clearly mention), but the one you just pointed out is still present. Thanks for the tip.

EDIT : Well i've done some seraching and it seems that perspective correction is not a subject that is much talked about. Could you help me ? Send me a few pointers maybe ? (no bad C++ joke please :P)
"Do, or do not. There is no try." - Yoda
I,ve managed to record a little video showing what's wrong. At first, I'm at position (0,0,0) and everything seems fine. But look as I go further from the plane, the deformation appears. And then, but I think it's not visible in the video, as I'm really far, it seems right again. See for yourself.

"Do, or do not. There is no try." - Yoda
Quote:Original post by GLForce
I,ve managed to record a little video showing what's wrong. At first, I'm at position (0,0,0) and everything seems fine. But look as I go further from the plane, the deformation appears. And then, but I think it's not visible in the video, as I'm really far, it seems right again. See for yourself.

Such a tough nut to crack :)

I think at this point you should take a frame snapshot with PIX and view what your geometry looks like before and after the vertex shader. This will show you if anything looks out of the ordinary. Since you already tested the shader elsewhere and it worked, the only possible sources of error are the geometry, texture or perhaps a sampler error. I'm looking forward to seeing this thing work!

P.S. Thanks for the diggs on the book and articles - if you have any comments or questions feel free to PM me and we can talk about it!

Well, I'll try this as soon as I can. The thing is, this soon may come late. I'm still on VC++ 6, which means I've never been able to use a SDK over Summer 2003 (ouch), which means no PIX. I've got to kick my butt and finally install VC++ 2008 and a decent version of the directx9 sdk. Thanks again.
"Do, or do not. There is no try." - Yoda
Hi,
I said "it looks like" there is no perspective correction. I thought that Texture0 was interpolated without perspective correction. Taking a closer look at your picture made me realize that the perspective correction is there. As pointed out by Jason Z, the problem seems to be in your main application. I suspect there is someting wrong with the normal vectors. As you know, you can check it quickly in your shader by setting the color equal to the normal vector.
Another thing I tested out before. In fact, I used color alot to test many different vectors. The normal vectors are right (the shape appears green, which means (0,1,0)). So normals are not the problem. Right now I managed to switch my project to VC++ 2008 and I installed the November 2008 SDK, so PIX is mine. I'll try it to see what it gives me.
"Do, or do not. There is no try." - Yoda
I'm asking alot from you but does anyone think he could help me get a conclusion from this PIX run file ? I mean, I guess everything I see is right, but how would I know. I'm particlary confused by 4 floats coordinates (what is the w for ?). So I've uploaded the trace file, and put two screenshots in case you can't get the file itself.

file :
http://www.2shared.com/file/5422200/310c1d13/cubicreflection.html

preVS:
http://img106.imageshack.us/img106/4861/prevs.jpg

postVS:
http://img106.imageshack.us/img106/7189/postvs.jpg

To make things clear, only Position and Texture0 count in the postVS output. The other texture coordinates are used for other applications (bump mapping and stuff).

Thanks alot !
"Do, or do not. There is no try." - Yoda
Ok, I've got some results now. I tested a little more in the engine I talked about earlier (Virtools) to find that the only reason why it worked right was because the primitives I was using had a good number of polygons. When I tested with a simple two-polygons plane like mine, same problem. I foudn my solution, however, I'm not very satisfied. Is it normal that with two polygons the interpolation is too bad to make a good reflection ? Is there a way to make it good enough ? Becuase I was planning to use this on a water plane, and so I was happy that I could use a minimum number of polygons. Now I've got to make it go over 2500 for a 100 by 100 plane, which is kind of too much. And at this count, there is still a little deformation but I just ignored it because it's water (which will be perturbated anyway). Any thought ? Thanks.
"Do, or do not. There is no try." - Yoda
If interpolation is the problem, then you have two options:

- Move some or more of the calculation from the vertex shader to the pixel shader.

- Subdivide the mesh into smaller polys.

Subdivision is usually the best performing option, as there should still be far less vertices than pixels. However subdivision doesn't work so well if you can get so close to the object that you'd need thousands of polys for it to look correct.

This topic is closed to new replies.

Advertisement