Artifact on shader
Asked Answered
R

7

0

Hi,

I started shaders with Godot while working on my first game, and I'm out of painkillers for my head so here I am.

I try to reproduce the whirpool shader made for unity in this blogpost. So far, I'm close to success but the shader has an artefact line at the location of the seam of polar coordinate, as you can see in the videoscreen below.

I found in this forum post that this could be related to mipmap and anisotropic filter but I didn't find any place to set this on the Godot shader material.

Please find the shader code here

Any help is welcome, thanks.

Recur answered 24/10, 2021 at 1:32 Comment(0)
M
0

mipmapping and anisotropic filtering are texture settings/flags not material/shader settings. That line is likely a UV seam and while it might have something to do with texture filtering I'm not 100% sure that it is that. That is the first thing to check tho.

Monadism answered 24/10, 2021 at 1:34 Comment(0)
R
0

Well I disabled mipmap on the noise texture used, and it did the trick. Thanks you.

Recur answered 24/10, 2021 at 15:20 Comment(0)
A
0

You can still use mipmaps, but you need to add a few empty pixels on the side so they don't blend (and adjust the UV so it is smaller and doesn't cover the extra pixels).

Aragon answered 24/10, 2021 at 21:17 Comment(0)
R
0

I use a NoiseTexture directly generated by Godot, so I'm not sure how to add pixels on side without having to generate noise from shader code or use a noise texture from image, which I would like to avoid.

So if I understand right, disabling mipmaps can cause aliasing when texture is displayed from some angles. This can be corrected by anisotropic filter, or did I get that wrong ? What about antialiasing ? Also I read that mipmap would increase video memory used by 33%. What is the impact on performance of alternatives ?

Thanks, sorry if what I say make no sense, this stuff is new for me.

Recur answered 25/10, 2021 at 11:20 Comment(0)
M
0

I'm 99% sure anisotropic filtering still needs MIPs.

Monadism answered 25/10, 2021 at 14:43 Comment(0)
A
0

I believe you can create a NoiseTexture at any resolution you want. For example 500x500 instead of 512x512. Then use Image.blit_rect() to copy the data into a 512x512 image (with an offset of 6, 6 so you create a buffer). Then in your fragment shader you'd have to adjust the UV where you sample to take the buffer into account.

Aragon answered 25/10, 2021 at 17:35 Comment(0)
B
0

This can be corrected by anisotropic filter, or did I get that wrong ? What about antialiasing ?

MSAA only affects polygon edges (and in Godot, it's currently limited to 3D). Shader-induced aliasing can only be fully remedied by supersampling, which is more expensive. See the 3D render scaling demo for an example of this (the same approach works in 2D too).

Also I read that mipmap would increase video memory used by 33%. What is the impact on performance of alternatives ?

A 33% memory usage increase in a 2D project is most likely unnoticeable, even on mobile.

@Megalomaniak said: I'm 99% sure anisotropic filtering still needs MIPs.

Indeed, anisotropic filtering will only improve rendering quality if the texture has mipmaps available.

Bohaty answered 25/10, 2021 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.