Oneminus node not behaving properly even with a clamp node

I have a material effect that I’m working on and I’m trying to simplify it down because in order to make this “invert” part of it, I have to attach a power node with a really high exponent (300-500) after the 1-x node. I’m pretty sure that it’s not efficient to have to chain multiply something 300 times in a row… Leading into the two clamps, I have channel masks. Adding the two clamped numbers would put them into the 0 to 2 range and dividing by two would put them back into the 0 to 1 range. Therefore, as far as I know, a 1-x node shouldn’t be having a problem with this. The only thing I can think is that maybe the preview window is doing some kind of auto range scaling and tricking me(I even have it set to unlit).

EDIT: I’ve even made a range remapper with the equation of valueout=((((valuein-lowin)*(lowout-highout))/(lowin-highin))+lowout) and it works great at remapping, but I still get the improper reversal with the 1-x node.

How do I fix this?

Here is an example of what I’m talking about(The black band is intentional):
80c27e0c47f791fad43815cb14fc37875a6c8317.jpeg

what exactly you clamp?
world Z coordinates?

If a number has been clamped into a range of 0 to 1 and outputs a “proper” result, like the first picture, then the 1-x of that should yield the inverse of that image. However, it’s not inverting correctly…

Let me point out that the complete shader, as a whole, works perfectly fine for me and does what I want it to do. I just find it ridiculous that I have to raise something to a power in the 100+ range. Just as an example, I ran these two versions into a multiply*color and put it into the emissive channel. The first image is the non-inverted and the second is the inverted. Notice what exponent powers I’m using on these: 3 for the non-inverted, 100 for the inverted; to achieve a similar “inverse” band(it’s not perfectly matched up, but gets the point across).

56405403f5b2c3bc66658345ee799eaf3050e45c.jpeg

The range isn’t going to 1 on your input. The 1-x is just a simple math instruction and the odds of it actually being wrong are incredibly unlikely. Looks like the input on the image is 0.3 or 0.5 at most to 0. Try boosting the value and clamping it before 1-x.

Alright, I tried boosting the gain on it before clamping and it’s still not inverting properly. The whites are sampling at 254-255 in photoshop. I inverted the image in photoshop to show what it should be and as you can see, it’s still not flipping the colors correctly(what unreal yielded is on the bottom). The viewport in unreal is set to unlit and i have exposure set to log0.

Looks correct to me. The only difference I see is in photoshop there is a gamma curve making it sharper. but the inverted unreal gradient looks right.

Oh wow, I forgot all about gamma woes…

Anyways, I ended up reworking a lot of it and greatly simplified it all. Instead of making two separate sets of calculations, for the up and down Z, I just used an absolute value to mirror it. I used my range remapping function that I made to clip things out. I think I ended up using an input range of 0.05 to 0.2 and scaled that to 0 to 1. After that, I used a power function to control/smooth things over a little more and it works with low values now.

Basically, it’s a scanning/pulse wave effect that is world axis based (you can switch for different axis, but I wanted it in the Z) and is completely agnostic to the model’s position or rotation. It will always swipe up/down, no matter what way the model is turned. It’s more or less a world Z aligned effect, but is localized to the model so that it allows the model to be moved freely on the world Z axis and still have the effect start from the bottom of the actor’s bounds.

PS: Ignore the terrible tree model. I threw it together in less than three minutes; for the sake of experimentation. I have some real models that I’m using an emissive effect like this on though.