Lamp effect processing method and device of virtual model, electronic equipment and storage medium
By generating a dynamic black and white mask image and overlaying it on the original lighting image of the virtual model, the problems of long time consumption in drawing mask images and unstable noise images in the existing technology are solved, realizing a fast and random flashing light effect for the virtual model and ensuring the integrity and applicability of the lighting effect.
Patent Information
- Application Number
- CN202511224426.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-12-12
AI Technical Summary
When generating random flashing light effects in virtual models, existing technologies require manual drawing of mask maps, which is time-consuming and inefficient. On the other hand, using noise maps results in unstable light areas, making them unsuitable for every virtual model.
By obtaining the original lighting map of the virtual model and the user configuration parameters, a dynamic black and white mask map is generated. The dynamic black and white mask map randomly presents white areas, which are superimposed on the original lighting map to achieve a random flashing effect of the lights. The brightness of the white areas increases, while the brightness of the black areas remains unchanged.
It enables the rapid generation of random flashing light effects for different virtual models, ensuring the integrity of the lighting effects. It eliminates the need to draw a mask map for each model, thus improving efficiency and applicability.
Smart Images

Figure CN121120907A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for processing lighting effects in a virtual model. Background Technology
[0002] In the game scene, virtual models such as spaceships and buildings are set with multiple lighting areas to simulate the effect of having residents inside. In order to make the virtual scene more realistic, it is necessary to create the effect of random flashing lights.
[0003] In existing technologies, one way to add the effect of random light flickering is to draw a mask map that fits the light area for each virtual model, and then overlay the light map with the mask map to achieve the effect of random light flickering. Another way is to sample the noise map of the material flow in the material shader of the virtual model, and then mix the noise map with the light map to randomly occlude the light area to achieve the effect of random light flickering.
[0004] The above-mentioned method of manually drawing mask maps requires a lot of manpower and time to draw a mask map for each virtual model when there are a large number of virtual models. It is time-consuming and inefficient. On the other hand, the noise map method has unstable noise shape, which will cut off and destroy the light area in the virtual model and cannot be applied to each virtual model. Therefore, there is an urgent need for a method to quickly generate random flashing light effects for different virtual models. Summary of the Invention
[0005] This disclosure provides a method, apparatus, electronic device, and storage medium for processing lighting effects of virtual models, enabling the rapid generation of randomly flashing lighting effects for each different virtual model.
[0006] Firstly, this disclosure provides a method for processing lighting effects in a virtual model, including:
[0007] Obtain the original lighting map of the virtual model and the user's configuration parameters, wherein the original lighting map includes lighting areas;
[0008] A dynamic black and white mask image is generated based on the original light image and the configuration parameters. Multiple white areas are randomly and dynamically presented in the dynamic black and white mask image, and each white area is the target light area for which the flashing light effect is to be achieved.
[0009] The target light image is obtained by overlaying the dynamic black and white mask image with the original light image. The brightness of the target light area corresponding to the white area in the target light image is increased, while the brightness of the target light area corresponding to the black area remains unchanged.
[0010] The virtual model is textured using the target light map to obtain a virtual model with a random flashing light effect.
[0011] Secondly, this disclosure provides a lighting effect processing device for a virtual model, comprising:
[0012] The original lighting map and configuration parameter acquisition module is used to acquire the original lighting map of the virtual model and the user's configuration parameters. The original lighting map includes lighting areas.
[0013] The dynamic black and white masking image generation module is used to generate a dynamic black and white masking image based on the original light image and the configuration parameters. The dynamic black and white masking image randomly and dynamically presents multiple white areas, and each white area is the target light area to be implemented with the flashing light effect.
[0014] The overlay module is used to overlay the dynamic black and white mask image with the original light image to obtain a target light image. In the target light image, the brightness of the target light area corresponding to the white area increases, while the brightness of the target light area corresponding to the black area remains unchanged.
[0015] The texturing module is used to apply the target light map to the virtual model to obtain a virtual model with a random light flashing effect.
[0016] Thirdly, this disclosure provides an electronic device, the electronic device comprising:
[0017] At least one processor; and
[0018] A memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the lighting effect processing method for the virtual model described in the first aspect of this disclosure.
[0020] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the lighting effect processing method for the virtual model described in the first aspect of this disclosure.
[0021] The embodiments disclosed herein have the following beneficial effects:
[0022] In the dynamic black-and-white mask image generated based on the original lighting map and configuration parameters, multiple white areas are randomly and dynamically presented. Each white area represents the target lighting area for the flashing effect. When the dynamic black-and-white mask image is superimposed on the original lighting map, the brightness of the corresponding target lighting area increases, while the brightness of the target lighting area corresponding to the black area remains unchanged. This achieves a random flashing effect on the virtual model. Furthermore, the brightness of the target lighting area corresponding to the white area in the dynamic black-and-white mask image remains unchanged when the white area is masked, without disrupting the lighting effect and ensuring the integrity of the virtual model's lighting effect. On the other hand, users can generate a dynamic black-and-white mask image and superimpose it on the original lighting map simply by providing the original lighting map and setting the corresponding configuration parameters. This is applicable to different virtual models and eliminates the need for manually drawing a mask image for each virtual model, enabling the rapid generation of random flashing lighting effects for different virtual models.
[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a schematic diagram illustrating the use of noise and light patterns to achieve a flashing light effect in related technologies;
[0026] Figure 2 This is a flowchart of a lighting effect processing method for a virtual model provided in an embodiment of this disclosure;
[0027] Figure 3 This is a schematic diagram of the user interface provided in an embodiment of this disclosure;
[0028] Figure 4 It is a schematic diagram of a dynamic black and white mask image at different times;
[0029] Figure 5 It is an equivalent schematic diagram on a virtual model;
[0030] Figure 6 This is a flowchart of a lighting effect processing method for a virtual model provided in another embodiment of this disclosure;
[0031] Figure 7 This is a schematic diagram of the original lighting pattern;
[0032] Figure 8 This is a schematic diagram of the baseline diagram;
[0033] Figure 9 This is a schematic diagram of traversing the baseline graph;
[0034] Figure 10 This is a schematic diagram of a static black and white mask image;
[0035] Figure 11 It is a graphical representation of a periodic function;
[0036] Figure 12 It is a schematic diagram of a static black and white mask image mixed with a stripe image;
[0037] Figure 13 It is a schematic diagram of the superimposed dynamic black and white mask image and the original lighting image;
[0038] Figure 14 This is a schematic diagram of the structure of a virtual model lighting effect processing device provided in an embodiment of this disclosure;
[0039] Figure 15 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this disclosure. Detailed Implementation
[0040] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.
[0041] In related technologies, one way to achieve a flashing light effect on a virtual model is to manually draw a corresponding mask map for each virtual model. This mask map is used to mask the light areas in the virtual model that do not require a flashing effect, such as... Figure 1 As shown in Figure a, there are multiple lighting areas on the virtual model. If there are many virtual models in the virtual scene, since the lighting areas of each virtual model are different, it will take a lot of manpower and time to draw the corresponding mask map for each virtual model.
[0042] In another approach, the flickering effect is achieved by mixing the noise map with the original light map, such as... Figure 1In the noise map of image b, white represents the value 1 and black represents the value 0. When the noise map is multiplied and mixed with the original light map, the value 1 multiplied by any value (non-zero value) equals any value, and the value 0 multiplied by any value equals 0. When the random noise map is unstable, the resulting light map is also unstable, and may even affect all light areas, such as... Figure 1 In the mixed image, the light area in diagram c (which becomes 0) disappears, which obviously cannot achieve the random flashing effect of the light required by the design.
[0043] Based on the above, this disclosure provides a method, apparatus, electronic device, and storage medium for processing lighting effects of virtual models, which can quickly create random flashing lighting effects for various virtual models.
[0044] Figure 2 This is a flowchart of a lighting effect processing method for a virtual model provided in this embodiment. This embodiment can be applied to situations where random flashing lighting effects are generated for a virtual model, such as... Figure 2 As shown, the lighting effect processing method for this virtual model includes:
[0045] S201. Obtain the original lighting map of the virtual model and the user's configuration parameters. The original lighting map includes the lighting areas.
[0046] In this embodiment, the virtual model can be various three-dimensional models in a virtual scene. For example, it can be a virtual spaceship model, building model, etc. The original lighting map can be an image used to apply textures to the virtual model. The original lighting map can include multiple lighting areas, each of which occupies a certain number of pixels in the original lighting map. The configuration parameters can be parameters set by the user to filter out the target lighting area to be implemented for the flashing lighting effect from the original lighting map, as well as parameters to control the flashing effect of the target lighting area to be implemented for the flashing lighting effect.
[0047] For example, the configuration parameters may include light area filtering conditions and light flashing control parameters. The light area filtering conditions may be the constraints for filtering the target light area to achieve the flashing effect from the original light map. For example, the light area filtering conditions may include light area size constraints, light area rejection methods, distance thresholds for filtering light areas, etc. The light flashing control parameters may be the parameters for controlling the target light area to achieve the flashing effect. For example, when controlling the target light area to achieve light flashing with black and white stripes, the light flashing control parameters may include the stripe density factor of the black and white stripes, the stripe flow speed factor, and the time factor, etc. Of course, when controlling the light flashing in other ways, the light flashing control parameters may be the light flashing frequency, brightness, etc.
[0048] like Figure 3The image shown is a schematic diagram of the user interface, where users can... Figure 3 The configuration parameters are set in the user interface shown, for example, such as... Figure 3 As shown, users can select the target folder where the original light map is located, the format of the original light map, the storage location of the log file, and set the maximum width and maximum height of the light areas that need to achieve the flashing effect from the original light map. They can also set the culling method for the light areas that need to be masked. Of course, other configuration parameters can also be set.
[0049] After setting the lighting area filtering conditions and lighting flashing control parameters in the user interface, the user can trigger the processing by clicking the "Start Processing" control. The system can then read the original lighting images of the virtual models in the corresponding format from the target folder and receive the configuration parameters set by the user. It should be noted that when creating random flashing lighting effects for multiple virtual models, the original lighting images of multiple virtual models can be stored in the same target folder. For example, the original lighting images of multiple virtual spaceships can be stored in one target folder. By selecting the corresponding image format in the user interface, multiple original lighting images of the same format in the target folder can be obtained for batch processing.
[0050] S202. Generate a dynamic black and white mask image based on the original light map and configuration parameters. Multiple white areas are randomly and dynamically presented in the dynamic black and white mask image, and each white area is the target light area for the flashing light effect to be achieved.
[0051] In this embodiment, the dynamic black-and-white mask image can be a black-and-white mask image with the same resolution as the original light image, and randomly and dynamically presenting white areas. Each white area can be the target light area in the original light image where the flashing light effect is to be achieved, such as... Figure 4 The image shown is a schematic diagram of a dynamic black and white masking image at two different times. The positions of the white areas are different and random at the two times. Each white area represents a target light area for which a flashing light effect is to be achieved. That is, the target light area corresponding to the white area is not masked. The black area represents the masked area. That is, the light area located in the black area is masked.
[0052] In an optional embodiment, a static black-and-white mask image including a white area can be generated based on the original light image and configuration parameters, and a stripe image including dynamic flowing black-and-white stripes can be generated. The white area in the static black-and-white mask image is the target light area to be achieved with the flashing light effect. The static black-and-white mask image and the stripe image are mixed to obtain a dynamic black-and-white mask image. In the dynamic black-and-white mask image, the white area is not masked when the white stripes flow through the white area, and the white area is masked when the black stripes flow through the white area.
[0053] Specifically, the configuration parameters can include user-defined light area filtering conditions for selecting the target light area to achieve the flashing effect from the original light image, as well as control parameters for light flashing, such as the stripe density factor, stripe flow speed factor, and time factor for generating a dynamic flowing black and white stripe image. Based on the light area filtering conditions in the user's configuration parameters, the target light area to achieve the flashing effect can be selected from the original light image, generating a black image with the same resolution as the original light image. In the black image, the pixels corresponding to the target light area are modified to white to obtain a static black and white mask image. Further, by performing operations such as transformation and rotation on the UV coordinates of the original light image, new UV coordinates are obtained. The periodic function value is calculated using the new UV coordinates and the stripe density factor, stripe flow speed factor, and time factor in the user-defined configuration parameters, and the periodic function value is graphically generated to obtain a stripe image of dynamic flowing black and white stripes. This stripe image is mixed with the static black and white mask image to obtain a dynamic black and white mask image, so that when white stripes flow through the static black and white mask image, the white area is preserved, and when black stripes flow through the white area, they are masked. In the state of black and white stripe flow, white areas are randomly and dynamically presented as unmasked areas in the dynamic black and white mask image.
[0054] S203. The dynamic black and white mask image is superimposed on the original light image to obtain the target light image. The brightness of the target light area corresponding to the white area in the target light image is increased, while the brightness of the target light area corresponding to the black area remains unchanged.
[0055] In this embodiment, after the dynamic black and white mask image is superimposed on the original light image, for the same target light area, when the area of the target light area in the dynamic black and white mask image is white, the brightness of the target light area increases, and when the area in the dynamic black and white mask image is black, the brightness remains unchanged. That is, the brightness of the target light area in the target light image alternates between brightening and remaining constant, thus achieving a light flickering effect. Moreover, the white area in the dynamic black and white mask image appears dynamically and randomly, thus achieving randomness in the target light area with the flickering effect.
[0056] S204. Use the target light map to perform texture processing on the virtual model to obtain a virtual model with random light flashing effect.
[0057] Specifically, texture mapping can be performed using the UV coordinates of the target light map to obtain a virtual model with a random flashing light effect, such as... Figure 5 The image shown depicts the lighting effect after the light pattern is placed on the spaceship model. Figure 5 The target lighting areas P1 and P2 can achieve a flashing light effect.
[0058] In this embodiment, a dynamic black-and-white mask image generated based on the original lighting map and configuration parameters randomly and dynamically presents multiple white areas. Each white area represents the target lighting area for which a flashing lighting effect is to be achieved. This results in the brightness of the corresponding target lighting area increasing when the dynamic black-and-white mask image is superimposed on the original lighting map, while the brightness of the target lighting area corresponding to the black area remains unchanged. This achieves a random flashing lighting effect on the virtual model. Furthermore, the brightness of the corresponding target lighting area remains unchanged when the white area in the dynamic black-and-white mask image is masked, without damaging the lighting effect and ensuring the integrity of the lighting effect of the virtual model. On the other hand, users can generate a dynamic black-and-white mask image and superimpose it on the original lighting map simply by providing the original lighting map and setting the corresponding configuration parameters. This is applicable to different virtual models and eliminates the need for manual drawing of a corresponding mask image for each virtual model, enabling the rapid generation of random flashing lighting effects for different virtual models.
[0059] Figure 6 A flowchart of a lighting effect processing method for a virtual model provided in another optional embodiment of this disclosure is shown below. Figure 6 As shown, the lighting effect processing method for this virtual model includes:
[0060] S601. Obtain the original lighting map of the virtual model and the user's configuration parameters. The original lighting map includes the lighting areas.
[0061] like Figure 3 The image shown is a schematic diagram of the user interface, where users can... Figure 3 The user interface allows users to select the target folder containing the original lighting map, the format of the original lighting map, and the storage location of the log file. Users can also set relevant configuration parameters. For example, configuration parameters can include light area filtering conditions for selecting target light areas to achieve flashing effects from the original lighting map. Users can set the maximum width and maximum height of the light areas to be filtered to achieve flashing effects in the user interface, and set the culling method for light areas to be masked, etc., to generate the configuration parameters set by the user. Of course, configuration parameters can also include light flashing control parameters such as stripe density factor, stripe flow speed factor, and time factor. Users can set light flashing control parameters in other user interfaces. After the user triggers the start of processing through the control in the user interface, the original lighting map of the virtual model can be read from the target folder and the configuration parameters set by the user can be received.
[0062] like Figure 7 The image shown is a schematic diagram of the original lighting map. The original lighting map can be an image used for texturing virtual models, and it can include multiple lighting areas. Figure 7 (The non-black areas) Each light area occupies a certain number of pixels in the original light map.
[0063] S602. Generate a static black and white mask image including white areas based on the original light image and configuration parameters. The white areas in the static black and white mask image are the target light areas for the flashing light effect to be implemented.
[0064] In this embodiment, the static black and white mask image is used to mask the light areas in the original light image that do not need to implement the flashing light effect. The white areas in the static black and white mask image are the areas corresponding to the target light areas in the original light image where the flashing light effect is to be implemented. In an optional embodiment, S602 may include sub-steps S6021-S6023, as follows:
[0065] S6021. Determine the target lighting area from multiple lighting areas in the original lighting map based on configuration parameters.
[0066] In one embodiment, the configuration parameters may include light area filtering conditions for selecting the target light area to achieve the flashing light effect. The pixel value of each pixel in the original light map can be traversed, and the light area can be determined based on the pixel value. The target light area that meets the light area filtering conditions can be selected from multiple light areas based on the light area filtering conditions set by the user.
[0067] Specifically, first select any RGB channel from the original lighting map as the base map, such as... Figure 8 The baseline image shown is a single-channel image containing only black, white, and gray pixels. Compared to directly traversing the original light map, it reduces the influence of pixels of other colors, making the method of determining the light area simpler and more accurate.
[0068] Since the reference image is a channel image of the original light image, and its resolution is the same as that of the original light image, a string list can be generated and initialized. The number of elements in the string list is equal to the number of pixels in the reference image, and each element corresponds one-to-one with a pixel in the reference image. The initial value of each element in the string list is equal to the first string, which indicates that the pixel is a non-light pixel. For example, the first string can be "0", but it can also be other strings, such as "F".
[0069] After initializing the string list, each pixel in the baseline image can be traversed based on a preset search algorithm. When determining whether the current pixel is gray or white based on its pixel value, the neighboring pixels of the current pixel are identified, and it is determined whether the string corresponding to the element of the neighboring pixel in the string list is the first string. If so, the string corresponding to the element of the current pixel in the string list is set to the second string, which represents the sequence number of the traversed light area. If not, the string corresponding to the element of the current pixel in the string list is set to the same string as the neighboring pixel. After the traversal is completed, the area formed by the pixels corresponding to the elements in the string list that have the same string and are not the first string is determined as the light area.
[0070] Specifically, such as Figure 9 The diagram shows a partial area of the baseline image. Each pixel in the baseline image can be traversed from top to bottom using a breadth-first search or depth-first search algorithm. Upon reaching a pixel, its value is used to determine if it is white or gray. If so, the pixel is identified as a light pixel. Further checks are made to ensure that the strings corresponding to the pixels above, below, left, and right of the current pixel in the string list are all the same as the first string "0". If so, a new light area has been reached. The string corresponding to the current pixel is set to the second string in the string list. This second string can be the sequence number of the traversed light area, such as... Figure 9 The second string can be light-i, where i is the index of the light area being traversed.
[0071] If the string corresponding to any of the current pixel's top, bottom, left, or right adjacent pixels is not the first string "0" in the string list, it is determined that the current pixel is a pixel in the already traversed light area, and the string of the current pixel in the string list can be set to the string of the pixels in the already traversed light area.
[0072] After the traversal is complete, the region consisting of pixels corresponding to elements in the string list that have the same string but are not the first string is defined as the lighting area, such as... Figure 9 In the image, the pixels corresponding to the elements of the string "light2" constitute the light area 2. In this embodiment of the present disclosure, when traversing the reference image, whether a pixel is a light pixel is recorded by a string. The pixels of the same light area can be determined by whether the strings are the same, and the light area in the original light image can be quickly determined.
[0073] S6022. Based on the user-defined lighting area filtering conditions, select the target lighting area that meets the lighting area filtering conditions from multiple lighting areas.
[0074] In this embodiment of the disclosure, pixel data of the light area can be stored using a composite dictionary structure. For example, the composite dictionary structure stores the pixel data of the light area as follows:
[0075] dir{light1:[(x1,y1),…,(xn,yn)],…, lightn:[(x1,y1),…,
[0076] (xn,yn)]}.
[0077] Where xn and yn represent the pixel coordinates of each pixel in the light area, and lightn represents the nth light area. For each light area, the pixel coordinates of all pixels in each light area can be obtained from the stored pixel data of the light areas. The center position of each light area is then calculated using the pixel coordinates. A light area is randomly selected from multiple light areas as a sample. The distance from the center position of each light area to the center position of the sample is calculated. The target light area is selected from the light areas whose distance is less than a preset distance threshold. For example, the selected sample can be a sample near the center of the virtual model. The light area within the threshold distance centered on this sample is selected as the target light area, thus realizing the creation of flashing light effects using light areas within a preset range.
[0078] In yet another optional embodiment, the light area filtering conditions may further include light area size restrictions and light rejection methods, such as... Figure 3 The settings include the maximum width, maximum height, and elimination method for the light area. It can also filter out candidate light areas that meet the light area size restriction conditions from multiple light areas that are less than the preset distance threshold, eliminate light areas from the candidate light areas according to the preset elimination strategy, and determine the light areas that are not eliminated as the target light areas.
[0079] For example, Figure 3 The user interface shown sets the maximum width and maximum height of the light area to 5 pixels. After uniform culling and adjusting the culling ratio, light areas with a width greater than 5 pixels and a height greater than 5 pixels within the selected range can be uniformly culled to obtain the target light area. The data of the culled light areas is then removed from the pixel data of the light areas stored in the composite dictionary structure. This achieves the creation of flashing light effects by selecting a target light area of a specified size within a preset size range according to the user's configuration parameters. There is no need to manually select the target light area, and the target light area can be evenly distributed in the light map, avoiding the flashing light effect being concentrated in a small area and improving the effect of the flashing light effect of the virtual model after texturing.
[0080] S6023. Generate a static black and white mask image with the same resolution as the original light image, where the white areas correspond one-to-one with the target light areas.
[0081] In an optional embodiment, a black image with the same resolution as the original light image can be generated, the pixel coordinates of the target light area in the original light image can be obtained, and the black pixels corresponding to the pixel coordinates in the black image can be modified to white pixels to obtain a static black and white mask image including the white area.
[0082] Specifically, in Python, the Matplotlib library can be used to create a blank black image in the a channel of the original light map, resulting in a black image with the same resolution as the original light map. Then, the pixel coordinates of the target light region stored in the composite dictionary structure are assigned to the a channel, and the corresponding pixels are modified to white to obtain a static black-and-white mask image. The white areas in this static black-and-white mask image correspond to the target light region in the original light map where the flashing effect is to be achieved. Figure 10 The image shown is a schematic diagram of a static black and white mask image, relative to... Figure 8 The baseline image has already removed some of the lighting areas. Figure 10 The white area shown corresponds to the target light area, which is the area where the flashing light effect is to be implemented.
[0083] This embodiment generates a static black-and-white mask image including white areas based on the original lighting map and the user-defined lighting area filtering conditions. It is applicable to lighting maps of different virtual models, generating a static black-and-white mask image for the lighting area of each virtual model. This eliminates the need for manual drawing of mask images for each virtual model, saving manpower. Furthermore, users can select a target folder containing multiple original lighting maps of a specified format via the user interface, enabling batch selection of original lighting images. Figure 1 The key processing generates mask images, improving the efficiency of batch mask image generation.
[0084] S603. Generate a stripe pattern including dynamic flowing black and white stripes based on the UV coordinates and configuration parameters of the original light map.
[0085] In this embodiment, the stripe pattern can refer to a dynamic image including dynamically flowing black and white stripes. The resolution of the stripe pattern is the same as that of the original light pattern. In an optional embodiment, the UV coordinates of the original light pattern can be scaled, rotated, and restored to obtain the processed UV coordinates. The periodic function value is calculated on the horizontal component of the processed UV coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters. The periodic function value is then graphically represented to obtain a stripe pattern including dynamically flowing black and white stripes. The periodic function value is between 0 and 1, which represents a gradient from black to white, and between -1 and 0, which represents black.
[0086] Specifically, the range of UV coordinates is usually from 0 to -1, with the lower left corner as the origin (0, 0). The UV coordinates of the original light pattern can be transformed from 0 to -1 to -1 to obtain the first UV coordinates, so that the origin (0, 0) is located at the center of the original light pattern. Then, the first UV coordinates are multiplied by a preset rotation rectangle to obtain the second UV coordinates after rotating around the center point at any angle. The second UV coordinates are then restored from -1 to -1 to 0 to -1 to obtain the processed UV coordinates. The pseudocode for the UV coordinate processing is as follows:
[0087] Center uv = UV - float2(0.5, 0.5) ----- This transforms the uv coordinates from 0-1 to -1-1, so that the uv coordinates of point (0, 0) are at the center of the image;
[0088] UV rotation around any angle = (center uv hybrid rotation matrix) ----- Multiply the transformed uv by the rotation matrix to rotate the uv around the center point at any angle;
[0089] Rotate the UV coordinates around any angle + = center point ----- then add (0.5, 0.5) to the converted UV coordinates to restore them to the 0-1 range.
[0090] After completing the UV coordinate transformation, the periodic function value Y is calculated using the following expression:
[0091] Y = f(Rotate_UV_x × C + t × V);
[0092] F() is a periodic function, Rotate_UV_x is the horizontal component of the preprocessed uv coordinates, C is the stripe density factor, t is the time factor, and V is the stripe flow velocity factor.
[0093] The periodic function can be a sine or cosine function, such as... Figure 11 Taking the horizontal component of UV from -300 to 300 as an example, the periodic function value is between -1 and 1 and changes periodically. In image representation in computer graphics, -1 to 0 represents displaying black, and the range of 0 to 1 represents a gradient from black to white, ultimately resulting in... Figure 12 The stripe pattern shown in Figure b has the same resolution as the original light pattern. It should be noted that... Figure 12 Although the stripes shown in Figure b are static, in practical applications, the black and white stripes in the stripe diagram are fluid and changing.
[0094] S604. Mix the static black and white mask image with the stripe image to obtain a dynamic black and white mask image. In the dynamic black and white mask image, the white area is not masked when the white stripes flow through the white area, and the white area is masked when the black stripes flow through the white area.
[0095] In this embodiment, the mixing of the static black and white mask image and the stripe image can be a multiplication mixing operation. Specifically, in the stripe image, the value of white pixels is 1 and the value of black pixels is 0. The static black and white mask image and the stripe image have the same resolution. For each pixel in the white area of the static black and white mask image, the pixel value remains unchanged when the white stripe in the stripe image flows through it (1 multiplied by any number equals any number), and it is still white. This is reflected in the fact that the white stripe does not mask the white area when it flows through it. When the black stripe flows through the white area of the static black and white mask image, the pixel value of each pixel becomes 0 (0 multiplied by any number equals 0), that is, the white area in the static black and white mask image becomes black, that is, the white area is not masked.
[0096] like Figure 12 Image a is a static black and white mask image. The white areas in this image correspond to the target light area where the blinking effect is to be achieved. Figure 12 Image b is a stripe pattern, where the black and white stripes are fluid and changing, as shown in the image. Figure 12 Figure c illustrates the multiplication and blending of a static black-and-white mask image and a stripe image. The black and white stripes in the stripe image flow dynamically. For a white area in the static black-and-white mask image, it is alternately passed through by black and white stripes. When white stripes pass through a white area, it is not masked. Figure 12 In the middle of the image, the white area P1 is traversed by white stripes. Figure 12 In the dynamic black-and-white masking diagram shown in Figure d, the white area P1 is not masked and is visible; the white area is masked when black stripes flow through it, as shown in Figure d. Figure 12 In the middle of the image, the white area P2 is crossed by black stripes. Figure 12 In the dynamic black-and-white masking image shown in Figure d, the white region P2 is masked and invisible. As the black and white stripes in the stripe pattern move dynamically, each white region in the static black-and-white masking image alternates between masked and unmasked states, thus forming a dynamic black-and-white masking image, as shown below. Figure 4 The image shown is a schematic diagram of a dynamic black and white mask at two different times. The position of the white area is different and random at the two times.
[0097] In this embodiment, a dynamic black and white stripe image is obtained by multiplying and mixing a static black and white mask image with a stripe image that includes dynamic flowing black and white stripes. By controlling the stripe density, flow speed and period time in the stripe image, each white area in the dynamic black and white mask image periodically presents two states: unmasked and masked, and has randomness. The dynamic black and white mask image can achieve a random flashing light effect when superimposed with the original light image.
[0098] S605. The dynamic black and white mask image is superimposed with the original light image to obtain the target light image. The brightness of the target light area corresponding to the white area in the target light image is increased, while the brightness of the target light area corresponding to the black area remains unchanged.
[0099] Specifically, in this embodiment, the overlay operation can be an addition operation. In the dynamic black and white mask image, a pixel has a value of 1 when it is black and a value of 0 when it is white. The resolution of the dynamic black and white mask image is the same as the resolution of the original light image. The pixel values of the two images are added together. When the white area in the dynamic black and white mask image is not masked, the value is 1. After being overlaid with the original light image, since the result of adding 1 to any non-zero number is greater than 1, the brightness of the target light area corresponding to the white area increases. When the white area in the dynamic black and white mask image is masked, the value is 0. After being overlaid with the original light image, since the result of adding 0 to any non-zero number remains unchanged, the brightness of the target light area corresponding to the masked white area remains unchanged. Figure 13 The image shown is a schematic diagram of a dynamic black-and-white mask image superimposed on the original light image at a certain moment. The light in the white area of the image is brighter, while the brightness of the light that is not masked remains unchanged.
[0100] For the same target light area, due to the flow of black and white stripes, the white area corresponding to each target light area in the dynamic black and white masking image alternately presents two states: masked and unmasked. In the target light image, the brightness of the target light area presents two states: brightening and remaining unchanged, thus achieving the light flickering effect. Moreover, the target light area that achieves the light flickering effect has randomness as the dynamic black and white stripes flow.
[0101] S606. Use the target light map to perform texture processing on the virtual model to obtain a virtual model with a random light flashing effect.
[0102] Specifically, texture mapping can be performed in the game engine using the UV coordinates of the target light map to obtain a virtual model with a random flickering light effect, such as... Figure 5 The image shown depicts the lighting effect after the light pattern is placed on the spaceship model. Figure 5 The target lighting areas P1 and P2 can achieve a flashing light effect.
[0103] This application embodiment generates a static black-and-white mask image including white areas based on the original lighting image and configuration parameters, and generates a stripe image including dynamically flowing black-and-white stripes. The static black-and-white mask image and the stripe image are mixed to obtain a dynamic black-and-white mask image. The dynamic black-and-white mask image is then superimposed on the original lighting image to obtain the target lighting image. The static black-and-white mask image includes white areas corresponding to multiple target lighting areas. When the static black-and-white mask image and the stripe image are mixed, the white areas through which the white stripes flow are preserved, while the white areas through which the black stripes flow are masked. As the black and white stripes in the stripe image flow, a dynamic black-and-white mask image that randomly and dynamically presents multiple white areas is obtained. After the mask image is overlaid with the original light image, the brightness of the target light area corresponding to the white area in the dynamic black and white mask image increases, while the brightness of the target light area corresponding to the black area remains unchanged. This achieves a random flashing effect of the lights on the virtual model. Even when the target light area is masked, the brightness remains unchanged, which does not destroy the lighting effect and ensures the integrity of the lighting effect of the virtual model. On the other hand, users can provide the original light image and set the corresponding configuration parameters to dynamically overlay the black and white mask image with the original light image. This can be applied to different virtual models without the need to manually draw a corresponding mask image for each virtual model. It can quickly generate random flashing light effects for different virtual models.
[0104] Figure 14 This is a schematic diagram of the structure of a lighting effect processing device for a virtual model provided in an embodiment of this application. Figure 14 As shown, the lighting effect processing device for this virtual model includes:
[0105] The original lighting map and configuration parameter acquisition module 1401 is used to acquire the original lighting map of the virtual model and the user's configuration parameters, wherein the original lighting map includes lighting areas;
[0106] The dynamic black and white mask image generation module 1402 is used to generate a dynamic black and white mask image based on the original light image and the configuration parameters. The dynamic black and white mask image randomly and dynamically presents multiple white areas, and each white area is the target light area to be implemented with the flashing light effect.
[0107] The overlay module 1403 is used to overlay the dynamic black and white mask image with the original light image to obtain a target light image, wherein the brightness of the target light area corresponding to the white area in the target light image is increased, and the brightness of the target light area corresponding to the black area remains unchanged.
[0108] The texturing module 1404 is used to perform texturing processing on the virtual model using the target light map to obtain a virtual model with a random light flashing effect.
[0109] The lighting effect processing device for the virtual model provided in this application embodiment can execute the lighting effect processing method for the virtual model provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0110] Figure 15 A schematic diagram of the structure of an electronic device 40 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0111] like Figure 15 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0112] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0113] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the lighting effect processing method for a virtual model.
[0114] The lighting effect processing methods for virtual models include:
[0115] Obtain the original lighting map of the virtual model and the user's configuration parameters, wherein the original lighting map includes lighting areas;
[0116] A dynamic black and white mask image is generated based on the original light image and the configuration parameters. Multiple white areas are randomly and dynamically presented in the dynamic black and white mask image, and each white area is the target light area for which the flashing light effect is to be achieved.
[0117] The target light image is obtained by overlaying the dynamic black and white mask image with the original light image. The brightness of the target light area corresponding to the white area in the target light image is increased, while the brightness of the target light area corresponding to the black area remains unchanged.
[0118] The virtual model is textured using the target light map to obtain a virtual model with a random flashing light effect.
[0119] Optionally, generating a dynamic black-and-white mask image based on the original light map and the configuration parameters includes:
[0120] Based on the original light map and the configuration parameters, a static black and white mask map including a white area is generated, and a stripe map including dynamic flowing black and white stripes is generated. The white area in the static black and white mask map is the target light area for which the flashing light effect is to be achieved.
[0121] The static black and white mask image is mixed with the stripe image to obtain a dynamic black and white mask image. In the dynamic black and white mask image, the white area is not masked when white stripes flow through the white area, and the white area is masked when black stripes flow through the white area.
[0122] Optionally, generating a static black-and-white mask image including white areas based on the original light map and the configuration parameters, and generating a stripe image including dynamically flowing black-and-white stripes, includes:
[0123] The target light area is determined from multiple light areas of the original light map based on the configuration parameters;
[0124] Generate a static black and white mask image with the same resolution as the original light image, where the white areas correspond one-to-one with the target light areas;
[0125] A stripe pattern including dynamic flowing black and white stripes is generated based on the UV coordinates of the original light map and the configuration parameters.
[0126] Optionally, the configuration parameters include light area filtering conditions, and the target light area is determined from multiple light areas in the original light map based on the configuration parameters, including:
[0127] The pixel value of each pixel in the original light map is traversed, and the light area is determined based on the pixel value;
[0128] Based on the user-defined lighting area filtering criteria, the target lighting area that meets the filtering criteria is selected from multiple lighting areas.
[0129] Optionally, traversing the pixel values of each pixel in the original light map and determining the light area based on the pixel values includes:
[0130] Select any channel diagram of the original lighting diagram as the reference diagram;
[0131] Generate a list of strings and initialize all elements in the list with the first string. The number of elements in the list is equal to the number of pixels in the reference image, and each element corresponds one-to-one with a pixel in the reference image. The first string indicates that the pixel is a non-light pixel.
[0132] Based on a preset search algorithm, each pixel in the reference image is traversed. When the current pixel is determined to be a gray or white pixel based on the pixel value of the traversed current pixel, the adjacent pixels of the current pixel are determined.
[0133] Determine whether the string corresponding to the element of the adjacent pixel in the string list is the first string;
[0134] If so, set the string of the element corresponding to the current pixel in the string list as the second string, where the second string is the sequence number of the traversed light area;
[0135] If not, set the string of the element corresponding to the current pixel in the string list to the same string as the adjacent pixel;
[0136] After the traversal is completed, the area formed by the pixels corresponding to the elements in the string list that have the same string and are not the first string is determined as the light area.
[0137] Optionally, the light area filtering conditions include at least a distance threshold. Based on the user-defined light area filtering conditions, a target light area that meets the light area filtering conditions is selected from multiple light areas, including:
[0138] Calculate the center position of each of the aforementioned light areas;
[0139] Randomly select one of the multiple light regions as a sample;
[0140] Calculate the distance from the center of each light area to the center of the sample;
[0141] Select the target light area from the light areas whose distance is less than a preset distance threshold.
[0142] Optionally, the light area filtering conditions also include light area size restrictions and light rejection methods, filtering target light areas from light areas whose distance is less than a preset distance threshold, including:
[0143] Candidate light areas that meet the light area size restriction conditions are selected from light areas whose distance is less than the preset distance threshold;
[0144] According to the preset elimination strategy, light areas are eliminated from the candidate light areas, and the light areas that are not eliminated are determined as target light areas.
[0145] Optionally, generating a static black-and-white mask image with the same resolution as the original light map and where the white areas correspond one-to-one with the target light areas includes:
[0146] Generate a black image with the same resolution as the original light map;
[0147] Obtain the pixel coordinates of the target light area in the original light map;
[0148] The black pixels corresponding to the pixel coordinates in the black image are modified to white pixels to obtain a static black and white mask image that includes white areas.
[0149] Optionally, a stripe pattern including dynamically flowing black and white stripes is generated based on the UV coordinates of the original light map and the configuration parameters, including:
[0150] The UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates;
[0151] The periodic function value is calculated on the horizontal component of the processed uv coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters. The periodic function value is then graphically represented to obtain a stripe pattern including dynamic flowing black and white stripes. The periodic function value is between 0 and 1, representing a gradient from black to white, and between -1 and 0, representing black.
[0152] Optionally, the UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates, including:
[0153] The UV coordinates of the original light map are transformed from a first range to a second range to obtain the first UV coordinates, where the first range is from 0 to -1 and the second range is from -1 to -1.
[0154] Multiply the first uv coordinates by the preset rotation rectangle to obtain the second uv coordinates after rotation around the center point;
[0155] The second UV coordinates are restored from the second range to the first range to obtain the processed UV coordinates.
[0156] Optionally, the periodic function value is calculated for the horizontal component of the processed uv coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters, including:
[0157] Calculate the value of the periodic function Y using the following expression:
[0158] Y = f(Rotate_UV_x × C + t × V);
[0159] F() is a periodic function, Rotate_UV_x is the horizontal component of the preprocessed uv coordinates, C is the stripe density factor, t is the time factor, and V is the stripe flow velocity factor.
[0160] Optionally, mixing the static black-and-white mask image with the stripe image to obtain a dynamic black-and-white mask image includes:
[0161] The static black and white mask image is multiplied by the stripe image to obtain the dynamic black and white mask image.
[0162] In some embodiments, the lighting effect processing method for the virtual model can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the lighting effect processing method for the virtual model described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to perform the lighting effect processing method for the virtual model by any other suitable means (e.g., by means of firmware).
[0163] The lighting effect processing methods for virtual models include:
[0164] Obtain the original lighting map of the virtual model and the user's configuration parameters, wherein the original lighting map includes lighting areas;
[0165] A dynamic black and white mask image is generated based on the original light image and the configuration parameters. Multiple white areas are randomly and dynamically presented in the dynamic black and white mask image, and each white area is the target light area for which the flashing light effect is to be achieved.
[0166] The target light image is obtained by overlaying the dynamic black and white mask image with the original light image. The brightness of the target light area corresponding to the white area in the target light image is increased, while the brightness of the target light area corresponding to the black area remains unchanged.
[0167] The virtual model is textured using the target light map to obtain a virtual model with a random flashing light effect.
[0168] Optionally, generating a dynamic black-and-white mask image based on the original light map and the configuration parameters includes:
[0169] Based on the original light map and the configuration parameters, a static black and white mask map including a white area is generated, and a stripe map including dynamic flowing black and white stripes is generated. The white area in the static black and white mask map is the target light area for which the flashing light effect is to be achieved.
[0170] The static black and white mask image is mixed with the stripe image to obtain a dynamic black and white mask image. In the dynamic black and white mask image, the white area is not masked when white stripes flow through the white area, and the white area is masked when black stripes flow through the white area.
[0171] Optionally, generating a static black-and-white mask image including white areas based on the original light map and the configuration parameters, and generating a stripe image including dynamically flowing black-and-white stripes, includes:
[0172] The target light area is determined from multiple light areas of the original light map based on the configuration parameters;
[0173] Generate a static black and white mask image with the same resolution as the original light image, where the white areas correspond one-to-one with the target light areas;
[0174] A stripe pattern including dynamic flowing black and white stripes is generated based on the UV coordinates of the original light map and the configuration parameters.
[0175] Optionally, the configuration parameters include light area filtering conditions, and the target light area is determined from multiple light areas in the original light map based on the configuration parameters, including:
[0176] The pixel value of each pixel in the original light map is traversed, and the light area is determined based on the pixel value;
[0177] Based on the user-defined lighting area filtering criteria, the target lighting area that meets the filtering criteria is selected from multiple lighting areas.
[0178] Optionally, traversing the pixel values of each pixel in the original light map and determining the light area based on the pixel values includes:
[0179] Select any channel diagram of the original lighting diagram as the reference diagram;
[0180] Generate a list of strings and initialize all elements in the list with the first string. The number of elements in the list is equal to the number of pixels in the reference image, and each element corresponds one-to-one with a pixel in the reference image. The first string indicates that the pixel is a non-light pixel.
[0181] Based on a preset search algorithm, each pixel in the reference image is traversed. When the current pixel is determined to be a gray or white pixel based on the pixel value of the traversed current pixel, the adjacent pixels of the current pixel are determined.
[0182] Determine whether the string corresponding to the element of the adjacent pixel in the string list is the first string;
[0183] If so, set the string of the element corresponding to the current pixel in the string list as the second string, where the second string is the sequence number of the traversed light area;
[0184] If not, set the string of the element corresponding to the current pixel in the string list to the same string as the adjacent pixel;
[0185] After the traversal is completed, the area formed by the pixels corresponding to the elements in the string list that have the same string and are not the first string is determined as the light area.
[0186] Optionally, the light area filtering conditions include at least a distance threshold. Based on the user-defined light area filtering conditions, a target light area that meets the light area filtering conditions is selected from multiple light areas, including:
[0187] Calculate the center position of each of the aforementioned light areas;
[0188] Randomly select one of the multiple light regions as a sample;
[0189] Calculate the distance from the center of each light area to the center of the sample;
[0190] Select the target light area from the light areas whose distance is less than a preset distance threshold.
[0191] Optionally, the light area filtering conditions also include light area size restrictions and light rejection methods, filtering target light areas from light areas whose distance is less than a preset distance threshold, including:
[0192] Candidate light areas that meet the light area size restriction conditions are selected from light areas whose distance is less than the preset distance threshold;
[0193] According to the preset elimination strategy, light areas are eliminated from the candidate light areas, and the light areas that are not eliminated are determined as target light areas.
[0194] Optionally, generating a static black-and-white mask image with the same resolution as the original light map and where the white areas correspond one-to-one with the target light areas includes:
[0195] Generate a black image with the same resolution as the original light map;
[0196] Obtain the pixel coordinates of the target light area in the original light map;
[0197] The black pixels corresponding to the pixel coordinates in the black image are modified to white pixels to obtain a static black and white mask image that includes white areas.
[0198] Optionally, a stripe pattern including dynamically flowing black and white stripes is generated based on the UV coordinates of the original light map and the configuration parameters, including:
[0199] The UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates;
[0200] The periodic function value is calculated on the horizontal component of the processed uv coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters. The periodic function value is then graphically represented to obtain a stripe pattern including dynamic flowing black and white stripes. The periodic function value is between 0 and 1, representing a gradient from black to white, and between -1 and 0, representing black.
[0201] Optionally, the UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates, including:
[0202] The UV coordinates of the original light map are transformed from a first range to a second range to obtain the first UV coordinates, where the first range is from 0 to -1 and the second range is from -1 to -1.
[0203] Multiply the first uv coordinates by the preset rotation rectangle to obtain the second uv coordinates after rotation around the center point;
[0204] The second UV coordinates are restored from the second range to the first range to obtain the processed UV coordinates.
[0205] Optionally, the periodic function value is calculated for the horizontal component of the processed uv coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters, including:
[0206] Calculate the value of the periodic function Y using the following expression:
[0207] Y = f(Rotate_UV_x × C + t × V);
[0208] F() is a periodic function, Rotate_UV_x is the horizontal component of the preprocessed uv coordinates, C is the stripe density factor, t is the time factor, and V is the stripe flow velocity factor.
[0209] Optionally, mixing the static black-and-white mask image with the stripe image to obtain a dynamic black-and-white mask image includes:
[0210] The static black and white mask image is multiplied by the stripe image to obtain the dynamic black and white mask image.
[0211] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0212] Computer programs used to implement the methods of this disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0213] In the context of this disclosure, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0214] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0215] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0216] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0217] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0218] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for processing lighting effects in a virtual model, characterized in that, include: Obtain the original lighting map of the virtual model and the user's configuration parameters, wherein the original lighting map includes lighting areas; A dynamic black and white mask image is generated based on the original light image and the configuration parameters. Multiple white areas are randomly and dynamically presented in the dynamic black and white mask image, and each white area is the target light area for which the flashing light effect is to be achieved. The target light image is obtained by overlaying the dynamic black and white mask image with the original light image. In the target light image, the brightness of the target light area corresponding to the white area increases, while the brightness of the target light area corresponding to the black area remains unchanged. The virtual model is textured using the target light map to obtain a virtual model with a random flashing light effect.
2. The method according to claim 1, characterized in that, Generate a dynamic black-and-white mask image based on the original light map and the configuration parameters, including: Based on the original light map and the configuration parameters, a static black and white mask map including a white area is generated, and a stripe map including dynamic flowing black and white stripes is generated. The white area in the static black and white mask map is the target light area for which the flashing light effect is to be achieved. The static black and white mask image is mixed with the stripe image to obtain a dynamic black and white mask image. In the dynamic black and white mask image, the white area is not masked when white stripes flow through the white area, and the white area is masked when black stripes flow through the white area.
3. The method according to claim 2, characterized in that, Based on the original light map and the configuration parameters, a static black-and-white mask map including white areas is generated, and a stripe map including dynamic flowing black-and-white stripes is generated, including: The target light area is determined from multiple light areas of the original light map based on the configuration parameters; Generate a static black and white mask image with the same resolution as the original light image, where the white areas correspond one-to-one with the target light areas; A stripe pattern including dynamic flowing black and white stripes is generated based on the UV coordinates of the original light map and the configuration parameters.
4. The method according to claim 3, characterized in that, The configuration parameters include lighting area filtering conditions. Based on the configuration parameters, a target lighting area is determined from multiple lighting areas in the original lighting map, including: The pixel value of each pixel in the original light map is traversed, and the light area is determined based on the pixel value; Based on the user-defined lighting area filtering criteria, the target lighting area that meets the filtering criteria is selected from multiple lighting areas.
5. The method according to claim 4, characterized in that, Traversing the pixel values of each pixel in the original light map, and determining the light area based on the pixel values, including: Select any channel diagram of the original lighting diagram as the reference diagram; Generate a string list and initialize the string of all elements in the string list as the first string. The number of elements in the string list is equal to the number of pixels in the reference image, and each element corresponds one-to-one with a pixel in the reference image. The first string indicates that the pixel is a non-light pixel. Based on a preset search algorithm, each pixel in the reference image is traversed. When the current pixel is determined to be a gray or white pixel based on the pixel value of the traversed current pixel, the adjacent pixels of the current pixel are determined. Determine whether the string corresponding to the element of the adjacent pixel in the string list is the first string; If so, set the string of the element corresponding to the current pixel in the string list as the second string, where the second string is the sequence number of the traversed light area; If not, set the string of the element corresponding to the current pixel in the string list to the same string as the adjacent pixel; After the traversal is completed, the area formed by the pixels corresponding to the elements in the string list that have the same string and are not the first string is determined as the light area.
6. The method according to claim 5, characterized in that, The light area filtering criteria include at least a distance threshold. Based on the user-defined light area filtering criteria, a target light area that meets the filtering criteria is selected from multiple light areas, including: Calculate the center position of each of the light areas; Randomly select one of the multiple light regions as a sample; Calculate the distance from the center of each light area to the center of the sample; Select the target light area from the light areas whose distance is less than a preset distance threshold.
7. The method according to claim 6, characterized in that, The light area filtering criteria also include light area size restrictions and light rejection methods, filtering target light areas from light areas whose distance is less than a preset distance threshold, including: Candidate light areas that meet the light area size restriction conditions are selected from light areas whose distance is less than the preset distance threshold; According to the preset elimination strategy, light areas are eliminated from the candidate light areas, and the light areas that are not eliminated are determined as target light areas.
8. The method according to any one of claims 3-7, characterized in that, Generating a static black-and-white mask image with the same resolution as the original light map, where the white areas correspond one-to-one with the target light areas, includes: Generate a black image with the same resolution as the original light map; Obtain the pixel coordinates of the target light area in the original light map; The black pixels corresponding to the pixel coordinates in the black image are modified to white pixels to obtain a static black and white mask image that includes white areas.
9. The method according to any one of claims 3-7, characterized in that, Based on the UV coordinates of the original light map and the configuration parameters, a stripe pattern including dynamically flowing black and white stripes is generated, including: The UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates; The periodic function value is calculated on the horizontal component of the processed uv coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters. The periodic function value is then graphically represented to obtain a stripe pattern including dynamic flowing black and white stripes. The periodic function value is between 0 and 1, representing a gradient from black to white, and between -1 and 0, representing black.
10. The method according to claim 9, characterized in that, The UV coordinates of the original light map are scaled, rotated, and restored to obtain the processed UV coordinates, including: The UV coordinates of the original light map are transformed from a first range to a second range to obtain the first UV coordinates, where the first range is from 0 to -1 and the second range is from -1 to -1. Multiply the first uv coordinates by the preset rotation rectangle to obtain the second uv coordinates after rotation around the center point; The second UV coordinates are restored from the second range to the first range to obtain the processed UV coordinates.
11. The method according to claim 10, characterized in that, The periodic function value is calculated for the horizontal component of the processed UV coordinates using a preset periodic function and the stripe density factor, time factor, and stripe flow velocity factor in the configuration parameters, including: Calculate the value of the periodic function Y using the following expression: Y = f(Rotate_UV_x × C + t × V); F() is a periodic function, Rotate_UV_x is the horizontal component of the preprocessed uv coordinates, C is the stripe density factor, t is the time factor, and V is the stripe flow velocity factor.
12. The method according to any one of claims 2-7, characterized in that, The static black-and-white mask image is mixed with the stripe image to obtain a dynamic black-and-white mask image, including: The static black and white mask image is multiplied by the stripe image to obtain the dynamic black and white mask image.
13. A lighting effect processing device for a virtual model, characterized in that, include: The original lighting map and configuration parameter acquisition module is used to acquire the original lighting map of the virtual model and the user's configuration parameters. The original lighting map includes lighting areas. The dynamic black and white masking image generation module is used to generate a dynamic black and white masking image based on the original light image and the configuration parameters. The dynamic black and white masking image randomly and dynamically presents multiple white areas, and each white area is the target light area to be implemented with the flashing light effect. The overlay module is used to overlay the dynamic black and white mask image with the original light image to obtain a target light image. In the target light image, the brightness of the target light area corresponding to the white area increases, while the brightness of the target light area corresponding to the black area remains unchanged. The texturing module is used to apply the target light map to the virtual model to obtain a virtual model with a random light flashing effect.
14. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the lighting effect processing method of the virtual model according to any one of claims 1-12.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the lighting effect processing method of the virtual model according to any one of claims 1-12.