cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Fit texture coordinates to rectangle/trapezoid geometry

Open lilleyse opened this issue 9 years ago • 16 comments

It would be useful to support stretching a texture along a rectangle/trapezoid geometry, or perhaps even support explicit texture coordinates. The effect would look like the second image:

screen_shot_2016_07_25_at_11_22_39_pm cesium_good

@rumicuna created a demo for testing this:

https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases&gist=079b7bbc6c2c16bdaf23c57fe0a7f2c4

lilleyse avatar Aug 01 '16 20:08 lilleyse

We also need this to support KML latLonQuads

hpinkos avatar Aug 01 '16 20:08 hpinkos

We have done this in some of our other projects; see http://help.agi.com/AGIComponentsJava/html/BlogTrapezoidalTextureProjectionWithOpenGL.htm

pjcozzi avatar Aug 01 '16 20:08 pjcozzi

I took the very first steps of this in https://github.com/AnalyticalGraphicsInc/cesium/tree/trapezoid but this requires GroundPrimitive to support other appearances than just PerInstanceColorAppearance

hpinkos avatar Dec 07 '16 17:12 hpinkos

Specifically, this requires texturing ground primitive. @bagnell has most of the work done in this branch: https://github.com/AnalyticalGraphicsInc/cesium/compare/ground-primitive-tex-coords

pjcozzi avatar Dec 07 '16 17:12 pjcozzi

This came up again on the forum: https://groups.google.com/d/msg/cesium-dev/x3sYLgIr8Mc/wH2tdn_hCwAJ

hpinkos avatar Feb 15 '17 15:02 hpinkos

Came up on the forum again: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/zYikVZcfRMo

lilleyse avatar Jan 07 '20 16:01 lilleyse

Talked about this offline with @likangning93. This will require specific changes to GroundPrimitive.

Some early thoughts:

There may be a uv -> uv mapping that could accomplish this, you'd probably need to start by mapping the corners of the trapezoid into the ground primitive uv space. Perhaps you could pass the 4 corners in groundPrimitiveUvSpace as uniforms or constants in the shader, then do a barycentric operation using the fragment's groundPrimitiveUvSpace coordinate.

It might be possible to do a proof-of-concept using a custom shader material.

lilleyse avatar Jan 07 '20 16:01 lilleyse

@likangning93 @lilleyse read http://help.agi.com/AGIComponentsJava/html/BlogTrapezoidalTextureProjectionWithOpenGL.htm if you haven't already

hpinkos avatar Jan 07 '20 18:01 hpinkos

Hi guys! Any progress with this issue? Or maybe someone has a samples of code at least?

tmshv avatar Aug 24 '20 01:08 tmshv

Any progress with this issue?

wq8806 avatar Apr 16 '21 02:04 wq8806

4 years later. Please - Any progress with this issue?

jony89 avatar Aug 08 '21 12:08 jony89

I updated the sandcastle demo to reproduce it with the latest Cesium (link below). On the bright side, there has been an awesome improvement since I posted this, the video is now overlaid on the 3D terrain! Nice! Having this capability would mean we would be able to ovelay live drone video on the terrain (that is not directly pointing down and is not north up).

https://sandcastle.cesium.com/index.html#c=tVb7b9s2EP5XiAxDbMDRw5LlR5xgaZoG6Zo1aLK0W10UtHSWiFKkSlJ2tMH/+46S/Ara7ZdVfpA83nd3PH48ynXJfSZXmixZApJQkRCW0xSIgSdTKiBSkELyKpViJlzX/sidknMO+YSUSxJLqRJNaGkkSUGAogYSouUWz3CSr2iliZDKZKQsultD74EIQHXEzoFQNGq7GgwxGbTW0bhc1OM2DFSZ1Gh8vJ7XI37z5+PIJ/UME9oATVpgjsaZSOsYtyHOcDlLqnDZsAJFzjCQFbkEzcrceaxlndlRXI8vpTCUIW521CN/zwTBtSmFEsyDzZqabICxArT9XiqePDQqnW5vJtbd0507zPIVJg+EQaeJjEvbdVIwrfRFdZN0jg2COajjHbLNZ3LXZuGsDd1BDDMMtEOTpFOHRzBVGmWotQ3tkiqDPSoCZ6Fk/hJSBaA7w3GPBPjzPc+zoVqwoDkg8HiTb/zqUi1oDMe9jflmZkJaf/bJGGZWxVl1KN4PR/9XPBeYtKrz8RBtnxPf7zsDPxpHwdjve77n28CHziDqB6ORHw2jyBsEve8CQ9QIET8KvLAFRmhkFAR+fxwNvg8MvHEwDkdBFPajFhhgCENvNAjHYf9fkGEfbXvheBQNhi3Sj/xROA6iKBr6h7hP3WeGloD5eXolVU7NLmt28zlS8VJyqS6KAqiiIgbn8erdw9WHz6/evru9eNgZWvfIboCGQDHK0do+CxuF9Y6lDauQgPEXSK4suSok2zP61ar3WC1iqg0Hy70HKfmcqlsQZecjEmBmZsaikEmPdW15aExYEtk5pANwiHF+UYrY0qPTJS2uQe75c1rKOdtVnB2s4rTBrW2zrh0cRnBT17T/O4K9mlE7uG2nsDAUuH9VZ2tsZuqqipFkxhQT1w2deeHMuUx1IY0Ty9w9CYOT7PXruzy6HrmPv1565jr58764cS/ax5O/u+Pst9sP19HXN2nsaj/yPPeRYXVK4ef+i5TxBBLbkdw2C6RGZVuFB7puwTaFsgistdjv+F2nEOkmIfZDeZHRCfGcwUbWEGOb3Zn41D096h1Ntak4nG8I9gvLCyzwpFS84ziugbzgmA7tzkskEi5R64ZgjfpPbYXbLxWbMjHBq0BLXho43U3OpTES75zhoHjaEyuWZriB3p5oxRKTTUjQ9w40M2hU/dG+fN10pu5mNe04YUvCkrNv3AEk5lRrnFmUnN+zv2B2dD51Uf/8OZRLmuDF8xbPMqeVVcv88zeN0HGcqYvDbyNNc5b2LLcazS3d6DQJxIByzJSVYNfecZj3qhlxKYumFyuptcRkMdEKcEFKcl2Ptps41bJUMRCtYpywVNXI1bi93ZCkRTnnLHZ3J/+e4j7DS2qoO2fpid1s/BOi+tzG56xgnqNDUxWANusFuI3sh7rNi/C511r0Y53K5XOnX0sWf8HTD3uu/0DPZK7wtQsPQCLBvhsZvGSL+gTZd51pLBM4ry1M3bpPoKl0zoaw9WRr8h8

rumicuna avatar Aug 20 '21 20:08 rumicuna

Reported on the forum in https://community.cesium.com/t/how-to-project-textures-correctly/20592.

ggetz avatar Oct 10 '22 18:10 ggetz

Hi! Any progress with this issue?

ysp avatar Jul 25 '24 03:07 ysp

@ysp There hasn't been any activity on this item recently.

If you'd like to add more information about your use case, that may help us prioritize. If you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR. Thanks!

ggetz avatar Jul 25 '24 13:07 ggetz

updated sandcastle demo: https://sandcastle.cesium.com/index.html#c=tVZ7b9s2EP8qhIch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