Archived

This topic is now archived and is closed to further replies.

Carandiru

Spherical Enviroment Mapping

Recommended Posts

Carandiru    212
Anyone know of a good tutorial for DirectX 8 / 8.1b that will use spherical enviroment mapping WITHOUT pixel/vertex shaders & effect scripts? Please let me know! .:[Carandiru]:. -Skilled C++ Programmer -DirectX 8.1b, Win32

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Set your texture coordinate index to D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR or D3DTSS_TCI_CAMERASPACENORMAL. Reflection vector looks better, but takes more time to compute. Normal vector will not really work on a flat surface.

The your texture transform to scale of 0.5 and offset of 0.5

_11 = _22 = 0.5f;
_31 = _32 = 0.5f

Enable texture transform and set the texture transform, Draw, turn off texture transform.


  
pDev->SetTextureStageState( nStage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
pDev->SetTextureStageState(nStage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
pDev->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+nStage), &xformmatrix);
...
Draw
...
pDev->SetTextureStageState(nStage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );


Typical use:
Stage 0 = diffuse texture. Stage 1 = env texture.
Stage 0, selectarg1 (texture).
Stage 1, add (texture, current).
Stage 2, disable.

Share this post


Link to post
Share on other sites
Carandiru    212
Thank you very much, it was suprisingly hard to find any information on this.

.:[Carandiru]:.
-Skilled C++ Programmer
-DirectX 8.1b, Win32

Share this post


Link to post
Share on other sites