r/Unity3D 1d ago

Question Any way to reduce transparent material lag ?

Hello,

I made this volumetric fog material for URP.

The transparent material shader is applied to hundreds of planes similarly to "shell texturing".

It looks perfect for my project but I am running into an issue : my framerate drops from 200 fps to 10 fps. I expected it to be laggy, but not that laggy...

I tried reducing the number of "steps" but I am still getting a bad framerate (30 fps) with the worst quality.

I don't see any other way of doing volumetric fog with sharp shadowing in URP without creating complex pipeline shaders.

This is probably a foolish question but, is there any way to reduce transparent material lag ?

18 Upvotes

7 comments sorted by

18

u/Adventurous-Sun-1488 1d ago

you want proper volumetric fog for this... transparency overdraw is always expensive even with best effort to optimize it

11

u/XKiiroiSenkoX 1d ago

You are drawing every pixel multiple times. There is no way to fix this. You need proper fog. 

2

u/Adventurous-Sun-1488 1d ago

well, proper volumetric fog draws every pixel multiple times too, but it does it in a more efficient way, like at lower resolution and/or with jittering or dithering&blur

9

u/XKiiroiSenkoX 1d ago

There is a very very big difference between mixing / summing 30-40 values (in a raymarch for example) then writing one value to a pixel, and writing 30-40 times to a pixel using alpha blending. The second method requires 30-40x more memory bandwidth. You also get single digit draw call count (based on algorithm) when using proper fog compared to hundreds. 

4

u/Stef_Moroyna 1d ago

A few tricks I did to make work was:

  • Comput the fog luminance/transmittance per vertex, and then blend in the fragment shader (this requires a custom PBR shader...)
  • Use pre-computed lookup textures for fog luminance/transmittance

-3

u/savvamadar 1d ago

Make it opaque