Shader Graph output is poor quality

I have noticed that the output of the shaders I am building seems very poor and low resolution. Here’s an example:

I have followed this tutorial exactly and the nodes I have in my shader are an exact match: https://youtu.be/uR8BJGBMzEo?si=UmaOkPqEoQMjCtw0
This is a screenshot from the YouTube tutorial:

and here is the result from the same graph that I built:

The remap node is what creates the thickness of the sine wave. There are other nodes for noise, speed etc.

I have noticed this poor quality in other shaders I am trying to create, including one where I am using a texture of a sine wave and then colouring it for use in a Line Render. Even though the texture is 1024 when it is applied to a material and added to the line, it looks like a resized 32 pixel image stretched out.

Any ideas what I am doing wrong here?

Looks like floating point precision problem, but can you show us the whole graph?
It’s hard to guess what exactly caused this from these 3 nodes - waves on the left already look off, so maybe there is big number coming from time node or something similar.

1 Like

Here’s the graph
SineWaveProcedural.zip (9.9 KB)

Thanks for taking a look.

The reason is precision of high numbers, when I start Unity I get this:

The time node gives you constantly growing time value, but float loses precision with high numbers, so it can produce jumps, gaps, pixelization and similar stuff depending on what you do.
To be more precise, when time goes above 30.000s (in your graph) you can notice quality is significantly dropping and above certain threshold it starts to chunkify your wave - you can test it by adding some big number to time value.

You may say that your editor is not running for such a long time, but you multiply your input by speed and perform some other calculations, so it can become distorted even after 1-2 hours.

I know two ways to fix that, you either provide your custom time to shader with “looping” to reset it when scene is loaded or other event happens (bug). Or the other way is to put modulo to make time loop in shader, but the obvious downside is that at some point in time there will be “jump” to 0.


In addition you could offset time by substracting some number.

Possibly there is someone else who knows other, or better solution to fix this problem.

2 Likes

Yes, this makes sense. Thank you. I will try the modulo fix and look into how others tackle this issue.

1 Like

It was running overnight again and when I looked at it the sine wave had completely broken down into a few blocks! This is quite an interesting problem. Would the Modulo work if you also added 0.01 so it was never zero?

Not sure I understand what you mean here, but if you want to offset result od modulo, then there is no problem