Game light object rendering method and device
By obtaining and adjusting the vertex map of the lens flare model in the game, combining the scene depth map and light source direction, the problems of low rendering efficiency and poor accuracy in the existing technology are solved, and more efficient halo rendering and more realistic light source effect.
Patent Information
- Application Number
- CN202311394532.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-25
- Publication Date
- 2025-01-10
AI Technical Summary
The rendering efficiency and accuracy of existing game light objects is low, especially when the lens flare appears, rendering and ray detection after full screen consume a lot of system resources, resulting in a decrease in the accuracy of scene display.
By obtaining the lens flare model film carried by the game camera, sampling the scene depth map according to the direction of the light source. If the pixel value is less than the threshold, adjust the vertex map and render it, generate the linkage direction to bind the lens flare model film and the camera, and detect the movement of the light source. Update the vertex map, adjust the halo brightness using vector point multiplication for occlusion and rendering.
It reduces the system calculation consumption of occlusion judgment, improves the realistic display of halos, and improves the rendering efficiency and accuracy of game light objects.
Smart Images

Figure CN119295641A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game development technology, and in particular to a rendering method and device for a game light object. Background Art
[0002] In game scene development, when the game camera is facing the light source, a lens flare effect will be generated, that is, the lens flare in the game scene, and the lens flare will disappear when the light source is blocked or backlit.
[0003] At present, the existing lens flare is realized by Unreal Engine through full-screen post-rendering processing or blueprints hung on the light source. However, the computing performance consumption of all pixels in the full screen during full-screen post-processing rendering is large, and the ray detection method used by the blueprint method to determine whether the light source is blocked consumes a lot of system resources, reducing the scene display accuracy of game development. Therefore, a rendering method for game light objects is urgently needed to solve the above problems. Summary of the invention
[0004] In view of this, the present invention provides a method and device for rendering a game light object, the main purpose of which is to solve the problem of low efficiency and poor accuracy in the existing rendering of game light objects.
[0005] According to one aspect of the present invention, a method for rendering a game light object is provided, comprising:
[0006] Obtaining a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene;
[0007] Sampling a scene depth map of the game scene according to the direction of the light source;
[0008] Under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold, the vertex map of the lens flare model piece is occluded and adjusted, and the adjusted lens flare model piece is rendered.
[0009] Furthermore, before obtaining the lens flare model sheet of at least one game light object carried by the game camera, the method further includes:
[0010] Generate at least one lens flare model piece of the game light object based on the spatial illumination direction of the game camera, wherein the spatial illumination direction is determined based on the planar light source direction of the game camera and the world light source direction;
[0011] Converting the spatial illumination direction corresponding to the lens flare model piece into a world space direction, and binding the lens flare model to the game camera according to the world space direction;
[0012] After configuration and binding, the lens flare model piece and the game camera are in a linkage direction.
[0013] Furthermore, the configuration binding of the lens flare model piece and the game camera in a linkage direction includes:
[0014] Convert the world space positions of the game light object and the game camera into the game screen space to obtain the screen position of the game light object in the game screen space;
[0015] The direction between the world space direction and the screen position is configured as the linkage direction between the lens flare model piece and the game camera.
[0016] Furthermore, the method further comprises:
[0017] Under the condition that the movement of the game light object is detected, the vertex map is driven to move in association with the linkage direction of the game camera through the connected virtual spring; or,
[0018] Under the condition that the movement of the game light object is detected, the relative position of the linkage direction of the game camera is calculated, and the vertex map is driven to move in association based on the relative position.
[0019] Further, the occlusion adjustment of the vertex map of the lens flare model piece includes:
[0020] Determine the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction;
[0021] The halo brightness of the game light object is determined based on the difference between the vector dot product value and the brightness threshold, and the vertex map is adjusted based on the halo brightness.
[0022] Furthermore, before performing occlusion adjustment on the vertex map of the lens flare model piece, the method further includes:
[0023] Acquire a plurality of adjacent scene depth maps corresponding to the sampled scene depth map, and determine an average pixel value of the adjacent scene depth maps;
[0024] Under the condition that the average pixel value is less than a preset pixel threshold, it is determined that the game light object is occluded, so as to perform the step of occlusion adjustment on the vertex map of the lens flare model piece.
[0025] Furthermore, the method further comprises:
[0026] Under the condition that the pixel value of the sampled scene depth map is greater than or equal to a preset pixel threshold, the lens flare model piece is rendered.
[0027] Furthermore, rendering the adjusted lens flare model piece includes:
[0028] Under the condition that the vector dot product value between the plane light source direction of the game camera and the spatial illumination direction is positive, the vertex map of the lens flare model piece is configured as a transparent material, and the lens flare model piece is rendered; or,
[0029] Under the condition that the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction is positive, rendering of the lens flare model piece is disabled.
[0030] According to another aspect of the present invention, a rendering device for a game light object is provided, comprising:
[0031] An acquisition module, used to acquire a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene;
[0032] A sampling module, used for sampling the scene depth map of the game scene according to the direction of the light source;
[0033] A rendering module is used to perform occlusion adjustment on the vertex map of the lens flare model piece and render the adjusted lens flare model piece under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold.
[0034] Furthermore, the device also includes:
[0035] A generation module, configured to generate at least one lens flare model piece of the game light object based on a spatial illumination direction of the game camera, wherein the spatial illumination direction is determined based on a planar light source direction of the game camera and a world light source direction;
[0036] A conversion module, used for converting the spatial illumination direction corresponding to the lens flare model piece into a world space direction, and binding the lens flare model with the game camera according to the world space direction;
[0037] A configuration module is used to configure the bound lens flare model piece and the game camera to be in a linkage direction.
[0038] Furthermore, the configuration module is specifically used to convert the world space position of the game light object and the game camera into the game screen space to obtain the screen position of the game light object in the game screen space; and configure the linkage direction of the lens flare model piece and the game camera according to the direction between the world space direction and the screen position.
[0039] Furthermore, the device also includes:
[0040] A driving module, used for driving the vertex map to move in association with the linkage direction of the game camera through a connected virtual spring when the movement of the game light object is detected; or
[0041] The calculation module is used to calculate the relative position of the linkage direction of the game camera under the condition that the movement of the game light object is detected, and drive the vertex map to move in an associated manner based on the relative position.
[0042] Furthermore, the rendering module is specifically used to determine the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction; determine the halo brightness of the game light object based on the difference between the vector dot product value and the brightness critical value, and adjust the vertex map based on the halo brightness.
[0043] Furthermore, the device also includes:
[0044] A determination module is used to obtain multiple adjacent scene depth maps corresponding to the sampled scene depth map, and determine the average pixel value of the adjacent scene depth maps; under the condition that the average pixel value is less than a preset pixel threshold, determine that the game light object is occluded, so as to perform the step of occlusion adjustment on the vertex map of the lens flare model piece.
[0045] Furthermore, the rendering module is further configured to render the lens flare model film under the condition that the pixel value of the sampled scene depth map is greater than or equal to a preset pixel threshold.
[0046] Furthermore, the rendering module is specifically used to configure the vertex map of the lens flare model piece as a transparent material and render the lens flare model piece under the condition that the dot product value of the vector between the planar light source direction of the game camera and the spatial lighting direction is positive; or, to disable the rendering of the lens flare model piece under the condition that the dot product value of the vector between the planar light source direction of the game camera and the spatial lighting direction is positive.
[0047] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the above-mentioned method for rendering a game light object.
[0048] According to another aspect of the present invention, there is provided a terminal, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0049] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the above-mentioned rendering method of the game light object.
[0050] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0051] The present invention provides a method and device for rendering a game light object. Compared with the prior art, the embodiment of the present invention obtains a lens flare model piece of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene; samples a scene depth map of the game scene according to the direction of the light source; and, under the condition that a pixel value of the sampled scene depth map is less than a preset pixel threshold, performs occlusion adjustment on a vertex map of the lens flare model piece, and renders the adjusted lens flare model piece, thereby reducing system calculation consumption for occlusion judgment, achieving the purpose of flexible and realistic display of halos, and thus improving the rendering efficiency of game light objects.
[0052] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0054] Figure 1 A flow chart of a method for rendering a game light object provided by an embodiment of the present invention is shown;
[0055] Figure 2 A schematic diagram of a spatial lighting direction provided by an embodiment of the present invention is shown;
[0056] Figure 3A schematic diagram of a game scene halo provided by an embodiment of the present invention is shown;
[0057] Figure 4 A block diagram showing a composition of a rendering device for a game light object provided by an embodiment of the present invention is shown;
[0058] Figure 5 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0059] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0060] The embodiment of the present invention provides a method for rendering a game light object, such as Figure 1 As shown, the method includes:
[0061] 101. Obtain a lens flare model piece of at least one game light object carried by a game camera.
[0062] In the embodiment of the present invention, the current execution end as the execution end of game development can be a cloud server or a terminal server, so as to develop the game scene. Among them, the game light object is the light source in the game scene, including but not limited to large luminous bodies in the virtual game scene, such as the sun, and small luminous bodies, such as lamps, fire, stars, light panels, etc., which are not specifically limited in the embodiment of the present invention. In addition, the game camera is the perspective of the game scene constructed for the game user to show the scene content. During the game development process, lens halo model pieces showing halo effects can be generated in advance for different game light objects. At this time, the lens halo model piece can be a halo map, and the halo color, halo size, and halo shape of the lens halo model piece can be configured based on the game light object, which are not specifically limited in the embodiment of the present invention.
[0063] It should be noted that, since the perspective presented to the game user in the game scene may include multiple game light objects, that is, the game camera may carry at least one game light object, and the halo effect that each game light object can display may be multiple apertures, at this time, there may be multiple lens halo model pieces, which is not specifically limited in the embodiment of the present invention.
[0064] 102. Sample a scene depth map of the game scene according to a direction of the light source.
[0065] In the embodiment of the present invention, since the light source is irradiated in a certain direction to present a halo effect, in order to reduce the processing pressure of the game engine, the current execution end samples the scene depth map of the game scene according to the direction of the light source to determine the scene depth in the game scene. Among them, the scene depth map is an image that shows different scene depths based on the color changes of the image channel in the development of the game scene. The current execution end obtains the adopted scene depth map by performing multi-channel scene depth image sampling on the UV coordinates in the game scene, and the embodiment of the present invention does not make specific limitations.
[0066] 103. Under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold, perform occlusion adjustment on the vertex map of the lens flare model piece, and render the adjusted lens flare model piece.
[0067] In an embodiment of the present invention, the current execution end compares the pixel value of the sampled scene depth map with a preset pixel threshold. At this time, the preset pixel threshold is used as a standard pixel value for determining whether there is occlusion in the scene, and can be configured according to the scene color of different game scenes, etc., and the embodiment of the present invention does not make specific limitations. If the pixel value of the scene depth map is less than the preset pixel threshold, the current execution end performs an occlusion adjustment on the vertex map of the lens flare model piece to render the lens flare model piece after the occlusion adjustment. At this time, the occlusion is the light source occlusion effect displayed by the occlusion of the game light source, that is, the occlusion adjustment of the vertex map of the lens flare model piece can be to adjust the brightness parameters and color depth of the vertex map to show the dark effect of being occluded. Among them, the specific adjustment reference value can be configured or adjusted based on the brightness intensity of the game light object in the game scene, and the embodiment of the present invention does not make specific limitations.
[0068] In another embodiment of the present invention, for further definition and explanation, before the step of obtaining a lens flare model sheet of at least one game light object carried by the game camera, the method further includes:
[0069] Generate at least one lens flare model piece of the game light object based on the spatial lighting direction of the game camera;
[0070] Converting the spatial illumination direction corresponding to the lens flare model piece into a world space direction, and binding the lens flare model to the game camera according to the world space direction;
[0071] After configuration and binding, the lens flare model piece and the game camera are in a linkage direction.
[0072] In order to achieve a realistic display effect of the halo of the game light object, the current execution end pre-binds the game camera with the lens halo model piece. Specifically, firstly, at least one lens halo model piece of the game light object is generated based on the spatial lighting direction of the camera. Among them, the spatial lighting direction is determined based on the plane light source direction of the game camera and the world light source direction. At this time, since the game light objects include but are not limited to the sun, lamps, fire and other luminous bodies in the game scene, the spatial lighting direction is the line between the plane light source direction and the world light source direction. Among them, the plane light source direction is the direction of the light source in the plane viewing angle of the game camera, and the world light source direction is the direction of the world light source in the game scene, such as Figure 2 As shown, the generated lens flare model piece is located in the spatial illumination direction. Preferably, the plane light source direction is the direction in which the plane light source at the center of the screen diverges to the surroundings. In addition, since the spatial illumination direction is the line between the plane light source direction and the world light source direction, the generated lens flare model piece can generate model pieces of different sizes according to the distance between the lines, which is not specifically limited in the embodiment of the present invention. After obtaining the lens flare model piece, the current execution end converts this spatial illumination direction into the world space direction in the game scene, thereby showing the three-dimensional effect of the halo. At this time, the illumination vector of the spatial illumination direction can be converted into the world space through the correspondence between the plane coordinate vector and the three-dimensional space coordinate vector to obtain the world space direction, that is, the illumination vector of the world space direction, which is not specifically limited in the embodiment of the present invention.
[0073] It should be noted that after converting the spatial illumination direction into the world space direction, in order to make the halo move with the lens movement, the current execution end binds the lens halo model to the game camera according to the world space direction, so that the perspective of the game camera can display the halo of the matching scene light source. Figure 3 shown.
[0074] In another embodiment of the present invention, for further definition and explanation, the step of configuring the bound lens flare model piece and the game camera to be in a linkage direction includes:
[0075] Convert the world space positions of the game light object and the game camera into the game screen space to obtain the screen position of the game light object in the game screen space;
[0076] The direction between the world space direction and the screen position is configured as the linkage direction between the lens flare model piece and the game camera.
[0077] In order to make the halo move along with the camera angle, thereby producing a realistic halo effect, the current execution end configures the lens halo model piece and the game camera in a linkage direction. Specifically, the world space position of the game light object and the game camera is first converted to the game screen space to obtain the screen position of the game light object in the game screen space. At this time, the game screen space is the screen space displayed after the game camera shoots the game scene. It is a three-dimensional space, that is, the screen space changes according to the different camera angles selected by different game users. The embodiment of the present invention does not make specific limitations. At this time, the relative position of the game light object and the game camera in the world space position can be calculated and converted to the screen space to obtain the position of the game light object distributed in the game screen space, which is the screen position. Furthermore, the direction between the world space direction and the screen position is configured as the linkage direction of the lens flare model piece and the game camera, that is, the linkage direction can be calculated by a virtual spring or relative position relationship in the game development engine, so that the direction between the world space direction and the screen position is used as the linkage direction of the lens flare model piece and the game camera, so that when the game camera moves, the lens flare model piece is driven to move according to the linkage direction, and because the linkage direction is determined based on the direction between the world space direction and the screen position, the halo effect moves with the screen viewing angle during the movement, and the embodiment of the present invention does not make specific limitations.
[0078] In another embodiment of the present invention, for further definition and description, the steps further include:
[0079] Under the condition that the movement of the game light object is detected, the vertex map is driven to move in association with the linkage direction of the game camera through the connected virtual spring; or,
[0080] Under the condition that the movement of the game light object is detected, the relative position of the linkage direction of the game camera is calculated, and the vertex map is driven to move in association based on the relative position.
[0081] In order to show a realistic halo effect, the halo changes with the movement of the viewing angle, and because the linkage direction can be calculated based on a virtual spring or a relative position relationship, in the scene where the game light object moves, the halo also moves with it. In a specific implementation scenario, when the movement of the game light object is detected, the vertex map of the lens flare model piece can be driven by the virtual spring connected in the linkage relationship on the lens flare model piece to move in association with the linkage direction of the game camera, so that the halo moves when the game camera moves. In a specific implementation scenario, when the movement of the game light object is detected, the relative position of the linkage direction of the game camera can be calculated, and based on this relative position, the vertex map of the lens flare model piece can be driven to move in association, so that the halo moves when the game camera moves.
[0082] In another embodiment of the present invention, for further definition and explanation, the step of occluding and adjusting the vertex map of the lens flare model piece includes:
[0083] Determine the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction;
[0084] The halo brightness of the game light object is determined based on the difference between the vector dot product value and the brightness threshold, and the vertex map is adjusted based on the halo brightness.
[0085] In order to achieve the lighting effect of the halo matching game scene being blocked by the scene objects, that is, when the game character moves away from the light source, the angle of view corresponding to the game camera is also away from the light source. At this time, the halo will be blocked. Therefore, when the current execution end is performing the occlusion adjustment on the vertex map of the lens halo model, specifically, first determine the vector dot product value between the plane light source of the game camera and the spatial lighting direction. Among them, since the world light source direction is constant, the spatial lighting direction is determined based on the plane light source direction of the game camera and the world light source direction, and the plane light source direction of the game camera changes with the moving angle of the game camera. Therefore, the vector dot product can be performed based on the direction vector of the plane light source and the direction vector of the spatial lighting direction to determine the direction of the game character relative to the light source during the movement of the camera. Among them, the vector dot product value is a value between 0-1. In order to achieve the realistic display effect of the halo, the vector dot product value is subtracted from the brightness critical value to determine the halo brightness of the game light object based on the difference, so as to adjust the vertex map based on the halo brightness. Among them, the brightness critical value is configured based on the lighting requirements of the game scene. In a specific implementation scenario, the vector dot product value is 0-1, and the corresponding brightness critical value corresponds to 0-1, that is, 0 means no brightness, and 1 means the brightest. After calculating the vector dot product value, the difference between 0-1 is determined, and determined as the halo brightness. The brightness of the vertex map is adjusted according to this halo brightness, so as to achieve the halo effect that the game character is brightest when facing the light source, the brightness is also the same when moving a certain angle, and it begins to gradually darken after exceeding a certain angle until the halo disappears.
[0086] In another embodiment of the present invention, for further definition and explanation, before the step of occluding and adjusting the vertex map of the lens flare model piece, the method further includes:
[0087] Acquire a plurality of adjacent scene depth maps corresponding to the sampled scene depth map, and determine an average pixel value of the adjacent scene depth maps;
[0088] Under the condition that the average pixel value is less than a preset pixel threshold, it is determined that the game light object is occluded, so as to perform the step of occlusion adjustment on the vertex map of the lens flare model piece.
[0089] Since the efficiency of game resource processing is improved by sampling the scene depth map, in order to prevent the stroboscopic phenomenon in the game scene, the current execution end can also obtain multiple adjacent scene depth maps of the sampled scene depth map when sampling the scene depth map, and calculate the average pixel value of all adjacent scene depth maps, so as to compare the average pixel value with the preset pixel threshold. If the average pixel value is less than the preset pixel threshold, it means that the light source is blocked. Therefore, the step of occlusion adjustment of the vertex map of the lens flare model piece can be performed here to hide the lens flare.
[0090] In another embodiment of the present invention, for further definition and description, the steps further include:
[0091] Under the condition that the pixel value of the sampled scene depth map is greater than or equal to a preset pixel threshold, the lens flare model piece is rendered.
[0092] In order to achieve the purpose of efficient rendering of halo and reduce system resource consumption, when the pixel value of the sampled scene depth map is greater than or equal to the preset pixel threshold, it means that the light source is not blocked. Therefore, the lens flare model piece can be rendered directly.
[0093] In another embodiment of the present invention, for further definition and explanation, the step of rendering the adjusted lens flare model piece includes:
[0094] Under the condition that the vector dot product value between the plane light source direction of the game camera and the spatial illumination direction is positive, the vertex map of the lens flare model piece is configured as a transparent material, and the lens flare model piece is rendered; or,
[0095] Under the condition that the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction is positive, rendering of the lens flare model piece is disabled.
[0096] In order to reduce the system energy consumption of halo rendering and thus improve the efficiency of halo rendering, when the vector dot product value between the plane light source direction of the game camera and the spatial illumination direction is positive, it means that the game character is facing away from the light source. In a specific implementation scenario, when the current execution end renders the halo model piece, it configures the vertex map of the lens halo model piece as a transparent material, and renders the lens halo model piece, that is, all the vertex map color channels of the halo model piece are configured as transparent channel color values, so as to eliminate the halo in a transparent manner. In another specific implementation scenario, the current execution end disables the rendering of the lens halo model piece to cancel the rendering of the halo model piece to eliminate the halo.
[0097] An embodiment of the present invention provides a rendering method for a game light object. Compared with the prior art, the embodiment of the present invention obtains a lens flare model piece of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene; samples a scene depth map of the game scene according to the direction of the light source; and, under the condition that a pixel value of the sampled scene depth map is less than a preset pixel threshold, performs occlusion adjustment on a vertex map of the lens flare model piece, and renders the adjusted lens flare model piece, thereby reducing the system computing consumption of occlusion judgment, achieving the purpose of flexible and realistic display of halos, and thus improving the rendering efficiency of game light objects.
[0098] Furthermore, as a response to the above Figure 1 The embodiment of the present invention provides a rendering device for a game light object, such as Figure 4 As shown, the device comprises:
[0099] An acquisition module 21 is used to acquire a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene;
[0100] A sampling module 22, used for sampling the scene depth map of the game scene according to the direction of the light source;
[0101] The rendering module 23 is used to perform occlusion adjustment on the vertex map of the lens flare model piece and render the adjusted lens flare model piece under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold.
[0102] Furthermore, the device also includes:
[0103] A generation module, configured to generate at least one lens flare model piece of the game light object based on a spatial illumination direction of the game camera, wherein the spatial illumination direction is determined based on a planar light source direction of the game camera and a world light source direction;
[0104] A conversion module, used for converting the spatial illumination direction corresponding to the lens flare model piece into a world space direction, and binding the lens flare model with the game camera according to the world space direction;
[0105] A configuration module is used to configure the bound lens flare model piece and the game camera to be in a linkage direction.
[0106] Furthermore, the configuration module is specifically used to convert the world space position of the game light object and the game camera into the game screen space to obtain the screen position of the game light object in the game screen space; and configure the linkage direction of the lens flare model piece and the game camera according to the direction between the world space direction and the screen position.
[0107] Furthermore, the device also includes:
[0108] A driving module, used for driving the vertex map to move in association with the linkage direction of the game camera through a connected virtual spring when the movement of the game light object is detected; or
[0109] The calculation module is used to calculate the relative position of the linkage direction of the game camera under the condition that the movement of the game light object is detected, and drive the vertex map to move in an associated manner based on the relative position.
[0110] Furthermore, the rendering module is specifically used to determine the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction; determine the halo brightness of the game light object based on the difference between the vector dot product value and the brightness critical value, and adjust the vertex map based on the halo brightness.
[0111] Furthermore, the device also includes:
[0112] A determination module is used to obtain multiple adjacent scene depth maps corresponding to the sampled scene depth map, and determine the average pixel value of the adjacent scene depth maps; under the condition that the average pixel value is less than a preset pixel threshold, determine that the game light object is occluded, so as to perform the step of occlusion adjustment on the vertex map of the lens flare model piece.
[0113] Furthermore, the rendering module is further configured to render the lens flare model film under the condition that the pixel value of the sampled scene depth map is greater than or equal to a preset pixel threshold.
[0114] Furthermore, the rendering module is specifically used to configure the vertex map of the lens flare model piece as a transparent material and render the lens flare model piece under the condition that the dot product value of the vector between the planar light source direction of the game camera and the spatial lighting direction is positive; or, to disable the rendering of the lens flare model piece under the condition that the dot product value of the vector between the planar light source direction of the game camera and the spatial lighting direction is positive.
[0115] An embodiment of the present invention provides a rendering device for a game light object. Compared with the prior art, the embodiment of the present invention obtains a lens flare model piece of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene; samples a scene depth map of the game scene according to the direction of the light source; and, under the condition that a pixel value of the sampled scene depth map is less than a preset pixel threshold, performs occlusion adjustment on a vertex map of the lens flare model piece, and renders the adjusted lens flare model piece, thereby reducing the system computing consumption of occlusion judgment, achieving the purpose of flexible and realistic display of halos, and thus improving the rendering efficiency of game light objects.
[0116] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the method for rendering a game light object in any of the above method embodiments.
[0117] Figure 5 A schematic diagram of the structure of a terminal provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the terminal.
[0118] like Figure 5 As shown, the terminal may include: a processor (processor) 302 , a communication interface (Communications Interface) 304 , a memory (memory) 306 , and a communication bus 308 .
[0119] The processor 302 , the communication interface 304 , and the memory 306 communicate with each other via the communication bus 308 .
[0120] The communication interface 304 is used to communicate with other devices such as clients or other servers.
[0121] The processor 302 is used to execute the program 310, and specifically can execute the relevant steps in the above-mentioned game light object rendering method embodiment.
[0122] Specifically, the program 310 may include program codes, which include computer operation instructions.
[0123] The processor 302 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the terminal may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0124] The memory 306 is used to store the program 310. The memory 306 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0125] The program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0126] Obtaining a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene;
[0127] Sampling a scene depth map of the game scene according to the direction of the light source;
[0128] Under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold, the vertex map of the lens flare model piece is occluded and adjusted, and the adjusted lens flare model piece is rendered.
[0129] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0130] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for rendering a game light object, characterized in that: include: Obtaining a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene; Sampling a scene depth map of the game scene according to the direction of the light source; Under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold, the vertex map of the lens flare model piece is occluded and adjusted, and the adjusted lens flare model piece is rendered.
2. The method according to claim 1, characterized in that Before obtaining the lens flare model sheet of at least one game light object carried by the game camera, the method further includes: Generate at least one lens flare model piece of the game light object based on the spatial illumination direction of the game camera, wherein the spatial illumination direction is determined based on the planar light source direction of the game camera and the world light source direction; Converting the spatial illumination direction corresponding to the lens flare model piece into a world space direction, and binding the lens flare model to the game camera according to the world space direction; After configuration and binding, the lens flare model piece and the game camera are in a linkage direction.
3. The method according to claim 2, characterized in that The configuration binding of the lens flare model piece and the game camera includes: Convert the world space positions of the game light object and the game camera into the game screen space to obtain the screen position of the game light object in the game screen space; The direction between the world space direction and the screen position is configured as the linkage direction between the lens flare model piece and the game camera.
4. The method according to claim 3, characterized in that: The method further comprises: Under the condition that the movement of the game light object is detected, the vertex map is driven to move in association with the linkage direction of the game camera through the connected virtual spring; or, Under the condition that the movement of the game light object is detected, the relative position of the linkage direction of the game camera is calculated, and the vertex map is driven to move in association based on the relative position.
5. The method according to claim 1, characterized in that The occlusion adjustment of the vertex map of the lens flare model piece comprises: Determine the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction; The halo brightness of the game light object is determined based on the difference between the vector dot product value and the brightness threshold, and the vertex map is adjusted based on the halo brightness.
6. The method according to claim 1, characterized in that Before the occlusion adjustment is performed on the vertex map of the lens flare model piece, the method further includes: Acquire a plurality of adjacent scene depth maps corresponding to the sampled scene depth map, and determine an average pixel value of the adjacent scene depth maps; Under the condition that the average pixel value is less than a preset pixel threshold, it is determined that the game light object is occluded, so as to perform the step of occlusion adjustment on the vertex map of the lens flare model piece.
7. The method according to claim 1, characterized in that The method further comprises: Under the condition that the pixel value of the sampled scene depth map is greater than or equal to a preset pixel threshold, the lens flare model piece is rendered.
8. The method according to any one of claims 1 to 7, characterized in that: The rendering of the adjusted lens flare model film comprises: Under the condition that the vector dot product value between the plane light source direction of the game camera and the spatial illumination direction is positive, the vertex map of the lens flare model piece is configured as a transparent material, and the lens flare model piece is rendered; or, Under the condition that the vector dot product value between the planar light source direction of the game camera and the spatial lighting direction is positive, rendering of the lens flare model piece is disabled.
9. A rendering device for a game light object, characterized in that: include: An acquisition module, used to acquire a lens flare model of at least one game light object carried by a game camera, wherein the game light object is a light source in a game scene; A sampling module, used for sampling the scene depth map of the game scene according to the direction of the light source; A rendering module is used to perform occlusion adjustment on the vertex map of the lens flare model piece and render the adjusted lens flare model piece under the condition that the pixel value of the sampled scene depth map is less than a preset pixel threshold.
10. A storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the method for rendering a game light object according to any one of claims 1 to 8.