Skip to content
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

Merged

Conversation

AnimatedRNG
Copy link
Contributor

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.

@AnimatedRNG AnimatedRNG force-pushed the point-cloud-processor-ss branch from ab7d69b to 3424709 Compare June 12, 2017 14:43
Copy link
Contributor

@pjcozzi pjcozzi left a 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,
Copy link
Contributor

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) {
Copy link
Contributor

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
Copy link
Contributor

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({
Copy link
Contributor

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({
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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;' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

Copy link
Contributor

@lilleyse lilleyse left a 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);
Copy link
Contributor

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
Copy link
Contributor

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;
}
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comma.

* @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
Copy link
Contributor

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)');
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

@lilleyse lilleyse Sep 11, 2017

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']);
Copy link
Contributor

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);
Copy link
Contributor

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) {
Copy link
Contributor

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';
Copy link
Contributor

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

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
Copy link
Contributor

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.

@AnimatedRNG AnimatedRNG force-pushed the point-cloud-processor-ss branch from 437a285 to 4b1a918 Compare October 18, 2017 17:26
@lilleyse
Copy link
Contributor

@pjcozzi do you want to review this before it goes into point-cloud-processor?

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 18, 2017

do you want to review this...

Yes

...before it goes into point-cloud-processor?

No

I'll review as soon as I can - and comment here - but please merge in the meantime.

@lilleyse
Copy link
Contributor

Thanks for all the work on this @AnimatedRNG!

@lilleyse lilleyse merged commit 93145ba into CesiumGS:point-cloud-processor Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants