Search Issue Tracker
By Design
Votes
0
Found in
2017.2.0f3
Issue ID
960241
Regression
No
[ShaderCompiler] Inline constant and property behave differently in pow
See comparison of frag functions in BrokenShader.shader and SensibleBehavior.shader. Something seems to be wrong with the way the shader compiler deals with float properties in pow.
_FloatProperty.xxx behaves like float3(1,0,0), but _FloatInline.xxx behaves, as expected, like float3(1,1,1).
Repro steps:
1. Open attached project and Scene.unity
2. Notice difference between left and right sphere
3. Compare shaders
Reproduced in 5.6.4.0f1 and 2017.2.0f3
--
Update: Closing as by design. Explanation:
The root cause seems to be that components of in.normal can be negative and pow(a,b) is not well defined for a < 0. The inline version is saved by the fact that b is known at compile time so the compiler can optimize pow(a,1) into just a.
You can observe this by changing the inline constant to 1.00001 instead of 1, thus disabling the optimization. When b is not known at compile time, the compiler has no other choice than actually performing the pow and the problem is observed.
In general, you should not be calling pow(a,b) with negative a.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Add comment