# 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.

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

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 76
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632968
• Total Posts
3009584
• ### Who's Online (See full list)

There are no registered users currently online

×