-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grid material and Ellipsoid primitive #601
Conversation
Cool. I won't be able to check this out until next week, but @bagnell is welcome to review and merge this sooner if you want it to make b15. At a quick glance, the code looks OK. Also, update CHANGES.md and the Fabric Wiki. |
No rush. Before this goes in I could use some advice on how to get the Volume demo to show both the front and back sides of the ellipsoids. Currently when the camera is outside an EllipsoidPrimitive, it only sees the outside wall (facing the camera), but when the camera flies inside, it sees the inside wall. It's as if the backface culling changes when the camera goes inside, or maybe the depth buffer is blocking the farther wall. Is there any way to fix this? |
In some cases, this will actually be useful. We can also imagine different materials for the front and back. For example, the front has thick lines and the back has thin lines. I coded all of this in Insight3D, but with the fixed function. It is much easier with GPU ray casting. Anyway, the issue is we only take the closest ray intersection, not both. So if the closest one has an alpha of zero, we never check the back. We could do both and even refraction if we want. This will require a change to the ellipsoid itself, which we should do (at least initially) in a separate pull request. |
Also fixed an issue with the final alpha value.
…bagnell's desk. Also commented out picking in the Volume demo because its bugs are driving me completely insane.
…soid Make Ellipsoids double-sided.
Conflicts: Apps/Sandcastle/gallery/Volumes.html Source/Shaders/EllipsoidFS.glsl
uniform vec4 gridColor; | ||
uniform float holeAlpha; | ||
uniform vec2 lineCount; | ||
uniform vec2 lineThickness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What unit is lineThickness
in? I want them to be pixels and for the thickness to be uniform in screenspace, just like polylines are. That doesn't look like what's happening now though. Also, why call it lineThickness
when we use width
everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The units are different depending whether your GPU supports GL_OES_standard_derivatives
. Without derivatives, the unit is a percentage, where 0.0 is no line and 1.0 is all line and no hole. With derivatives, the units are somewhere in the vicinity of tens-of-pixels, a unit scale chosen to make available some reasonable default values that work pretty well in both environments. I'm open to change of course, but I'm going to wait for @pjcozzi to come back from GDC and have a chance to review this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in person, these units have changed to be more pixel-like, and the default is now 1.0.
OK, I think this is ready for final review. |
Specs? |
@emackey will look at this tomorrow. |
Spec added for Grid material. The EllipsoidPrimitive gets no new parameters or tests now that the multi-res grid is reverted. |
@@ -310,6 +310,11 @@ | |||
primitive.material = new Cesium.Material.fromType(scene.getContext(), 'Grass'); | |||
} | |||
|
|||
function applyGridMaterial(primitive, scene) { | |||
Sandcastle.declare(applyGridMaterial); // For highlighting in Sandcastle. | |||
primitive.material = new Cesium.Material.fromType(scene.getContext(), 'Grid'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to actually set all the uniform values here, so that people can see what they can manipulate and play with it in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but in a previous note we discussed upgrading this demo for auto-discovery of all uniforms on all materials. This demo in its current form contains many materials with only their default uniforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, my reply to that would be to add uniform settings for all of the materials then, this demo overall is kind of useless without them (from a purely coding standpoint). That being said, if you don't have the bandwidth for it, we can just punt to a later date; no big deal.
|
I realize my comments are all design/usability related. I'm just trying to determine what actual requirements for customers may be. |
Perhaps |
Then I would rename |
All tests pass and Sandcastle demo works fine. This is fine with me assuming @pjcozzi is satisfied with the glsl, I'll let him merge when he's happy. |
Updated Fabric wiki page. |
@@ -46,7 +46,8 @@ | |||
e.center = ellipsoid.cartographicToCartesian( | |||
Cesium.Cartographic.fromDegrees(-75.0, 40.0, 500000.0)); | |||
e.radii = new Cesium.Cartesian3(500000.0, 500000.0, 500000.0); | |||
e.material = Cesium.Material.fromType(undefined, Cesium.Material.RimLightingType); | |||
e.material = Cesium.Material.fromType(undefined, Cesium.Material.GridType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just add a new volume to show the grid material? I want to keep these examples to show the rim lighting and stripe material.
@emackey did you test this on mobile? |
@emackey just those few comments. This is good otherwise. Thanks! Materials are always welcome. |
Just tested Grid material on Motorola Xoom. Works great, derivatives are enabled and all. |
I'll live with the derivative artifacts for now. One option might be to detect the tangent points on the ellipsoid (or places on the material where the normal is 90 degrees from the camera) and color them separately. But that's for another day. This is ready for merge. |
Merging. |
Grid material and Ellipsoid primitive
This is my first attempt at creating a Cesium material.
This branch now includes another merged branch with changes to the
EllipsoidPrimative
to make it appear double-sided (to show the far wall of the ellipsoid even when outside).There are some known depth issues where ellipsoids intersect, but these existed prior to this branch and may eventually be addressed by #607.
This branch used to include logic for adding additional grid lines. This code has been reverted, as it made overlapping ellipsoids look too crowded. It is still available for inspection on other branches.