Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 07:51

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: per vertex fog help
PostPosted: 19.12.2010, 18:44 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
Hello!

I'm trying to add per vertex fog into the model shader. But the final color
overcomes to white.

end of the VS_GENERAL:
Code:
   float _dist = length(vsPos);
   if (  _dist >= gl_Fog.start )
   {
      fogFactor = clamp( ((_dist-gl_Fog.start)/gl_Fog.end) , 0.0 , 1.0);
   }
   else
   {
      fogFactor = 0.0;
   }


end of the FS_LIGHTING:
Code:
   gl_FragColor.rgb += ( gl_Fog.color.rgb - gl_FragColor.rgb ) * fogFactor;


end of the FS_AMBIENT:
Code:
   gl_FragColor.rgb += ( gl_Fog.color.rgb - gl_FragColor.rgb ) * fogFactor;


Note: Exactly same shader approach worked for me in irrlicht.
Maybe the light, and the ambient pass added together? If yes, where?

Expected result:
Image

Actual result:
Image

(The fog color ofcourse not white :))


Top
 Profile  
Reply with quote  
 Post subject: Re: per vertex fog help
PostPosted: 19.12.2010, 19:25 
Offline

Joined: 15.06.2008, 11:21
Posts: 166
Location: Germany
Light passes are rendered additively after the ambient pass, one for every light in the scene. So you probably only want to fade to your fog color in the ambient pass and fade to black in the light pass (= nothing added for lights if you are rendering sth very far away)


Top
 Profile  
Reply with quote  
 Post subject: Re: per vertex fog help
PostPosted: 19.12.2010, 23:13 
Offline

Joined: 29.10.2010, 14:28
Posts: 46
Location: Hungary
Thank You for the help!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group