Skip to main content
GameDev.net gamedev.net
🔒 Locked

Spherical Environment Mapping?

Started by GameDev.net Oct 17, 2005 at 7:44 AM 4 replies 900+ views
Original Post
GameDev.net
GameDev.net
Hi there! I want to add Spherical Environment Mapping to my games and I wonder which is the best/easiest way to do it. I don't need dynamic stuff, just to apply a simple texture to objects so they can look like polished metal. DirectX sample (that pot) is nice, but there is to much to compute, isn't there any special functions or something to automate this?
Oxyacetylene
Oxyacetylene
I don't think you need to add anything special, just enable texture coordinate generation for sphere mapping.

As long as the normals of your model are correct, there shouldn't be any problems.
Khaos Dragon
Khaos Dragon
I am wondering this too. Do you basically render to a cubemap around the sphere, and then perhaps in a shader calculate a reflection vector to lookup the texel to use from the cubemap?
Nik02
Nik02
These coordinate generators are designed to work with cubemaps; the range of the coordinate vectors are -1...+1. However, you could apply a texture coordinate transform that scales them to 0...1 - which is the range for a 2d texture - effectively stretching the texture to cover the mesh.

The transformation needed is a simple combination of scaling and translation of the x and y vectors (or u and v in the context of texture coordinates). You don't need to modify z since it doesn't get used with a 2d texture.

I recommend using the camera-space reflection as the generator for "chrome" coordinates, it is the most physically correct one out of the options, provided that the texture image is defined spherical coordinates.

EDIT: I assume that D3DTSS_TCI_SPHEREMAP would convert the flat texture space into a spherical one automatically. Haven't tried it, though!
Niko Suni

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.