-
Notifications
You must be signed in to change notification settings - Fork 104
I2375 added active voxels in volume render #1630
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there can be uint overflow for big volumes voxel index it makes sanse to calculate voxel index directly |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,6 +51,7 @@ std::string getVolumeFragmentShader() | |||||||||
|
|
||||||||||
| uniform sampler3D volume; | ||||||||||
| uniform sampler2D denseMap; | ||||||||||
| uniform highp usampler2D activeVoxels; // (in from base) selection BitSet | ||||||||||
|
|
||||||||||
| uniform bool useClippingPlane; // (in from base) clip primitive by plane if true | ||||||||||
| uniform vec4 clippingPlane; // (in from base) clipping plane | ||||||||||
|
|
@@ -163,6 +164,8 @@ std::string getVolumeFragmentShader() | |||||||||
| vec3 rayStep = step * normRayDir; | ||||||||||
| rayStart = rayStart - rayStep * 0.5; | ||||||||||
| vec3 diagonal = maxPoint - minPoint; | ||||||||||
| uint dimsXY = uint( dims.y * dims.x ); | ||||||||||
| uint dimsX = uint( dims.x ); | ||||||||||
|
Comment on lines
+167
to
+168
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see next |
||||||||||
| while ( outColor.a < 1.0 ) | ||||||||||
| { | ||||||||||
| rayStart = rayStart + rayStep; | ||||||||||
|
|
@@ -174,6 +177,17 @@ std::string getVolumeFragmentShader() | |||||||||
| if (useClippingPlane && dot( vec3( model*vec4(rayStart,1.0)),vec3(clippingPlane))>clippingPlane.w) | ||||||||||
| continue; | ||||||||||
|
|
||||||||||
| { | ||||||||||
| ivec2 texSize = textureSize( activeVoxels, 0 ); | ||||||||||
| // TODO fix potential ovewflow | ||||||||||
| uint voxelId = uint( textCoord.z * dims.z ) * dimsXY + uint( textCoord.y * dims.y ) * dimsX + uint( textCoord.x * dims.x ); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. textCoord is not voxel center (textCoord = voxelCenter + smallShift) |
||||||||||
| uint index = voxelId / 32u; | ||||||||||
| uint block = texelFetch( activeVoxels, ivec2( index % uint( texSize.x ), index / uint( texSize.x ) ), 0 ).r; | ||||||||||
| bool active = bool( block & uint( 1 << ( voxelId % 32u ) ) ); | ||||||||||
| if ( !active ) | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| float density = texture( volume, textCoord ).r; | ||||||||||
| if ( density < minValue || density > maxValue ) | ||||||||||
| continue; | ||||||||||
|
|
@@ -237,6 +251,7 @@ std::string getVolumePickerFragmentShader() | |||||||||
| uniform sampler3D volume; | ||||||||||
| uniform sampler2D denseMap; | ||||||||||
|
|
||||||||||
| uniform highp usampler2D activeVoxels; // (in from base) selection BitSet | ||||||||||
| uniform bool useClippingPlane; // (in from base) clip primitive by plane if true | ||||||||||
| uniform vec4 clippingPlane; // (in from base) clipping plane | ||||||||||
|
|
||||||||||
|
|
@@ -313,6 +328,8 @@ std::string getVolumePickerFragmentShader() | |||||||||
| vec3 rayStep = step * normRayDir; | ||||||||||
| rayStart = rayStart - rayStep * 0.5; | ||||||||||
| vec3 diagonal = maxPoint - minPoint; | ||||||||||
| uint dimsXY = uint( dims.y * dims.x ); | ||||||||||
| uint dimsX = uint( dims.x ); | ||||||||||
| while ( !firstFound ) | ||||||||||
| { | ||||||||||
| rayStart = rayStart + rayStep; | ||||||||||
|
|
@@ -324,6 +341,17 @@ std::string getVolumePickerFragmentShader() | |||||||||
| if (useClippingPlane && dot( vec3( model*vec4(rayStart,1.0)),vec3(clippingPlane))>clippingPlane.w) | ||||||||||
| continue; | ||||||||||
|
|
||||||||||
| { | ||||||||||
| ivec2 texSize = textureSize( activeVoxels, 0 ); | ||||||||||
| // TODO fix potential ovewflow | ||||||||||
| uint voxelId = uint( textCoord.z * dims.z ) * dimsXY + uint( textCoord.y * dims.y ) * dimsX + uint( textCoord.x * dims.x ); | ||||||||||
| uint index = voxelId / 32u; | ||||||||||
| uint block = texelFetch( activeVoxels, ivec2( index % uint( texSize.x ), index / uint( texSize.x ) ), 0 ).r; | ||||||||||
| bool active = bool( block & uint( 1 << ( voxelId % 32u ) ) ); | ||||||||||
| if ( !active ) | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| float density = texture( volume, textCoord ).r; | ||||||||||
| if ( density < minValue || density > maxValue ) | ||||||||||
| continue; | ||||||||||
|
|
||||||||||
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.
do we need export this class?
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.
why we don't need this (unlike others object classes)?