-
Notifications
You must be signed in to change notification settings - Fork 272
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
Increase texture coordinate precision on picking #764
base: master
Are you sure you want to change the base?
Conversation
X3DOM supports only 8-bit precision when picking texture coordinates. This is leads to poor quality results when textures are > 256 in any dimension. The "B" channel is currently not used during this operation. This modification uses the "B" channel to add 4 bits each to the U & V coordinates when picking textures giving a total of 12 bits or 4096 unique coordinate values in each direction. No change was made to any computation of S & T coordinates (X3D texture coordinates) to retain the [0.0,1.0] range. The change is in the value stored in the picking (mouseover) event. Returned values are integers in [0,4095].
I should have included the link to the online demo of this revision - http://tools.realism.com/Basx3D/x3dom/tmp/TexturePickingTest.html. This example uses a texture of 2048x2048 and automatically sets 'debug' mode. |
* | ||
* shader += "z = floor(x/256.)/levels/levels;\n"; | ||
* shader += "z = z + floor(levels*fragColor[1])/levels*(1.+1./256.);\n"; | ||
* |
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.
Does this part of the comment still apply ?
src/shader/gfx_webgl.js
Outdated
this.stateManager.enable(gl.DEPTH_TEST); | ||
|
||
//Set Depth Mask | ||
this.stateManager.depthMask(!depthMod |
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.
start
src/shader/gfx_webgl.js
Outdated
this.stateManager.enable(gl.DEPTH_TEST); | ||
|
||
//Set Depth Mask | ||
this.stateManager.depthMask(!depthMod |
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.
end. This would need to go into src/gfx_webgl.js . Any reason to have the file in src/shader ?
src/shader/gfx_webgl.js
Outdated
this.stateManager.enable(gl.DEPTH_TEST); | ||
|
||
//Set Depth Mask | ||
this.stateManager.depthMask(!depthMod |
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 in src/shader ? Probably the file should just stay in src/ .
z is not used, so ok.
Andreas,
I am booked up until end of next week. I'll look at this then. It would
really help me if you sent a reminder on Wednesday.
Thanks.
Leonard Daly
… ***@***.**** requested changes on this pull request.
------------------------------------------------------------------------
In src/shader/ShaderDynamicPicking.js
<#764 (comment)>:
> @@ -318,6 +318,42 @@ x3dom.shader.DynamicShaderPicking.prototype.generateFragmentShader = function(gl
} else if(pickMode == 3) { //Picking with 24bit precision
shader += "color.r = d;\n";
}
+
+/*
+ * Support 12-bit u/v picking by using "B" channel to store 4-bits of each U/V coordinates
+ * This method stores the additional low-order bits of precision in the B channel. If the need
+ * Is to store the high-order bits use the following two lines instead of the 3 lines for computation
+ * of x, y, z.
+ *
+ * To get the proper results, a compatible change must be made in 'gfx_webgl.js\\renderPickingPass'
+ * so that the additional 4 bits is incorporated into the result. The change is after the call to
+ * 'readPixels' around line 3046.
+ *
+ * shader += "z = floor(x/256.)/levels/levels;\n";
+ * shader += "z = z + floor(levels*fragColor[1])/levels*(1.+1./256.);\n";
+ *
Does this part of the comment still apply ?
------------------------------------------------------------------------
In src/shader/gfx_webgl.js
<#764 (comment)>:
> + this.stateManager.disable(gl.CULL_FACE);
+ }
+
+ //===========================================================================
+ // Set DepthMode
+ //===========================================================================
+ var depthMode = s_app ? s_app._cf.depthMode.node : null;
+ if (depthMode)
+ {
+ if (depthMode._vf.enableDepthTest)
+ {
+ //Enable Depth Test
+ this.stateManager.enable(gl.DEPTH_TEST);
+
+ //Set Depth Mask
+ this.stateManager.depthMask(!depthMod
start
------------------------------------------------------------------------
In src/shader/gfx_webgl.js
<#764 (comment)>:
> + this.stateManager.disable(gl.CULL_FACE);
+ }
+
+ //===========================================================================
+ // Set DepthMode
+ //===========================================================================
+ var depthMode = s_app ? s_app._cf.depthMode.node : null;
+ if (depthMode)
+ {
+ if (depthMode._vf.enableDepthTest)
+ {
+ //Enable Depth Test
+ this.stateManager.enable(gl.DEPTH_TEST);
+
+ //Set Depth Mask
+ this.stateManager.depthMask(!depthMod
end. This would need to go into src/gfx_webgl.js . Any reason to have
the file in src/shader ?
------------------------------------------------------------------------
In src/shader/gfx_webgl.js
<#764 (comment)>:
> + this.stateManager.disable(gl.CULL_FACE);
+ }
+
+ //===========================================================================
+ // Set DepthMode
+ //===========================================================================
+ var depthMode = s_app ? s_app._cf.depthMode.node : null;
+ if (depthMode)
+ {
+ if (depthMode._vf.enableDepthTest)
+ {
+ //Enable Depth Test
+ this.stateManager.enable(gl.DEPTH_TEST);
+
+ //Set Depth Mask
+ this.stateManager.depthMask(!depthMod
why in src/shader ? Probably the file should just stay in src/ .
z is not used, so ok.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#764 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AH4P52sjECzo6QnrEIQTRysrG2mZbVVoks5sylMAgaJpZM4O_Eu9>.
--
*Leonard Daly*
3D Systems Architect & Cloud Consultant
President, Daly Realism - /Creating the Future/
|
Please take a look. I didn't see collisions with existing functionality but perhaps it is worth checking again. |
X3DOM supports only 8-bit precision when picking texture coordinates. This is leads to poor quality results
when textures are > 256 in any dimension. The "B" channel is currently not used during this operation. This
modification uses the "B" channel to add 4 bits each to the U & V coordinates when picking textures giving a
total of 12 bits or 4096 unique coordinate values in each direction. No change was made to any computation of
S & T coordinates (X3D texture coordinates) to retain the [0.0,1.0] range. The change is in the value stored
in the picking (mouseover) event. Returned values are integers in [0,4095].
This change is public domain.