PDA

View Full Version : D3D9 fog problem



Dan
28-09-2005, 07:33 AM
I'm using Clootie's headers for D3D in Delphi
and was trying to make fog (just a simple linear fog)
but it just won't appear...
Here's what I did:


var
fogStart, fogEnd: single;
...
Device.SetRenderState(D3DRS_FOGENABLE, ITRUE);
Device.SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
Device.SetRenderState(D3DRS_FOGCOLOR, $00ff0000);
Device.SetRenderState(D3DRS_FOGSTART, PDWORD(@fogStart)^);
Device.SetRenderState(D3DRS_FOGSTART, PDWORD(@fogEnd)^);


After this the geometry is rendered normally without any fog... :roll:

//edit: D3DRS_FOGSTART twice!!! How could I be so stupid :D !!!

Firlefanz
28-09-2005, 08:06 AM
Hi Dan,

nice to hear from you :)

I make it like this:



procedure TCommandoForm.draw_fog;
var fogstart,fogend,fogdensity: single;
begin
fogstart:=0;//5
fogend:=1200; //64
fogdensity:=0.002;
xenscreen.Device.setrenderstate(d3drs_fogenable,1) ;
xenscreen.Device.setrenderstate(d3drs_fogvertexmod e,d3dfog_linear);
xenscreen.Device.setrenderstate(d3drs_fogcolor,d3d color_xrgb(40,40,50));
xenscreen.Device.setrenderstate(d3drs_fogstart,dwo rd((@fogstart)^));
xenscreen.Device.setrenderstate(d3drs_fogdensity,d word((@fogdensity)^));
xenscreen.Device.setrenderstate(d3drs_fogend,dword ((@fogend)^));
end;


Perhaps try much lower fogend value, I have a very big camera view field, try 50 for the beginning or something. And try different colors in Fogcolor!

Helps?

Firle

Dan
28-09-2005, 08:27 AM
Device.SetRenderState(D3DRS_FOGSTART, PDWORD(@fogStart)^);
Device.SetRenderState(D3DRS_FOGSTART, PDWORD(@fogEnd)^);

I knew that it was supposed to be bloody simple!!!
I just used D3DRS_FOGSTART twice!!!
Thanks Firle :D

Firlefanz
28-09-2005, 08:29 AM
Glad I could help :D

Firle