At the moment
BlurPostProcess seems to be using output texture resolution as “texel size”
delta for the gaussian blur kernel if available. There doesn’t seem to be any way to avoid that except writing extended class that re-sets the delta uniform again with desired value.
It happens in the constructor here:
I’m not quite sure in which cases sampling the blur on output texture texel size would be preferred (doesn’t that cause non-continous blur artifacts if the source texture is smaller than the output texture and unnecessarily many samples if texture is larger?), but at least all my use cases I need to sample the blur kernel on the input texture texels, regardless of how much lower the input texture resolution is compared to the next texture in the post process chain.
Would it be possible to add an option to always sample the blur on the input texture instead? As in skip that “if outputTexture” condition even if output texture exists?
Actually it helps ensuring continuity as it also relates to how the kernels are created. direction here is is normalized when using it so what we want is the space between to texels in the output.
I am not opposed to a PR but I wonder how this would also fit with the rest of the post process.
Now that I think of it more, probably even better solution would be to just allow passing custom texelSize as an option. That way one would have full control of how the blur is applied in all cases.
@sebavan For reference, my use case is doing a bit more advanced “bloom” post process effect than the basic one included with babylonjs. In this case there are multiple layers of blur that are finally combined. In three.js this is called “unreal bloom” as it is inspired by the Unreal Engine bloom look.
So for example:
- 7 kernel size blur rendered to 1/2 sized target
- 11 kernel size blur rendered to 1/4 sized target
- 19 kernel size blur rendered to 1/8 sized target
Each pass samples the previously blurred result. That way the largest and heaviest kernel sizes are rendered on smallest target so you can get massive bloom sizes with high performance.
However, in that example when rendering the 3rd and final bloom blur pass, the next postprocess is blur combine pass at full resolution target. Yet it should sample the blur on the previous blur texture 1/4 resolution target texels, not on the full resolution texels that are fraction of the size. Because otherwise you are just sampling the subpixels of the source texture.
yup it is pretty similar to what we do in our glow post process