Rendering method and system for locally selecting UI chartlet and triggering corresponding event
By drawing and sampling color block maps, the efficiency problem of local selection of UI maps and event triggering in game UI development is solved, a simplified cutting and alignment process is achieved, and development efficiency and scalability are improved.
Patent Information
- Application Number
- CN202310176744.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2024-08-30
AI Technical Summary
In game UI development, it is difficult to efficiently partially select UI textures and trigger different events with existing technology. When the UI textures need to be modified, the process of cutting and aligning small textures is cumbersome, which reduces development efficiency and scalability.
By drawing color block maps of the same size, recording the trigger events corresponding to color blocks of different colors, sampling the color block map in the shader of the UI map, and triggering corresponding events based on the click position, realizing local selection rendering of the UI map.
It simplifies the cutting and alignment process of UI maps, improves development efficiency and scalability, and makes it more convenient for artists to create color block maps. There is no need to modify the color block map when the regional content changes, which improves the convenience of dynamic expansion.
Smart Images

Figure CN118570355A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of game UI textures, and in particular to a rendering method and system for partially selecting a UI texture and triggering a corresponding event. Background Art
[0002] In game UI development, it is necessary to partially select a UI map and when the UI map is partially selected, the selected area needs to have different renderings, and different events are triggered when different positions of the UI map are selected; for example, a world map is a UI map, and the world map is divided into various parts of the area map, and the shapes of each area are irregular. Clicking different area blocks requires different rendering effects for the blocks, and triggering different events (for example, jumping to different area map scenes). For UI maps that need to be partially rendered, small maps of all blocks of the UI map are often used, and then the positions of the blocks corresponding to the UI maps that need to be partially rendered are aligned with UI controls. When a certain block is selected, the small map UI controls of the corresponding blocks are displayed, and all small maps are hidden by default; this method requires a lot of man-hours to cut small maps and align small maps as UI controls to the positions of UI maps that need to be partially rendered, and if the overall UI map needs to be modified, the small maps need to be re-cut and aligned, which is not conducive to dynamic expansion and modification, and is time-consuming and labor-intensive, reducing efficiency. Summary of the invention
[0003] The object of the present invention is to provide a rendering method for partially selecting a UI map and triggering a corresponding event, which can render a local partition of a selected UI map and trigger a corresponding event.
[0004] To achieve the above object, the present invention provides the following technical solution: a method for rendering a UI map partially selected and triggering a corresponding event, characterized in that the method comprises the following steps:
[0005] Step S1, draw a color block map of the same size as the corresponding UI map;
[0006] Step S2, recording corresponding trigger events for different color blocks on the color block map;
[0007] Step S3, the entire area of the UI map is rendered by default;
[0008] Step S4, sampling the color block map in rendering of the UI map;
[0009] Step S5: According to the clicked position on the UI map, the color block at the corresponding position of the color block map triggers a corresponding event, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
[0010] Furthermore, the UI map in step S1 is a whole map that needs to be partitioned.
[0011] Furthermore, the step S2 is further specifically to record in advance different events corresponding to different colors of different color blocks on the color block map, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
[0012] Furthermore, the initial rendering effect in step S3 is the original effect of the UI map produced by the artist, and grayscale processing is performed in the pixel shader of the shader.
[0013] Furthermore, the sampling of the color block map in step S4 is specifically to expose a map parameter in the shader of the UI map, and drag the color block map into the map parameter of the shader.
[0014] Furthermore, the color block at the corresponding position of the color block map in step S5 triggers a corresponding event specifically according to the local coordinates of the clicked UI map, the x-axis value of the local coordinates divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinates divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained according to the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
[0015] The present invention also provides a rendering system for partial selection of a UI map and triggering corresponding events, the system comprising a color block map drawing module, an event recording module, an initial rendering module, a color block sampling module, and a click processing module; the color block map drawing module is responsible for drawing a color block map of the same size as the corresponding UI map; the event recording module is responsible for recording corresponding triggering events for color blocks of different colors on the color block map; the initial rendering module is responsible for the default initial rendering effect of the entire area of the UI map; the sampling color block module is responsible for sampling the color block map in the rendering of the UI map; the click processing module is responsible for triggering a corresponding event based on the color block at the corresponding position of the color block map according to the position on the click of the UI map, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
[0016] Furthermore, the UI map in the color block map drawing module is a whole map that needs to be partitioned.
[0017] Furthermore, the event recording module is further specifically configured to record different events corresponding to different colors of different color blocks on the color block map in advance, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
[0018] Furthermore, the initial rendering effect in the initial rendering module is the original effect of the UI map produced by the artist, and grayscale processing is performed in the pixel shader of the shader.
[0019] Furthermore, the sampling color block map in the sampling color block module specifically discloses a map parameter in the shader of the UI map, and drags the color block map into the map parameter of the shader.
[0020] Furthermore, the color block at the corresponding position of the color block map in the click processing module triggers a corresponding event specifically based on the local coordinates of the clicked UI map, the x-axis value of the local coordinate divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinate divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained based on the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
[0021] The beneficial effects of the present invention are as follows: the color block map used in the present invention is a whole map of the same size as the UI map that needs to be rendered in different areas, and does not need to be cut, and the alignment method is relatively simple; for example, if a color block map is to be made for a world map in a game, an empty map of the same size as the world map is created, and the world map and the color block map can be placed in the same position in PS, and then the transparency of the world map is lowered, and color blocks can be drawn on the empty color block map, and color blocks of different colors can be drawn on different areas of the world map, and it is more convenient for artists to make color block maps. If the area does not change and only the content in the area is changed, there is no need to modify the color block map separately, thereby improving development efficiency and facilitating expansion. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the method of the present invention;
[0023] Figure 2 It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described below in conjunction with the accompanying drawings.
[0025] See also Figure 1 As shown, the present invention provides an embodiment: a method for rendering a UI map partially selected and triggering a corresponding event, characterized in that the method comprises the following steps:
[0026] Step S1, draw a color block map of the same size as the corresponding UI map;
[0027] Draw a color block map of the same size according to the area where the UI texture is to be rendered in blocks. There are multiple color blocks in the color block map. The color blocks correspond to the areas where the UI texture is to be rendered in blocks. Each color block corresponds to each independent rendering area of the UI texture.
[0028] Step S2, recording corresponding trigger events for different color blocks on the color block map;
[0029] Record the colors of different color blocks to trigger different events, and use the event system to mount the corresponding logic for events of different colors. The event system specifically partitions the local coordinates of the rendered texture according to the needs of the click. Because the size of the color block texture is the same as the size of the partitioned rendering texture, the x-axis and y-axis values of the local coordinates can be used to call the engine's built-in assembly to obtain the pixel of the point at the corresponding position of the color block texture, and use the pixel to obtain the event corresponding to the cache dictionary.
[0030] Step S3, the entire area of the UI map is rendered by default;
[0031] The UI map that needs partial rendering initializes the default rendering effect of all blocks. In the pixel shader in the UI map of the UI, the default effect calculation is performed on all pixels of the UI map by default, such as a gray rendering effect, or any desired effect.
[0032] Step S4, sampling the color block map in rendering of the UI map;
[0033] Sample the block map in the shader of the UI map that needs local rendering, define a block map parameter for the shader of the map that needs partitioning and drag the block map into the block map parameter of the shader, and call the existing sampling function of the shader in the vertex shader of the shader. The sampling function of the shader is built into the engine. Texture sampling is to obtain the color of the corresponding position of the map through UV (texture coordinates).
[0034] Step S5: According to the clicked position on the UI map, the color block at the corresponding position of the color block map triggers a corresponding event, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
[0035] When you click on a UI map that needs to be partially rendered, the pixel at the corresponding position of the corresponding color block map is obtained according to the position of the clicked UI map, and the corresponding event is triggered according to the obtained pixel color. The triggering method is to define a dictionary and initialize the dictionary in advance. The key of the dictionary corresponds to the color, and the value is the specific triggered event. The clicked color is obtained and the value event is executed; according to the color of the color block selected by clicking, in the pixel shader stage of the shader of the UI map that needs to be partially rendered, if the color of the sampled color block map is the same as the color selected by clicking, the desired rendering effect operation is performed. The clicked color obtains the color corresponding to the color block map of the same size according to the position ratio of the map that needs to be partitioned, and the color of the color block map at the clicked position is passed to the map shader that needs to be partitioned. When the shader renders the map that needs to be partitioned, how to render each pixel is distinguished according to the color of the pixel at the same position of the sampled block map. When the color of the pixel point of the map that needs to be partitioned is the clicked color on the block map, different processing is performed. Because the color block map and the map that needs to be partitioned are the same size, when rendering the map that needs to be partitioned, the color of the pixel in the color block map corresponding to each pixel is judged for differentiated rendering. If the color in the corresponding color block map is the clicked color, it is rendered according to the original effect of the art drawing, such as removing the grayscale effect, and displaying the original effect of the selected block. If the color in the corresponding color block map is not the clicked color, grayscale processing is performed, that is, the pixel color is multiplied by a grayscale value.
[0036] The UI map in step S1 is a whole map that needs to be partitioned.
[0037] The step S2 is further specifically to record in advance different events corresponding to different colors of different color blocks on the color block map, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
[0038] The initial rendering effect in step S3 is the original effect of the UI map produced by the artist, which is gray-scaled in the pixel shader of the shader.
[0039] The sampling color block map in step S4 specifically discloses a map parameter in the shader of the UI map, and drags the color block map into the map parameter of the shader.
[0040] The color block at the corresponding position of the color block map in step S5 triggers a corresponding event specifically by clicking on the local coordinates of the UI map, the x-axis value of the local coordinate divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinate divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained according to the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
[0041] See also Figure 2 As shown, the present invention also provides a rendering system for partial selection of a UI map and triggering corresponding events, the system includes a color block map drawing module, an event recording module, an initial rendering module, a color block sampling module, and a click processing module; the color block map drawing module is responsible for drawing a color block map of the same size as the corresponding UI map; the event recording module is responsible for recording corresponding triggering events for color blocks of different colors on the color block map; the initial rendering module is responsible for the default initial rendering effect of the entire area of the UI map; the sampling color block module is responsible for sampling the color block map in the rendering of the UI map; the click processing module is responsible for triggering a corresponding event based on the color block at the corresponding position of the color block map according to the position on the click of the UI map, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
[0042] The UI map in the color block map drawing module is a whole map that needs to be partitioned.
[0043] The event recording module is further specifically configured to record in advance different events corresponding to different colors of different color blocks on the color block map, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
[0044] The initial rendering effect in the initial rendering module is the original effect of the UI map produced by the artist, and grayscale processing is performed in the pixel shader of the shader.
[0045] The sampling color block map in the sampling color block module specifically discloses a map parameter in the shader of the UI map, and drags the color block map into the map parameter of the shader.
[0046] The color block at the corresponding position of the color block map in the click processing module triggers a corresponding event specifically according to the local coordinates of the clicked UI map, the x-axis value of the local coordinate divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinate divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained according to the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
[0047] In summary, the present invention uses the division of color block map areas and pairs them with UI maps, making it easier for artists to create color block maps without using the cumbersome common methods used in the background technology. Furthermore, if the area remains unchanged and only the content inside the area is changed, there is no need to modify the color block map separately, thereby improving development efficiency and facilitating expansion.
[0048] The above description is only a preferred embodiment of the present invention and should not be construed as limiting the present application. All equivalent changes and modifications made within the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A rendering method for partially selecting a UI texture and triggering a corresponding event. It is characterized in that The method comprises the following steps: Step S1, draw a color block map of the same size as the corresponding UI map; Step S2, recording corresponding trigger events for different color blocks on the color block map; Step S3, the entire area of the UI map is rendered by default; Step S4, sampling the color block map in rendering of the UI map; Step S5: According to the clicked position on the UI map, the color block at the corresponding position of the color block map triggers a corresponding event, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
2. A method for rendering a UI map by partially selecting and triggering a corresponding event according to claim 1, Features: The UI map in step S1 is a whole map that needs to be partitioned.
3. A method for rendering a UI map partially selected and triggering a corresponding event according to claim 1, Features: The step S2 is further specifically to record in advance different events corresponding to different colors of different color blocks on the color block map, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
4. A method for rendering a UI map by partially selecting and triggering a corresponding event according to claim 1, Features: The initial rendering effect in step S3 is the original effect of the UI map produced by the artist, which is gray-scaled in the pixel shader of the shader.
5. A method for rendering a UI map partially selected and triggering a corresponding event according to claim 1, Features: The sampling color block map in step S4 specifically discloses a map parameter in the shader of the UI map, and drags the color block map into the map parameter of the shader.
6. A method for rendering a UI map partially selected and triggering a corresponding event according to claim 1, Features: The color block at the corresponding position of the color block map in step S5 triggers a corresponding event specifically by clicking on the local coordinates of the UI map, the x-axis value of the local coordinate divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinate divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained according to the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
7. A rendering system for partial selection of UI textures and triggering corresponding events, Features: The system includes a color block map drawing module, an event recording module, an initial rendering module, a color block sampling module, and a click processing module; the color block map drawing module is responsible for drawing a color block map of the same size as the corresponding UI map; the event recording module is responsible for recording corresponding trigger events for color blocks of different colors on the color block map; the initial rendering module is responsible for the default initial rendering effect of the entire area of the UI map; the sampling color block module is responsible for sampling the color block map in the rendering of the UI map; the click processing module is responsible for triggering a corresponding event based on the position of the click on the UI map, and the color of the clicked color block corresponds to the same color area of the sampled color block map to select and render the UI map.
8. A rendering system for partially selecting a UI map and triggering a corresponding event according to claim 7, Features: The UI map in the color block map drawing module is a whole map that needs to be partitioned.
9. A rendering system for partially selecting a UI map and triggering a corresponding event according to claim 7, Features: The event recording module is further specifically configured to record different events corresponding to different colors of different color blocks on the color block map in advance, store them in a dictionary, and click on a color to correspond to a corresponding specific event.
10. A rendering system for partially selecting a UI map and triggering a corresponding event according to claim 7, Features: The initial rendering effect in the initial rendering module is the original effect of the UI map produced by the artist, and grayscale processing is performed in the pixel shader of the shader.
11. A rendering system for partially selecting a UI map and triggering a corresponding event according to claim 7, Features: The sampling color block map in the sampling color block module specifically discloses a map parameter in the shader of the UI map, and drags the color block map into the map parameter of the shader.
12. A rendering system for partially selecting a UI map and triggering a corresponding event according to claim 7, Features: The color block at the corresponding position of the color block map in the click processing module triggers a corresponding event specifically according to the local coordinates of the clicked UI map, the x-axis value of the local coordinate divided by the width of the UI map is the horizontal proportional position of the click; the y-axis value of the local coordinate divided by the height of the UI map is the vertical proportional position of the click; the pixel at the proportional position of the color block map of the same size is obtained according to the horizontal proportional position and the vertical proportional position, and the color of the pixel triggers the corresponding event.
