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

Geoid2 #511

Closed
wants to merge 2 commits into from
Closed

Geoid2 #511

wants to merge 2 commits into from

Conversation

qdnguyen
Copy link
Contributor

@qdnguyen qdnguyen commented Oct 6, 2017

Description

This PR is needed to visualize geoid color and DTM.

The changes were done

  • Add zfactor to deform geoid DTM
  • Add geoid example

Screenshots

image

Copy link
Contributor

@peppsac peppsac left a comment

Choose a reason for hiding this comment

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

Thanks for the rebase :)

Please use proper wording for your commits (see http://codeinthehole.com/writing/a-useful-template-for-commit-messages/ for some help) and split them in separate topics (e.g: 1 for the zFactor feature and 1 for the new example)

@@ -14,6 +14,8 @@ uniform sampler2D dTextures_00[1];
uniform vec3 offsetScale_L00[1];
uniform int loadedTexturesCount[8];

uniform float zFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move all the zFactor stuff to a specific commit.

@@ -59,7 +59,8 @@ void main() {
}

#elif defined(DATA_TEXTURE_ELEVATION)
float dv = max(texture2D( dTextures_00[0], vVv ).w, 0.);
float dv = texture2D( dTextures_00[0], vVv ).w;
dv *=zFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be doing dv *=zFactor; below (just before vPosition = vec4( position + vNormal * dv ,1.0 )).
This way it would work with all elevation data sources.

Copy link
Contributor Author

@qdnguyen qdnguyen Oct 6, 2017

Choose a reason for hiding this comment

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

i did it before like you said and it work but i dont know why it does not work now if i put it before vPosition = vec4( position + vNormal * dv ,1.0 )). I think three is a problem with vNormal

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. I don't know what is the underlying issue here, but you need to fix this so the z factor feature works independently of the elevation data source.

Choose a reason for hiding this comment

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

i set zFactor value by default to 1, so it will not impact on elevation data.

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is: we want this to work regardless of the data source used for elevation.
As an example, zFactor feature should work on planar.html demo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, done

Copy link
Contributor

@peppsac peppsac left a comment

Choose a reason for hiding this comment

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

Quick review, focusing mostly on style issues.

.gitignore Outdated
@@ -6,3 +6,5 @@
/node_modules/
/dist/
/lib/
/nbproject/private/
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't belong to the itowns's .gitignore - gitignore is only populated with folders/files that are by-product or temp files of itowns.

Copy link
Contributor

Choose a reason for hiding this comment

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

(You can add your own ignore stuff in the .gitignore in your home folder)

@@ -0,0 +1,71 @@
<!DOCTYPE html>
<!--
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this generated header.

-->
<html>
<head>
<title>Globe</title>
Copy link
Contributor

Choose a reason for hiding this comment

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

And fix the title :)

promises.push(itowns.Fetcher.json('layers/JSONLayers/GeoidTexture.json').then(function(result) { return globeView.addLayer(result); }));
//promises.push(itowns.Fetcher.json('layers/JSONLayers/Ortho.json').then(function(result) { return globeView.addLayer(result); }));
promises.push(itowns.Fetcher.json('layers/JSONLayers/GeoidMNT.json').then(function(result) { return globeView.addLayer(result); }));
//promises.push(itowns.Fetcher.json('layers/JSONLayers/IGN_MNT.json').then(function(result) { return globeView.addLayer(result); }));
Copy link
Contributor

Choose a reason for hiding this comment

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

And remove dead code in all this file.

@@ -0,0 +1,3 @@
files.encoding=UTF-8
Copy link
Contributor

Choose a reason for hiding this comment

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

This nbproject folder must not be added to iTowns.

Choose a reason for hiding this comment

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

thanks for your advice

@@ -59,7 +59,8 @@ void main() {
}

#elif defined(DATA_TEXTURE_ELEVATION)
float dv = max(texture2D( dTextures_00[0], vVv ).w, 0.);
float dv = texture2D( dTextures_00[0], vVv ).w;
dv *=zFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. I don't know what is the underlying issue here, but you need to fix this so the z factor feature works independently of the elevation data source.

@@ -2,3 +2,4 @@ export { default as Debug } from './Debug';
export { default as PointCloudDebug } from './PointCloudDebug';
export { default as createTileDebugUI } from './TileDebug';
export { default as create3dTilesDebugUI } from './3dTilesDebug';

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not add empty lines please.

Choose a reason for hiding this comment

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

done

@@ -69,6 +70,7 @@ void main() {
#endif

vPosition = vec4( position + vNormal * dv ,1.0 );

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not add empty lines please.

Choose a reason for hiding this comment

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

done

return this.geometry.OBB;
var zFactor = this.material.uniforms.zFactor.value;
var OBB = this.geometry.OBB;
OBB.box3D.min.z *= zFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation is wrong here.

Choose a reason for hiding this comment

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

don't understant! We need it to adapt Bbox to geoid tiles'bbox, zFactor is set by default to 1 so it will not have an impact on DTM

Copy link
Contributor

@peppsac peppsac Oct 23, 2017

Choose a reason for hiding this comment

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

The code indentation is wrong.

Btw, the code is wrong too since you're going to modify OBB.box3D.min.z (and max) each time the OBB() function is called.
So for instance if min.z = 1.0 and zFactor = 3.0 initially, min.z will be: 3 then 9 then 27...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a posibility that in TileMesh i can have a notification when zFactor is changed ?

Copy link
Contributor Author

@qdnguyen qdnguyen Oct 25, 2017

Choose a reason for hiding this comment

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

@peppsac is there a copy function of OBB? what do you think if i make a copy of OBB and modify it?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, I don't think you want to build a copy of the OBB.
You should be able to use the OBB.scale attribute to store the zFactor (ie: scale = (1, 1, zFactor)).

Choose a reason for hiding this comment

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

Thank @peppsac for help, i tried it before but it did not work (i have holes as you can see in image), i think i need to modify OBB max min to adapt bbox for SSE.

image

Copy link
Contributor

@peppsac peppsac Oct 30, 2017

Choose a reason for hiding this comment

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

My reasonning is the following: OBB is an Object3D. If you can't get Object3D properties (like scale) to work then it's a bug in OBB.
And this bug needs to be fixed (instead of adding another function to OBB).

Copy link

@nguyenign nguyenign Oct 31, 2017

Choose a reason for hiding this comment

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

No, there is no bug and i understand what you said but I tried the scale and it did not work, because the problem is Box3D in OBB. Do not update it, the calculation of SSE will be wrong and the results as you can see in the picture above.

Btw, i also do not think the code above is wrong, because in the case there is no geoid, zFactor is always equal to 1, there is no effect on MNT. In geoid case, when zFactor is greater than 1, i saw it runs just fine as you can see in picture below.

image

Choose a reason for hiding this comment

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

please dont take into account my last comment, i forgot update OBB, it work now by using OBB.scale and OBB.update .

@@ -491,5 +493,9 @@ LayeredMaterial.prototype.setSelected = function setSelected(selected) {
this.uniforms.selected.value = selected;
};

LayeredMaterial.prototype.setLayerZFactor = function setLayerZFactor(zFactor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method useful? It's just a one-line method and you don't use it https://github.com/iTowns/itowns/pull/511/files#diff-caf5227be4f9e2f283d82df32a678e4bL523 so I'd suggest removing it for now.

Choose a reason for hiding this comment

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

yes, i used it in updateLayeredMaterialNodeElevation to deform geoid

Copy link
Contributor

@peppsac peppsac Oct 23, 2017

Choose a reason for hiding this comment

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

I meant: it's a one-liner and you only use once.
So I'd prefer you to remove it (and replace it's usage in updateLayeredMaterialNodeElevation with material.uniforms.zFactor.value = layer.zFactor;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@peppsac
Copy link
Contributor

peppsac commented Oct 25, 2017

Just tested:

Thanks!

@qdnguyen qdnguyen force-pushed the geoid2 branch 2 times, most recently from c8c79f4 to fa5920b Compare October 31, 2017 10:24
@nguyenign
Copy link

ok, pr is ready to merge

Copy link
Contributor

@peppsac peppsac left a comment

Choose a reason for hiding this comment

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

This PR is improving, thanks.

You still need to fix a few minor issues.
Then you can rebase you commits on master and:

@@ -107,7 +107,7 @@ export function createGlobeLayer(id, options) {
}
}

const wgs84TileLayer = new GeometryLayer(id, options.object3d || new THREE.Group());
const wgs84TileLayer = new GeometryLayer(id, options.object3d);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you changed this?

Choose a reason for hiding this comment

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

it's changed automatically when i did rebase, i will change it back!

@@ -194,6 +194,8 @@ function GlobeView(viewerDiv, coordCarto, options = {}) {
// Setup View
View.call(this, 'EPSG:4978', viewerDiv, options);

options.object3d = options.object3d || this.scene;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question: why did you change this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to modify GlobeView, except for adding the setZFactor method.

return this.geometry.OBB;
var zFactor = this.material.uniforms.zFactor.value;
var OBB = this.geometry.OBB;
OBB.scale.z = zFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Code indentation is still wrong (#511 (comment)).
And please use const instead of var.

Choose a reason for hiding this comment

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

what wrong? it work for me!

@@ -1,4 +1,4 @@
export { default as Debug } from './Debug';
export { default as PointCloudDebug } from './PointCloudDebug';
export { default as createTileDebugUI } from './TileDebug';
export { default as create3dTilesDebugUI } from './3dTilesDebug';
export { default as create3dTilesDebugUI } from './3dTilesDebug';
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to modify this file.

@nguyenign
Copy link

ok, it's ready to merge now :)

@gchoqueux gchoqueux mentioned this pull request Nov 10, 2017
@nosy-b
Copy link
Contributor

nosy-b commented Nov 21, 2017

@qdnguyen Any news on that nice feature?

@nguyenign
Copy link

no, as i said it's ready to merge!

@nosy-b
Copy link
Contributor

nosy-b commented Nov 21, 2017

@qdnguyen Could you rebase?

@nguyenign
Copy link

rebased!

@nosy-b
Copy link
Contributor

nosy-b commented Nov 21, 2017

You have some lint problems
### 302:1 error Trailing spaces not allowed no-trailing-spaces
303:5 error Expected exception block, space or tab after '//' in comment spaced-comment

Plus, could you add the example.html in the example/index.html page with the right screenshot as it's a new feature?

@gchoqueux gchoqueux added this to the 2.xx.x milestone Feb 1, 2019
zarov added a commit to zarov/itowns that referenced this pull request Jul 3, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
@gchoqueux
Copy link
Contributor

moved in #1174

@gchoqueux gchoqueux closed this Jul 3, 2019
zarov added a commit to zarov/itowns that referenced this pull request Jul 19, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
zarov added a commit to zarov/itowns that referenced this pull request Jul 19, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
zarov added a commit to zarov/itowns that referenced this pull request Jul 29, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
zarov added a commit to zarov/itowns that referenced this pull request Jul 30, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
zarov added a commit to zarov/itowns that referenced this pull request Jul 30, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of iTowns#511
zarov added a commit that referenced this pull request Jul 30, 2019
Changing the `scale` property of an `ElevationLayer` can changed the
aspect of the visual, allowing exageration of the elevation of the
globe, as in the tiff.html example.

This is an up-to-date version of #511
@gchoqueux gchoqueux deleted the geoid2 branch July 30, 2019 14:13
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.

6 participants