Jump to content
  • Advertisement
Sign in to follow this  
CodeBoyCjy

how to make real time reflection on XNA?

This topic is 3610 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

hey: I want to simulate real time reflection in my racing game , I don't know how to do it properly , and how does the next gen game(NFS UnderCover or ...) finish the task. I recall that there is a simple demo in the sample of the DirectX SDK which showes a shpere reflects the plane flying aroung it , but the cost of generating that cube reflection map could be much small than generating a real cube reflection map in the game bacause in the game there are a lot of models to be rendered . And I've got an idea I don't know if it works , I record the radius of the bounding sphere of each model and when rendering the reflection cube map , if the model is too far from the car , I don't need to render them , so every time with little cost , there will be only a little model to be rendered on the cube map . Does the way speed up the generating of the cube map?? Any ideas is really appreciated!!! Thank you for your attension.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by CodeBoyCjy
And I've got an idea I don't know if it works , I record the radius of the bounding sphere of each model and when rendering the reflection cube map , if the model is too far from the car , I don't need to render them


You'll actually want to better than that. Using that bounding sphere, you can actually determine whether a model should be rendered to any of the 6 individual faces of a cubemap. You can do this the same way visibility testing is done with the main view frustum: testing the sphere against each of the 6 planes that make up the view frustum.

If you haven't implemented view frustum culling yet, the XNA Framework has a class called BoundingFrustum that makes the process very easy. You simply give it your combined view * projection matrix, and then you can test any BoundingSphere or BoundingBox for visibility. So your algorithm will go like roughly like this:

for each model
if Distance(modelPos - carPos) < reflectionDistance
for each cubemap face
if cubemapFaceFrustum.Intersects(modelBoundSphere)
render model to cubemap face


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!