# \[bug\] power don't work with negative values in Decals

**URL:** <https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095>\
**Category:** Rendering\
**Tags:** coordinates, unreal-engine, Decals, question\
**Created:** [March 17, 2018, 4:36pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095 "2018-03-17T16:36:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 17, 2018, 4:36pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/1 "2018-03-17T16:36:32Z")

</div>

Using solution shown below doesn’t result with getting negative values.  
And the flag “Allow negative emissive value” doesn’t work with decals.

 ![234083-uvneg.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/6/fa689c4db2693865b6365fcafcf15ae03da39b2d.jpeg)

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 17, 2018, 4:40pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/2 "2018-03-17T16:40:40Z")

</div>

It is insane! why?

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [March 17, 2018, 4:51pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/3 "2018-03-17T16:51:10Z")

</div>

It is intended and not a bug. Use Abs material expression before power node to get the functionality, you’d expect.

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 18, 2018, 9:13am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/4 "2018-03-18T09:13:08Z")

</div>

Indeed.

![234151-screenshot1521364333.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/6/c066a8da39e23f1060d562e08c744e85eb53952f.png)

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 8:20am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/5 "2018-03-19T08:20:23Z")

</div>

But power doesn’t work like that - so it is a bug. If you want to add such node which works like that then add another one - don’t mess with basic math please.  
I fount this only in one place right now - obvious to fix, but it can cause a lot more bugs, and why? this change is totally illogical and counter-intuitive.

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 19, 2018, 8:30am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/6 "2018-03-19T08:30:22Z")

</div>

It’s not. It is how shaders work:

> **[pow - Win32 apps](https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow?redirectedfrom=MSDN)**
>
> Returns the specified value raised to the specified power.

[https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/pow.xhtml](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/pow.xhtml)

As you may notice:

![234287-screenshot1521448154.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/d/d9d4f75c941e2924bd86d2a40daad8aea1a7eef3.png)

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 9:43am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/7 "2018-03-19T09:43:07Z")

</div>

I am not talking about shaders - only about math - in math power works also for negative values - so wehn you see a node with name “power” you expect to see it works like power.  
If you want to use in other way name it differently.  
It should not be needed to read description for such simple and basic nodes.  
Also you don’t change such basic functionality without giving alternative solutions.  
And argument about working in such ways in shader is irrelevant - because otherwise we should work on ones and zeros.

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 9:53am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/8 "2018-03-19T09:53:02Z")

</div>

It was still working in 4.15 - so why it was good then and not now? please explain.

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 10:34am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/9 "2018-03-19T10:34:07Z")

</div>

Also:

 ![234288-powerwork.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/3/a/e3a1894dfafa236123e58cef85698ef4d95dddb6.jpeg)

So it works somehow in custom node - so there is logical and in regular node it’s not?

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 19, 2018, 12:35pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/10 "2018-03-19T12:35:57Z")

</div>

It is shader optimization. `pow(x,2)` will be compiled to `x*x`.  
Try to change exp to `2.1`.

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [March 19, 2018, 12:56pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/11 "2018-03-19T12:56:21Z")

</div>

This is change is totally backed up by logic and is intuitive. Before 4.16 Power Material Expression used to translate to:

```
pow(max(abs(X),0.000001f),Y) 

```

in 4.16 and above Power Material expression translates to:

```
pow(max(X,0.0f),Y)

```

Reason is pretty obvious: errors when using X values near 0;

Not a bug. Intended change.

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 1:14pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/12 "2018-03-19T13:14:55Z")

</div>

why should you optimize shader on this level with cost of usability?  
why from 4.0 - 4.15 it worked fine?

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 1:17pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/13 "2018-03-19T13:17:51Z")

</div>

From my point of view it doesn’t matter - I generate effects based on nodes - and suddenly the mechanics of node changes - and in a way it is not logical in math point of view (I don’t care about code).

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 19, 2018, 2:08pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/14 "2018-03-19T14:08:17Z")

</div>

Don’t ask me. Ask Microsoft and Khronos Group. It is how shaders work.

If you’re talking why Epic changed it. So it’s to avoid spiking when negative base is used.

I think it is clear that optimization made not by Epic.

Wen you type `pow(x,2)` it will be interpreted by the driver as `x*x`. Shader code will be the same.  
But that creates major issue. `pow(x,y)` is defined as `pow(x,y) = exp2 (y * log2 (x))` and it is not defined when `X < 0`. So even values of Y produce “errors” when Y defined explicitly.

 ![234324-screenshot1521470114.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/6/166a283c505b9d4ec797542e1f71fd928cdfcc18.png)

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 2:10pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/15 "2018-03-19T14:10:32Z")

</div>

Fair enough. At least now i know who to blame.

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 19, 2018, 3:13pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/16 "2018-03-19T15:13:07Z")

</div>

For me the main issue is that for years I used power to modulate values in places like normals and coordinates which naturally have negative values - an now I would have to check all my functions and materials if they are still working properly. And As I tend to generate a lot of procedural complex materials it will potentially generates a lot of bugs - that is the main reason I am considering this a bug - because from my perspective it brakes things.

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 21, 2018, 10:27am UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/17 "2018-03-21T10:27:42Z")

</div>

From context examples 4.19.  
At least change the name of the node and fix content sample.

 ![234522-unrealpower.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/d/72dbb1846ce21a6a997355242462822cb0ea65d4.jpeg)

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 21, 2018, 12:56pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/18 "2018-03-21T12:56:20Z")

</div>

What’s wrong with the content example?

---

<div class="post-metadata">

**Author:** ![Gomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gomo](https://forums.unrealengine.com/u/Gomo)\
**Post date:** [March 21, 2018, 2:32pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/19 "2018-03-21T14:32:03Z")

</div>

“Notice that negative values become positive just like ABS”

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [March 21, 2018, 2:34pm UTC](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095/20 "2018-03-21T14:34:38Z")

</div>

Hah. I didn’t notice the description.

[Next page](https://forums.unrealengine.com/t/bug-power-dont-work-with-negative-values-in-decals/420095.md?page=2)
