Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,365 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Shader not happy with fog? #208629
05/28/08 13:11
05/28/08 13:11
Joined: Aug 2007
Posts: 44
QLD, Australia
Serex Offline OP
Newbie
Serex  Offline OP
Newbie

Joined: Aug 2007
Posts: 44
QLD, Australia
So I think this is more of a shader problem than anything else since my fog was working perfectly fine before applying the shader's to the objects.

The shader used is the Specular one by Taco Cohen.

before:



after:



I have played around with the fog_start and fog_end parameters but nothing seems to change.

Code:
function func_toggleFog()
{
	fog1_on += 1;
	fog1_on %= 2;
	
	if (fog1_on)
	{
		camera.fog_start = 10;
		d3d_fogcolor1.red = 64;
		d3d_fogcolor1.green = 64;
		d3d_fogcolor1.blue = 64;
		fog_color = 1;
		
		while (fog1_on)
		{
			camera.fog_end = 1400;
			wait (1);
		}
	}
	else
	{
		fog_color = 0;
	}
}


Probably won't end up using it in the end, but would be nice to know what it is thats happening. Any feedback welcome.

Re: Shader not happy with fog? [Re: Serex] #208688
05/28/08 20:17
05/28/08 20:17
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
I don't think it's the aspect of the shader not liking the fog but simply the aspect of the camera which doesn't like the fog in combo with a particular shader ^^
I had this problem too with postprocessing (PP) effects (pixel based) and I resolved it by increasing the fog start parameter of the view that is used.
First try these simple lines in your function main without the function for controlling the fog:

Code:
 
camera.fog_start = 200; 
camera.fog_end = 4000;


If that doesn't work, I would add a fog parameter into the shader code. Since fog is processed at a per vertex way, you need to do the following:

Code:
 
// add this parameter and function before the vertex shader(VS)

float4 vecFog;

float doFog(float3 WPos)
{
   return(1 - (distance(WPos, vecViewPos) - vecFog.x) * (vecFog.z));
}


Then you need to add the following things to the VS:

Code:
 
// put this in the output struct from the vertex shader

float fog: FOG;

// put this in the vertex shader

Out.fog = doFog(mul(In.position, matWorld));



Since a specular effect has got a VS, I assume this should work if step 1 doens't help wink wink
Btw, I didn't use step 2 to overcome my problem as a PP effect is pixel based.

Thanks in progress

Frazzle



Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Shader not happy with fog? [Re: frazzle] #208752
05/29/08 10:00
05/29/08 10:00
Joined: Aug 2007
Posts: 44
QLD, Australia
Serex Offline OP
Newbie
Serex  Offline OP
Newbie

Joined: Aug 2007
Posts: 44
QLD, Australia
yeah i have tried changed the camera settings for fog with no luck, thanks for the tip regarding the shader, looks like something else i shal read into. will post back with results

Re: Shader not happy with fog? [Re: Serex] #208857
05/30/08 04:25
05/30/08 04:25
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
If your only having fog problems with the shader then the shader most likely isn't setup to support fog. This is a very simple fix though as shown above by Frazzle...


...If it's not setup to use fog then when fog is enebled by the engine the entity will be "fully fogged".


xXxGuitar511
- Programmer

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | 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