Comments (8)
Thanks for the report. I'm on Mac Firefox and am able to see the rings. So I suspect it may be some combination of OS+GPU.
Here is an old but potentially related issue. However, my ring shader doesn't return any structs. So I'm not sure the fix is directly applicable.
from spacekit.
So I suspect it may be some combination of OS+GPU.
Yes, this happens to be a Windows-specific issue. Ubuntu 18.04 on the same machine (using Live USB) renders rings as intended.
from spacekit.
However, my ring shader doesn't return any structs.
It seems that the version of RING_SHADER_FRAGMENT
from src/shaders.js
is not called from anywhere in the Saturn demo. Instead the shader is in build/spacekit.js
.
Warning: D3D shader compilation failed with default flags.
I've found out the similar error in the TensorFlow JS library (tensorflow/tfjs#1337). It's not directly aplicable to this case, but the solution for that bug (tensorflow/tfjs-core#1646) showed that there might be flaws hidden deep in a valid and working code because of the GPU drivers (like an inability to handle integer division correctly in TensorFlow case).
So I've checked the ring's frament shader for suspicious things. There is the following calculation of the pixel's colour:
void main(void) {
gl_FragColor = color() * vec4(lights() * shadow(), 1.0);
}
The color()
function contains discard
option as the conditional path.
vec4 color() {
...
if (...) {
discard;
}
...
}
Commenting this out (or replacing with return vec4(0.0)
) fixes the problem (and renders rings wrong of course).
My guess is that the driver on Windows cannot handle variable deallocation correctly. When an operand of the multiplication operation (color()
function) calls discard
it does not discard the multiplication operation as a whole. Light and shadow components are calculated anyway and when the second operand vec4(...)
is calculated it tries to multiply the result by the left operand that has already been discarded and the driver crashes (hence the vague 'unbound variable' text in the error log).
Switching the operands of the final multiplication allows rings to be rendered:
gl_FragColor = vec4(lights() * shadow(), 1.0) * color();
Also, saving light&shadow components to a temporary vector also works fine as right value is already known when discard
in color()
is executed:
vec3 lightAndShadow = lights() * shadow();
gl_FragColor = color() * vec4(lightAndShadow , 1.0);
This is just my first look on the problem and I'm not sure this is the final or 'proper' way to fix this.
P.S. The following version also works for some mysterious reason:
void main(void) {
vec3 foo = lights();
vec3 bar = shadow();
gl_FragColor = color() * vec4(lights() * shadow(), 1.0);
}
from spacekit.
@Postrediori Thanks so much for the detailed debugging help! I've made one of your suggested changes:
gl_FragColor = vec4(lights() * shadow(), 1.0) * color();
This means the example should load correctly (you may have to hard refresh): https://typpo.github.io/spacekit/examples/saturn/index.html. How does it look?
from spacekit.
Rings are rendered correctly:
Checked on Win10 & 8.1, Firefox and Chromium.
Thanks!
from spacekit.
Thank you again for the help!
from spacekit.
FYI Maybe a bit late, I reported this issue to Chromium bugtracker: https://bugs.chromium.org/p/chromium/issues/detail?id=1192924. It was labeled as Wont Fix though, because is is a bug somewhere in legacy DirectX dll.
from spacekit.
This is interesting, thanks so much for following up. I've run into strange issues with ANGLE before.
from spacekit.
Related Issues (20)
- Add milky way dust clouds
- ReadMe is incorrect HOT 1
- can't see cloud HOT 3
- Add bumpcharts, atmosphere for SphereObjects
- Convert skydome to a cube texture
- Add support for hyperbolic orbits
- Simulation time can't be set to greater than day precision
- Add field of view for SpaceObject,such as cone...
- addObject() not working HOT 2
- Particles of moons aren't appearing HOT 1
- Just wanted to say hi as I've done something similar HOT 1
- Labels dont' show properly for objects without ephem
- Ring shader not working on SphereObjects with Ephem
- Scene suddenly stopped working in Safari and on iOS
- Option to uniformly scale ShapeObject
- Add probe object with mass, velocity and direction vector? HOT 1
- Rename JED -> JD
- Make milky way orientation more accurate
- Add time-based rotation for shapeobject
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spacekit.