Display method, device, electronic equipment and readable storage medium
By dynamically adjusting the lighting and shadow effects of each pixel in the patch plant, the problem of point light source feedback not changing with the environment is solved, and the lighting and shadow effects of the patch plant are synchronized with the player's perspective, which improves the immersion of the game and reduces performance overhead.
Patent Information
- Application Number
- CN202411569701.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-11-05
AI Technical Summary
The point light feedback of patch plants will not adjust accordingly with the dynamic changes in the in-game environment, resulting in inaccurate lighting effects and affecting the immersion and visual effects of the game.
By determining the spatial and light source information of each pixel in the patch plant at different perspectives, dynamically adjusting the illumination direction and distance of the point light source, and correcting the light and shadow effects in real time, the light and shadow feedback of the patch plant changes synchronously with the player's perspective.
The lighting and shadow effects of patch plants are synchronized with the player's perspective, improving the immersion and visual effects of the game while reducing the overall performance overhead of the scene.
Smart Images

Figure CN119701349B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of games, in particular to a display method and device, electronic equipment and a readable storage medium. BACKGROUND
[0002] When constructing a game scene, in order to enhance the immersion and authenticity of the game world, the morphology of plants in nature (such as trees, shrubs, flowers, etc.) is simulated by plant models. However, plant models are presented by a series of polygonal facets to show the details of the plants, and each polygon needs to be processed for vertex shading, lighting calculation and texture mapping, etc. This not only consumes a large amount of GPU resources, but also makes the rendering speed of the plant model slower.
[0003] In order to quickly arrange the scene or optimize the rendering performance, for some background plants located at the far end of the player's field of view or not needing to interact with the player, a faceted plant (Billboard Plants) is usually used instead of a model plant (Mesh Plants). In order to have a better visual effect for the player's line of sight, a calculation logic is usually added in the shader, which dynamically adjusts the rotation of the faceted model according to the changes in the position or direction of the virtual camera when the position or direction of the virtual camera changes, so that the side of the faceted model on which the texture map is pasted always faces the position and direction of the camera.
[0004] Since the faceted plant applies the rendering result of the model plant at a specific view angle as a texture map to the faceted model, the appearance of the faceted plant is static in the visual performance in the game. The point light feedback of the faceted plant will not be adjusted accordingly with the dynamic changes of the in-game environment, so when the faceted model rotates according to the changes in the position or direction of the virtual camera, the point light feedback of the faceted plant is likely to be exposed. SUMMARY
[0005] The present application provides a display method, device, electronic equipment and readable storage medium, which solves the problem that the point light feedback of the faceted plant will not be adjusted accordingly with the dynamic changes of the in-game environment.
[0006] In a first aspect, the embodiments of the present application provide a display method,
[0007] The virtual space includes at least one faceted plant, and the faceted plant synchronously rotates with the change of the view angle; and the method comprises:
[0008] According to the first spatial information of each pixel in the faceted plant at a first view angle and the view angle transformation information between the first view angle and a second view angle, the second spatial information of each pixel in the faceted plant at the second view angle is determined, wherein the second view angle is a view angle transformed on the basis of the first view angle.
[0009] determine, according to the second spatial information corresponding to each pixel in the patch plant and light source information of a preset point light source in the virtual space, an irradiation direction and an irradiation distance of the point light source to each pixel in the patch plant under the second view angle;
[0010] determine, according to the second spatial information, the irradiation direction and the irradiation distance of the point light source to each pixel in the patch plant under the second view angle, light-shadow correction information of each pixel in the patch plant under the second view angle;
[0011] change first light-shadow information corresponding to each pixel in the patch plant according to the light-shadow correction information of each pixel in the patch plant under the second view angle, to form a light-shadow effect of the patch plant under the second view angle, the first light-shadow information being a color presented by each pixel in the patch plant under the first view angle.
[0012] In a second aspect, the embodiments of the present application further provide a display device, at least including a patch plant in a virtual space, the patch plant synchronously rotating with view angle transformation; the device includes:
[0013] a second spatial information determination module, configured to determine second spatial information of each pixel in the patch plant under a second view angle according to first spatial information of each pixel in the patch plant under a first view angle and view angle transformation information between the first view angle and the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle;
[0014] an irradiation direction and irradiation distance determination module, configured to determine an irradiation direction and an irradiation distance of a point light source to each pixel in the patch plant under the second view angle according to the second spatial information corresponding to each pixel in the patch plant and light source information of the preset point light source in the virtual space;
[0015] a light-shadow correction information determination module, configured to determine light-shadow correction information of each pixel in the patch plant under the second view angle according to the second spatial information, the irradiation direction and the irradiation distance of the point light source to each pixel in the patch plant under the second view angle;
[0016] a light-shadow effect determination module, configured to change first light-shadow information corresponding to each pixel in the patch plant according to the light-shadow correction information of each pixel in the patch plant under the second view angle, to form a light-shadow effect of the patch plant under the second view angle, the first light-shadow information being a color presented by each pixel in the patch plant under the first view angle.
[0017] In a third aspect, the embodiments of the present application further provide an electronic device, comprising:
[0018] a processor; and
[0019] a memory for storing a data processing program, after the electronic device is powered on and the program is run by the processor, the method as described in the first aspect is executed.
[0020] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, storing a data processing program, after the program is run by the processor, the method as described in the first aspect is executed.
[0021] Compared with the prior art, the present application has the following advantages:
[0022] An embodiment of the present application provides a display method, which determines the second spatial information of each pixel in a patch plant at a second perspective based on the first spatial information of each pixel in the patch plant at a first perspective and the perspective transformation information between the first perspective and the second perspective, wherein the second perspective is a perspective transformed based on the first perspective. 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 perspective. Based on the second spatial information corresponding to each pixel in the patch plant and the light source information of a preset point light source in the virtual space, the illumination direction and illumination distance of the point light source for each pixel in the patch plant at the second perspective are determined; based on the second spatial information, the illumination direction and illumination distance of the point light source for each pixel in the patch plant at the second perspective, the light and shadow correction information of each pixel in the patch plant at the second perspective is determined; that is, the light and shadow correction information is generated based on 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, forming 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, and 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 is obtained. This method can obtain the light and shadow effect, that is, the shading data, of each pixel of the patch plant under different viewing angles 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, greatly expanding 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 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 This is a schematic diagram of using a patch plant to replace a model plant, as provided in an embodiment of the present application;
[0024] Figure 2 This is a schematic diagram of obtaining the incoming direction of light for each pixel in a plant picture under a first viewing angle, provided by an embodiment of the present application;
[0025] Figure 3 This 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 It 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 This 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 the interface of a tool for setting point light source information provided in an embodiment of the present application;
[0031] Figure 9 This is a schematic diagram of an interface for previewing an adjustment range provided in an embodiment of the present application;
[0032] Figure 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] Figure 11 This is a flow chart of a display method provided by an embodiment of the present application;
[0034] Figure 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] Figure 13 This is a method provided in the embodiment of the present application. Figure 12 A schematic diagram of feedback information of a point light source of a surface plant obtained according to the display method of the present application when the viewing angle changes from front to back;
[0036] Figure 14 This is a method provided in the embodiment of the present application. Figure 12 A schematic diagram of feedback information of a point light source of a patch plant obtained according to the display method of the present application when the viewing angle changes from front to right;
[0037] Figure 15 is a structural block diagram of a display device provided in an embodiment of the present application;
[0038] Figure 16 This is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the person skilled in the art better understand the scheme of the present application, the technical scheme 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 a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should be within the scope of protection of the present application.
[0040] It should be noted that the terms "first", "second", "third" and the like in the claims, the specification and the 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 can be interchangeable under appropriate circumstances, 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 "include", "have" and their variants are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] When constructing a game scene, in order to enhance the immersion and reality of the game world, the morphology of plants in nature (such as trees, shrubs, flowers, etc.) is simulated by plant models. However, plant models are presented by a series of polygonal patches to show the details of plants, and each polygon needs to be processed for vertex shading, lighting calculation and texture mapping, which not only consumes a large amount of GPU resources, but also makes the rendering speed of plant models slower.
[0042] In order to quickly arrange the scene or optimize the rendering performance, for some background plants located at the far end of the player's field of view or not needing to interact with the player, Decals are usually used to replace MeshPlants. As shown in Figure 1 , a schematic diagram for using Decals to replace MeshPlants is provided in the embodiments of the present application, as shown in Figure 1 (a), the position, direction and field of view angle (FOV) of the virtual camera are determined according to the player's perspective or ideal observation angle. After determining the position, direction and field of view angle of the virtual camera, the virtual camera captures the image of the plant model under a certain perspective, as shown in Figure 1 (b), the image of the plant model obtained by the virtual camera in Figure 1 (a) is shown. The image shown in Figure 1 (b) is applied as a texture map to the Decal model, as shown in Figure 1 (c).
[0043] In order to have a better visual effect for the player's view, a calculation logic is usually added in 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 of the position or direction of the virtual camera, so that the side of the patch model on which the texture map is pasted always faces the position and direction of the camera. Since the patch plant is to apply the rendering result of the captured model plant at a specific viewing angle as a texture map to the patch model, the appearance of the patch plant is static in the visual performance in the game and will not be adjusted accordingly with the dynamic changes of the environment in the game, so when the patch model rotates according to the change of the position or direction of the virtual camera, the appearance of the patch plant is prone to the problem of bug.
[0044] If a street lamp (point light source) is placed around the patch plant, the patch plant will not be partially brightened due to the illumination of the street lamp. In order to have a point light source feedback after placing a street lamp (point light source) around the patch plant, the existing technology is to place a point light source around the model plant in advance, and the image of the plant model captured by the virtual camera at a specific viewing angle will have a point light source feedback. However, in this method, the feedback of the point light source is fixed when the patch plant is obtained, and when the patch model rotates according to the change of the position or direction of the virtual camera, the bug problem of the point light source feedback will occur. For example, in the current game scene, the player is in front of the patch plant, and the point light source is on the right side of the model plant, and the obtained image is that the corresponding right side 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 following the movement of the player, and the patch plant point light source feedback will not be adjusted with the rotation of the patch plant, resulting in an error of the patch plant point light source feedback.
[0045] Alternatively, a point light source feedback is constructed using a game engine, and the constructed point light source feedback is baked in the patch plant. However, the feedback of the point light source added by baking in the patch plant is also calculated in advance during the rendering process, and will not be dynamically changed when the objects in the scene rotate or move in position during the running of the game or application. If the position or direction of the object in the game scene changes, the actual displayed lighting effect may not match the expected one.
[0046] In order to solve the above problems in the related art, the display method provided in the embodiments of the present application is provided. The execution subject of the scheme provided in the present application can be an electronic device, which can be a desktop computer, a notebook computer, a mobile device, a smart watch, a smart television, a tablet computer, a server, etc., or other devices with data processing and display functions.
[0047] The display method provided in the present application can be used to obtain the feedback information of the point light source at different viewing angles of the player in real time.
[0048] The plant model is created using 3D modeling software (such as Blender, Maya, 3ds Max, Houdini, etc.) or software specifically designed for plant modeling (such as Speed Tree, Plant Factory, etc.). Textures are added to the created plant model. The plant is given a realistic appearance, lighting scene, etc. through the rendering engine in the 3D modeling software (such as Cycles or EEVEE of Blender, Mantra of Houdini, etc.), and the created plant model is obtained.
[0049] After the plant model is created, an image of the plant model under the first perspective is obtained. When obtaining the image of the plant model under the first perspective, the position, direction and field of view (FOV) of the virtual camera are first determined, the virtual camera is adjusted according to the determined position, direction and field of view of the virtual camera, the virtual camera is placed at the first perspective, and the image of the plant model under 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 a perspective set for the purpose of game experience or plot development (such as optimal perspective, narrative perspective and tactical perspective, etc.).
[0051] The position of the virtual camera is a three-dimensional space point in the game coordinate system (such as Cartesian coordinate system or screen coordinate system) where the virtual camera is placed, i.e. X, Y, Z coordinate values. The direction of the virtual camera can be defined by the rotation angle, i.e. the rotation on the three axes (X, Y, Z), including yaw (Yaw), pitch (Pitch) and roll (Roll). Or by calculating the vector from the position of the virtual camera to the plant model, and taking the vector as the forward vector of the virtual camera.
[0052] In some embodiments, the plant model is photographed under the first perspective to obtain an image corresponding to the plant model under the first perspective; the image corresponding to the plant model under the first perspective is a patch plant. The color of each pixel in the patch plant under the first perspective is extracted to obtain the first light and shadow information of each pixel of the patch plant.
[0053] In the embodiments of the present application, the first light and shadow information refers to various attributes related to color, including but not limited to 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). 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 can be obtained from an image of the plant model under the first view angle, or can be obtained by counting the pixel distribution of each pixel of the patch plant under the first view angle in each color channel. That is, reading the BGR color space of each pixel of the patch plant under the first view angle, converting the BGR color space of each pixel of the patch plant under the first view angle to the RGB color space, and calculating the distribution of the pixel value of each color channel respectively to obtain the first light and shadow information of each pixel of the patch plant under the first view angle.
[0055] It should be noted that before extracting the first light and shadow information of each pixel of the patch plant under the first view angle, the image of the plant model under the first view angle can be preprocessed, including: (1) cropping, removing the background in the image and only keeping the part of the plant; (2) scaling, scaling the image to a predetermined size for easy processing; (3) filtering, using Gaussian filtering or other denoising filters to reduce noise in the image.
[0056] In some embodiments, uniform rays are emitted on the side of the plant model corresponding to the first view angle, the rays collide with the plant model, and the BentNormal algorithm is performed at the collision point to obtain the first spatial information of each pixel of the patch plant under the first view angle.
[0057] In the embodiments of the present application, the first spatial information includes the incoming direction of the light ray of each pixel of the patch plant under the first view angle. To ensure the feedback of the subsequent point light source, when taking a picture of the plant model, no additional lighting effect is added or the lighting condition is changed, and the picture is taken directly using the ambient light in the virtual scene. Wherein, not adding additional lighting effect means that no additional lamps are used to enhance or change the lighting during the process of obtaining the image, such as not using flash, soft light box, spotlight and other devices to illuminate the plant model. Ambient light refers to the light condition naturally existing in the shooting site, for example, natural light in the room, sunlight outdoors, or indoor light, etc. The first spatial information includes: (1) brightness, which refers to the light and dark degree of each pixel, usually represented by a gray value; (2) shadow, which refers to a darker area caused by the blocking of the light source. The shape and relative position of the pixel can be identified through the shadow; (3) highlight, which refers to the bright spot of the surface of each pixel of the object reflecting strong light, which can reveal the smoothness and reflection characteristics of the surface of each pixel. By analyzing the shadow and highlight in the image, the incoming direction of the light ray can be inferred.
[0058] The first spatial information of each pixel of the patch plant under the first perspective can also be 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 light. The occlusion information includes: (1) depth information (Depth), indicating the distance of each pixel from the camera. Through the depth information, it can be judged which pixels are occluded by other objects, so as to determine which parts should be invisible. (2) Shadow Mapping, which calculates the depth information of the scene from the perspective of the light source, and then compares the depth of each pixel with the depth value in the shadow mapping when rendering to determine whether the pixel is in the shadow. (3) Global Illumination (GI), which simulates the multiple bounces of light in the scene, including direct light and indirect light. That is, in this application, whether the light path of each pixel is blocked is obtained through the occlusion information, so as to obtain the incoming direction of the light.
[0059] The incoming direction of the light of each pixel refers to the average direction of the light emitted by the point light source to the surface of each pixel in the patch plant under the first perspective without being occluded by other objects (or geometric elements). Specifically, a plurality of directional light sampling can be performed on each pixel in the patch plant under the first perspective, that is, a light ray is emitted along a selected direction at each pixel, and it is checked whether the light ray emitted in the selected direction encounters an obstacle, such as an obstacle. If it is encountered, the direction is marked as occluded; if not, it is marked as unoccluded. The average direction of the light direction of the surface of each pixel in the patch plant without being occluded by other objects (or geometric elements) is obtained, and the incoming direction of the light of each pixel in the patch plant under the first perspective is obtained.
[0060] As shown in Figure 2 , a schematic diagram for obtaining the incoming direction of the light of each pixel in the patch plant under the first perspective is provided in an embodiment of the present application. As shown in Figure 2 (a) is a schematic diagram of a 12*12 parallel ray detection, as shown in Figure 2 (b) is another schematic diagram of a 12*12 parallel ray detection. A large number of parallel dense rays are uniformly emitted on one side of the plant model, the rays collide with the plant model, and the BentNormal algorithm is performed at the collision point, so that the main direction of the incoming light of the pixel on the plant model is obtained.
[0061] As shown in Figure 3 , a BentNormal algorithm schematic diagram is provided in an embodiment of the present application, which points to Sample: x, which is a detection ray, Sample: x is a pixel of the patch plant to be detected, Normal: n iRay: w is the visibility of the current pixel x in the w direction.
[0062] A hemisphere is constructed with Normal as the center, and a large number of rays are randomly emitted from each pixel in the plant under the first view angle as a starting point in the hemisphere region. The average direction of the rays that are not blocked by the plant itself is taken as the vector, which is the BentNormal: N(x i ) of each pixel in the plant under the first view angle.
[0063] Exemplarily, when maxangle (cone size) is Pi (i.e. 180°), the rays are 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] wherein vector center is the center direction of the cone; float maxangle is the cone size; vector2 u is the specific emission direction of the detection ray, and letting u be a two-dimensional random floating point number can meet the requirement of randomly emitting rays; sample_direction_cone() is to generate a random direction in the cone according to the given center direction center and maximum half-angle maxangle, and two random numbers u.
[0066] It should be noted that the BentNormal (the incoming direction of the light) is a unit vector, and therefore its length is 1.
[0067] In some embodiments, a pixel picture recording the first spatial information is obtained, and the pixel picture is obtained by recording the first spatial information of each pixel in the plant under the first view angle in the pixel of the pixel picture.
[0068] In an embodiment of the present application, after obtaining the incoming direction of light for each pixel in the patch plant, the incoming direction of light for each pixel is transmitted to the game engine. Currently, the transmission medium for transmitting the incoming direction of light calculated in Houdini to the game engine can be an image. Since the incoming direction of light for each pixel in the patch plant under the first perspective has a one-to-one correspondence with the previously emitted dense parallel rays, each pixel corresponds to a parallel detection ray, and the incoming direction of light at the collision point collected is stored as a pixel color value. That is, the incoming direction of light for each pixel in the patch plant under the first perspective is converted into a pixel image that records the first spatial information. Since the incoming direction of light for each pixel in the patch plant under the first perspective is a three-dimensional space vector with positive and negative values, while the pixel color value has only positive values, each component value of the incoming direction of light is first added by 1 and then multiplied by 0.5, and the value range from -1 to 1 is mapped to 0 to 1. In this way, the incoming direction of light can be stored using the pixel color value.
[0069] In some embodiments, to improve pixel utilization in an image, the patch of plants is made to fill the image in the width or height direction. When acquiring the plant model from a first perspective, the position of the virtual camera can be first determined so that the patch of plants from the first perspective 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, a schematic diagram of a bounding box of a plant model provided in an embodiment of the present application can be created in a 3D software. 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, we can obtain the length, width, and height information of the plant model. Based on the length, width, and height information of the plant model, we adjust the position of the virtual camera so that the plant model fills the image as much as possible.
[0071] When adjusting the virtual camera's position based on the plant model's length, width, and height information, the virtual camera uses an orthogonal mode and is therefore insensitive to the plant model's distance. Therefore, when adjusting the virtual camera's position, only the left-right and up-down offsets of the plant model's image from the first perspective are considered. Therefore, the left-right and up-down offsets of the virtual camera are calculated based on the plant model's length, width, and height information, ensuring that the patch plant fills the plant model's image from the first perspective in terms of width or height.
[0072] The offset of the virtual camera in the left-right direction and the up-down direction is calculated based on the length, width and height information of the plant model. The center point of the plant model bounding box, the maximum point (x maximum value, y maximum value and z maximum value) of the plant model and the minimum point (x minimum value, y minimum value and z minimum value) of the plant model can be obtained. The maximum height of the plant model in the up-down direction and the maximum width of the plant model in the left-right direction are determined based on the maximum point (x maximum value, y maximum value and z maximum value) of the plant model and the minimum point (x minimum value, y minimum value and z minimum value) of the plant model. It is determined whether the maximum height of the plant model in the up-down direction is greater than the maximum width of the plant model in the left-right direction. If the maximum height of the plant model in the up-down direction is greater than the maximum width of the plant model in the left-right direction, the offset of the virtual camera in the left-right direction 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-down direction; and the offset of the virtual camera in the up-down direction is the maximum height of the plant model in the up-down direction minus the maximum width of the plant model in the left-right direction, 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-down direction is less than or equal to the maximum width of the plant model in the left-right direction, the offset of the virtual camera in the up-down direction 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-right direction, and the offset of the virtual camera in the left-right direction is 0.
[0073] Exemplarily, after determining the position of the virtual camera according to the above method of 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, the plant model in Figure 4 is photographed to obtain an image of the plant model in the first view as shown in Figure 5 Figure 5 is a schematic diagram of an image of a plant model in a first view provided by an embodiment of the present application, in which Figure 5 the plant model in the first view is fully filled in the left-right direction of the image. The pixel ray incoming direction of the patch plant in the first view shown in Figure 5 is detected and calculated by parallel rays of 2048*2048, and the pixel ray incoming direction of each pixel in the patch plant in the first view is recorded in the pixel of the pixel picture, and the obtained picture is as shown in Figure 6 Figure 5 is a schematic diagram of the converted picture of the pixel ray incoming direction of the patch plant, in which Figure 6 In the picture shown in, the color value of each pixel (or fragment) represents a direction vector (i.e., a normal vector), which indicates the average direction of the pixel that is not blocked by other parts of the plant model itself, i.e., the pixel ray incoming direction of each pixel in the patch plant in the first view.
[0074] It should be noted that, Figure 6 The picture shown is only a schematic and is not intended to limit Figure 6 The picture shown is limited to black and white grayscale pictures, Figure 6 The picture shown can also be a picture of other colors.
[0075] In some embodiments, a point light source can be preset in a virtual scene, and the position, radius, color, and brightness of the point light source, etc. attributes are set.
[0076] As Figure 7 The schematic diagram of the point light source information provided by the embodiment of the application is shown, in a virtual scene (such as a UE4 scene), each point light source can be set as custom primitive data, which 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 0th, 1st, and 2nd data in Figure 7 The 3rd data in Figure 7 The 4th, 5th, and 6th data in Figure 7 The 7th data in
[0077] Exemplarily, after setting the custom primitive data of the point light source as described above, in the shader of the patch plant, the
Use Custom Primitive Data
[0078] It should be noted that, since there are usually many plants in a 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 the present application, as shown in Figure 8 The interface schematic diagram of the point light source information setting tool provided by the embodiment of the application is shown, the automatic recognition of the light source in Figure 8 is checked, the tool will analyze the point light source in the scene and determine the position of the point light source. Otherwise, the pivot position of the selected object will be used as the light source position. Clicking on Figure 8 “Preview Adjustment Range” in , the tool will create a preview sphere frame in the scene using the spherical ray detection function of the engine, with the light source position as the center and the adjustment range set by the panel as the radius, to help the user determine which plants are in the adjustment range.Figure 9 As shown in FIG. 13, it is an interface schematic diagram of previewing the adjustment range provided by the embodiment of the present application. Clicking "Run" in the interface, the tool will use the sphere ray detection function of the engine to detect and filter the plant patches in the range based on the determined light source position as the center and the adjustment range set by the panel, and set the parameters on the tool panel to the point light source information of the plant patches in batches. As shown in FIG. 14, it is an interface schematic diagram of the tool running of the light source information setting provided by the embodiment of the present application. Figure 8 Figure 10 As shown in FIG. 13, it is an interface schematic diagram of previewing the adjustment range provided by the embodiment of the present application. Clicking "Run" in the interface, the tool will use the sphere ray detection function of the engine to detect and filter the plant patches in the range based on the determined light source position as the center and the adjustment range set by the panel, and set the parameters on the tool panel to the point light source information of the plant patches in batches. As shown in FIG. 14, it is an interface schematic diagram of the tool running of the light source information setting provided by the embodiment of the present application.
[0079] It should be noted that when using the light source information setting tool, the user does not need to care about the point light source information set on the plant patch, and only takes the street lamp as the anchor point to batch, large-scale and quickly adjust the point light source information of all plant patches near the street lamp, so as to quickly adjust the point light source feedback effect of the plant patch.
[0080] When determining the coordinates of the point light source, if "Automatic identification of light source" is checked in the interface, the component traversal will be performed on the selected object to find the light source component, and the coordinates of the light source component will be taken as the light source coordinates; if it is not checked or no light source component is found, the selected object will be directly taken as the light source coordinates. Figure 8 When setting the point light source information of the plant patch, the Multi Sphere Trace For Objects function provided by the engine is used to detect all the mesh bodies in the range with the point light source coordinates as the center and "adjustment range" as the detection radius, and the World Static as the detection type. The shader of the mesh body is judged, and if the shader has the "UseFake Point Light" parameter, it is considered that the mesh body is the plant patch that needs to be set with the point light source information. For each plant patch in the range, the 0, 1 and 2 parameters of the point light source in the interface will be set to the 0, 1 and 2 parameters of the point light source in the interface, the 3 parameter of the light source radius in the interface will be set to the 3 parameter of the light source radius in the interface, the 4, 5 and 6 parameters of the light source color in the interface will be set to the 4, 5 and 6 parameters of the light source color in the interface, and the 7 parameter of the light source intensity in the interface will be set to the 7 parameter of the light source intensity in the interface.
[0081] Figure 7 Figure 7 Figure 7 Figure 7 Figure 7 Figure 7 Figure 7 Figure 7
[0082] It should be noted that the strength, range, color and position of the point light source can be quickly adjusted by the above-mentioned tool, which not only can quickly respond to design requirements and creative inspiration, but also can accurately present the required atmosphere and effect in different scenes and situations. Players can experience more vivid, delicate and infectious visual effects.
[0083] As shown in Figure 11 a flowchart of a display method provided by an embodiment of the present application, the method comprises:
[0084] In step S1101, first spatial information of each pixel in the patch plant at a first view angle and view angle transformation information between the first view angle and a second view angle are used to determine second spatial information of each pixel in the patch plant at the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle.
[0085] In the present application, the patch plant in the game scene is dynamically adjusted according to the view angle of the player, so that the side of the patch plant on which the texture map is pasted always faces the player. When the position of the player in the game scene changes, the view angle of the player relative to the patch plant will change. According to the change of the view angle of the player, the patch plant in the scene is dynamically adjusted. After the adjustment, the world coordinates of the patch plant after the adjustment are obtained.
[0086] When the world coordinates are obtained, the position of the current pixel in the world coordinate system can be obtained through the "World Position" node in the material editor.
[0087] It should be noted that the world coordinate system is a system absolute coordinate system, which provides a reference for the positions of all points on the picture. Before the user coordinate system is established, the coordinates of all points on the picture are determined with the origin of the world coordinate system. The world coordinate system is not only used for graphic conversion, but also supports scaling, translation, rotation, deformation, projection and other conversion operations.
[0088] When the position of the player in the virtual environment changes, the patch plant follows the corresponding rotation of the view angle of the virtual character, and the view angle of the player changes from the first view angle to the second view angle. According to the change of the view angle of the player from the first view angle to the second view angle, the rotation view angle in the view angle transformation process of the player is determined. According to the rotation view angle, a rotation matrix is created, and the first spatial information of each pixel in the patch plant at the first view angle is rotated through the rotation matrix to obtain the second spatial information of each pixel in the patch plant at the second view angle.
[0089] The first space information of each pixel in the patch plant at the first view angle is rotated by a rotation matrix, which can be multiplying the first rotation information corresponding to the first space information of each pixel in the patch plant at the first view angle by the rotation matrix, to obtain a second rotation matrix corresponding to the second space information of each pixel in the patch plant at the second view angle. The first space information of the patch plant is rotated according to the second rotation matrix to obtain the second space information of each pixel in the patch plant at the second view angle. That is, the first space information of the patch plant before rotation is rotated according to the rotation of the patch plant following the view angle of the player, so that the space information matches the rotation of the patch plant.
[0090] In step S1102, the illumination direction and the illumination distance of each pixel in the patch plant at the second view angle are determined 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 the embodiment of the present application, when the position of the player in the virtual environment changes, the corresponding rotation of each pixel in the patch plant following the view angle of the virtual character is obtained, and the second space information of each pixel in the patch plant at the second view angle after rotation is obtained. The second space information includes the second coordinates of each pixel in the patch plant after rotation; the first space 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 point light source. The second coordinates of each pixel in the patch plant at the second view angle after rotation are subtracted from the third coordinates of the point light source to obtain the illumination direction of the point light source to each pixel in the patch plant and the illumination distance of the point light source to each pixel in the patch plant.
[0092] In step S1103, the light shadow correction information of each pixel in the patch plant at the second view angle is determined according to the second space information, the illumination direction and the illumination distance of the point light source to each pixel in the patch plant at the second view angle.
[0093] In the embodiment of the present application, the second spatial information includes the incoming direction of the light ray of each pixel in the patch plant at the second view angle. The first shadow correction information of each pixel point in the patch plant at the second view angle is determined based on the closeness between the incoming direction of the light ray of each pixel included in the second spatial information and the irradiation direction of each pixel in the patch plant at the second view angle. The closeness between the incoming direction of the light ray of each pixel and the irradiation direction of each pixel in the patch plant can be determined based on the included angle between the incoming direction of the light ray and the irradiation direction. The smaller the included angle between the incoming direction of the light ray of a certain pixel and the irradiation direction, the greater the influence of the light source on the pixel, the greater the first shadow correction information of the pixel, and the brighter the surface of the pixel. The greater the included angle between the incoming direction of the light ray of a certain pixel and the irradiation direction, the smaller the influence of the light source on the pixel, the smaller the first shadow correction information of the pixel, and the darker the surface of the pixel.
[0094] The second shadow correction information of each pixel point in the patch plant at the second view angle is determined according to the irradiation distance of the point light source to each pixel in the patch plant. The greater the irradiation distance of the point light source to each pixel in the patch plant, the smaller the second shadow correction information of each pixel point in the patch plant at the second view angle, indicating that the smaller the influence of the light source on the pixel, the smaller the second shadow correction information of the pixel, and the darker the surface of the pixel. The smaller the irradiation distance of the point light source to each pixel in the patch plant, the greater the second shadow correction information of each pixel point in the patch plant at the second view angle, indicating that the greater the influence of the light source on the pixel, the greater the second shadow correction information of the pixel, and the brighter the surface of the pixel.
[0095] The first shadow correction information and the second shadow correction information obtained above can be fused, such as multiplying the first shadow correction information and the second shadow correction information of each pixel point in the patch plant, to obtain the shadow correction information of each pixel point in the patch plant at the second view angle.
[0096] In step S1104, the first shadow information corresponding to each pixel in the patch plant is changed according to the shadow correction information of each pixel point in the patch plant at the second view angle, to form the shadow effect of the patch plant at the second view angle. The first shadow information is the color presented by each pixel in the patch plant at the first view angle.
[0097] In the embodiment of the present application, after the light and shadow correction information of each pixel point in the plant patch under the second view angle is obtained, the brightness of the light irradiated on each pixel point in the plant patch is corrected according to the light and shadow correction information, and the brightness of each pixel point in the plant patch after correction is obtained. The first light and shadow information corresponding to each pixel point in the plant patch is changed by using the brightness of each pixel point in the plant patch after correction, and the light and shadow effect of the plant patch under the second view angle is obtained.
[0098] The display method provided in the embodiment of the present application comprises the following steps: determining second spatial information of each pixel in the plant patch under a second view angle according to first spatial information of each pixel in the plant patch under a first view angle and view angle transformation information between the first view angle and the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle. That is, the spatial information of each pixel in the plant patch is rotated according to the rotation of the plant patch according to the player's view angle. Determining an irradiation direction and an irradiation distance of a preset point light source to each pixel in the plant patch under the second view angle according to the second spatial information corresponding to each pixel in the plant patch and light source information of the point light source in the virtual space; determining light and shadow correction information of each pixel point in the plant patch under the second view angle according to the second spatial information, the irradiation direction and the irradiation distance of the point light source to each pixel in the plant patch under the second view angle; that is, generating the light and shadow correction information according to the second spatial information of each pixel in the plant patch after rotation and the light source information of the preset point light source. Finally, changing the first light and shadow information corresponding to each pixel in the plant patch by using the light and shadow correction information of each pixel point in the plant patch under the second view angle, and forming a light and shadow effect of the plant patch under the second view angle, wherein the first light and shadow information is a color presented by each pixel in the plant patch under the first view angle. That is, the light and shadow effect of each pixel in the plant patch under the first view angle is corrected by using the light and shadow correction information, and the light and shadow effect of each pixel under the second view angle after the plant patch is rotated according to the player's view angle is obtained. The method can obtain the light and shadow effect, that is, the coloring data, of each pixel of the plant patch under different view angles in real time according to the player's view angle, so that the point light source of the plant patch can have correct light and shadow feedback under different player's view angles, and the application scenarios of the plant patch are greatly expanded. At the same time, a model plant does not need to be used near the point light source to avoid exposure, and the performance overhead of the whole scene is significantly reduced under the premise of ensuring the artistic effect.
[0099] In some embodiments, the step of determining the second spatial information of each pixel in the plant patch under the second view angle according to the first spatial information of each pixel in the plant patch under the first view angle and the view angle transformation information between the first view angle and the second view angle comprises:
[0100] construct a view angle transformation matrix according to the view angle transformation information;
[0101] transform first spatial information of each pixel in the patch plant under the first view angle based on the view angle transformation matrix to obtain second spatial information of each pixel in the patch plant under the second view angle.
[0102] In the embodiments 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 the view angle transformation matrix. Wherein, when synthesizing, the sub-rotation matrices can be multiplied to obtain the view angle transformation matrix. And the first spatial information of each pixel in the patch plant under the first view angle is converted into the second spatial information of each pixel in the patch plant under the second view angle through the view angle transformation matrix.
[0103] In some embodiments, the determination of the illumination direction and the illumination distance of the preset point light source to each pixel in the patch plant under the second view 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 comprises:
[0104] determining 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 under the second view angle;
[0105] determining the illumination direction of the preset point light source to each pixel in the patch plant through the coordinate difference;
[0106] determining the illumination distance of the preset point light source to each pixel in the patch plant through the coordinate difference.
[0107] In the embodiments of the present application, after the patch plant follows the rotation of the player's view angle, the world coordinates of each pixel in the patch plant under the second view angle are obtained. 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. The illumination direction of the point light source to each pixel in the patch plant is determined based on the coordinate difference. The 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 illumination distance of the preset point light source to each pixel in the patch plant.
[0108] In some embodiments, the determining of the light shadow correction information of each pixel in the patch plant under the second view angle according to the light source information of the preset point light source in the virtual space and the illumination direction and the illumination distance of the point light source to each pixel in the patch plant under the second view angle comprises:
[0109] determining first light shadow correction information of each pixel in the patch plant under the second view angle based on the similarity between the second space information corresponding to each pixel in the patch plant and the illumination direction;
[0110] determining second light shadow correction information of each pixel in the patch plant under the second view angle by the ratio of the illumination distance of the preset point light source to each pixel in the patch plant and the radius of the preset point light source;
[0111] multiplying the first light shadow correction information and the second light shadow correction information to take the multiplication result as the light shadow correction information of each pixel in the patch plant under the second view angle.
[0112] In the implementation of the present application, the similarity between the second space information of each pixel in the patch plant under the second view angle and the illumination direction can be obtained based on the dot product between the incoming direction of the light ray of each pixel in the patch plant and the illumination direction. For example, the dot product of the illumination direction and the incoming direction of the light ray after rotation is performed, and the result is returned according to the proximity of the incoming direction and the illumination direction vectors of the light ray of each pixel in the patch plant after rotation following the player's view angle, wherein the returned result can be a value from -1 to 1.
[0113] It should be noted that the dot product, also known as the inner product or scalar product of vectors, is used to measure the angle between two vectors. The greater the result of the dot product, the closer the second space information of each pixel in the patch plant under the second view angle to the illumination direction; the smaller the result of the dot product, the farther the second space information of each pixel in the patch plant under the second view angle to the illumination direction. The greater the result of the dot product, the greater the influence of the pixel in the patch plant on the light source, and the brighter the brightness of the pixel should be, and vice versa.
[0114] In an optional embodiment, a matching relationship between a plurality of dot product results of the second space information and the illumination direction and a plurality of first light shadow correction information can be constructed in advance. After obtaining the dot product result of the second space information and the illumination direction, the first light shadow correction information of each pixel in the patch plant is obtained according to the dot product result and the matching relationship.
[0115] Wherein, the dot product result of 1 indicates that the pixel point is a completely light-facing surface, and the first light shadow correction information is larger. The dot product result of -1 indicates that the pixel point is a completely light-facing surface or a completely light-facing surface, and the first light shadow correction information is smaller.
[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 can be the incoming direction of the light obtained above. Since the incoming direction of the light is a unit vector, the illumination direction is also normalized to become a unit vector. This will result in a more accurate dot product calculation.
[0118] It should be noted that the incoming direction of the light is transmitted to the game engine using an image as the transmission medium. Therefore, before performing the above calculations, the incoming direction of the light is first restored. To restore, each component of the image is multiplied by 2 and then subtracted by 1, reverse mapping the pixel color value from the range of 0 to 1 back to the spatial vector range of -1 to 1.
[0119] 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. Second light and shadow correction information is determined based on the ratio between the illumination distance and the radius of the preset point light source. When the ratio between the illumination 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 illumination 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 surface 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 a ratio of an illumination distance of the preset point light source to each pixel in the patch plant to a 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 patch plant at the second viewing angle.
[0124] In this embodiment of the present application, the illumination distance from a preset point light source to each pixel in the patch plant is divided by the radius of the preset point light source to obtain a ratio between the illumination distance and the radius of the preset point light source. The ratio result is clamped to [0, 1]. Assuming the complete attenuation value is 1, the clamped ratio result is subtracted from 1 to obtain a subtraction result. The subtraction result is then 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 corrected brightness of the preset point light source and the color information of the preset point light source are superimposed on the first light and shadow information corresponding to each pixel in the patch plant 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 light and shadow correction information for each pixel in the patch plant at a second viewing angle, the brightness of each pixel in the patch plant is corrected using the light and shadow correction information. This can be achieved by multiplying 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 Figure 12 As shown in the figure, it is a schematic diagram of a point light source feedback of a player's first perspective provided by an embodiment of the present application. Assume that Figure 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: Figure 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 this application, the feedback information of the point light source of the patch plant is obtained as shown in FIG. Figure 13 As shown, Figure 13 A method provided in the embodiment of this application Figure 12Fig. 6 is a schematic diagram of feedback information of a point light source of a plant according to the display method of the present application, when the view angle changes from the front to the back. When the view angle of the player changes from the front of the plant shown in Fig. 12 to the right side of the plant, according to the display method provided in the present application, the feedback information of the point light source of the plant is as shown in Fig. 13. Figure 14 Figure 14 Fig. 14 is a schematic diagram of feedback information of a point light source of a plant according to the display method of the present application, when the view angle changes from the front to the right. Figure 12 Fig. 15 is a schematic diagram of feedback information of a point light source of a plant according to the display method of the present application, when the view angle changes from the front to the right.
[0130] Corresponding to the display method provided in the embodiments of the present application, the embodiments of the present application further provide a display device, wherein a virtual space includes at least a plant, and the plant rotates synchronously with the change of the view angle; as shown in Fig. 16, the device 1500 includes: Figure 15
[0131] A second space information determination module 1501 is configured to determine second space information of each pixel in the plant under a second view angle according to first space information of each pixel in the plant under a first view angle and view angle transformation information between the first view angle and the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle.
[0132] An irradiation direction and irradiation distance determination module 1502 is configured to determine an irradiation direction and an irradiation distance of a point light source to each pixel in the plant under the second view angle according to the second space information corresponding to each pixel in the plant and light source information of the point light source in the virtual space.
[0133] A light and shadow correction information determination module 1503 is configured to determine light and shadow correction information of each pixel in the plant under the second view angle according to the second space information, the irradiation direction and the irradiation distance of the point light source to each pixel in the plant under the second view angle.
[0134] A light and shadow effect determination module 1504 is configured to change first light and shadow information corresponding to each pixel in the plant according to the light and shadow correction information of each pixel in the plant under the second view angle, to form a light and shadow effect of the plant under the second view angle, wherein the first light and shadow information is a color presented by each pixel in the plant under the first view angle.
[0135] In some embodiments, the second space information determination module is further configured to:
[0136] construct a view angle transformation matrix according to the view angle transformation information.
[0137] transform the first spatial information of each pixel in the patch plant under the first view angle based on the view angle transformation matrix, to obtain second spatial information of each pixel in the patch plant under the second view angle.
[0138] In some embodiments, the illumination direction and distance determination module is further configured to:
[0139] determine a coordinate difference between the first coordinate of each pixel in the patch plant and a second coordinate of the preset point light source in the virtual space under the second view angle;
[0140] determine the illumination direction of the preset point light source to each pixel in the patch plant through the coordinate difference;
[0141] determine the illumination distance of the preset point light source to each pixel in the patch plant through the coordinate difference.
[0142] In some embodiments, the light and shadow correction information determination module is further configured to:
[0143] determine first light and shadow correction information of each pixel in the patch plant under the second view 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 under the second view angle through the ratio of the illumination distance of the preset point light source to each pixel in the patch plant to the radius of the preset point light source;
[0145] multiply the first light and shadow correction information and the second light and shadow correction information, and use the multiplication result as the light and shadow correction information of each pixel in the patch plant under the second view angle.
[0146] In some embodiments, the light and shadow correction information determination module is further configured to:
[0147] subtract the ratio of the illumination distance of the preset point light source to each pixel in the patch plant to the radius of the preset point light source from the full attenuation value to obtain a subtraction result;
[0148] square the subtraction result to obtain the second light and shadow correction information of each pixel in the patch plant under the second view angle.
[0149] In some embodiments, the light and shadow effect determination module is further configured to:
[0150] According to the light and shadow correction information of each pixel in the patch plant under the second view angle, the brightness of each pixel in the patch plant is corrected, to obtain the brightness of each pixel in the patch plant after correction.
[0151] The brightness after the preset point light source correction and the color information of the preset point light source are superimposed on the first light and shadow information corresponding to each pixel in the patch plant, to obtain the light and shadow effect of the patch plant under the second view angle.
[0152] In some embodiments, the device further comprises:
[0153] The pixel picture acquisition module is configured to acquire a pixel picture recording first spatial information, the pixel picture being obtained by recording the first spatial information of each pixel in the patch plant under the first view angle in the pixels of the pixel picture.
[0154] Corresponding to the display method provided in the embodiments of the present application, the embodiments of the present application further provide an electronic device. Figure 16 As shown in the figure, the electronic device comprises a processor 1601 and a memory 1602 for storing a display method program. After the electronic device is powered on and the processor runs the display method program, the following steps are performed:
[0155] According to the first spatial information of each pixel in the patch plant under the first view angle and the view angle transformation information between the first view angle and the second view angle, the second spatial information of each pixel in the patch plant under the second view angle is determined, wherein the second view angle is a view angle transformed on the basis of the first view angle.
[0156] 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 illumination direction and the illumination distance of the point light source to each pixel in the patch plant under the second view angle are determined.
[0157] According to the second spatial information, the illumination direction and the illumination distance of the point light source to each pixel in the patch plant under the second view angle, the light and shadow correction information of each pixel in the patch plant under the second view angle is determined.
[0158] According to the light and shadow correction information of each pixel in the patch plant under the second view angle, the brightness of each pixel in the patch plant is corrected, to obtain the brightness of each pixel in the patch plant after correction.
[0159] Corresponding to the display method provided in the embodiments of the present application, the embodiments of the present application also provide a computer readable storage medium, which stores a program of the display method, and the program is run by a processor to execute the following steps:
[0160] According to the first spatial information of each pixel in the patch plant under the first view angle and the view angle transformation information between the first view angle and the second view angle, second spatial information of each pixel in the patch plant under the second view angle is determined, wherein the second view angle is a view angle transformed on the basis of the first view angle;
[0161] 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, an irradiation direction and an irradiation distance of the point light source to each pixel in the patch plant under the second view angle are determined;
[0162] According to the second spatial information, the irradiation direction and the irradiation distance of the point light source to each pixel in the patch plant under the second view angle, light shadow correction information of each pixel point in the patch plant under the second view angle is determined;
[0163] According to the light shadow correction information of each pixel point in the patch plant under the second view angle, first light shadow information corresponding to each pixel in the patch plant is changed to form a light and shadow effect of the patch plant under the second view angle, and the first light shadow information is a color presented by each pixel in the patch plant under the first view angle.
[0164] Corresponding to the display method provided in the embodiments of the present application, the embodiments of the present application also provide a computer program product, which includes a computer program stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to make the electronic device execute the following steps:
[0165] According to the first spatial information of each pixel in the patch plant under the first view angle and the view angle transformation information between the first view angle and the second view angle, second spatial information of each pixel in the patch plant under the second view angle is determined, wherein the second view angle is a view angle transformed on the basis of the first view angle;
[0166] 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, an irradiation direction and an irradiation distance of the point light source to each pixel in the patch plant under the second view angle are determined;
[0167] According to the second view, the second spatial information, the irradiation direction and irradiation distance of the point light source to each pixel in the patch plant, the light and shadow correction information of each pixel in the patch plant under the second view is determined;
[0168] According to the light and shadow correction information of each pixel in the patch plant under the second view, the first light and shadow information corresponding to each pixel in the patch plant is changed, and the light and shadow effect of the patch plant under the second view is formed. The first light and shadow information is the color presented by each pixel in the patch plant under the first view.
[0169] It should be noted that the detailed description of the device, the electronic equipment, the computer readable storage medium and the computer program product provided by the embodiments of the present application can refer to the related description of the method of the embodiments of the present application, which will not be repeated here.
[0170] Although the above-mentioned preferred embodiments of the present application are disclosed, the present application is not intended to limit the present application, and any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be limited by the scope defined by the claims of the present application.
[0171] In several embodiments provided by 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. In actual implementation, another division mode can be adopted, for example, a plurality of modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed elements can be indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0172] The integrated modules realized in the form of software function modules can be stored in a computer readable storage medium. The software function modules stored in the storage medium include a plurality of instructions for causing an electronic device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute part of the steps of the method described in various embodiments of the present application.
[0173] It should be understood that the above-mentioned processor can be a central processing module (English: Central Processing Unit, CPU for short), and can also be other general-purpose processors, digital signal processors (English: Digital Signal Processor, DSP for short), application specific integrated circuits (English: Application Specific Integrated Circuit, ASIC for short), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the application can be directly embodied as hardware processor execution or executed by a combination of hardware and software modules in the processor.
[0174] The memory can include a high-speed RAM memory, and can also include a non-volatile storage NVM, for example, at least one disk memory, and can also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0175] The bus can be an industry standard architecture (Industry Standard Architecture, ISA) bus, a peripheral component interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, the bus in the drawings of the present application does not limit only one bus or one type of bus.
[0176] The above-mentioned storage medium can be realized by any type of volatile or non-volatile storage device or their combination, 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 storage, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0177] Those of ordinary skill in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware. The above-mentioned program can be stored in a computer readable storage medium. The program executes to perform the steps of the above-mentioned method embodiments; and the above-mentioned storage medium includes ROM, RAM, magnetic disk or optical disk and various storage medium 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, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A display method characterized by comprising: The virtual space includes at least a piece of plant, and the piece of plant rotates synchronously with a change of a view angle; the method comprises: determining second spatial information of each pixel in the piece of plant at a second view angle based on first spatial information of each pixel in the piece of plant at a first view angle and view angle transformation information between the first view angle and the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle; determining an irradiation direction and an irradiation distance of a preset point light source to each pixel in the piece of plant at the second view angle based on the second spatial information corresponding to each pixel in the piece of plant and light source information of the preset point light source in the virtual space; determining light and shadow correction information of each pixel in the piece of plant at the second view angle based on the second spatial information, the irradiation direction and the irradiation distance of the point light source to each pixel in the piece of plant at the second view angle; changing first light and shadow information corresponding to each pixel in the piece of plant based on the light and shadow correction information of each pixel in the piece of plant at the second view angle, to form a light and shadow effect of the piece of plant at the second view angle, wherein the first light and shadow information is a color presented by each pixel in the piece of plant at the first view angle.
2. The display method according to claim 1, wherein The determining of the second spatial information of each pixel in the piece of plant at the second view angle based on the first spatial information of each pixel in the piece of plant at the first view angle and the view angle transformation information between the first view angle and the second view angle comprises: constructing a view angle transformation matrix based on the view angle transformation information; transforming the first spatial information of each pixel in the piece of plant at the first view angle based on the view angle transformation matrix to obtain the second spatial information of each pixel in the piece of plant at the second view angle.
3. The display method according to claim 1, wherein The determining of the irradiation direction and the irradiation distance of the preset point light source to each pixel in the piece of plant at the second view angle based on the second spatial information corresponding to each pixel in the piece of plant and the light source information of the preset point light source in the virtual space comprises: determining a coordinate difference between a first coordinate of each pixel in the piece of plant and a second coordinate of the preset point light source in the virtual space at the second view angle; determining the irradiation direction of the preset point light source to each pixel in the piece of plant through the coordinate difference; determining the irradiation distance of the preset point light source to each pixel in the piece of plant through the coordinate difference.
4. The display method according to claim 3, wherein The determining of the light and shadow correction information of each pixel in the piece of plant at the second view angle based on the light source information of the preset point light source in the virtual space and the irradiation direction and the irradiation distance of the point light source to each pixel in the piece of plant at the second view angle comprises: determining first light and shadow correction information of each pixel in the piece of plant at the second view angle based on a similarity between the second spatial information corresponding to each pixel in the piece of plant and the irradiation direction; Determine second light shadow correction information of each pixel in the sheet plant at the second view angle according to a ratio of an irradiation distance of the preset point light source to each pixel in the sheet plant to a radius of the preset point light source; Multiply the first light shadow correction information and the second light shadow correction information, and use a multiplication result as light shadow correction information of each pixel in the sheet plant at the second view angle.
5. The display method according to claim 4, wherein The determining of the second light shadow correction information of each pixel in the sheet plant at the second view angle according to the ratio of the irradiation distance of the preset point light source to each pixel in the sheet plant to the radius of the preset point light source includes: Subtract a complete attenuation value from the ratio of the irradiation distance of the preset point light source to each pixel in the sheet plant to the radius of the preset point light source to obtain a subtraction result; Square the subtraction result to obtain the second light shadow correction information of each pixel in the sheet plant at the second view angle.
6. The display method according to claim 1, wherein The changing of the first light shadow information corresponding to each pixel in the sheet plant according to the light shadow correction information of each pixel in the sheet plant at the second view angle to form the light shadow effect of the sheet plant at the second view angle includes: Correct the brightness of each pixel in the sheet plant according to the light shadow correction information of each pixel in the sheet plant at the second view angle to obtain the brightness of each pixel in the sheet plant after correction; Superimpose the brightness after the preset point light source correction and the color information of the preset point light source on the first light shadow information corresponding to each pixel in the sheet plant to obtain the light shadow effect of the sheet plant at the second view angle.
7. The display method according to claim 1, wherein Before the determining of the second space information of each pixel in the sheet plant at the second view angle according to the first space information of each pixel in the sheet plant at the first view angle and view angle transformation information between the first view angle and the second view angle, the method further includes: Obtain a pixel picture recording the first space information, wherein the pixel picture is obtained by recording the first space information of each pixel in the sheet plant at the first view angle in pixels of the pixel picture.
8. A display device, characterized by comprising: The virtual space includes at least a sheet plant, and the sheet plant rotates synchronously with view angle transformation; the device includes: A second space information determination module is configured to determine second space information of each pixel in the sheet plant at a second view angle according to first space information of each pixel in the sheet plant at a first view angle and view angle transformation information between the first view angle and the second view angle, wherein the second view angle is a view angle transformed on the basis of the first view angle; An irradiation direction and irradiation distance determination module is configured to determine an irradiation direction and an irradiation distance of a preset point light source to each pixel in the sheet plant at the second view angle according to the second space information corresponding to each pixel in the sheet plant and light source information of the point light source in the virtual space. The light and shadow correction information determination module is configured to determine light and shadow correction information of each pixel in the sheet plant at the second view angle according to the second view angle, the second spatial information, and the irradiation direction and irradiation distance of the point light source to each pixel in the sheet plant. The light and shadow effect determination module is configured to change the first light and shadow information corresponding to each pixel in the sheet plant according to the light and shadow correction information of each pixel in the sheet plant at the second view angle, to form a light and shadow effect of the sheet plant at the second view angle, wherein the first light and shadow information is a color presented by each pixel in the sheet plant at the first view angle.
9. An electronic device, comprising: Comprise: a processor; and a memory for storing a data processing program, after the electronic device is powered on and the program is run by the processor, the method as claimed in any one of claims 1-7 is executed.
10. A computer-readable storage medium, characterized in that, A data processing program is stored, and the program is run by the processor to execute the method as claimed in any one of claims 1-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