Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Adding fog to shaders

Author
Message
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Dec 2017 21:26
So I added



to my pixel shader and updated the final colour



and this works. However, it applies a uniform fog to the whole object, presumably because PosVarying is just the co-ord of the object, when I would want it to be the co-ord of the pixel.
Do I need to do something with the lighting as well?


nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Dec 2017 23:38
It was the light
I added GetVSLighting() to the vertex shader and its all good.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 17th Dec 2017 01:10
Fog should work without any light at all
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 17th Dec 2017 23:35
The fog did work, but the lighting overall was wrong and it looked like the fog needed it.
In fact it's still wrong, but I can pass the global light value into the shader and affect the brightness in some way which is probably wrong, but gives the right results.

My actual problem was that I wanted fog to affect my shaded object differently than the other objects because of it's bigger size.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 12th Feb 2018 05:53
Ive found shaders can use allot of resources, I do love them tho
but I figure if you just want fog I created this effect very simply with a large sprite
that was basically a circle hundred percent transparent in the centre and dithered black off towards
the sides

http://users.tpg.com.au/subarpk/blackCircle.png

moving this around was much faster than using a shader and was better for android devices
fubar
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 26th Mar 2018 17:17
Quote: "
My actual problem was that I wanted fog to affect my shaded object differently than the other objects because of it's bigger size. "


You can do that. Just apply the regular default shaders to objects that should be affected by fog the normal way and add a different shader to whatever big object in the distance should behave differently.
You could still add the ApplyFog stuff, but change it's strength or position I guess!

Login to post a reply

Server time is: 2024-04-20 03:02:14
Your offset time is: 2024-04-20 03:02:14