question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Why not use same floating point number in common.glsl.js

See original GitHub issue

I think it will be better, why not use same floating point number in common.glsl.js

--- a/src/renderers/shaders/ShaderChunk/common.glsl.js
+++ b/src/renderers/shaders/ShaderChunk/common.glsl.js
@@ -1,9 +1,9 @@
 export default /* glsl */`
 #define PI 3.14159265359
 #define PI2 6.28318530718
-#define PI_HALF 1.5707963267949
+#define PI_HALF 1.570796326795
 #define RECIPROCAL_PI 0.31830988618
-#define RECIPROCAL_PI2 0.15915494
+#define RECIPROCAL_PI2 0.15915494309
 #define LOG2 1.442695

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bhoustoncommented, May 29, 2020

Just remember that glsl currently is precision limited to float32 or lower, where as JavaScript uses doubles for all mathematical calculations. Thus JavaScript’s Math.PI and other math constants will have more precision than needed for GLSL. Probably don’t hurt though as GLSL probably just truncates.

I am okay with removing EPSILON. I had a friend in university who could analyze any floating point calculation and tell you the exact epsilon you should use in that case. But it is a lot of work to do that on a per mathematical equation basis.

1reaction
WestLangleycommented, May 28, 2020
RECIPROCAL_PI = 1 / PI
Read more comments on GitHub >

github_iconTop Results From Across the Web

GLSL - Using an attribute which is equal to a number, is not ...
GLSL - Using an attribute which is equal to a number, is not the same as directly using the number · Ask Question....
Read more >
WebGL Precision Issues
For floating point values they can range from: -2 to +2, for integer values ... be used everywhere, is often not high enough...
Read more >
Image Format - OpenGL Wiki - Khronos Group
Color formats can be stored in one of 3 ways: normalized integers, floating-point, or integral. Both normalized integer and floating-point ...
Read more >
GLSL Shaders - Game development - MDN Web Docs
Shaders use GLSL (OpenGL Shading Language), a special OpenGL Shading Language with syntax ... GLSL is not as intuitive as JavaScript.
Read more >
Shaders - LearnOpenGL
GLSL is tailored for use with graphics and contains useful features specifically ... We're not using this uniform in the vertex shader so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found