godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.22k stars 21.04k forks source link

pow() function in shading language produces negative numbers for negative bases and even exponents above 2.0 #38196

Closed Underwaterbob closed 4 years ago

Underwaterbob commented 4 years ago

Godot version: 3.2.1 OS/device including version: Windows 10.0.18362, RTX 2060 Driver Version 26.21.14.4575 Issue description: pow() function in shading language even exponents above 2.0 on negative bases result in negative numbers. Noticeable when making rounded corners by: vec2 uv = -1.0+2.0*UV; COLOR.a = 1.0-step(1.0, pow(uv.x, 4.0)+pow(uv.y, 4.0)); Only the bottom right hand corner is rounded. I tried different even exponents above 4.0 and got the same results. Exponent 2.0 produces a perfect circle as expected. Steps to reproduce: Use a pow() function with a negative base, and a positive exponent above 2.0. Minimal reproduction project: pow() function bug.zip

bruvzg commented 4 years ago

Is it a bug? According to GL docs, pow(x, y) result is undefined if x < 0 or if x = 0 and y ≤ 0.

Underwaterbob commented 4 years ago

I did not see that. Even exponents above 2.0 work in other versions though. I tried on my Lunbuntu laptop, and even exponents above 2.0 are as expected (mathematically). If they're supposed to be undefined, I suppose it doesn't matter.

Thanks.

On Sat, Apr 25, 2020, 5:53 PM bruvzg notifications@github.com wrote:

Is it a bug? According to GL docs https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/pow.xhtml, pow(x, y) result is undefined if x < 0 or if x = 0 and y ≤ 0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/38196#issuecomment-619345692, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFABUWMK4Q6E3TKBKB5RZ3ROKQKDANCNFSM4MQUXSUQ .

Calinou commented 4 years ago

Closing, as this is intended per the OpenGL specification.