Fog shader?

Everything about development and the OpenMW source code.
darkbasic
Posts: 153
Joined: 18 Apr 2016, 15:45
Contact:

Re: Fog shader?

Post by darkbasic »

visvaldas wrote: 14 Mar 2019, 23:05 In fact - yes ;)
You just made my day :)
1Mac
Posts: 62
Joined: 20 Feb 2019, 19:50

Re: Fog shader?

Post by 1Mac »

Huh, how about that! That’s great news.
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas »

OK, I'm running into problems.
For testing purposes I've set

Code: Select all

gl_FragData[0].xyz = vec3(0.5);
in terrain_fragment.glsl.
screenshot000.png
screenshot000.png (581.56 KiB) Viewed 8816 times
The far terrain looks as expected, but the near terrain is off.
It appears as if for the near terrain, the output of the fragment shader gets added to the framebuffer.

Does anybody know what's going on here?
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Fog shader?

Post by wareya »

Terrain texture blending adds terrain textures (multiplied by their blend alpha) onto a pitch black base layer now, instead of alpha blending them over a base dirt texture. Aside from that, I have no idea. The black layer may be rendering through the terrain fragment shader.
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas »

Hmm, I guess that means I need to multiply the fog color by the blend alpha.
I will try that.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Fog shader?

Post by wareya »

I think that happens automatically, since you only set x y and z. The issue is probably the underlying black layer.
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas »

Alright - problem solved!
If I multiply the fog amount with 1-gl_Fog.scale everything looks as intended.

Edit: I'm not sure though if that's the proper way to do it.
It would be best if some precprocessor define was set to indicate that no fog should be added, as in the case of the black base layer.
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas »

Newest version: https://gitlab.com/vrresto/openmw/tree/my-fog-shader
Note: shadows don't work yet.
Esqu1sito
Posts: 1
Joined: 23 May 2019, 13:26

Re: Fog shader?

Post by Esqu1sito »

Hi, could someone direct me to how to use shaders like this?
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Fog shader?

Post by AnyOldName3 »

Basically, you'll need to build OpenMW yourself (by following this guide http://wiki.openmw.org/index.php?title= ... ment_Setup) having checked out the branch linked above. The guide should be more-or-less idiot-proof, but it's still potentially too daunting for most people to bother with.
Post Reply