Fog shader?

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

Re: Fog shader?

Post by darkbasic » 15 Mar 2019, 09:40

visvaldas wrote:
14 Mar 2019, 23:05
In fact - yes ;)
You just made my day :)

1Mac
Posts: 47
Joined: 20 Feb 2019, 19:50

Re: Fog shader?

Post by 1Mac » 15 Mar 2019, 14:22

Huh, how about that! That’s great news.

visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas » 15 Mar 2019, 15:53

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 1853 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: 335
Joined: 09 May 2015, 13:07

Re: Fog shader?

Post by wareya » 15 Mar 2019, 16:05

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.
paying attention to #1751 #2473 #3609 #3862/#3929 #3807 #4297 #4623

visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas » 15 Mar 2019, 16:22

Hmm, I guess that means I need to multiply the fog color by the blend alpha.
I will try that.

User avatar
wareya
Posts: 335
Joined: 09 May 2015, 13:07

Re: Fog shader?

Post by wareya » 15 Mar 2019, 16:23

I think that happens automatically, since you only set x y and z. The issue is probably the underlying black layer.
paying attention to #1751 #2473 #3609 #3862/#3929 #3807 #4297 #4623

visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: Fog shader?

Post by visvaldas » 15 Mar 2019, 17:23

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 » 18 Mar 2019, 20:34

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 » 23 May 2019, 13:29

Hi, could someone direct me to how to use shaders like this?

User avatar
AnyOldName3
Posts: 1477
Joined: 26 Nov 2015, 03:25

Re: Fog shader?

Post by AnyOldName3 » 23 May 2019, 17:14

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.
AnyOldName3, Master of Shadows

Post Reply