Blake
November 29, 2021, 10:19pm
1
For the GridMaterial, the places where grid lines intersect was too bright and it was really annoying me LOL, like below.
GridMaterial with default settings: https://playground.babylonjs.com/#2KKVBH#113
Currently the contribution of each axis is added together. If instead we use the max axis contribution then the issue of overlapping lines being too bright is resolved.
Below is from the same playground using the updated GridMaterial.
Here’s a PR to update GridMaterial’s fragment shader with this fix.
BabylonJS:master
← BlakeOne:master
opened 10:18PM - 29 Nov 21 UTC
Fixes the issue seen in the below playground where the points of intersection be… tween the grid lines are too bright, by using the max axis contribution instead of the sum of the axes contributions.
Playground: https://playground.babylonjs.com/#2KKVBH#113
Forum: https://forum.babylonjs.com/t/fix-for-gridmaterial-line-intersections/25644
Also here’s the NME grid material updated with this fix as well.
2 Likes
sebavan
November 29, 2021, 10:52pm
3
I kinda liked the dots
joking aside I think this is a breaking change and I wonder if you could add it under a special #define ?
1 Like
Blake
November 29, 2021, 11:10pm
4
Okay I’ll model it after fogEnabled with a define and property then. Hmm what to call the flag thou, maxAxisEnabled?
1 Like
sebavan
November 29, 2021, 11:14pm
5
I am super dumb with names…
could be as simple as
#ifdef MAXLINES
// Create the grid value from the max axis.
float grid = clamp(max(max(x, y), z), 0., 1.);
#else
float grid = clamp(x + y + z, 0., 1.);
#endif
and MAXLINES would map to a property named as you see best fit
2 Likes
Blake
November 29, 2021, 11:21pm
6
Yep that’s what I was thinking too, then model the property mapping after fogEnabled. Maybe just maxLinesEnabled for the name then unless inspiration strikes.
2 Likes
Blake
November 30, 2021, 12:03am
7
Okay all done (I think). I went with calling the property useMaxLine and distinguished it from using the sum of the lines for the documentation.
1 Like
sebavan
November 30, 2021, 12:39am
8
Nailed it, thanks a lot !!!
1 Like
Blake
April 6, 2022, 1:54am
9
Oops I realized that I forgot to add anything for this property, useMaxLine, to the documentation guide, so I just added a little section and PG to the list of notes for the GridMaterial properties, to hopefully make it more clear when it might be useful.
BabylonJS:master
← BlakeOne:master
opened 01:54AM - 06 Apr 22 UTC
Adds a little info on when to use the new GridMaterial property useMaxLine, alon… g with an example playground to show when it may be useful. :)
Forum discussion: https://forum.babylonjs.com/t/fix-for-gridmaterial-line-intersections/25644/9
3 Likes