Please tell me the secret to recalculating normals

I have tried every method listed here:

Guide

And not a single on of them worked for my water. I have been trying to make sine wave shader water for ages and have had shadowing issues because of normals and can’t find a fix.
(please note, this is not a shadow maps issue, it’s not a ray trace shadows, or any of that crap.)

I am guessing they removed the AbsWorldPosition (excluding materials offets) node too? not surprised.

The only thing that has even slightly improved my normals so far has been hooking a constant–>COS–>normals and keeping the constant at 0. it’s improved on opaque and transparent modes but if I add metallic sheen to the material it goes haywire.

I watched videos on youtube, I watched ben clowards DDX DDY videos as well as some british dudes.
I need a fool proof way of recalculating normals on sinewave water, and something that is not 50 nodes long.

THIS IS MY SINEWAVE

You will probably find the answer here

Didn’t fix it on either of his methods

1 Like

But one of his examples is exactly what you’re doing, no? :slight_smile:

A sine wave with normal correction.

1 Like

As you can see in my previus picture, the lightning on metallic set to 1 is still trash.

in my guide I posted in OP they have a world position before material offsets, where the heck did that go?

The plane picks up other shadows fine, it’s the self shadowing that is broken.
for example, if I put a block over it, it will pick up the blocks shadow perfectly and distort it with the waves in a reasonably nice way.

1 Like

I think you probably have to use world position all the way ( including the normal correction ), or not at all. I have no idea how to do that, I’m afraid… :expressionless:

So here I replaced the completely overused multiply nodes with a exponential node and it fixes everything

but the problem is that whatsoever lies beneath the X line on sine (here I’m using cosine to avoid the .25 offset) is not shading correctly regardless of whether or not I am recalculating normals.

Does anyone have a fix for this?

EDIT
if I choose double sided, because the positive on the first side works, the other side is negative (concaved because its protruding on the other side) so the other side has shading issues.

2 Likes

I can’t look right now, but the usual reason something is black with sin or cos, is that a lot of shader nodes don’t understand negative.

Have you tried some combination where the cos is always positive, like

image

math? find a way to compute an angle lerp in one quadrant. the normal angle is identical at the peaks of the curve. ofc you can scale the normal with wave height and renormalize the length.

but… this is for one wave only. intereference gotta be computed differently.

2 Likes

So dabbling around last night I found that I have two problems.

the first one is that if the emissive color is darker than, say, 180 = I get horrible shadows in the crevices of the backside of the mesh. If I kick the color up, the shadows return to normal.

I tried this with lumen and screen space reflections.

the second is that the multiplication after sine or cosine breaks the shadows on the top layer, while if
I use a power node instead (does not matter what the power is) it fixes the shadows on the top and the emissive still breaks them on the bottom.
the problem with the power node is without some form of smoothing it is very blocky because of the exponential timing. multiplication is smoother.

One noticable difference is that exponential does not go negative, it stays flat and then increases while cosine with multiplication goes -1, 0, 1 (or .25 offset in case of sine).

The shadows are much improved in the actual level if I place a plane or box, the box seems to do better because its not utilizing unreal’s “two sided” option which I suppose is too much to ask for the engine to work with that and these janky sine waves.

However, the shadows still look “noisy” I kicked shadows to highest, lumen to highest, SSR to highest
ray cast shadows, and literally no difference.

Is it supposed to look like this?

In material editor
s3

in level (the multiple folds are wave math I have not worked out yet with exponents)

reflections in level

Another weird problem im getting with wall intersections that have tiny black dots that look like lice jumping around

s4

The black dots are sometimes subtle, they are also sometimes taking up half a character of area.

I’m trying to do multi layer sine or FFT water so that is not an option for me

Also I have noticed that when the wave is at an angle, looking at it from the top looks fine, looking at it from the “side” of the angle looks fine, but looking at the angle slope coming towards me has weird color/shadow reflection noise.

I don’t seem to get any of this when I have small waves, so maybe the solution for Notreal engine is to
use little waves/scale mesh up?

Having similar issues and also tried what you have already, did you come closer to a solution?

I missed this one year ago.

The OP issue is partially related to the material itself and transparency sorting the way the engine manages it.

Even then, the engine provided the single layer water shading model which does all of the correct basic things for noobs - since fixing it yourself is not for the faint of heart and making it work with 0 knowledge is like a month’s long exploration that inevitably ends with you learning HLSL and changing engine.

Even back a year ago, the WPO node had a toggle to select what option to go with from its properties panel.

That could be important when making things yourself (or it could not if you just do the right math off WPO. All depends).

The other issue the OP had was driven from bad texture linkage on the math - and bad math as he later detected - but apparently made worse?.

Then he had issues with reflections, which in this engine are just part for of the course naturally.

You either have to do reflections manually in the water material yourself by adding a texture of the sky that bounces back…

Or you are at the mercy of the engine reflection, which causes issues like the black dots as well as having objects in the fustrum being mirrored into far away distances in a 2:1 or maybe even 3:1 size creating an hideous effect to say the least.

The only cure for this that I know of is to disable reflections and change things to ray traced. Distant materials (like the edge of a sea at the horizon) will still have rendering issues.

Also, fwis there isn’t a “fix" in this situation because we don’t know what you are doing in your custom material. You can definitely get them to look good and work while doing way more complex stuff.

Though, I really suggest for anyone trying this should just learn HLSL and use it by creating their own water shader model (.usf).

Since it gives you access to way more options and lets you fix things you otherwise cannot - and that is why epic ultimately provided a shader model - it is the best option.