Closed brianchirls closed 8 years ago
Not sure... I'd stick to spec and deal with the warning rather than risk breakage. @toji what do you think?
On Thu, Dec 31, 2015, 7:21 AM Brian Chirls notifications@github.com wrote:
I'm getting the following warning in Chrome when compiling the BarrelDistortionFragment (v2) shader:
WARNING: 0:22: '=' : global variable initializers should be constant expressions (uniforms and globals are allowed in global initializers for legacy compatibility)
It's on the declaration of projectionRight and unprojectionRight. If you move those declarations inside of main, the warning goes away. I'm not sure, but I suspect this might break on certain devices. There's some discussion of it and a proper reference to the spec on Stack Overflow http://stackoverflow.com/questions/28076568/is-it-ever-reasonable-to-do-computations-outside-of-main-in-an-opengl-shader
.
You can view, comment on, or merge this pull request online at:
https://github.com/borismus/webvr-boilerplate/pull/96 Commit Summary
- Declare non-constant fragment shader variables inside main
File Changes
- M src/distortion/barrel-distortion-fragment-v2.js https://github.com/borismus/webvr-boilerplate/pull/96/files#diff-0 (12)
Patch Links:
- https://github.com/borismus/webvr-boilerplate/pull/96.patch
- https://github.com/borismus/webvr-boilerplate/pull/96.diff
— Reply to this email directly or view it on GitHub https://github.com/borismus/webvr-boilerplate/pull/96.
As I read it, placing the declarations inside of main
does both stick to the spec and gets rid of the warning. Everybody wins.
I think what @brianchirls was saying is "I suspect [leaving these variables where they currently are] might break on certain devices." And I agree, it feels awkward to do computation outside of a function. Moving the declarations inside main
should be harmless and get rid of the warning.
I'm getting the following warning in Chrome when compiling the BarrelDistortionFragment (v2) shader:
WARNING: 0:22: '=' : global variable initializers should be constant expressions (uniforms and globals are allowed in global initializers for legacy compatibility)
It's on the declaration of
projectionRight
andunprojectionRight
. If you move those declarations inside ofmain
, the warning goes away. I'm not sure, but I suspect this might break on certain devices. There's some discussion of it and a proper reference to the spec on Stack Overflow.