Traditional Culture Encyclopedia - Photography and portraiture - Simple arrangement of polygon clipping in cesium three-dimensional tile model

Simple arrangement of polygon clipping in cesium three-dimensional tile model

Almost three years, I wrote four articles. Basically, I don't want to write cesium. First of all, I have no time. Secondly, I am really lazy. I haven't seen cesium for over a year. At most, I just pay attention to official website's updates. I really didn't try to know more about cesium.

Recently, the company's business has been adjusted, and all the business at hand has stopped, only maintenance is left, and it is meaningless to keep it. While changing jobs, I sorted out some things I had copied, consulted and written before. If you are not sure how much you can write, just make a brief record.

Ceisum itself has a clipping plane, but it doesn't support polygon clipping. It takes a lot of effort to support polygon clipping.

The main principle of polygon clipping:

1, build a clipping polygon;

2. Normalize the fixed point of the constructed polygon into the local coordinate system of the model, obtain the model rectangle, record it and transmit it to the chip shader;

3. Render the polygon onto the constructed texture, endow the polygon with the drawn color, and endow the texture to the patch shader;

Fourthly, the fixed point obtained from the attribute is passed to the chip shader in the vertex shader, for example

GL _ Position = czm _ projection * u _ modelViewMatrix * view pos; //Projection matrix * Model view matrix * Vertex coordinates

ViewPos.xyz in

5. In the patch shader, judge whether the vertex is in the rectangle in (2) according to the vertex passed in (4). If so, calculate the uv coordinates of the texture of the vertex in (3), and use texture2D(texture, uv) to obtain the color value of the current vertex. If it is not empty, continue; If it is empty, it is discarded and returned.

Through the above steps, the model clipping with polygon as the boundary can be realized.