CN115588071A - Method and device for realizing projection based on cos2d-x - Google Patents

Method and device for realizing projection based on cos2d-x Download PDF

Info

Publication number
CN115588071A
CN115588071A CN202211072843.3A CN202211072843A CN115588071A CN 115588071 A CN115588071 A CN 115588071A CN 202211072843 A CN202211072843 A CN 202211072843A CN 115588071 A CN115588071 A CN 115588071A
Authority
CN
China
Prior art keywords
projection
cos2d
sprite
rendering
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211072843.3A
Other languages
Chinese (zh)
Inventor
余志杰
杨清山
陈燕
王振华
唐光宇
闫乃永
卢学明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Baobao Bus Co ltd
Original Assignee
Baobao Bus Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Baobao Bus Co ltd filed Critical Baobao Bus Co ltd
Priority to CN202211072843.3A priority Critical patent/CN115588071A/en
Publication of CN115588071A publication Critical patent/CN115588071A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Geometry (AREA)
  • Image Generation (AREA)

Abstract

The invention provides a method and a device for realizing projection based on cos2d-x, wherein the method comprises the following steps: superposing the textures of all projection nodes and then rendering to obtain a sprite; and performing projection display according to the sprites. Compared with the prior art, each node is independently rendered firstly, and then the transparency is changed under the condition of direct superimposition, so that the superimposition problem is caused, the mode of obtaining the sprite by rendering after the textures of all projection nodes are superimposed is adopted, the consistency of the color value and the transparency is ensured, the superimposition problem is avoided, the color deepening and the reality changing are caused, the textures and the rendering of all projection nodes are obtained through RenderTexture, only the texture of the projection nodes is obtained for drawing and the projection is carried out according to the sprite, the creation and the destruction of the projection nodes are not needed, and the performance overhead is reduced.

Description

Method and device for realizing projection based on cos2d-x
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for realizing projection based on cos2 d-x.
Background
Currently, the method for projecting the shadow of the projection node is generally to directly copy a projection node to directly set the color attribute of the projection node to be black and change the transparency attribute of the projection node. When a plurality of shadows overlap, the color of the overlapping part becomes solid, the processing effect of the method is not ideal, and the performance consumption is increased due to a large number of operations of destroying and creating projection nodes in the processing process. In addition, when the projection node has a dynamic effect, the method cannot realize a simulated dynamic effect, and the projection display generally uses the ClippingNode to cut out the content outside the range, so that the effect of blurring the edge of the aperture cannot be realized.
Disclosure of Invention
Technical problem to be solved
In order to solve the above problems in the prior art, the present invention provides a method and an apparatus for implementing projection based on cos2d-x, which can avoid the problem of superposition and reduce the performance overhead.
(II) technical scheme
In order to achieve the purpose, the invention adopts a technical scheme that:
a method for realizing projection based on cos2d-x comprises the following steps:
s1, overlaying the textures of all projection nodes and then rendering to obtain a sprite;
and S2, performing projection display according to the sprites.
In order to achieve the purpose, the invention adopts another technical scheme as follows:
an apparatus for implementing projection based on cos2d-x, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:
s1, overlaying the textures of all projection nodes and then rendering to obtain a sprite;
and S2, performing projection display according to the sprites.
(III) advantageous effects
The invention has the beneficial effects that: compared with the prior art, the method has the advantages that each node is independently rendered firstly, and then the transparency is changed under the condition of direct superposition, so that the superposition problem is caused, the mode that the textures of all projection nodes are superposed and then rendered to obtain the sprite is adopted, the consistency of the color value and the transparency is ensured, so that the superposition problem is avoided, the color deepening and the reality are generated, the textures and the renderings of all projection nodes are obtained through RenderTexture, the texture drawing of the projection nodes is only obtained, the projection is carried out according to the sprite, the creation and the destruction of the projection nodes are not needed, and the performance overhead is reduced.
Drawings
FIG. 1 is a flowchart of a method for implementing projection based on cos2d-x according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an overall structure of an apparatus for implementing projection based on cos2d-x according to an embodiment of the present invention.
[ description of reference ]
1: a device for realizing projection based on cos2 d-x;
2: a memory;
3: a processor.
Detailed Description
For the purpose of better explaining the present invention and to facilitate understanding, the present invention will be described in detail by way of specific embodiments with reference to the accompanying drawings.
Example one
Referring to fig. 1, a method for implementing projection based on cos2d-x includes the steps of:
s0, creating a render texture, and screening out all projection nodes with the positions within the display range.
S1, overlaying the textures of all projection nodes and then rendering to obtain a sprite;
in this embodiment, step S1 specifically includes:
and superposing the textures of all the projection nodes through RenderTexture, and then uniformly rendering to obtain the sprites containing shape, color and outline information.
And S2, performing projection display according to the sprites.
In this embodiment, step S2 specifically includes:
and performing edge smooth transition through a shader according to the sprites, and performing projection display.
In this embodiment, the performing of the edge smooth transition through the loader according to the sprite specifically includes:
calculating the distance between a central point and a pixel point by using a shader coordinate according to the sprite;
and calculating a transparency value through a smooth step function according to the distance, so that pixels in a preset range have a transparency transition region.
Specifically, the shader is used for changing the attribute of the render texture, simulating the shadow effect, and enabling pixels in a preset range to have a transparency transition area, so that the edge blurring effect of the aperture is achieved.
In this embodiment, the method further comprises the steps of:
a scheduler is created for updating the rendering, updating the texture in the RenderTexture every interval time.
Specifically, a simulation animation is realized by updating the texture in the RenderTexture with the scheduler interval time.
Example two
The embodiment further illustrates how the above method for implementing projection based on cos2d-x is implemented in combination with a specific application scenario:
1. rendering process
1.1 creating RenderTexture for rendering shading;
1.2 creating a scheduler for updating the rendering, updating the texture in the RenderTexture every interval;
1.3, screening out all projection nodes with the positions in the display range in front of the light source by judging whether the nodes are in front of the light source or not in the rendering process;
1.4, overlaying the textures of all projection nodes through RenderTexture, then uniformly rendering to obtain a Sprite (Sprite) containing shape, color and outline information, and finishing the rendering process;
1.5 waiting for the next rendering process, and repeating the steps 1.3 and 1.4.
2. shader processing flow
2.1 transmitting the Sprite (Sprite) containing the shape, color and outline information obtained in the RenderTexture to the shader processing;
2.2 calculating the distance between the central point and the pixel point by using the shader coordinate according to the Sprite (Sprite);
and 2.3, calculating to obtain a transparency value through a smooth step function according to the distance, so that a transition region with the transparency of 1- >0 exists in the pixels in the range from the radius lightRadius to the radius +0.05, and the shader processing is completed.
EXAMPLE III
Referring to fig. 2, an apparatus 1 for implementing projection based on cos2d-x includes a memory 2, a processor 3, and a computer program stored in the memory 2 and capable of running on the processor 3, wherein the processor 3 implements the steps of the first embodiment when executing the computer program.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for realizing projection based on cos2d-x is characterized by comprising the following steps:
s1, overlaying the textures of all projection nodes and then rendering to obtain a sprite;
and S2, performing projection display according to the sprites.
2. The method for realizing projection based on cos2d-x as claimed in claim 1, wherein step S1 specifically comprises:
and superposing the textures of all the projection nodes through RenderTexture, and uniformly rendering to obtain the sprite containing shape, color and outline information.
3. The method for realizing projection based on cos2d-x as claimed in claim 1, wherein step S2 is specifically:
and performing edge smooth transition according to the sprites through the shaders, and performing projection display.
4. The method for achieving projection based on cos2d-x as claimed in claim 3, wherein the performing edge smoothing transition by a shader according to the sprite is specifically:
calculating the distance between a central point and a pixel point by using a shader coordinate according to the sprite;
and calculating a transparency value through a smooth step function according to the distance, so that pixels in a preset range have a transparency transition region.
5. The method for realizing projections based on cos2d-x as claimed in claim 2, wherein step S1 is preceded by:
s0, creating RenderTexture, and screening out all projection nodes with the positions within the display range.
6. The method for realizing projections based on cos2d-x as claimed in claim 1, further comprising the steps of:
a scheduler is created for updating the rendering, updating the texture in the RenderTexture every interval time.
7. An apparatus for implementing projection based on cos2d-x, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the steps of:
s1, overlaying the textures of all projection nodes and then rendering to obtain a sprite;
and S2, performing projection display according to the sprites.
8. The apparatus for realizing projection based on cos2d-x as claimed in claim 7, wherein step S1 is specifically:
and superposing the textures of all the projection nodes through RenderTexture, and then uniformly rendering to obtain the sprites containing shape, color and outline information.
9. The apparatus for realizing projection based on cos2d-x as claimed in claim 7, wherein the step S2 is specifically:
and performing edge smooth transition through a shader according to the sprites, and performing projection display.
10. The apparatus for implementing projection based on cos2d-x as claimed in claim 9, wherein said performing edge smoothing transition by a shader according to said sprite is specifically:
calculating the distance between a central point and a pixel point by using a shader coordinate according to the sprite;
and calculating a transparency value through a smooth step function according to the distance, so that pixels in a preset range have a transparency transition region.
CN202211072843.3A 2022-09-02 2022-09-02 Method and device for realizing projection based on cos2d-x Pending CN115588071A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211072843.3A CN115588071A (en) 2022-09-02 2022-09-02 Method and device for realizing projection based on cos2d-x

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211072843.3A CN115588071A (en) 2022-09-02 2022-09-02 Method and device for realizing projection based on cos2d-x

Publications (1)

Publication Number Publication Date
CN115588071A true CN115588071A (en) 2023-01-10

Family

ID=84772121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211072843.3A Pending CN115588071A (en) 2022-09-02 2022-09-02 Method and device for realizing projection based on cos2d-x

Country Status (1)

Country Link
CN (1) CN115588071A (en)

Similar Documents

Publication Publication Date Title
CN111145326B (en) Processing method of three-dimensional virtual cloud model, storage medium, processor and electronic device
TWI618030B (en) Method and system of graphics processing enhancement by tracking object and/or primitive identifiers, graphics processing unit and non-transitory computer readable medium
US8345059B2 (en) Methods, systems, and data structures for generating a rasterizer
CN111400024B (en) Resource calling method and device in rendering process and rendering engine
JPH08512156A (en) Graphic edge system
CN103810742A (en) Image rendering method and system
JP2009516250A (en) Antialiasing vector graphic image
CN108399646B (en) Image rendering method and device
RU2422902C2 (en) Two-dimensional/three-dimensional combined display
WO2023197762A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
US20230125255A1 (en) Image-based lighting effect processing method and apparatus, and device, and storage medium
CN112037117A (en) Method, apparatus and computer storage medium for running high performance GPU applications
CN114742931A (en) Method and device for rendering image, electronic equipment and storage medium
CN114527980A (en) Display rendering method and device, electronic equipment and readable storage medium
CN111091620A (en) Map dynamic road network processing method and system based on graphics and computer equipment
CN117611703A (en) Barrage character rendering method, barrage character rendering device, barrage character rendering equipment, storage medium and program product
CN116797701A (en) Diffusion effect rendering method and device, storage medium and electronic equipment
CN115588071A (en) Method and device for realizing projection based on cos2d-x
WO2023173728A1 (en) Graphic rendering method and apparatus, and storage medium
CN103543974A (en) Method and system for improving font clarity
CN110874856A (en) Optimization method for real-time rendering of GUI (graphical user interface) based on GPU (graphics processing Unit) characteristics
CN113192173B (en) Image processing method and device of three-dimensional scene and electronic equipment
EP4231243A1 (en) Data storage management method, object rendering method, and device
JP7352032B2 (en) Video generation method, apparatus, electronic device and computer readable storage medium
CN112257134B (en) Model management method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination