I am very close. Material Editor is something I am not well versed in or understand to the highest of degrees.
Here is an auto layer painting based on slope angles to determine which material function to use (grass, dirt, cliff face).
I have this nice crisp blending between the two layers. My problem is that I have no idea how to go about locking the painting to follow the faces and not bleed into other faces. Locked to the vertex normals.
I assume what he is basicly doing is a problematic thing with the light.
I have that all the time, you place a directional light and let it do cascade 4.
That will shadow the triangles of the landscape at different slopes. All you need is a rough material with bare details.
Okay I am getting closer. I have started playing with a really simple basic landscape material to get this working. I am having a few artifacts I am trying to resolve.
Here is the mat
Here is how it turns out
Bring the camera a hair closer however and this is the result
You’re hitting the limits of the numeric precision. The triangles that show this issue have values so close to 0.5 that rounding errors make some pixels end up above and others below the threshold of the If node.
I would recommend removing the If node altogether and simply raising the sharpness of the World Aligned Blend node to something really high. (Should also be a bit more performant)
I appreciate your input on this. I attempted this by using insanely high numbers like 10 billion in the sharpness, but as sharpness increases I have to increase the bias to ensure on flatter terrain the grass is showing and not dirt, but it doesn’t seem to change the issue. Any other options you can think of?
After digging into the World_Aligned_Blend node and looking into Arnage’s answer I can now see that each pixel is being filled with a color based on the alpha. And since float precision is not perfect this results in the issue based on camera location. What I need to figure it is how to do this based on faces and not pixels. I tore out all of the unnecessary parts of the world_aligned_blend and stripped it down to a custom material function shown below:
This outputs an alpha value per pixel. I have tried to change the PixelNormalWS t o VertexNormalWS but that did not solve the issue. Any ideas based on these findings?
You could do it with low res cubemap, with necessary color variations across the sides. Later in material for each triangle just sample cubemap in direction of the normal. To add more randomness for different object just “rotate” sampling vector by some random value individually per object, so that two object next to each other with similarly facing triangles won’t get exactly the same color.
Another option is some simple 2d color noise with triangle normal+object id as a seed, this might be more performance heavy and harder to control from artistic point of view.
I don’t have much experience with shaders in UE4 but similar pattern can appear when calculated values go beyond float range. Clamping them to 0…1 doesn’t help as when float is “over-flooded” it will randomly jump from highest negative to highest positive value.
To avoid case when your normals are right on the edge between blends you could simply bend them a little. For example, you could take a z coordinate of normal and add 0.001 to it if it’s value is above 0.5 or remove 0.001 if it’s value is below. This add “if” statement which is not nice, maybe there a better way, like bending them during export from modelling package.
I appreciate your input. I am a little confused about this as it seems you are talking about objects. Does that mean different objects in the scene or ‘objects’ as in triangles? Could you clear it up for me/show me what you mean by sampling a cubemap in direction of the normal? My material skills are severely lacking. Thanks!
Again, I apologize, my skillset is subpar on this. Anyway you could mock something up to help describe the process of handling the ‘over-flodding?’ Not sure exactly how to go about changing the normal inside of the material editor to account for this. The last portion seems like you think I am bringing in a landscape from a modelling program. This is the built in landscape in UE4 which I am trying to use. If i was pulling them in from blender I could color by hand, but I really want to try and be able to use the built in functionality for easy of use. Again, thank you for the help very much!!
I’ve tried to replicate your setup but got smooth shading without any similar artifacts, I guess you were doing something else to achieve flat-normal look on the landscape:
This is the other way to do, I would still get rid of IF node as it’s not very performance friendly:
By object I mean different instances of your 3D meshes, for example tress, rocks and etc. If you sample cubemap just using objects normal, then shading might look repetitive among instances of the same object, when they have similar facing. To avoid this you can add material instance parameter, which will be just some random vector which you generate individually for each instance. Then in material graph you just add this random vector to normal and normalize result right before sampling cubemap (this is only for sampling cubemap.
hey guys,
I didn’t read the last few replies but saw the part about pixel precision.
You could pipe your world aligned blend (or just your manual IF mask) over to the CustomUVs in order to compute them on the vertex shader. Then you know they will be solid values per vertex. It might chance the way your interpolation across hard edges looks though.
I appreciate the guidance on the cubemap. This is something I will definitely play with trying to get correct. As far as the masking you put together I still get the pixel precision issue when the camera gets close to the object with your solution or mine. Do you not get that issue when you do it? I replicated your material but still had the issue when the camera was close.
Hello Ryan, thanks for stopping in. I tried to do what you said, unless I am doing it incorrectly, but nothing changed for me. I also tried just the world aligned blend alpha as well. See the screen grabs here: http://imgur.com/a/45gaq
I don’t get any issue with it. Did you happen to change default settings for depth buffer? Maybe landscape got duplicated twice? Otherwise it can be hardware issue.
I tried this in a brand new empty FP project and added a landscape. I wanted to go the route of hardware trouble shooting. What exactly are the mat settings? Unchecked tangent normal option? Fully rough? How close did you move the camera? Have you tried making more steep landscape, not the smooth one you have? I find this happens on the edges of slightly more step edges.
I appreciate your help in trying to nail this down to a hardware issue, because I have approximately a 3 month old PC with decent specs. gtx 970. i5-6600k (no OC). 16gb ram. win 10 x64
Could you give me that info as well as try out the steeper landscapes and moving the camera closer and further away. When the LODs happen when you move the camera far away you can see triangles flipping their color between the two. Interestingly enough most of the triangles are perfectly colored with no pixel issue like I have pointed out. But those on the edge between the two at steeper angles have this issue. Thanks for your help BP
All settings of material were default, for landscape I’ve just added default something X something path and painted heighmap a little.
I’ll place project on dropbox when I get home.