#Tutorial for frosted glass blur HDRP?
1 messages · Page 1 of 1 (latest)
You can get that working with some pre-pass options IIRC but the performance implications are huge
This is a quite common issue with transparency.
The blur/frosted effect of transparency works by bluring the color buffer of what has been drawn before.
But in rendering, you are not allowed to at the same time read and write to the same buffer. Because pixels are rendered in parallel, it could lead to unexpected behaviour.
So what is happening in HDRP is that the color buffer is copied before transparent objects are drawn, and the refraction/blur is made by sampling from this copy, to write into the "original" buffer.
This graph shows in which order HDRP passes are drawn.
Focus on the Transparent section, and look at when the Color Pyramid PreRefraction is done. That the buffer copy I mentioned.
By default, all transparent object are drawn during the Transparents pass, that means that they will not show other transparent objects in their refraction.
If you want a transparent object to display in the refraction of an other transparent, you need to change its Rendering Pass to Before Refraction, in that case if will be rendered before the Color Pyramid, and be avalable to display in refractions.
Right, I remember what I ran into now
This means transparent pixels behind opaque objects also get rendered. So if you have like a big ocean below your terrain, you're now rendering every pixel multiple times.
No, transparent pixels behind opaque are not rendered, because it is still tested against the depth buffer.
The vertices still need to be evaluated for proper placement, but pixels are discarded during depth test.
Do wonder why it cost me 3ms to reorder these things then
Thank you for the detailed reply!
I got it to work with a custom pass and layer, which renders transparents on that layer before PreRefraction.
The downside is that I simply can't just draw all transparent objects or put objects that render refraction on that layer to be drawn before PreRefraction, because any objects that need to draw refraction won't work anymore.
I'm also confused, by "in rendering, you are not allowed to at the same time read and write to the same buffer"
I guess I'm confused on why in a custom transparent shader I couldn't just access the current color buffer and blur the portion that is overlapping with the current object and set that to the shader's output?
Imagine that you are rendering a transparent object with rough refraction, that needs to blur+offset what is behind it to have the effect working.
Without the double buffered approach (color pyramid), you will try to read and write to the color buffer with this shader.
Bluring is basically the operation of fetching multiple pixels around a defined one and doing an average, and pure refraction is fetching a pixel that isn't directly under the one that is currently drawn.
With that in mind, also consider that all pixels are drawn in parallel : what waranty do you have that a pixel A, reading from the color buffer at an other place, isn't reading the data that was already written and modified by a pixel B ?
That why usually it's not allowed to read and write to a buffer at the same time, and we use a duplicate of the color buffer to warant a "safe ground" for reading pixels.
I don't really understant to what cas you are comparing, so I can't guess.
But if you want to have a discussion about it, it would be better to start a dedicated thread to not hijack this one.
Couldn't I have a custom pass that blits the current color buffer into another buffer and pass that temp buffer to the shader? That way it isn't reading and writing to the same buffer?
Yes, you can totally do this.
You'd also need to do yourself the color pyramid (kind of like mip maps) for the blur effect
Okay ty, I think I have somewhat of a grasp on how to approach. Might need to do a bit more reasarch on rendering in general. It confuses the hell out of me lol
I can understand that feeling 😉