Sign in to follow this  
J-Fox

TextureStageStates for selfmade Vertexfog

Recommended Posts

Hey, I wrote my own code for vertexfog which returns the fogamount for each vertex [0;1] and by that I get the vertexcolor. Now I ran into problems with white fog. DirectX will use a diffusecolor of &H000000 for a black object and &HFFFFFF for a fully textured object. I need it to be like this: 0,0,0 = Full black 127,127,127 = Full texture 255,255,255 = Full white Without vertex or pixelshaders though. (DirectX8)

Share this post


Link to post
Share on other sites
Try this instead:

Set D3DRS_TEXTUREFACTOR to fog color (ie: white = 0xFFFFFFFF).
Set diffuse alpha to fog amount (0-255). Your diffuse color can be whatever you want. If you don't want diffuse colors you can set it to white, or put the fog color in here instead.

In stage 0 do the regular MODULATE, TEXTURE, DIFFUSE.
In stage 1 do BLENDDIFFUSEALPHA, CURRENT, TFACTOR, which will lerp between textured/lit and fog based on your fog amount.

Since you're not using vertex shaders you must be modifying each vertex whenever the fog amount changes... every frame when you're moving. Ouch! Do you realize D3D has an optimized path for software vertex shader support. You can use SM2 vertex shaders mixed with fixed pipe pixel processing on any DX9 compatible card (ie: DX7 hardware or later).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this