Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,484 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adding fog? #283485
08/07/09 23:13
08/07/09 23:13
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline OP
Serious User
Claus_N  Offline OP
Serious User

Joined: May 2004
Posts: 1,510
Denmark
How do I add fog using the DoFog() from default.fx? Can't get it working frown

Re: Adding fog? [Re: Claus_N] #283550
08/08/09 11:25
08/08/09 11:25
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline OP
Serious User
Claus_N  Offline OP
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Nevermind, I just had to add "fog_color = 1;" in the Lite-C code grin

Edit:
This is the vertex shader in case someone else don't know how to use fog (it supports 8 lights as well):
Code:
struct VS_OUTPUT
{
	float4 Pos :	POSITION;
	float2 Tex0 :	TEXCOORD0;
	float2 Tex1 :	TEXCOORD1;
	float2 Tex2 :	TEXCOORD2;
	float  Fog :	FOG;
	float4 Diffuse:	COLOR0;
	float4 Ambient:	COLOR1;
};

VS_OUTPUT vs_main(VS_OUTPUT _in,float3 inNormal: NORMAL)
{
	_in.Fog = DoFog(_in.Pos);
	_in.Pos = mul(_in.Pos,matWorldViewProj);
	_in.Tex1 = _in.Tex0;
	_in.Tex2 = _in.Tex0;
	_in.Ambient = ambientLighting;
	
	float4 LightColor = 0;
	for(int i = 0;i < 8;i++)
		LightColor += DoLight(_in.Pos,inNormal.xyz,i);
	
	_in.Diffuse = LightColor;
	
	return _in;
}


I thought I needed to do something in the pixelshader as well to add the fog, but that isn't necessary it seems. Also, remember "#inlcude <fog>" of course wink

Last edited by Claus_N; 08/08/09 11:29.

Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1