Jump to content
  • Advertisement
Sign in to follow this  


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

I am trying to reflect my world and all the dynamic objects in it in a water plane and have come up with a few questions, if anyione can help it would be appreciated, I apologise in advance for the questions being so general. I am using the Irrlicht engine and as far as I understand it currently doesn't support cubemaps, I was wondering if somebody could point me in the direction of any tutorials that explain how to do this myself from scratch, rather than a DX demo that simply poinys me in the direction of DX's generatecubemap() or whatever it is? I assume it would simply be a matter of aiming the camera along the + and - of each axes (postioning it at the 'centre' of my environemnt?) then rendering to a texture, the resulting 6 textures could be used as a cubemap. once I have the cubemap (or the 6 textures) how do I figure out the texture coordinates. Could i just use a vertex location and its normal to decide at which texture it would intersect and at which point (using a shader?)? Would this be better done on a per pixel basis with a shader? And if so I am really rather clueless as to how to claculate what the value of the pixel would be. Obviously I am not expecting an exactly detailed step by step but just then main theory would be a real help!

Share this post

Link to post
Share on other sites
Do you plan to use cubemaps or 6 seperate textures?

Either way, the filling is the same. For each surface, camera position is set to the center of the cubemap, looking down the axis. What I do is

Set projection matrix to something where the aspect ratio is 1

Dim iCubeMap As Integer = 0
Dim CamClone As clsCamera = New clsCamera
For iCubeMap = 0 To 5
RTDB.BeginScene(DB.GetCubeMapSurface(iCubeMap, 0))
D3DDevice.Clear(ClearFlags.ZBuffer Or ClearFlags.Target, Color.FromArgb(255, 255, 255, 255), 1.0F, 0)

Select Case iCubeMap
Case CubeMapFace.NegativeX
CamClone.CamViewDir = New Vector3(-1, 0, 0)
CamClone.CustomUpVec = New Vector3(0, 1, 0)
Case CubeMapFace.NegativeY
CamClone.CamViewDir = New Vector3(0, -1, 0)
CamClone.CustomUpVec = New Vector3(0, 0, 1)
Case CubeMapFace.NegativeZ
CamClone.CamViewDir = New Vector3(0, 0, -1)
CamClone.CustomUpVec = New Vector3(0, 1, 0)
Case CubeMapFace.PositiveX
CamClone.CamViewDir = New Vector3(1, 0, 0)
CamClone.CustomUpVec = New Vector3(0, 1, 0)
Case CubeMapFace.PositiveY
CamClone.CamViewDir = New Vector3(0, 1, 0)
CamClone.CustomUpVec = New Vector3(0, 0, -1)
Case CubeMapFace.PositiveZ
CamClone.CamViewDir = New Vector3(0, 0, 1)
CamClone.CustomUpVec = New Vector3(0, 1, 0)
End Select

CamClone.CamPos = CubeMapFilledFrom

Render reflected vertices here


If your going to use HLSL and shaders with a cube map, just use
samplerCUBE texSamplerCUBETEX : TEXUNIT0 = sampler_state
Texture = (cubesampletex);
texCUBE(texSamplerCUBETEX, sampledirection.xyz)

Share this post

Link to post
Share on other sites
Just a small comment, anisotropic filtering only applies to magnification and minification filters and thus shouldn't be used for the MipFilter. Better set that to Linear instead.

Share this post

Link to post
Share on other sites
If you have a flat plane for the water there is really no point in using a cubemap, it would be better to just render the scene upside down to a texture and sample this texture in the waters shader using screen space texture coordinates.

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!