A method for simulating the disappearance of the horizon by bending a 2D map
Patent Information
- Application Number
- CN202010621243.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-01
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-07-01
AI Technical Summary
When the prior art realizes the bending effect of 2D maps, transparency cannot be accurately set, resulting in image distortion, and the vertex position transformation method requires a lot of editing work and cannot transform each pixel.
By creating two textures of the same size, adding pending map data to one of the textures, and transforming the other texture with shaders, including projecting to virtual spheres and orthogonal projections, replacing pixel values pixel by pixel for smooth bending .
It realizes the replacement of each pixel point, prevents distortion of the bending effect, simplifies operation, and is suitable for large-scale promotion.
Smart Images

Figure CN111754606B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a method for simulating the disappearance of a horizon by bending a 2D map. Background Art
[0002] Under the current image technology, 2D maps are bent inward (hereinafter referred to as bending) to simulate the visual effect of the disappearance of the horizon. There are two mainstream methods. The first is to "squeeze" the image to process pixels, and the second is to process the mesh by transforming the vertex position.
[0003] The "extrusion" method is often used in image editing software (such as PhotoShop). This method is not real bending, but is achieved through local deformation. It is also impossible to set the transparency accurately. It is impossible to achieve the bending effect in real-time rendering, but the image will be distorted (the image does not achieve the characteristic of bending visually). The vertex position transformation method is to preset a large number of grid slices for the image texture (Texture), and achieve the bending effect by changing the vertices. Although this technology can prevent distortion, it requires a lot of work in editing vertices, and it is impossible to transform every pixel. Summary of the invention
[0004] The invention provides a method for simulating the disappearance of the horizon by bending a 2D map.
[0005] The present invention provides the following scheme:
[0006] A method for simulating the disappearance of the horizon by bending a 2D map, comprising:
[0007] Creating a first texture and a second texture, wherein the first texture and the second texture have the same size;
[0008] Adding the map image data to be processed into the second texture;
[0009] In the process of using a shader to color the first texture, the second texture to which the map image data to be processed is added is passed in as a parameter, and the first texture is transformed to complete the smooth bending of the map image to be processed.
[0010] Preferably: transforming the first texture includes projecting the second texture with the map image data to be processed added to a virtual sphere, and orthogonally projecting the virtual sphere to the first texture; and performing a reverse orthogonal projection process to replace the pixel values of the pixel points on the first texture.
[0011] Preferably: the replacement process includes obtaining the first pixel point to be rendered in the first texture through a shader; transforming the first pixel point to obtain a second pixel point; finding the pixel value of the second pixel point from the second texture, and using the pixel value of the second pixel point to replace the pixel value of the first pixel point; traversing all pixels in the first texture and replacing the pixel values of all pixels to complete the smooth bending of the map image to be processed.
[0012] Preferably: the first pixel point is transformed by formula 1 to obtain a second pixel point;
[0013] Formula 1:
[0014] a=asin((ty-by) / r)
[0015] z=(r-cos(a)*r)
[0016] sy=a*r+by
[0017] Where: r is the radius of the virtual circle, by is the Y-axis coordinate of the starting point of bending, a is the arc from the virtual point to the center of the circle, and z is the inward degree value.
[0018] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0019] Through the present invention, a method for simulating the disappearance of the horizon by bending a 2D map can be realized. In one implementation, the method can include creating a first texture and a second texture, wherein the first texture and the second texture have the same size; adding the map image data to be processed to the second texture; using a shader to color the first texture, passing the second texture with the map image data to be processed as a parameter, and transforming the first texture to complete the smooth bending of the map image to be processed. The method provided by the present application is simple and easy to implement, and can ensure that each pixel is replaced, effectively preventing the distortion of the bending effect. It is worthy of widespread promotion and use.
[0020] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1is a schematic diagram of a transformation process provided by an embodiment of the present invention;
[0023] Figure 2 It is a diagram of actual bending effect provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention.
[0025] Example
[0026] See also Figure 1 , a method for simulating the disappearance of the horizon by bending a 2D map provided by an embodiment of the present invention, such as Figure 1 As shown, the method includes creating a first texture and a second texture, wherein the first texture and the second texture have the same size;
[0027] Adding the map image data to be processed into the second texture;
[0028] In the process of using a shader to color the first texture, the second texture to which the map image data to be processed is added is passed in as a parameter, and the first texture is transformed to complete the smooth bending of the map image to be processed.
[0029] Furthermore, transforming the first texture includes projecting the second texture with the map image data to be processed added to a virtual sphere, orthogonally projecting the virtual sphere to the first texture; and performing a reverse orthogonal projection process to replace the pixel values of the pixels on the first texture. The replacement process includes taking the first pixel to be rendered in the first texture through a shader; transforming the first pixel to obtain a second pixel; finding the pixel value of the second pixel from the second texture, and replacing the pixel value of the first pixel with the pixel value of the second pixel; traversing all pixels in the first texture and replacing the pixel values of all pixels to complete the smooth bending of the map image to be processed.
[0030] The first pixel point is transformed by formula 1 to obtain a second pixel point;
[0031] Formula 1:
[0032] a=asin((ty-by) / r)
[0033] z=(r-cos(a)*r)
[0034] sy=a*r+by
[0035] Where: r is the radius of the virtual circle, by is the Y-axis coordinate of the starting point of bending, a is the arc from the virtual point to the center of the circle, and z is the inward degree value.
[0036] The solution provided in this application is described in detail below through a specific implementation process.
[0037] This method includes the following four steps:
[0038] Step 1: Create two textures Tex1 and Tex2 of the same size.
[0039] Step 2: Add the map image data to Tex2.
[0040] Step 3: Tex2 is passed into the Tex1 shader as a parameter to transform the Tex1 pixels.
[0041] Step 4: Render Tex1.
[0042] The transformation process is as follows Figure 1 As shown, Tex2 is projected onto a virtual sphere (dashed line part), and then the sphere is orthogonally projected onto Tex1.
[0043] The implementation process is to reverse the projection process. First, the pixel point P1 (x, ty) that Tex1 needs to render is obtained through the shader. Because it is an orthogonal projection of the virtual sphere, the point value of the virtual sphere corresponding to the point P1 is the same as (x, ty). After transformation through formula 1, point P2 (x, sy) is obtained. Formula 1:
[0044] a=asin((ty-by) / r)
[0045] z=(r-cos(a)*r)
[0046] sy=a*r+by
[0047] Where r is the radius of the virtual circle, by is the Y-axis coordinate of the starting point of the bend, a is the arc from the virtual point to the center of the circle, and z is the inward value. Find the pixel value V2 of point P2 on texture Tex2. If it exists, replace the pixel value of position P1(x,ty) on Tex1 with the value of V2.
[0048] After traversing all the pixels of Tex1, the image can be smoothly curved. Figure 2 As shown, the left side of the figure is the original image, and the right side is the bent image.
[0049] In short, the method provided by the present application is simple and easy to implement, and can ensure that each pixel is replaced, effectively preventing the distortion of the bending effect. It is worthy of being widely promoted and used.
[0050] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0051] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for simulating the disappearance of the horizon by bending a 2D map, characterized in that: The method comprises: Creating a first texture and a second texture, wherein the first texture and the second texture have the same size; Adding the map image data to be processed into the second texture; In the process of using a shader to color the first texture, the second texture to which the map image data to be processed is added is passed as a parameter, and the first texture is transformed to complete smooth bending of the map image to be processed; Transforming the first texture includes projecting the second texture with the map image data to be processed added to a virtual sphere, and orthogonally projecting the virtual sphere to the first texture; performing a reverse orthogonal projection process to replace the pixel values of the pixels on the first texture; the replacement process includes obtaining the first pixel to be rendered in the first texture through a shader; transforming the first pixel to obtain a second pixel; finding the pixel value of the second pixel from the second texture, and replacing the pixel value of the first pixel with the pixel value of the second pixel; traversing all the pixels in the first texture and replacing the pixel values of all the pixels to complete the smooth bending of the map image to be processed; The first pixel point is transformed by formula 1 to obtain a second pixel point; Formula 1: a=asin((ty-by) / r) z=(r-cos(a)*r) sy=a*r+by Where r is the radius of the virtual circle, by is the Y-axis coordinate of the starting point of bending, a is the arc from the virtual point to the center of the circle, z is the inward value, ty is the Y-axis coordinate of the first pixel, and sy is the Y-axis coordinate of the second pixel.
Citation Information
Patent Citations
Overlaying two-dimensional map data on a three-dimensional scene
CN105247575A
Virtual reality-based panoramic video interaction method
CN106527857A
Image display area shape setting method and device
CN107154063A
Equidistant cylindrical projection panoramic video pixel redistribution method and system
CN111091491A
Multichannel LED dome screen geometric correction method
CN111192552A
