Author Topic: Passing Alpha.8 texture to fog of war as mask  (Read 26 times)

Yang S Lin

  • Guest
Passing Alpha.8 texture to fog of war as mask
« on: June 30, 2020, 12:22:23 AM »
Hello,
I just upgraded from VolumetricFogAndMist2 from the first one. Thank you for creating a version for URP.
I have another unity asset that's managing my fog of war for me. It writes the fog info into a TextureFormat.Alpha8 texture.
Previously, when I was on LWRP, I just passed a Alpha32 texture converted from that Alpha8 texture into the with the DynamicFogPPS script and it worked fine. It seemed to ignore the fact that the Alpha32 texture's colors were all black.
However, with the new VolumetricFogAndMist2, when I pass in a texture that's all black except for the alpha, it renders the fog as black too. Is there a way I can modify the fog of war script to ignore the color values and just look at the alpha? Or do I have to convert my texture to white?
Thank you
-Yang

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Passing Alpha.8 texture to fog of war as mask
« Reply #1 on: June 30, 2020, 01:19:50 AM »
Hi Yang,

In this new version of Volumetric Fog & Mist, the rgba components are used because now, you can not only control fog transparency but also tint the fog color at that position.

There're 2 options here:

1) Modify your texture so rgb values are 1.

2) Modify Volumetric Fog & Mist shader so it only takes into account the alpha value.
In FogOfWar.cginc file, replace:
Code
return half4(fowColor.rgb * fowColor.a, fowColor.a);
with:
Code
return fowColor.aaaa;

Regards

Yang

  • Guest
Re: Passing Alpha.8 texture to fog of war as mask
« Reply #2 on: June 30, 2020, 04:36:21 PM »
Great, this is what I needed. Thank you

Yang

  • Guest
Re: Passing Alpha.8 texture to fog of war as mask
« Reply #3 on: Today at 02:20:00 AM »
Hello,
An additional question from me. I implemented the only using the alpha from the fog of war texture that you gave me (thank you!)
but the alpha doesn't seem to affect the fog as much as the post processing version

Ex the tall witch's tower in the back is supposed to be uncovered:
Here's the fog at 50%: https://drive.google.com/file/d/1T9jt-h_gqF6n0DBeU9laWpAldMHNl2ak/view?usp=sharing
here's the fog at 100%: https://drive.google.com/file/d/1r1jNApgzrHzXJKZ7aV52Aq7y7v9W8bs0/view?usp=sharing

In the post processing version, you'd at least be able to see all the way to the ground at 50% fog. In the URP version, you can barely see slightly more of the tower.
How can I get the fog of war to be more responsive to alpha?
Thanks
-Yang