Dot Product multiplied with green vector acting weird

Can any one tell me why multiplying a Dot Product like this with a split green vector creates these bands of black and white, instead of just multiplying the blacks together and removing the bottom white?

What I’m trying is to keep only the top green vector for a topdown projection for grass on top of rocks. Is there a smarter way. I don’t want to just use the Dot Product as I like the look I get with green vector.

This is URP Unity 2020.3.

Normalized dot product outputs number from 1 to -1 (in your case 10 to -10). Because of this you flip bottom and get bands.

Ok, I’m not a tech person so that knowledge doesn’t really help me. How would you isolate the top green vector? I’ve tried many nodes, like multiply, blend etc but nothing works. Do you have a solution for this?

A dot product compares two vector angles and returns how similar they are in (0, 1) format. You’re seemingly comparing a position to another position, with way too many implementations of contrast layered at once.

If your use case is to isolate top-facing surfaces, I would use the Normal Vector node rather than a Position node to get surface facing angles. Using Y position is going to give you something like a height fog mask rather than anything surface related. This type of comparison is similar to what’s used for Triplanar blending.

In this example, I used a property to store the facing angle so you could change it if you wanted. It’s still set to green. Without an Absolute node, the result will already produce a (0, 1) top facing mask with only three nodes.

I would recommend creating your top facing mask first, then creating contrast by manipulating the result. Your example includes at least two different implementations of contrast (Power and Contrast) as well as an arbitrary *10 multiplier. Power and Contrast may also be slightly more expensive nodes, though don’t quote me on that. I almost always create contrast with a Smoothstep node. In this example, I start with a reliable (0, 1) mask, then create another (0, 1) mask blending from (Threshold - Range) to (Threshold). Set both of those variables to be sliders with a (0, 1) range. Default both to 1 and it will have no effect.

If you want to increase the intensity of the values from (0, 1) to something like (0, 10), use a multiplier on the tail end.

1 Like

You can modify the surface normal using a height mask in the input stage to get nice looking edges on your grass. That’s heavily dependent on the masks you have available to you, but will generally look better than a smooth blend. I’ll sometimes experiment with a variety of masks in my library to see what I can get away with.

This is getting a bit complicated for me. I only need something to control a top down projection. I’m later multiplying it with a vertex painted heighmap, so don’t need that at this stage although I really appreciate you showing that too.

how can I just get a simple top down mask where I can control it’s softness/sharpness and it’s spread or angle limit?

As was in the first example:

  • Grass Angle = Vector3(0, 1, 0)

  • Grass Blend Threshold = Float with (0, 1) range. Controls where the blend starts relative to the (0, 1) mask.

  • Grass Blend Range = Float with (0, 1) range. Controls how far the blend extends.

Ah sorry for not getting it in the first post. This is perfect. Thank you so much.

When you add the height mask, I find it helpful to add -0.5 so that the effect is centered on the threshold you’ve already chosen.

9839646--1415718--surfaceNormals_04.gif

Hi Ben. Thank you so much! This was seriously perfect! Big improvement on my shader!

1 Like