-
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
More robust point cloud post processor #5455
More robust point cloud post processor #5455
Conversation
ab7d69b
to
3424709
Compare
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.
Looks good at quick glance. Just a few small comments. @lilleyse can review and merge when ready.
width : screenWidth, | ||
height : screenHeight, | ||
pixelFormat : PixelFormat.RGBA, | ||
pixelDatatype : PixelDatatype.FLOAT, |
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 to check for an extension for this?
WebGL 2 or https://www.khronos.org/registry/webgl/extensions/OES_texture_float/
sampler : createSampler() | ||
}); | ||
for (i = 0; i < 3; ++i) { | ||
if (i < 2) { |
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.
Use two separate for
loops; it will be cleaner.
// TODO : for now assume than any pass can write depth, possibly through EXT_frag_depth. | ||
// Definitely needed for the initial render into the FBO, possibly also the ping-pong processing. | ||
framebuffers[i] = new Framebuffer({ | ||
/* We want to reuse textures as much as possible, so here's the order |
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.
Stick with the //
comment style.
This is actually not in the Coding Guide, but I'm pretty sure it is a common practice throughout Cesium except for comments for generating reference doc with JSDoc.
Could you open a separate PR to mention this at the bottom of the Basic Code Construction?
*/ | ||
|
||
processor._framebuffers = { | ||
"prior": new Framebuffer({ |
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.
Here and similar properties below, "prior"
-> prior
Quotes are not needed here. When they are, use single quotes to be consistent with the rest of the code base.
var framebuffers = new Array(2); | ||
var depthTextures = new Array(3); | ||
|
||
var ecTexture = new Texture({ |
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.
Somewhere, we should comment (or rename this) about what "EC" stands for.
var framebuffers = processor._framebuffers; | ||
var clearCommands = new Array(4); | ||
i = 0; | ||
for (var name in framebuffers) { |
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.
Throughout, it looks like _framebuffers
is used as both an array and object. Be consistent. Perhaps this can be an array with constants in an enum for look ups.
@@ -222,15 +315,59 @@ define([ | |||
|
|||
if (resized) { | |||
destroyFramebuffers(processor); | |||
createFramebuffers(processor, context); | |||
updateCommandFramebuffers(processor); | |||
//createFramebuffers(processor, context); |
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.
We generally don't commit code that is commented out. Usually, remove it.
Otherwise, it can stay in your branch like this, but we would remove it before merging into master
.
'void main() \n' + | ||
'{ \n' + | ||
' czm_point_cloud_post_process_main(); \n' + | ||
//' gl_FragData[0] = gl_FragColor;' + |
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.
Same comment.
… is left dirty before use
…on't keep resetting
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.
Just a bunch of small things, overall it looks nearly ready.
derivedCommand.castShadows = false; | ||
derivedCommand.receiveShadows = false; | ||
|
||
var derivedCommandRenderState = new RenderState(derivedCommand.renderState); |
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.
We usually don't construct RenderStates
directly, instead we typically do clone(derivedCommand.renderState)
. The RenderState.fromCache
call below will actually create the render state from that.
|
||
var derivedCommandUniformMap = derivedCommand.uniformMap; | ||
var newUniformMap = { | ||
'u_pointAttenuationMaxSize' : attenuationUniformFunction |
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.
Remove the quotes.
@@ -255,7 +256,7 @@ define([ | |||
get : function() { | |||
return this._batchTable; | |||
} | |||
} | |||
}, |
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.
Remove comma.
Source/Scene/Cesium3DTileset.js
Outdated
* @param {Boolean} useTriangle Whether or not to use the triangle wave optimization | ||
* @param {Boolean} enableAO Whether or not to blend with ambient occlusion | ||
* @param {Boolean} depthViewEnabled Whether or not the depth view is enabled | ||
* @param {Boolean} AOViewEnabled Whether or not the ambient occlusion view is enabled |
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 you rename AOViewEnabled
to aoViewEnabled
throughout?
@@ -766,7 +770,7 @@ define([ | |||
} | |||
|
|||
// Edit the function header to accept the point position, color, and normal | |||
return source.replace('()', '(vec3 position, vec3 position_absolute, vec4 color, vec3 normal)'); | |||
return source.replace('()', '(vec3 position, vec3 positionWC, vec4 color, vec3 normal)'); |
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.
I was the one to suggest this before, but I realized this name change would break styles that use the POSITION_ABSOLUTE
built-in. At least this occurrence should remain as position_absolute
, but the others can stay positionWC
.
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.
I'm not exactly sure if the latest commit fixes this, but I think it's fixed
processor._edgeCullingTexture = undefined; | ||
processor._sectorLUTTexture = undefined; | ||
processor._aoTextures = undefined; | ||
processor._dirty = undefined; |
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.
This line can be removed.
|
||
var first = sectors[0]; | ||
var second = sectors[0]; | ||
sectors.forEach(function(element) { |
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.
Just a plain loop is fine and more fitting with code conventions. Also would sectors
be fine as a JS array?
this.sigmoidSharpness = tileset.pointCloudPostProcessorOptions.sigmoidSharpness; | ||
this.dropoutFactor = tileset.pointCloudPostProcessorOptions.dropoutFactor; | ||
this.delay = tileset.pointCloudPostProcessorOptions.delay; | ||
dirty = true; |
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.
@AnimatedRNG did you see this comment?
Edit: The original comment is here: https://github.com/AnalyticalGraphicsInc/cesium/pull/5455/files#r132295486
commandList.push(debugViewCommand); | ||
} | ||
|
||
commandList.push(clearCommands['prior']); |
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.
Style - clearCommands.prior
derivedCommand.castShadows = false; | ||
derivedCommand.receiveShadows = false; | ||
|
||
var derivedCommandRenderState = RenderState.fromCache(derivedCommand.renderState); |
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 a clone
here instead since the RenderState.fromCache
call is below. For example, look at https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Cesium3DTileBatchTable.js#L1329-L1332.
processor._stencilMaskTexture = stencilMaskTexture; | ||
} | ||
|
||
function addConstants(sourceFS, constantName, replacement) { |
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.
Rename replacement
to value
.
this._drawCommands = undefined; | ||
this._clearCommands = undefined; | ||
|
||
this.densityScaleFactor = '10.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.
This can be a number instead of a string.
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's slightly easier for it to remain a string because javascript keeps representing the number 10.0
as 10
when it is stringified. When the preprocessor define gets copied in, there are casting issues.
scene.primitives.removeAll(); | ||
}); | ||
|
||
it('enabling the point cloud post processor increases the number of draw calls', function() { |
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.
This test fails on Travis since the WebGL Stub does not enable the required extensions for the processor. You may want to make processingSupported
in PointCloudPostProcessor
a static function like PointCloudPostProcessor.isSupported
and check that before running the test.
densityEdgeCullFS = addConstants( | ||
densityEdgeCullFS, | ||
'epsilon8', | ||
1e-8 |
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.
Thinking about these defines some more, it might be cleaner to keep unchanging defines like this in the shader code, and only call addConstants
on those that do change.
437a285
to
4b1a918
Compare
@pjcozzi do you want to review this before it goes into |
Yes
No I'll review as soon as I can - and comment here - but please merge in the meantime. |
Thanks for all the work on this @AnimatedRNG! |
Still don't have the "change previous stages so that they write out ES coordinates to the texture" part working; everything else looks okay though.