-
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
Simplify voxel shaders #11838
Simplify voxel shaders #11838
Conversation
b199ba4
to
aa73207
Compare
RayShapeIntersection intersectRegularWedge(in Ray ray, in vec2 minMaxAngle, in bool convex) | ||
{ | ||
// Compute intersections with the two planes | ||
// TODO: the sign of the normals looks backwards?? But it works for convex == false |
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.
Should this TODO be addressed?
vec4 entry = inOrder ? intersect1 : intersect2; | ||
vec4 exit = inOrder ? intersect2 : intersect1; | ||
|
||
bool enterFromOutside = (entry.w >= 0.0) == (dot(ray.pos.xy, entry.xy) < 0.0); |
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.
Nitpick: Maybe assign the boolean values to intermediate variables to avoid any confusion or accidental assignments.
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.
Thanks @jjhembd! Tests are passing and the Sandcastle examples are working well.
Thanks for the feedback @ggetz! I looked through that TODO, and realized I had been confused about the meaning of a "regular wedge" -- it is actually a negative volume in this case, where the wedge is "outside" the shape bounds. I updated the naming and comments in that function to avoid confusion. |
Looks good to me! Thanks @jjhembd! |
Description
This PR simplifies the voxel shaders with two main changes:
IntersectLongitude.glsl
, so they can be re-used for both Ellipsoid and Cylinder shapesThe existing code handled different ranges of shape and render bounds by re-compiling with different defines. For example,
The case with
RADIUS_FLAT
is where the user is not viewing a volume, but a thin shell with constant radius.With this PR, when the user selects a single radius, the value of the scale and offset in
u_cylinderUvToShapeUvRadius
is adjusted on the CPU side to return 1.0, so that the same shader path can be used. This approach helps by:While this approach may add some render cost, I believe the added cost is justifiable because:
Testing plan
Voxel???Shape
specs run successfullyAuthor checklist
CONTRIBUTORS.md
[ ] I have updatedCode cleanup, does not affect user-facing behaviorCHANGES.md
with a short summary of my change[ ] I have added or updated unit tests to ensure consistent code coverageCode cleanup, does not affect test results or coverage