heremaps / harp.gl

3D web map rendering engine written in TypeScript using three.js
Apache License 2.0
1.28k stars 198 forks source link

Customize the texture of the extrudePolygon or extrudebuilding #1854

Closed datouzhan closed 3 years ago

datouzhan commented 4 years ago

Is your feature request related to a problem? Please describe. Will Harpgl support custom top and side texture maps for extrudePolygon?

Describe the solution you'd like i try to change texture maps for extrudePolygon,but it fail.like this,it covers the entire extrudePolygon

image What I want to achieve is to set the side and top textures separately,like this: image

nzjony commented 4 years ago

@datouzhan , thanks for your bug report.

We will need to have a new textureCoordinateType, which works with 3D buildings. I will create an internal ticket and discuss with the team.

datouzhan commented 4 years ago

Thank you very much and i hope to hear the good news. And then, if there will be a terrain example?Because the api provides TerrainTechnique And Terrain style, but I don’t know what type of data is needed to show the terrain.

nzjony commented 4 years ago

@datouzhan , just so I understand your needs correctly. You want to put some windows etc on the buildings?

There will be some artifacts at the boundary of tiles where buildings are cut. Is that acceptable? I.e. the texturing will be applied in this case twice, which may be undesirable.

datouzhan commented 4 years ago

i want to change the texture map on the top and side for the 3dbuilding.I don't think it has much impact.i can accept it.

datouzhan commented 4 years ago

By the way, how the terrain should be used. The api document provide the TerrainTechnique And Terrain style,But didn't tell me what data to use and how to apply it.

nzjony commented 4 years ago

@datouzhan , we have some terrain examples but they are only internally, because they use some internal services which are not yet production ready.

Maybe we can generate some simple demo which shows terrain using some randomly generated noise. I will ask internally if we can do something like that in the upcoming sprints.

datouzhan commented 4 years ago

I'm looking forward to hearing your good news.

datouzhan commented 4 years ago

I encountered some problems in the process of verifying shader. For example, to realize the dynamic flow of water surface.I tried to pass in pictures, textures and other dynamic parameters, but failed. {T8R4PYNTKU~H U0%CHW82K `IITH$6XVGH)@L79M_C%`Z4 Can you answer it for me?

nzjony commented 4 years ago

@datouzhan , I spoke with @robertoraggi, it seems there is some issue transferring the texture to the WebWorker, when you create the MapView, can you try and please add this option:

decoder: new VectorTileDecoder()

And let me know what error you get?

nzjony commented 4 years ago

@datouzhan , I spoke a bit more with @robertoraggi .

Here is an example uploading a texture: https://www.harp.gl/docs/master/examples/#styling_textured-areas.html

And here is the example using a custom shader: https://www.harp.gl/docs/master/examples/#datasource_geojson_custom-shader.html

We just need to make a task internally to create an example which using a custom texture in a custom shader. We looked at the code, but it isn't fully clear if this is supported, or not. At least there is quite a bit of hard coded properties that need to be looked at to see if they are doing what they should.

I will create a task and hopefully we can help you soon.

datouzhan commented 4 years ago

Yes, I am the reference example of using a custom shader.The example only defines that the color is passed by the test.And I tried to pass in the texture map but failed.Thank you very much for your support.I will be looking forward to hearing your good news. i will add this option:decoder: new VectorTileDecoder() to try it.

datouzhan commented 4 years ago

Because in addition to texturing, I also need to make the water flow. So I need to use custom shaders to achieve dynamic water flow like an ocean example to threejs.

nzjony commented 4 years ago

Sounds very cool what you are trying to achieve @datouzhan ! Hopefully we can prioritise this internally so we can help you out. I will keep you posted.

datouzhan commented 4 years ago

Thank you very much for your support.if i can achieve this scene,it will be very cool.

datouzhan commented 4 years ago

hi , @nzjony ,i try to use the custom shader to achieve flowing water,but it has some problem. I have no problem implementing it in a separate example of threejs,like this: image but when i want to achieve it in harpgl ,it has some problem ,like this: image When I rotated an angle, the color of the water changed.like this: image can u answer it for me, i don't know how to solve it. image And When I pull closer to the angle, the object will keep shaking.But if it is added to the map in the way of vector tiles, there will not be such a problem.

nzjony commented 4 years ago

@datouzhan , very awesome progress!

Do you have the demo available somewhere for me to test locally?

datouzhan commented 4 years ago

hi @nzjony ,I created an online demo. https://codepen.io/datouzhan/pen/XWdQNmR, can you open it? And this is created by threejs, https://codepen.io/datouzhan/pen/RwaOoOb.

nzjony commented 4 years ago

@datouzhan , cool demo, yes I can open it.

I think the problem is the normals for the texture: https://techbrood.com/threejs/examples/textures/waternormals.jpg

In harp.gl, we use a slightly different use of the coordinates, we use x to describe the longitude, y to describe the latitude, and z to describe the height. So basically, compared to a normal 3d engine which uses the x&z plane to move horizontally, and the y to move vertically, we swap the z and y. And my guess is that the normals in the texture assume that.

Actually, I just looked at the shader code in three.js for the water, and it seems that the z and y are flipped in the shader:

vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );'

Maybe try a local build of three.js with that modified and see if it fixes the issue?

datouzhan commented 3 years ago

yes,it fixes the issue, thank you very much.You helped me a lot. image But when I use the scroll wheel to move slowly, the scene will shake,can you answer it for me? This phenomenon only occurs on the additional threejs objects. shake

Astrak commented 3 years ago

Very beautiful, looking forward to it!

@nzjony how far is the team from delivering terrain? Will it work with all the other existing features? Will the shading of the globe atmosphere on the ground also adapt to the terrain's height? Thanks

nzjony commented 3 years ago

@Astrak , yeah, @datouzhan has made some cool demo!

Terrain requires some changes to the platform to be able to serve such tiles, I don't know how far we are away from this just yet, and I think it isn't such a high priority just yet. The terrain shading would also be blocked by that.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

d3vilsn0w commented 2 years ago

Is it possible to share an example adding a shader to the water layer?