Display method and device, electronic equipment and readable storage medium
By dynamically adjusting the light and shadow effects of the surface plants at different perspectives, the problem of the surface plants' point light source feedback does not adjust with the change of viewing angles, and the correct light and shadow feedback and performance optimization are achieved.
Patent Information
- Application Number
- CN202411569701.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-11-05
AI Technical Summary
The point light feedback of the surface plant will not be adjusted accordingly with the dynamic changes in the game environment, resulting in the problem of point light feedback leaks when the player's perspective changes.
By determining the spatial information and viewing angle transformation information of each pixel in the face sheet plant at the first viewing angle and its spatial information at the second viewing angle; combining the preset point light source information in the virtual space, the illumination direction and illumination distance of the point light source to each pixel are calculated; then light and shadow correction information is generated based on these information, and the light and shadow effect of each pixel is dynamically adjusted.
It realizes that the point light source feedback of the dough plant can have correct light and shadow feedback from different players' perspectives, expands the application scenarios of the dough plant, and significantly reduces the overall performance overhead of the scene while ensuring the artistic effect.
Smart Images

Figure CN119701349A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game technology, and in particular to a display method, device, electronic device and readable storage medium. Background Art
[0002] When building game scenes, in order to enhance the immersion and realism of the game world, plant models are used to simulate the morphology of plants in nature (such as trees, shrubs, flowers, etc.). However, plant models present plant details through a series of polygonal patches, and each polygon requires vertex shading, lighting calculation, and texture mapping, which not only consumes a lot of GPU resources, but also makes the rendering speed of plant models slow.
[0003] In order to quickly arrange the scene or optimize rendering performance, for some background plants that are far away from the player's field of vision or do not require player interaction, billboard plants are usually used instead of mesh plants. In order to provide better visual effects for the player's line of sight, calculation logic is usually added to the shader. When the position or direction of the virtual camera changes, the calculation logic in the shader dynamically adjusts the rotation of the billboard model according to the change in the position or direction of the virtual camera, so that the side of the billboard model with the texture map always faces the position and direction of the camera.
[0004] Since the patch plant is a texture map that is applied to the patch model by capturing the rendering result of the model plant at a specific perspective, the visual performance of the patch plant in the game is static. The point light feedback of the patch plant will not be adjusted accordingly with the dynamic changes of the in-game environment, so when the patch model rotates according to the change of the position or direction of the virtual camera, the point light feedback of the patch plant is prone to be exposed. Summary of the invention
[0005] The present application provides a display method, device, electronic device, and readable storage medium, which solves the problem that the point light source feedback of patch plants will not be adjusted accordingly with the dynamic changes of the in-game environment.
[0006] In a first aspect, an embodiment of the present application provides a display method.
[0007] The virtual space includes at least one sheet of plants, and the sheet of plants rotates synchronously with the change of viewing angle; the method includes:
[0008] Determine second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0009] According to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle;
[0010] Determine light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0011] According to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the first light and shadow information corresponding to each pixel in the patch plant is changed to form the light and shadow effect of the patch plant at the second viewing angle. The first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0012] In a second aspect, an embodiment of the present application further provides a display device, wherein the virtual space includes at least one sheet of plants, and the sheet of plants rotates synchronously with the change of viewing angle; the device includes:
[0013] A second spatial information determination module is used to determine the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0014] An illumination direction and illumination distance determination module, used to determine the illumination direction and illumination distance of each pixel in the patch plant from the point light source at the second viewing angle according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space;
[0015] a light and shadow correction information determination module, configured to determine the light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0016] A light and shadow effect determination module is used to change the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, so as to form the light and shadow effect of the patch plant at the second viewing angle, wherein the first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0017] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0018] Processor; and
[0019] The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method described in the first aspect is executed.
[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a data processing program, which is executed by a processor to perform the method described in the first aspect.
[0021] Compared with the prior art, this application has the following advantages:
[0022] A display method provided by an embodiment of the present application determines the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle. That is, the spatial information of each pixel in the patch plant is rotated accordingly according to the rotation of the patch plant generated according to the player's viewing angle. According to the second spatial information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle are determined; according to the second spatial information, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle, the light and shadow correction information of each pixel in the patch plant at the second viewing angle is determined; that is, the light and shadow correction information is generated according to the second spatial information of each pixel in the patch plant after rotation and the light source information of the preset point light source. Finally, the first light and shadow information corresponding to each pixel in the patch plant is changed according to the light and shadow correction information of each pixel in the patch plant under the second viewing angle, so as to form the light and shadow effect of the patch plant under the second viewing angle, and the first light and shadow information is the color presented by each pixel in the patch plant under the first viewing angle. That is, the light and shadow effect of each pixel of the patch plant under the first viewing angle is corrected by the light and shadow correction information, so as to obtain the light and shadow effect of each pixel of the patch plant under the second viewing angle after the patch plant rotates following the player's viewing angle. This method can obtain the light and shadow effect of each pixel of the patch plant under different viewing angles, that is, the shading data, in real time according to the player's viewing angle, so that the point light source of the patch plant can have correct light and shadow feedback under different player viewing angles, which greatly expands the application scenarios of the patch plant. At the same time, it is no longer necessary to use model plants near the point light source in order to avoid mistakes, and the overall performance overhead of the scene is significantly reduced while ensuring the artistic effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of using a faceted plant to replace a model plant provided in an embodiment of the present application;
[0024] Figure 2 The present application provides a schematic diagram of obtaining the incoming direction of light for each pixel in a plant in a first viewing angle, provided in an embodiment of the present application;
[0025] Figure 3 It is a schematic diagram of a BentNormal algorithm provided in an embodiment of the present application;
[0026] Figure 4 is a schematic diagram of a bounding box of a plant model provided in an embodiment of the present application;
[0027] Figure 5 is a schematic diagram of an image of a plant model at a first viewing angle provided in an embodiment of the present application;
[0028] Figure 6 Is for Figure 5 Schematic diagram of the image after BentNormal conversion of the pixels of the plant in the middle patch;
[0029] Figure 7 is a schematic diagram of point light source information provided by an embodiment of the present application;
[0030] Figure 8 This is a schematic diagram of an interface of a tool for setting point light source information provided in an embodiment of the present application;
[0031] Fig. 9 This is a schematic diagram of an interface for previewing an adjustment range provided in an embodiment of the present application;
[0032] Fig.10 This is a schematic diagram of an interface for operating a tool for setting light source information provided in an embodiment of the present application;
[0033] Fig.11 It is a flowchart of a display method provided by an embodiment of the present application;
[0034] Fig.12 This is a schematic diagram of a point light source feedback from a player's first-person perspective provided in an embodiment of the present application;
[0035] Fig.13 This is a method provided in the embodiments of the present application. Fig.12 A schematic diagram of feedback information of a point light source of a patch plant obtained according to the display method in the present application when the viewing angle changes from front to back;
[0036] Fig.14 This is a method provided in the embodiments of the present application. Fig.12 A schematic diagram of feedback information of a point light source of a patch plant obtained according to the display method in the present application when the viewing angle changes from front to right;
[0037] Fig.15 is a structural block diagram of a display device provided in an embodiment of the present application;
[0038] Fig.16 It is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0040] It should be noted that the terms "first", "second", "third", etc. in the claims, description and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having" and their variants are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] When building game scenes, in order to enhance the immersion and realism of the game world, plant models are used to simulate the morphology of plants in nature (such as trees, shrubs, flowers, etc.). However, plant models present plant details through a series of polygonal patches, and each polygon requires vertex shading, lighting calculation, and texture mapping, which not only consumes a lot of GPU resources, but also makes the rendering speed of plant models slow.
[0042] In order to quickly arrange the scene or optimize rendering performance, for some background plants that are far away from the player's field of view or do not require player interaction, Decals are usually used instead of MeshPlants. Figure 1 As shown in FIG. 1 , a schematic diagram of using a faceted plant to replace a model plant is provided in an embodiment of the present application, such as Figure 1 As shown in (a), the position, direction and field of view (FOV) of the virtual camera are determined according to the player's perspective or the ideal observation angle. After the position, direction and field of view of the virtual camera are determined, the virtual camera captures the image of the plant model under a specific perspective, such as Figure 1 (b) shows that Figure 1 The image of the plant model is obtained by the position, direction and field of view of the virtual camera in (a). Figure 1 The image shown in (b) is applied to the patch model as a texture map. Figure 1 (c) as shown.
[0043] In order to provide players with better visual effects, calculation logic is usually added to the shader. When the position or direction of the virtual camera changes, the calculation logic in the shader dynamically adjusts the rotation of the patch model according to the change in the position or direction of the virtual camera, so that the side of the patch model with the texture map always faces the position and direction of the camera. Since the patch plant is the rendering result of the captured model plant at a specific perspective applied to the patch model as a texture map, the visual performance of the patch plant in the game is static and will not be adjusted accordingly with the dynamic changes in the in-game environment. When the patch model is rotated according to the change in the position or direction of the virtual camera, the appearance of the patch plant is prone to problems.
[0044] For example, if street lamps (point light sources) are placed around the patch plants, the patch plants will not be partially brightened due to the illumination of the street lamps. In order to provide point light source feedback after street lamps (point light sources) are placed around the patch plants, the existing technology is: point light sources are placed near the model plants in advance, and the image of the plant model captured by the virtual camera at a specific viewing angle will have the feedback of the point light source. However, in this method, the feedback of the point light source is fixed when the patch plants are obtained. When the patch model rotates according to the change of the position or direction of the virtual camera, the problem of the feedback of the point light source will appear. For example, in the current game scene, the player is in front of the patch plant, and the point light source is located on the right side of the model plant. The image obtained is that the corresponding right part of the plant is illuminated. When the player passes through the patch plant and reaches the back of the patch plant, the patch plant rotates with the player's movement, and the feedback of the patch plant point light source will not be adjusted with the rotation of the patch plant, causing errors in the feedback of the patch plant point light source.
[0045] Alternatively, use the game engine to build point light feedback, and bake the built point light feedback into the patch plant. However, the feedback of adding point light to the patch plant by baking is also pre-calculated during the rendering process, and will not change dynamically as the objects in the scene rotate or move when the game or application is running. If the position or direction of the objects in the game scene changes, the actual lighting effect may not be consistent with expectations.
[0046] In order to solve the above problems in the related art, the embodiment of the present application provides a display method. The execution subject of the solution provided by the present application can be an electronic device, which can be a desktop computer, a laptop computer, a mobile device, a smart watch, a smart TV, a tablet computer, a server, etc., or other devices with data processing and display functions.
[0047] The display method provided in this application can be used to obtain feedback information of point light sources from different perspectives of players in real time.
[0048] Use 3D modeling software (such as Blender, Maya, 3ds Max, Houdini, etc.) or software specifically used for plant modeling (such as Speed Tree, Plant Factory, etc.) to create plant models. Add textures to the created plant models. Use the rendering engine in the 3D modeling software (such as Cycles or EEVEE in Blender, Mantra in Houdini, etc.) to give the plants a realistic appearance, lighting scene, etc., and obtain the created plant models.
[0049] After the plant model is created, an image of the plant model at the first perspective is obtained. When obtaining the image of the plant model at the first perspective, the position, direction, and field of view (FOV) of the virtual camera are first determined, and the virtual camera is adjusted according to the determined position, direction, and field of view of the virtual camera, so that the virtual camera is at the first perspective, and the image of the plant model at the first perspective is captured.
[0050] It should be noted that in the embodiments of the present application, the first perspective can be the perspective actually seen by the player during the game, or it can be a perspective set to facilitate the game experience or plot development (such as the optimal perspective, narrative perspective, and tactical perspective, etc.).
[0051] The position of the virtual camera is the three-dimensional space point where the virtual camera is placed in the game coordinate system (such as the Cartesian coordinate system or the screen coordinate system), that is, the X, Y, and Z coordinate values. The direction of the virtual camera can be defined by the rotation angle, that is, the rotation on the three axes (X, Y, and Z), including the yaw angle (Yaw), pitch angle (Pitch), and roll angle (Roll). Or by calculating the vector from the position of the virtual camera to the plant model and using the vector as the forward vector of the virtual camera.
[0052] In some embodiments, the plant model is photographed at a first viewing angle to obtain an image corresponding to the plant model at the first viewing angle; the image corresponding to the plant model at the first viewing angle is a patch plant. The color of each pixel in the patch plant at the first viewing angle is extracted to obtain first light and shadow information of each pixel of the patch plant.
[0053] In the embodiment of the present application, the first light and shadow information refers to various attributes related to color, including but not limited to the numerical representation of color (such as RGB value). Among them, RGB value is a numerical representation of color, which is composed of three components: red (Red), green (Green), and blue (Blue), and the value range of each component is usually from 0 to 255. For example, the RGB value of pure red is (255,0,0).
[0054] The first light and shadow information of each pixel of the patch plant may be obtained from the image of the plant model at the first viewing angle, or may be obtained by statistically analyzing the pixel distribution of each pixel on the patch plant at the first viewing angle in each color channel. That is, the BGR color space of each pixel in the patch plant at the first viewing angle is read, the BGR color space of each pixel in the patch plant at the first viewing angle is converted to the RGB color space, and the distribution of pixel values is calculated for each color channel to obtain the first light and shadow information of each pixel in the patch plant at the first viewing angle.
[0055] It should be noted that before extracting the first light and shadow information of each pixel of the plant in the first perspective, the image of the plant model in the first perspective can be preprocessed, including: (1) cropping, removing the background in the image and retaining only the plant part. (2) scaling, scaling the image to a preset size for easy processing. (3) filtering, using Gaussian filtering or other denoising filters to reduce noise in the image.
[0056] In some embodiments, rays are emitted uniformly on one side of the plant model corresponding to the first viewing angle, the rays collide with the plant model, and the BentNormal algorithm is executed at the collision point to obtain first spatial information of each pixel in the patch plant at the first viewing angle.
[0057] In an embodiment of the present application, the first spatial information includes the incoming direction of light for each pixel in the patch plant at the first viewing angle. To ensure the feedback of the subsequent point light source, when taking pictures of the plant model, no additional lighting effects are added or the lighting conditions are changed, and the ambient light in the virtual scene is directly used to take pictures. Among them, not adding additional lighting effects means that no additional lamps are used to enhance or change the lighting during the image acquisition process, such as flash, soft box, spotlight and other equipment will not be used to illuminate the plant model. Ambient light refers to the natural lighting conditions at the shooting scene, such as natural light in the room, daylight outside, or indoor lights. The first spatial information includes: (1) Brightness, which refers to the brightness of each pixel, usually expressed in grayscale values. (2) Shadow, which refers to the darker area caused by the light source being blocked. The shape and relative position of the pixel can be identified by the shadow. (3) Highlight, which refers to the bright spot on the surface of each pixel of the object that reflects strong light, can reveal the smoothness and reflective properties of the surface of each pixel. By analyzing the shadows and highlights in the image, the incoming direction of the light can be inferred.
[0058] Obtaining the first spatial information of each pixel of the patch plant under the first perspective can also be obtaining the occlusion of each pixel in the patch plant, that is, the visibility of each pixel relative to other pixels or light sources, which is mainly used to represent the occlusion effect of each pixel, such as shadow and indirect lighting. The occlusion information includes: (1) Depth information, which indicates the distance of each pixel from the camera. Through the depth information, it can be determined which pixels are occluded by other objects, thereby determining which parts should be invisible. (2) Shadow mapping, by calculating the depth information of the scene from the perspective of the light source, and then comparing the depth of each pixel with the depth value in the shadow mapping during rendering to determine whether the pixel is in the shadow. (3) Global illumination (GI), simulating multiple bounces of light in the scene, including direct lighting and indirect lighting. That is, in this application, the occlusion information is used to obtain whether the light path of each pixel is blocked, thereby obtaining the incoming direction of the light.
[0059] The incoming direction of each pixel light refers to the average direction of the light emitted by the point light source, reaching each pixel surface in the patch plant under the first perspective without being blocked by other objects (or geometric elements). Specifically, it can be: performing illumination sampling in multiple directions at each pixel in the patch plant under the first perspective, that is, emitting light along the selected direction at each pixel, and checking whether the light emitted in the selected direction encounters an obstacle. If an obstacle is encountered, the direction is marked as blocked; if not, it is marked as unblocked. By taking the average direction of the light direction of each pixel surface in the patch plant that is not blocked by other objects (or geometric elements), the incoming direction of the light for each pixel in the patch plant under the first perspective is obtained.
[0060] like Figure 2 As shown, it is a schematic diagram of obtaining the incoming direction of each pixel light in the plant in the first viewing angle according to an embodiment of the present application. Figure 2 (a) is a schematic diagram of a 12*12 parallel ray detection, such as Figure 2 (b) is another illustration of a 12*12 parallel ray detection. A large number of parallel and dense rays are uniformly emitted on one side of the plant model. The rays collide with the plant model, and the BentNormal algorithm is executed at the collision point to obtain the main direction of the light transmitted to the pixel on the plant model.
[0061] like Figure 3 As shown, it is a schematic diagram of a BentNormal algorithm provided in an embodiment of the present application, the detection ray points to Sample: x, Sample: x is the pixel of the plant to be detected, Normal: n iis the vertical vector of the plane where the pixel of the plant to be detected is located, and Ray: w is the visibility of the current pixel point x in the w direction.
[0062] A hemisphere is constructed with Normal as the center, and each pixel in the patch plant under the first perspective is used as the starting point. A large number of rays are randomly emitted in the hemisphere area. The rays that are not blocked by the patch plant itself are counted, and the vector obtained by taking their average direction is the BentNormal of each pixel of the patch plant under the first perspective: N(x i ).
[0063] For example, when maxangle (cone size) is Pi (i.e. 180°), a ray is emitted in the hemisphere, and the BentNormal of the collision point is calculated using the vex function:
[0064] BentNormal=sample_direction_cone(vector center,float maxangle,vector2 u)(1)
[0065] Among them, vector center is the center direction of the cone; float maxangle is the size of the cone; vector2u is the specific emission direction of the detection ray, and u is a two-dimensional random floating point number to meet the needs of random ray emission; sample_direction_cone() generates a random direction within the cone based on the given center direction center and maximum half angle maxangle, as well as two random numbers u.
[0066] It should be noted that BentNormal (the incoming direction of the light) is a unit vector, so its length is 1.
[0067] In some embodiments, a pixel image recording the first spatial information is obtained, where the pixel image is obtained by recording the first spatial information of each pixel in the patch plant at the first viewing angle in the pixels of the pixel image.
[0068] In an embodiment of the present application, after obtaining the incoming direction of the light of each pixel in the patch plant, the incoming direction of the light of each pixel is transmitted to the game engine. At present, the transmission medium for transmitting the incoming direction of the light calculated in Houdini to the game engine can be a picture. Since the incoming direction of the light of each pixel in the patch plant under the first perspective is a one-to-one correspondence with the dense parallel rays previously emitted, each pixel corresponds to a parallel detection ray, and the incoming direction of the light of the collision point collected is stored as a pixel color value. That is, the incoming direction of the light of each pixel in the patch plant under the first perspective is converted into a pixel picture recording the first spatial information. Since the incoming direction of the light of each pixel in the patch plant under the first perspective is a three-dimensional space vector, there are positive and negative, and the pixel color value has only positive values, each component value of the incoming direction of the light is first added by 1 and then multiplied by 0.5, and the value range of -1 to 1 is mapped to 0 to 1, so that the incoming direction of the light can be stored with the pixel color value.
[0069] In some embodiments, in order to improve the utilization rate of pixels in the image, the patch plant fills the image in the width or height direction. When acquiring the plant model at the first viewing angle, the position of the virtual camera can be determined first, so that the patch plant at the first viewing angle fills the image in the width or height direction.
[0070] When determining the position of the virtual camera, such as Figure 4 As shown in FIG. 1 , a schematic diagram of a bounding box of a plant model provided in an embodiment of the present application is provided. A bounding box can be created in a three-dimensional software, and the bounding box can wrap the entire plant model while being as small as possible. Figure 4 As shown, the bounding box of the plant model is a cuboid. By measuring the bounding box, the length, width and height information of the plant model can be obtained. The position of the virtual camera is adjusted according to the length, width and height information of the plant model so that the plant model fills the image as much as possible.
[0071] When adjusting the position of the virtual camera according to the length, width and height information of the plant model, since the virtual camera adopts an orthogonal mode, it is not sensitive to the distance of the plant model. Therefore, when adjusting the position of the virtual camera, only the left-right and up-down offsets of the image of the plant model obtained by the virtual camera from the first perspective are considered. Therefore, the left-right and up-down offsets of the virtual camera are calculated based on the length, width and height information of the plant model, so that the patch plant fills the image of the plant model from the first perspective in width or height.
[0072] The offset of the virtual camera in the left and right directions and the up and down directions is calculated by the length, width and height information of the plant model, which can be obtained by obtaining the center point of the plant model bounding box, the maximum point of the plant model (maximum x, maximum y and maximum z) and the minimum point of the plant model (minimum x, minimum y and minimum z). The maximum height of the plant model in the up and down directions and the maximum width of the plant model in the left and right directions are determined based on the maximum point of the plant model (maximum x, maximum y and maximum z) and the minimum point of the plant model (minimum x, minimum y and minimum z). It is judged whether the maximum height of the plant model in the up and down directions is greater than the maximum width of the plant model in the left and right directions. If the maximum height of the plant model in the up and down directions is greater than the maximum width of the plant model in the left and right directions, the offset of the virtual camera in the left and right directions is set to the horizontal coordinate value of the center point of the plant model bounding box; the orthogonal size of the virtual camera is the maximum height of the plant model in the up and down directions; the offset of the virtual camera in the up and down directions is the maximum height of the plant model in the up and down directions minus the maximum width of the plant model in the left and right directions, plus the horizontal coordinate value of the center point of the plant model bounding box. If the maximum height of the plant model in the up and down directions is less than or equal to the maximum width of the plant model in the left and right directions, the offset of the virtual camera in the up and down directions is set to the horizontal coordinate value of the center point of the plant model bounding box; the orthogonal size of the virtual camera is the maximum width of the plant model in the left and right directions, and the offset of the virtual camera in the left and right directions is 0.
[0073] For example, after calculating the offset of the virtual camera in the left-right direction and the up-down direction based on the length, width and height information of the plant model to determine the position of the virtual camera, Figure 4 The plant model in the image is photographed, and the image of the plant model obtained from the first perspective is as follows Figure 5 As shown, Figure 5 A schematic diagram of an image of a plant model at a first viewing angle provided in an embodiment of the present application, Figure 5 In the first-person perspective, the plant model fills the image in the left and right directions. Figure 5 The patch plant at the first viewing angle shown in the figure uses 2048*2048 parallel rays to detect and calculate the incoming direction of the light of the pixel of the patch plant at the first viewing angle, and records the incoming direction of the light of each pixel in the patch plant at the first viewing angle in the pixel of the pixel picture. The obtained picture is as follows Figure 6 As shown, Figure 5 Schematic diagram of the image after the direction of light input to the pixel of the plant in the middle patch is converted. Figure 6 In the picture shown, the color value of each pixel (or fragment) represents a direction vector (i.e., normal), which indicates the average direction of the pixel that is not blocked by other parts of the plant model itself, that is, the incoming direction of light for each pixel in the patch plant from the first perspective.
[0074] It should be noted that Figure 6 The pictures shown are for illustration only and are not intended to Figure 6 The images shown are limited to black and white grayscale images. Figure 6 The pictures shown may also be pictures in other colors.
[0075] In some embodiments, a point light source may be preset in a virtual scene, and properties such as the position, radius, color, and brightness of the point light source may be set.
[0076] like Figure 7 As shown in FIG. 1 , a schematic diagram of a point light source information provided by an embodiment of the present application is shown. In a virtual scene (such as a UE4 scene), each point light source can be set as custom primitive data. The custom primitive data can be read in a shader to achieve various custom effects. The custom primitive data includes: (1) the world coordinates of the point light source, such as Figure 7 The three data 0, 1, and 2 in the formula are used to represent the world coordinates of the point light source that affects it. (2) The radius of the point light source, such as Figure 7 The data No. 3 in the figure represents the radius of the point light source. (3) The color of the point light source, such as Figure 7 The three data 4, 5 and 6 in the above table represent the color of the point light source. (4) The brightness of the point light source, such as Figure 7 The data No. 7 in represents the brightness of the point light source.
[0077] For example, after setting the custom primitive data of the above point light source, in the shader of the patch plant, check the [Use Custom Primitive Data] option on the variable to read the previously marked custom primitive data.
[0078] It should be noted that since there are usually many plants in the game scene, in order to quickly set the point light source information of each plant, a matching point light source information setting tool BP AutoSet NightBillboard Params is developed in this application, such as Figure 8 As shown in the figure, it is a schematic diagram of the interface of a tool for setting point light source information provided in an embodiment of the present application. Figure 8 The tool will analyze the point light sources in the scene and determine their positions. Otherwise, the pivot position of the selected object will be used as the light source position. Click Figure 8 The "Preview Adjustment Range" in the panel will take the light source position as the center and the adjustment range set in the panel as the radius. The engine's spherical ray detection function will be used to create a preview sphere frame in the scene to help users determine which plants are within the adjustment range. Fig. 9 The figure is a schematic diagram of an interface for previewing an adjustment range provided in an embodiment of the present application. Click Figure 8 In "Run", the tool will use the determined light source position as the center and the adjustment range of the panel settings as the radius. It will use the engine's spherical ray detection function and the shdaer type to detect and filter the patch plants within the range, so as to batch set the various parameters on the tool panel to the point light source information of the patch plants. Fig.10 The figure is a schematic diagram of an interface for running a tool for setting light source information provided in an embodiment of the present application.
[0079] It should be noted that when using the tool for setting light source information, the user does not need to care about the point light source information set on the patch plants. Just use the street lamp as the anchor point to batch, large-scale and quickly adjust the point light source information of all patch plants near the street lamp, thereby quickly adjusting the point light source feedback effect of the patch plants.
[0080] When determining the coordinates of a point light source, if Figure 8 If "Automatically identify light source" is checked, the selected object will be traversed, the light source component will be found, and its coordinates will be taken as the light source coordinates; if it is not checked or the light source component is not found, the selected object will be directly taken as the light source coordinates;
[0081] When setting the point light source information of the plant patch, use the Multi Sphere Trace ForObjects function provided by the engine, with the point light source coordinates as the center, "Adjustment Range" as the detection radius, and World Static as the detection type. Detect all meshes within the range and judge the material shader of the mesh. If the shader has the "UseFake Point Light" parameter, the mesh is considered to be a plant patch that needs to set the point light source information. For each plant patch within the range, the light source coordinates are mapped to Figure 7 Parameters 0, 1, and 2 of the midpoint light source, such as the light source coordinates can be set to Figure 7 Parameters 0, 1, and 2 of the midpoint light source. The radius of the light source is set to correspond to Figure 7 Parameter No. 3 in, for example, you can set the radius of the light source to Figure 7 Parameter 3 in. The light source color corresponds to Figure 7 Parameters 4, 5, and 6 in the example can set the light source color to Figure 7 Parameters 4, 5, and 6 in the light source intensity correspond to Figure 7 Parameter No. 7 in sets the light intensity to Figure 7 Parameter No. 7 in .
[0082] It should be noted that the strength, range, color, and position of point light sources can be quickly adjusted through the above tools, which can not only quickly respond to design needs and creative inspiration, but also accurately present the required atmosphere and effects in different scenes and situations. Players can experience more vivid, delicate, and infectious visual effects.
[0083] like Fig.11 FIG. 1 is a flow chart of a display method according to an embodiment of the present application, wherein the method comprises:
[0084] Step S1101, determining second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0085] In the implementation of this application, the patch plants in the game scene are dynamically adjusted according to the player's perspective, so that the side of the patch plant with the texture map always faces the player. When the player's position in the game scene changes, the player's perspective relative to the patch plant will change. According to the change in the player's perspective, the patch plants in the scene are dynamically adjusted. After the adjustment, the world coordinates of the adjusted patch plants are obtained.
[0086] When obtaining the world coordinates, you can use the "World Position" node in the material editor to obtain the position of the current pixel in the world coordinate system.
[0087] It should be noted that the world coordinate system is an absolute coordinate system of the system, which provides a reference for the position of all points on the screen. Before the user coordinate system is established, the coordinates of all points on the screen are determined by the origin of the world coordinate system. The world coordinate system is not only used for graphic conversion, but also supports conversion operations such as scaling, translation, rotation, deformation, and projection.
[0088] When the position of the player in the virtual environment changes, the patch plant rotates accordingly with the perspective of the virtual character, and the player's perspective changes from the first perspective to the second perspective. According to the transformation from the first perspective to the second perspective, the rotation perspective of the player in the perspective transformation process is determined. A rotation matrix is created according to the rotation perspective, and the first spatial information of each pixel in the patch plant at the first perspective is rotated by the rotation matrix to obtain the second spatial information of each pixel in the patch plant at the second perspective.
[0089] Among them, the first spatial information of each pixel in the patch plant at the first viewing angle is rotated by the rotation matrix, and the first rotation information corresponding to the first spatial information of each pixel in the patch plant at the first viewing angle is multiplied by the rotation matrix to obtain the second rotation matrix corresponding to the second spatial information of each pixel in the patch plant at the second viewing angle. The first spatial information of the patch plant is rotated according to the second rotation matrix to obtain the second spatial information of each pixel in the patch plant at the second viewing angle. That is, the first spatial information of the patch plant before rotation is rotated according to the rotation generated by the patch plant following the player's perspective, so that the spatial information matches the rotation of the patch plant.
[0090] Step S1102, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space;
[0091] In an embodiment of the present application, when the position of the player in the virtual environment changes, each pixel in the patch plant follows the corresponding rotation generated by the perspective of the virtual character, and the second spatial information of each pixel in the patch plant after rotation at the second perspective is obtained. Among them, the second spatial information includes the second coordinates of each pixel in the patch plant after rotation; the first spatial information includes the first coordinates of each pixel in the patch plant before rotation. The light source information of the preset point light source in the virtual space includes the third coordinates of the set point light source. The second coordinates of each pixel in the patch plant after rotation at the second perspective are subtracted from the third coordinates of the set point light source to obtain the irradiation direction of the point light source to each pixel in the patch plant and the irradiation distance from the point light source to each pixel in the patch plant.
[0092] Step S1103, determining light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0093] In an embodiment of the present application, the second spatial information includes the incoming direction of light for each pixel in the patch plant at the second viewing angle. Based on the proximity between the incoming direction of light for each pixel contained in the second spatial information and the illumination direction of each pixel in the patch plant at the second viewing angle, the first light and shadow correction information of each pixel in the patch plant at the second viewing angle is determined. Among them, the proximity between the incoming direction of light for each pixel and the illumination direction of each pixel in the patch plant can be determined based on the angle between the incoming direction of light and the illumination direction. The smaller the angle between the incoming direction of light and the illumination direction of a certain pixel, the greater the influence of the light source on the pixel, the larger the first light and shadow correction information of the pixel, and the brighter the surface of the pixel. The larger the angle between the incoming direction of light and the illumination direction of a certain pixel, the less the influence of the light source on the pixel, the smaller the first light and shadow correction information of the pixel, and the darker the surface of the pixel.
[0094] According to the illumination distance of the point light source to each pixel in the patch plant, the second light and shadow correction information of each pixel in the patch plant at the second viewing angle is determined. It can be that the greater the illumination distance of the point light source to each pixel in the patch plant, the smaller the second light and shadow correction information of each pixel in the patch plant at the second viewing angle is, which means that the pixel is less affected by the light source, the second light and shadow correction information of the pixel is smaller, and the surface of the pixel is darker. The smaller the illumination distance of the point light source to each pixel in the patch plant, the greater the second light and shadow correction information of each pixel in the patch plant at the second viewing angle is, which means that the pixel is more affected by the light source, the second light and shadow correction information of the pixel is larger, and the surface of the pixel is brighter.
[0095] The first light and shadow correction information and the second light and shadow correction information obtained above can be fused, such as multiplying the first light and shadow correction information and the second light and shadow correction information of each pixel point in the surface plant to obtain the light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
[0096] Step S1104, changing the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, so as to form the light and shadow effect of the patch plant at the second viewing angle, wherein the first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0097] In the embodiment of the present application, after obtaining the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the brightness of the light irradiated on each pixel in the patch plant is corrected according to the light and shadow correction information to obtain the corrected brightness of each pixel in the patch plant. The first light and shadow information corresponding to each pixel in the patch plant is changed with the corrected brightness of each pixel in the patch plant to obtain the light and shadow effect of the patch plant at the second viewing angle.
[0098] A display method provided by an embodiment of the present application determines the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle. That is, the spatial information of each pixel in the patch plant is rotated accordingly according to the rotation of the patch plant generated according to the player's viewing angle. According to the second spatial information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle are determined; according to the second spatial information, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle, the light and shadow correction information of each pixel in the patch plant at the second viewing angle is determined; that is, the light and shadow correction information is generated according to the second spatial information of each pixel in the patch plant after rotation and the light source information of the preset point light source. Finally, the first light and shadow information corresponding to each pixel in the patch plant is changed according to the light and shadow correction information of each pixel in the patch plant under the second viewing angle, so as to form the light and shadow effect of the patch plant under the second viewing angle, and the first light and shadow information is the color presented by each pixel in the patch plant under the first viewing angle. That is, the light and shadow effect of each pixel of the patch plant under the first viewing angle is corrected by the light and shadow correction information, so as to obtain the light and shadow effect of each pixel of the patch plant under the second viewing angle after the patch plant rotates following the player's viewing angle. This method can obtain the light and shadow effect of each pixel of the patch plant under different viewing angles, that is, the shading data, in real time according to the player's viewing angle, so that the point light source of the patch plant can have correct light and shadow feedback under different player viewing angles, which greatly expands the application scenarios of the patch plant. At the same time, it is no longer necessary to use model plants near the point light source in order to avoid mistakes, and the overall performance overhead of the scene is significantly reduced while ensuring the artistic effect.
[0099] In some embodiments, determining the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle includes:
[0100] Constructing a perspective transformation matrix according to the perspective transformation information;
[0101] Based on the perspective transformation matrix, the first spatial information of each pixel in the patch plant at the first perspective is transformed to obtain the second spatial information of each pixel in the patch plant at the second perspective.
[0102] In an embodiment of the present application, the rotation angle of the patch plant around each axis is obtained: a sub-rotation matrix corresponding to each axis is constructed for the rotation angle of the patch plant around each axis. All sub-rotation matrices are synthesized into a total rotation matrix to obtain a perspective transformation matrix. During the synthesis, the sub-rotation matrices can be multiplied to obtain a perspective transformation matrix. And the first spatial information of each pixel in the patch plant at the first perspective is converted into the second spatial information of each pixel in the patch plant at the second perspective through the perspective transformation matrix.
[0103] In some embodiments, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space includes:
[0104] Under the second viewing angle, determining the coordinate difference between the first coordinate of each pixel in the surface plant and the second coordinate of the preset point light source in the virtual space;
[0105] Determine the irradiation direction of the preset point light source to each pixel in the surface plant by using the coordinate difference;
[0106] The irradiation distance of the preset point light source to each pixel in the surface plant is determined by the coordinate difference.
[0107] In an embodiment of the present application, after obtaining the rotation of the patch plant following the player's perspective, the world coordinates of each pixel in the patch plant under the second perspective are obtained, and the world coordinates of each pixel in the patch plant are subtracted from the world coordinates of the point light source to obtain the coordinate difference between the first coordinate of each pixel in the patch plant and the second coordinate of the preset point light source in the virtual space, and the irradiation direction of the point light source to each pixel in the patch plant is determined based on the coordinate difference. The modulus length of the coordinate difference between the world coordinates of each pixel in the patch plant and the world coordinates of the point light source is obtained to obtain the irradiation distance of the preset point light source to each pixel in the patch plant.
[0108] In some embodiments, the light and shadow correction information of each pixel point in the patch plant at the second viewing angle is determined according to the light source information of the preset point light source in the virtual space and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle, including:
[0109] Determine first light and shadow correction information of each pixel point in the patch plant at the second viewing angle based on the similarity between the second spatial information corresponding to each pixel in the patch plant and the illumination direction;
[0110] Determine second light and shadow correction information of each pixel in the patch plant at the second viewing angle according to the ratio of the irradiation distance of the preset point light source to each pixel in the patch plant and the radius of the preset point light source;
[0111] The first light and shadow correction information and the second light and shadow correction information are multiplied, and the multiplication result is used as the light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
[0112] In the implementation of the present application, the similarity between the second spatial information of each pixel in the plant on the second viewing angle and the illumination direction can be obtained based on the dot product between the incoming direction of the light of each pixel in the plant on the viewing angle and the illumination direction. For example, the illumination direction is dot-multiplied with the incoming direction of the light after the rotation, and the result is returned based on the closeness between the incoming direction of the light of each pixel in the plant on the viewing angle after the rotation following the player's viewing angle and the illumination direction vector, wherein the returned result can be a value from -1 to 1.
[0113] It should be noted that the dot product is also called the inner product or scalar product of vectors, which is used to measure the angle between two vectors. The larger the result of the dot product, the closer the second spatial information of each pixel in the plant in the second viewing angle is to the illumination direction; the smaller the result of the dot product, the farther the second spatial information of each pixel in the plant in the second viewing angle is from the illumination direction. The larger the result of the dot product, the greater the influence of the light source on the pixel in the plant, and the brighter the pixel should be, and vice versa.
[0114] In an optional embodiment, a matching relationship between multiple dot product results of the second spatial information and the illumination direction and multiple first light and shadow correction information can be pre-constructed. After obtaining the dot product result of the second spatial information and the illumination direction, the first light and shadow correction information of each pixel in the surface plant is obtained according to the dot product result and the matching relationship.
[0115] Wherein, if the dot product result is 1, it means that the pixel point is completely facing the light, and the first light and shadow correction information is large. If the dot product result is -1, it means that the pixel point is completely facing the light or completely backlit, and the first light and shadow correction information is small.
[0116] It should be noted that when the angle between the illumination direction and the incoming direction of each pixel light exceeds 90°, the dot product result is clamped so that all values less than 0 are equal to 0. In this way, the brightness when the angle between the illumination direction and the incoming direction of each pixel light exceeds 90° is the minimum value.
[0117] The second spatial information may be the incoming direction of the light obtained above. Since the incoming direction of the light is a unit vector, the irradiation direction is also normalized to become a unit vector. In this way, when performing dot product calculation, the dot product result is more accurate.
[0118] It should be noted that the incoming direction of the light is transmitted to the game engine using the image as the transmission medium, so before performing the above calculations, the incoming direction of the light is restored. When restoring, each component in the image form is multiplied by 2 and then subtracted by 1, and reversely mapped from the pixel color value range of 0 to 1 back to the space vector range of -1 to 1.
[0119] The irradiation distance from the preset point light source to each pixel in the patch plant is divided by the radius of the preset point light source to obtain the ratio between the irradiation distance and the radius of the preset point light source. The second light and shadow correction information is determined according to the ratio between the irradiation distance and the radius of the preset point light source. When the ratio between the irradiation distance and the radius of the preset point light source is large, the second light and shadow correction information is small. When the ratio between the irradiation distance and the radius of the preset point light source is small, the second light and shadow correction information is large.
[0120] The first light and shadow correction information and the second light and shadow correction information are multiplied to obtain the light and shadow correction information of each pixel point in the patch plant at the second viewing angle.
[0121] In some embodiments, determining the second light and shadow correction information of each pixel in the patch plant at the second viewing angle by using the ratio of the irradiation distance of the preset point light source to each pixel in the patch plant to the radius of the preset point light source includes:
[0122] Subtracting the ratio of the irradiation distance of each pixel in the patch plant by the preset point light source to the radius of the preset point light source from the complete attenuation value to obtain a subtraction result;
[0123] A square operation is performed on the subtraction result to obtain second light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
[0124] In the embodiment of the present application, the illumination distance from the preset point light source to each pixel in the patch plant is divided by the radius of the preset point light source to obtain the ratio between the illumination distance and the radius of the preset point light source. The ratio result is clamped at [0, 1]. Assuming that the complete attenuation value is 1, the ratio result after clamping is subtracted from 1 to obtain a subtraction result. The subtraction result is squared to obtain the distance attenuation value of each pixel relative to the point light source, i.e., the second light and shadow correction information.
[0125] In some embodiments, the step of changing the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle to form the light and shadow effect of the patch plant at the second viewing angle includes:
[0126] Correcting the brightness of each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle to obtain the corrected brightness of each pixel in the patch plant;
[0127] The first light and shadow information corresponding to each pixel in the patch plant is superimposed with the corrected brightness of the preset point light source and the color information of the preset point light source to obtain the light and shadow effect of the patch plant at the second viewing angle.
[0128] In an embodiment of the present application, after obtaining the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the brightness of each pixel in the patch plant is corrected using the light and shadow correction information, which may be to multiply the light and shadow correction information with the brightness of a preset point light source to obtain the corrected brightness of each pixel in the patch plant. The corrected brightness of each pixel in the patch plant is multiplied by the first light and shadow information corresponding to each pixel in the patch plant and the color of the preset point light source to obtain the light and shadow effect of the patch plant at the second viewing angle.
[0129] like Fig.12 As shown in FIG. 1 , a schematic diagram of a point light source feedback of a player from a first-person perspective provided in an embodiment of the present application is shown. Assume that Fig.12 In the game, the player is in front of the patch plant, and the feedback information of the point light source is as follows Fig.12 When the player's perspective changes, such as from the front of the patch plant shown in 12 to the back of the patch plant, according to the display method provided by the present application, the feedback information of the point light source of the patch plant is obtained as shown in FIG. Fig.13 As shown, Fig.13 A method provided in the embodiment of the present application Fig.12Schematic diagram of feedback information of point light sources of patch plants obtained according to the display method in the present application when the perspective changes from the front to the back. When the player's perspective shifts from the front of the patch plant shown in 12 to the right of the patch plant, according to the display method provided by the present application, feedback information of point light sources of patch plants is obtained as shown in FIG. Fig.14 As shown, Fig.14 A method provided in the embodiment of the present application Fig.12 A schematic diagram of feedback information of a point light source of a patch plant obtained according to the display method in the present application when the viewing angle changes from front to right.
[0130] Corresponding to the display method provided in the embodiment of the present application, the embodiment of the present application further provides a display device, wherein the virtual space includes at least one sheet of plants, and the sheet of plants rotates synchronously with the change of the viewing angle; Fig.15 As shown, the device 1500 includes:
[0131] A second spatial information determination module 1501 is used to determine the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0132] The illumination direction and illumination distance determination module 1502 is used to determine the illumination direction and illumination distance of each pixel in the patch plant from the point light source at the second viewing angle according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space;
[0133] A light and shadow correction information determination module 1503 is used to determine the light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0134] The light and shadow effect determination module 1504 is used to change the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel point in the patch plant at the second viewing angle, so as to form the light and shadow effect of the patch plant at the second viewing angle, wherein the first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0135] In some embodiments, the second spatial information determination module is further configured to:
[0136] Constructing a perspective transformation matrix according to the perspective transformation information;
[0137] Based on the perspective transformation matrix, the first spatial information of each pixel in the patch plant at the first perspective is transformed to obtain the second spatial information of each pixel in the patch plant at the second perspective.
[0138] In some embodiments, the illumination direction and illumination distance determination module is further used to:
[0139] Under the second viewing angle, determining the coordinate difference between the first coordinate of each pixel in the surface plant and the second coordinate of the preset point light source in the virtual space;
[0140] Determine the irradiation direction of the preset point light source to each pixel in the surface plant by using the coordinate difference;
[0141] The irradiation distance of the preset point light source to each pixel in the surface plant is determined by the coordinate difference.
[0142] In some embodiments, the light and shadow correction information determination module is further used to:
[0143] Determine first light and shadow correction information of each pixel point in the patch plant at the second viewing angle based on the similarity between the second spatial information corresponding to each pixel in the patch plant and the illumination direction;
[0144] Determine second light and shadow correction information of each pixel in the patch plant at the second viewing angle according to the ratio of the irradiation distance of the preset point light source to each pixel in the patch plant and the radius of the preset point light source;
[0145] The first light and shadow correction information and the second light and shadow correction information are multiplied, and the multiplication result is used as the light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
[0146] In some embodiments, the light and shadow correction information determination module is further used to:
[0147] Subtracting the ratio of the irradiation distance of each pixel in the patch plant by the preset point light source to the radius of the preset point light source from the complete attenuation value to obtain a subtraction result;
[0148] A square operation is performed on the subtraction result to obtain second light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
[0149] In some embodiments, the light and shadow effect determination module is further used to:
[0150] Correcting the brightness of each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle to obtain the corrected brightness of each pixel in the patch plant;
[0151] The first light and shadow information corresponding to each pixel in the patch plant is superimposed with the corrected brightness of the preset point light source and the color information of the preset point light source to obtain the light and shadow effect of the patch plant at the second viewing angle.
[0152] In some embodiments, the apparatus further comprises:
[0153] The pixel picture acquisition module is used to acquire a pixel picture recording the first spatial information, wherein the pixel picture is obtained by recording the first spatial information of each pixel in the patch plant at the first viewing angle in the pixels of the pixel picture.
[0154] Corresponding to the display method provided in the embodiment of the present application, the embodiment of the present application also provides an electronic device. Fig.16 As shown, the electronic device includes: a processor 1601; and a memory 1602, which is used to store a program of a display method. After the electronic device is powered on and the program storing the display method is run by the processor, the following steps are performed:
[0155] Determine second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0156] According to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle;
[0157] Determine light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0158] According to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the first light and shadow information corresponding to each pixel in the patch plant is changed to form the light and shadow effect of the patch plant at the second viewing angle. The first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0159] Corresponding to the display method provided in the embodiment of the present application, the embodiment of the present application further provides a computer-readable storage medium storing a program of the display method, the program is executed by a processor to perform the following steps:
[0160] Determine second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0161] According to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle;
[0162] Determine light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0163] According to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the first light and shadow information corresponding to each pixel in the patch plant is changed to form the light and shadow effect of the patch plant at the second viewing angle. The first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0164] Corresponding to the display method provided in the embodiment of the present application, the embodiment of the present application further provides a computer program product, the program product comprising: a computer program, the computer program is stored in a readable storage medium, at least one processor of the electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device performs the following steps:
[0165] Determine second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle;
[0166] According to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle;
[0167] Determine light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle;
[0168] According to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the first light and shadow information corresponding to each pixel in the patch plant is changed to form the light and shadow effect of the patch plant at the second viewing angle. The first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
[0169] It should be noted that for the detailed description of the apparatus, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application, reference can be made to the relevant description of the method in the embodiments of the present application, which will not be repeated here.
[0170] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0171] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0172] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application.
[0173] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0174] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0175] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0176] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0177] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0178] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A display method, characterized in that: The virtual space includes at least one sheet of plants, and the sheet of plants rotates synchronously with the change of viewing angle; the method includes: Determine second spatial information of each pixel in the patch plant at the second viewing angle according to first spatial information of each pixel in the patch plant at the first viewing angle and viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle; According to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, determining the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle; Determine light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle; According to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, the first light and shadow information corresponding to each pixel in the patch plant is changed to form the light and shadow effect of the patch plant at the second viewing angle. The first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
2. The display method according to claim 1, characterized in that: The determining, according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, the second spatial information of each pixel in the patch plant at the second viewing angle comprises: Constructing a perspective transformation matrix according to the perspective transformation information; Based on the perspective transformation matrix, the first spatial information of each pixel in the patch plant at the first perspective is transformed to obtain the second spatial information of each pixel in the patch plant at the second perspective.
3. The display method according to claim 1, characterized in that: The step of determining, according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant under the second viewing angle includes: Under the second viewing angle, determining the coordinate difference between the first coordinate of each pixel in the surface plant and the second coordinate of the preset point light source in the virtual space; Determine the irradiation direction of the preset point light source to each pixel in the surface plant by using the coordinate difference; The irradiation distance of the preset point light source to each pixel in the surface plant is determined by the coordinate difference.
4. The display method according to claim 3, characterized in that: The determining, according to the light source information of the preset point light source in the virtual space and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle, light and shadow correction information of each pixel point in the patch plant at the second viewing angle comprises: Determine first light and shadow correction information of each pixel point in the patch plant at the second viewing angle based on the similarity between the second spatial information corresponding to each pixel in the patch plant and the illumination direction; Determine second light and shadow correction information of each pixel in the patch plant at the second viewing angle according to the ratio of the irradiation distance of the preset point light source to each pixel in the patch plant and the radius of the preset point light source; The first light and shadow correction information and the second light and shadow correction information are multiplied, and the multiplication result is used as the light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
5. The display method according to claim 4, characterized in that: The determining of the second light and shadow correction information of each pixel point in the patch plant at the second viewing angle by using the ratio of the irradiation distance of the preset point light source to each pixel in the patch plant to the radius of the preset point light source includes: Subtracting the ratio of the irradiation distance of each pixel in the patch plant by the preset point light source to the radius of the preset point light source from the complete attenuation value to obtain a subtraction result; A square operation is performed on the subtraction result to obtain second light and shadow correction information of each pixel point in the surface plant at the second viewing angle.
6. The display method according to claim 1, characterized in that: The step of changing the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle to form the light and shadow effect of the patch plant at the second viewing angle includes: Correcting the brightness of each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle to obtain the corrected brightness of each pixel in the patch plant; The first light and shadow information corresponding to each pixel in the patch plant is superimposed with the corrected brightness of the preset point light source and the color information of the preset point light source to obtain the light and shadow effect of the patch plant at the second viewing angle.
7. The display method according to claim 1, characterized in that: Before the step of determining the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, the method further includes: A pixel image recording the first spatial information is obtained, where the pixel image is obtained by recording the first spatial information of each pixel in the patch plant at the first viewing angle in the pixels of the pixel image.
8. A display device, characterized in that: The virtual space includes at least one sheet of plants, and the sheet of plants rotates synchronously with the change of viewing angle; the device includes: A second spatial information determination module is used to determine the second spatial information of each pixel in the patch plant at the second viewing angle according to the first spatial information of each pixel in the patch plant at the first viewing angle and the viewing angle transformation information between the first viewing angle and the second viewing angle, wherein the second viewing angle is a viewing angle transformed on the basis of the first viewing angle; An illumination direction and illumination distance determination module, used to determine the illumination direction and illumination distance of each pixel in the patch plant from the point light source at the second viewing angle according to the second space information corresponding to each pixel in the patch plant and the light source information of the preset point light source in the virtual space; a light and shadow correction information determination module, configured to determine the light and shadow correction information of each pixel point in the patch plant at the second viewing angle according to the second spatial information and the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant at the second viewing angle; A light and shadow effect determination module is used to change the first light and shadow information corresponding to each pixel in the patch plant according to the light and shadow correction information of each pixel in the patch plant at the second viewing angle, so as to form the light and shadow effect of the patch plant at the second viewing angle, wherein the first light and shadow information is the color presented by each pixel in the patch plant at the first viewing angle.
9. An electronic device, characterized in that: include: processor; as well as The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method according to any one of claims 1 to 7 is executed.
10. A computer-readable storage medium, characterized in that: A data processing program is stored, and the program is run by a processor to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for displaying virtual three-dimensional model
CN111445572A
Method and device for displaying insert vegetation in game, storage medium and electronic equipment
CN111530078A
Image processing method and device, computer storage medium and electronic equipment
CN111612882A
Skin rendering method, device and equipment and readable storage medium
CN116934944A
Global illumination rendering method on the basis of virtual light source and adaptive sparse matrix reduction
WO2017167084A1