Why in shader cos(55) seems to give 1 instead of ~0

Hi guys

First of all i wasnt sure about proper section nor the title.

Anyway here is my problem.
I was looking for some way to render a grid.
I’ve found this post which generally gives me what i want.

However i fail to understand why it works.

Here is the shader from the link above:

Trying to follow what it does i’ve simplified it to such version:

And here is the result im getting:

The ball is just for reference and is at world position 5500,0,0.

The shader is applied to a plane.

I would expect that above shader generates BLACK field under the ball because cos(5500/100) ~ 0.02.
Still it seems to have generated 1 perfectly there.

How come??

Im not interested in blindly copying someone elses code and i want to understand the code im using but this behavior makes totally puzzled.

Can anyone explain how come that my above shader generates a line perfectly at each “cellsize” step even tho that world position is fed directly to cosine function so rendered line step should be different?

What do i miss?

Any help is greatly appreciated.


How are you getting cos 5.5 = .02?

I get .71 which ties up with what I see.

EDIT: At any rate, do you get that if you keep feeding the coordinates of a pixel into a cosine, as that pixel moves across the world, the COS will go between 1 and -1?

If you divide by 100, that natural oscillation happens less often, in other words, the lines get wider.

EDIT2: Tell me which part is unclear.

Hi, thanks for taking interest in my problem.

I should have worded my case somewhat better.

I was puzzled by the fact that it seems that in UE4 the period of cosine function is 1 instead of 2pi as would every math class teach you.

I got the answer at stackoverflow.

So to anyone interested.
Period of cosine material graph node is handled by its “period” parameter which defaults to 1.0