Virtual scene processing method and device, program product and electronic equipment
By obtaining the difference between terrain height and water surface height in the virtual scene, determining the wet state parameters and rendering, the problem of manual editing dependence and poor humidity effects in the existing technology is solved, and the moisture effect of automated editing is achieved, which enhances the realism of the virtual scene.
Patent Information
- Application Number
- CN202411701648.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-14
AI Technical Summary
When realizing the wet effect in a virtual scene, the prior art relies on manual editing, resulting in high labor and time costs and poor humidity effects.
By obtaining the height difference between the terrain height of the area in the virtual scene and the water surface height of the target water body, determine the humidity state parameters, and render the area based on this parameter to achieve the moisture effect of automatic editing.
Reduces the dependence of manual editing, reduces labor and time costs, and improves the expressiveness of the damp effect and the realism of the virtual scene.
Smart Images

Figure CN119625142A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer graphics technology, and in particular to a virtual scene processing method, a virtual scene processing device, a computer program product, and an electronic device. Background Art
[0002] In the development of games, animations, films, etc., it is often necessary to achieve a wet effect in a virtual scene, such as editing some objects and surfaces in the virtual scene to have a wet surface appearance to simulate the effect of being soaked or wet. The related wet effect implementation solutions have the problem of relying on manual editing or poor wet effects. Summary of the invention
[0003] The present disclosure provides a virtual scene processing method, a virtual scene processing device, a computer program product and an electronic device, so as to at least to some extent solve the problem that the realization of the wet effect depends on manual editing or the wet effect is not good.
[0004] According to a first aspect of the present disclosure, a virtual scene processing method is provided, the method comprising: obtaining a terrain height of a first area in a virtual scene; obtaining a water surface height of a target water body corresponding to the first area, wherein the wetness of the first area is affected by the target water body; determining a wetness state parameter of the first area according to a height difference between the terrain height and the water surface height; and rendering the first area based on the wetness state parameter.
[0005] According to a second aspect of the present disclosure, a virtual scene processing device is provided, the device comprising: a first acquisition module, configured to acquire a terrain height of a first area in a virtual scene; a second acquisition module, configured to acquire a water surface height of a target water body corresponding to the first area, wherein the wetness of the first area is affected by the target water body; a wetness state parameter determination module, configured to determine a wetness state parameter of the first area according to a height difference between the terrain height and the water surface height; and a rendering processing module, configured to render the first area based on the wetness state parameter.
[0006] According to a third aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method of the first aspect and possible implementations thereof are implemented.
[0007] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of the above-mentioned first aspect and its possible implementation methods by executing the executable instructions.
[0008] The technical solution disclosed in this disclosure has the following beneficial effects:
[0009] On the one hand, it provides a method of achieving wet effects through automated editing, which does not rely on manual editing, thus reducing manpower and time costs. On the other hand, based on the height difference between the terrain height and the water surface height of the first area, the wet state parameters are determined so that the wet state parameters are adapted to the geographical environment conditions of the first area. The first area is rendered based on the wet state parameters, which can ensure that the rendered effect conforms to the wet state of the first area, and different wet effects can be achieved for areas with different wet states, which is beneficial to improving the expressiveness of the wet effect and enhancing the realism of the virtual scene. On the other hand, this solution has strong applicability and is not restricted to the shape, size, etc. of the virtual scene or the first area. For example, any area in the virtual scene can be processed to obtain a more ideal wet effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A flowchart showing a virtual scene processing method in this exemplary embodiment;
[0011] Figure 2 A schematic diagram showing a method of determining a second water surface height in this exemplary embodiment;
[0012] Figure 3 A flow chart for determining a first water surface height in this exemplary embodiment is shown;
[0013] Figure 4 A flow chart for determining a wet state parameter in this exemplary embodiment is shown;
[0014] Figure 5 A schematic diagram showing a wet effect in this exemplary embodiment;
[0015] Figure 6 A schematic diagram showing the structure of a virtual scene processing device in this exemplary embodiment is shown;
[0016] Figure 7 A schematic structural diagram of an electronic device in this exemplary embodiment is shown. DETAILED DESCRIPTION
[0017] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings.
[0018] The accompanying drawings are schematic diagrams of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in hardware modules or integrated circuits, or in networks, processors or microcontrollers. The embodiments can be implemented in various forms and should not be construed as being limited to the examples set forth herein. The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the description below, many specific details are provided to provide a full description of the embodiments of the present disclosure. However, those skilled in the art should appreciate that one or more specific details may be omitted when implementing the technical solution of the present disclosure, or one or more specific details may be replaced by other methods, components, devices, steps, etc.
[0019] In virtual scenes, the wet effect can be applied to areas such as stagnant water, rivers, lakes, and swamps to simulate the effect of objects and surfaces being soaked or wetted by water, making the virtual scene realistic. In related technologies, the wet effect is mainly achieved through the following solutions:
[0020] Solution 1: Achieve the wet effect through manual editing. For example, artists determine which areas are wet based on the types or characteristics of different areas in the virtual scene, and manually place pre-made wet objects, or manually adjust parameters such as roughness to edit the wet effect. However, this solution will make the editing process cumbersome and consume too much manpower and time.
[0021] Solution 2: Use a wetness map to describe the wet areas in the virtual scene, and use a wetness map or texture for these areas. However, this solution cannot differentiate the wet areas, resulting in a single and fixed wet effect in the entire wet area, which is inconsistent with the real world.
[0022] Solution 3: Use geographic location detection to determine the wet area in the virtual scene, and achieve the wet effect through decals, etc. However, this solution can only simulate areas with simple shapes, and it is difficult to control areas with complex shapes, and it is also impossible to achieve the ideal wet effect.
[0023] It can be seen that the above solution 1 has the problem of relying on manual editing and having too high manpower and time costs, and both solutions 2 and 3 have the problem of poor moistening effect.
[0024] In view of one or more of the above problems, an exemplary embodiment of the present disclosure provides a virtual scene processing method, which can edit a wet effect in a virtual scene in an automated manner without relying on manual editing, thereby reducing manpower and time costs and improving the expressiveness of the wet effect.
[0025] Figure 1 The schematic flow of the decal processing method is shown, which may include the following steps:
[0026] Step S110, obtaining the terrain height of the first area in the virtual scene;
[0027] Step S120, obtaining the water surface height of the target water body corresponding to the first area, wherein the humidity level of the first area is affected by the target water body;
[0028] Step S130, determining a wet state parameter of the first area according to the height difference between the terrain height and the water surface height;
[0029] Step S140: rendering the first area based on the wet state parameter.
[0030] exist Figure 1 In the method shown, on the one hand, an automated editing method for achieving wet effects is provided, which does not rely on manual editing, thereby reducing manpower and time costs. On the other hand, based on the height difference between the terrain height and the water surface height of the first area, the wet state parameters are determined so that the wet state parameters are adapted to the geographical environment conditions of the first area. The first area is rendered based on the wet state parameters, which can ensure that the rendered effect conforms to the wet state of the first area, and different wet effects can be achieved for areas with different wet states, which is conducive to improving the expressiveness of the wet effect and enhancing the realism of the virtual scene. On the other hand, this solution has strong applicability and is not restricted to the shape, size, etc. of the virtual scene or the first area. For example, any area in the virtual scene can be processed to obtain a more ideal wet effect.
[0031] Below Figure 1 Provide detailed instructions for each step.
[0032] refer to Figure 1 In step S110, the terrain height of the first area in the virtual scene is obtained.
[0033] The first area is an area to be processed in the virtual scene, which may be any one or more areas in the virtual scene, or a specified area. Exemplarily, the first area may be a unit space or unit plane in the virtual scene, such as the virtual scene may be divided into pixel units (such as pixel points) on a horizontal plane (which may be an XY plane, indicating a plane formed by an X-axis and a Y-axis), and the first area may be one or more of the pixel units. In one embodiment, the first area may be a vertex of a model of the virtual scene.
[0034] If each unit space in the virtual scene is used as the first area, and the virtual scene processing method in this exemplary embodiment is used for processing, different unit spaces have corresponding moisture effects, which can achieve highly refined moisture effects even at the pixel level.
[0035] The terrain height may be a coordinate in the height direction, such as a Z coordinate. In one implementation, the Z-axis coordinate value of the first area in the world coordinate system may be obtained, that is, the terrain height of the first area.
[0036] In one embodiment, the first region includes a plurality of pixels with different terrain heights. For example, there is a vertical side of an object or terrain (such as a cliff wall of a mountain) in the first region, on which a plurality of pixels are distributed, and the terrain heights of these pixels are different. In this case, the terrain height of each pixel in the first region can be obtained, such as the Z-axis coordinate value of each pixel.
[0037] Continue to refer Figure 1 In step S120, the water surface height of the target water body corresponding to the first area is obtained, wherein the humidity level of the first area is affected by the target water body.
[0038] The target water body is a virtual water body area that can affect the humidity of the first area. For example, if there is a water body area in the first area, such as a pond, river, lake, ocean, etc., the water body area can be used as the target water body to determine the water surface height of the target water body corresponding to the first area. If there is no water body area in the first area, the water surface height of the target water body corresponding to the first area can be determined to be 0. Alternatively, a water body area adjacent to the first area is used as the target water body to determine the water surface height of the target water body corresponding to the first area.
[0039] In one embodiment, if there is no water body area in the first area, and the distance between the first area and the nearest water body area does not exceed a preset distance (the preset distance can be set based on experience or specific circumstances), the water body area closest to the first area is taken as the target water body, and the water surface height of the target water body corresponding to the first area is determined. If there is no water body area in the first area, and the distance between the first area and the nearest water body area exceeds the preset distance, the water surface height of the target water body corresponding to the first area is determined to be 0.
[0040] In one embodiment, the water surface heights corresponding to each area in the virtual scene may be recorded in a mask, such as an 8-bit grayscale image. In step S120, the water surface height of the target water body corresponding to the first area may be obtained from the mask.
[0041] In one embodiment, reference Figure 2As shown, the above-mentioned acquisition of the water surface height corresponding to the first area may include the following steps S210 to S230:
[0042] Step S210, obtaining a first water surface height of a target water body corresponding to a first area.
[0043] The first water surface height refers to the basic water surface height, which can be the water surface height without considering the water surface change factor. For example, if there is a water body area in the first area, the water body area is used as the target water body, and the basic water surface height of the target water body is used as the first water surface height. If there is no water body area in the first area, the first water surface height of the target water body corresponding to the first area is 0. Alternatively, if there is no water body area in the first area, and the first area is no more than a preset distance away from the nearest water body area, the water surface height of the water body area is used as the first water surface height of the target water body corresponding to the first area. If there is no water body area in the first area, and the first area is more than a preset distance away from the nearest water body area, the first water surface height of the target water body corresponding to the first area is 0.
[0044] In one embodiment, reference Figure 3 As shown, the above-mentioned obtaining of the first water surface height of the target water body corresponding to the first area may include the following steps S310 to S330:
[0045] Step S310, obtaining the plane coordinates of the first area on the horizontal plane of the virtual scene;
[0046] Step S320, sampling in the water surface height map of the virtual scene based on the plane coordinates to obtain a first mask value corresponding to the first area;
[0047] Step S330 , converting the first mask value into a numerical value according to the numerical range of the terrain height to obtain a first water surface height of the target water body corresponding to the first area.
[0048] The plane coordinates of the first area may be X coordinates and Y coordinates. The water surface height map is a map used to record the water surface heights of various areas in the virtual scene, such as a mask. The water surface height map records the first mask value of each area, and the first mask value is used to represent the water surface height. Since the water surface height map limits the value thereof not to exceed the interval [0,1], the first mask value may be the normalized water surface height.
[0049] The first mask value corresponding to the first area can be obtained by sampling in the water surface height map. Exemplarily, if the first area is a pixel, the corresponding first mask value is obtained from the water surface height map based on the plane coordinates of the pixel. If the first area includes multiple pixels, some of the pixels can be selected and the corresponding first mask value can be obtained from the water surface height map based on their plane coordinates, or the corresponding first mask value can be obtained from the water surface height map based on the plane coordinates of all the pixels.
[0050] After obtaining the first mask value, it can be converted to a numerical range of terrain height for the convenience of subsequent calculations. For example, the first mask value can be multiplied by the conversion coefficient of the numerical range and added to the preset basic value to obtain the first water surface height of the target water body corresponding to the first area, such as the following formula (1):
[0051] h1=m1p1+p2 (1)
[0052] Among them, h1 represents the first water surface height, m1 represents the first mask value, p1 and p2 are calculation parameters, p1 represents the conversion coefficient, and p2 represents the basic value.
[0053] pass Figure 3 In this way, the water surface height information is recorded in the water surface height map, which is convenient for quickly obtaining the water surface height information during the processing, unifying the numerical range of the first water surface height and the terrain height information, and facilitating subsequent calculations. Thus, the processing efficiency is improved.
[0054] Step S220: determining a water surface height increment corresponding to the first area according to the environmental parameters of the first area.
[0055] The water surface height increment refers to the change in water surface height determined by taking into account water surface change factors. Water surface change factors include but are not limited to one or more of the following aspects:
[0056] The spread of water surface. In the real world, water will spread upward along the surface of an object or terrain, so that some areas located on the water surface will also be wet. This exemplary embodiment can simulate the water surface spread phenomenon in the real world and calculate the water surface spread height. The water surface height increment can include the water surface spread height;
[0057] The fluctuation of the water surface. In the real world, due to the effects of wind, ships sailing on the water, etc., the water surface will fluctuate, resulting in changes in the water surface height. This exemplary embodiment can simulate the water surface fluctuation phenomenon in the real world and calculate the water surface fluctuation increment. The water surface height increment can include the water surface fluctuation height;
[0058] The rise and fall of the water surface simulates the tidal changes in the real world. The water surface height changes with time or day and night. The water surface height increment can include the water surface rise and fall height.
[0059] Accordingly, the environmental parameters of the first area may include one or more environmental parameters that affect the water surface height, for example: surface slope, which refers to the degree of surface inclination of the first area, which can affect the spreading height of the water surface, such as the area with a lower slope, the flatter its surface, the easier it is for water to spread upward, and the greater the spreading height of the water surface; wind force, which can affect the increment of water surface fluctuation, such as the greater the wind force, the more violent the fluctuation of the water surface, and the greater the increment of water surface fluctuation; day and night state, which can affect the rise and fall of the water surface. The environmental parameters of the first area can be obtained from the properties of the first area (including environmental properties), or can be calculated based on the existing parameters of the first area, or can be obtained from the current environmental information of the virtual scene. The calculation relationship (such as a functional relationship) between the environmental parameters and the water surface height increment can be pre-set; when the environmental parameters of the first area are obtained, the corresponding water surface height increment can be calculated through the calculation relationship between the environmental parameters and the water surface height increment.
[0060] In one embodiment, the environmental parameter includes a surface slope. The following is an exemplary description of how to determine the surface slope of the first area.
[0061] In one implementation, a dot product operation may be performed on the normal vector of the first region and the height direction vector of the virtual scene, and the surface slope of the first region may be determined according to the dot product operation result.
[0062] Among them, the normal vector is a vector perpendicular to the surface of the first area, and can be a unit vector in the normal direction. The height direction vector of the virtual scene can be a unit vector in the positive direction of the Z axis (perpendicular to the horizontal plane and upward). By calculating the dot product of the two, the cosine value of the angle between the normal vector and the height direction vector can be obtained, which is equivalent to the cosine value of the angle between the surface tangent of the first area and the horizontal plane. The dot product operation result can be used as the surface slope of the first area, and the dot product operation result can be further calculated. For example, when the normal vector or the height direction vector is not a unit vector, the dot product operation result can be calculated by the ratio of the modulus of the normal vector and the height direction vector to obtain the surface slope of the first area, or the dot product operation result can be normalized to serve as the surface slope of the first area.
[0063] Exemplarily, the surface slope of the first region can be calculated by the following formula (2):
[0064] Slope=saturate(N·(0,0,1)) (2)
[0065] Among them, slope represents the surface slope, N is the surface normal vector, and (0,0,1) represents the height direction vector.
[0066] In one embodiment, the surface slope of the first area may be calculated based on the difference between the terrain height of the first area and the terrain height of its adjacent area, and the distance between the first area and its adjacent area on the horizontal plane.
[0067] In one implementation, the surface slopes of various regions in the virtual scene may be recorded in advance in a mask or a map, and the surface slope of the first region may be read from the mask or the map.
[0068] In one embodiment, the above-mentioned determining the water surface height increment corresponding to the first area according to the environmental parameters of the first area may include the following steps:
[0069] The surface slope of the first area is used as a variable of the first negative correlation function, and the water surface height increment corresponding to the first area is obtained according to the calculation result of the first negative correlation function.
[0070] As mentioned above, the water surface height increment determined according to the surface slope may be the water surface spreading height. The two variables of the first negative correlation function are negatively correlated, such as functions of the form of y=1-x, y=1 / x, etc. or variants thereof. In this exemplary embodiment, the first negative correlation function is used to make the surface slope of the first area and the water surface height increment negatively correlated, which complies with the rule that the flatter the terrain, the easier the water surface spreads. Exemplarily, the surface slope of the first area may be substituted into the first negative correlation function and used as an independent variable, and the calculation result of the first negative correlation function, i.e., the function value corresponding to the surface slope, is output after calculation. The calculation result may be used as the water surface height increment corresponding to the first area, or the calculation result may be further calculated (such as normalized) to obtain the water surface height increment corresponding to the first area.
[0071] Exemplarily, the water surface height increment can be calculated by the following formula (3):
[0072] Δh=k2(1-slope) k1 (3)
[0073] Wherein, Δh represents the water surface height increment, k1 and k2 are calculation parameters, which can be determined based on experience or specific circumstances (such as terrain height, numerical range of the first water surface height), such as k1 is 2 and k2 is 2000.
[0074] Step S230: determining a second water surface height corresponding to the first area according to the first water surface height and the water surface height increment.
[0075] The second water surface height is the water surface height that takes into account the water surface change factor. The first water surface height can be added to the water surface height increment to obtain the second water surface height. Alternatively, the addition result of the first water surface height and the water surface height increment is further calculated, such as limiting the addition result within a certain value range, to obtain the second water surface height.
[0076] pass Figure 2 In this way, when obtaining the water surface height, the basic water surface height and the water surface change factor are considered, so that the second water surface height obtained is more in line with the geographical environment characteristics of the virtual scene or the first area, and can achieve diverse water surface heights, which is conducive to achieving diverse humidity effects.
[0077] Continue to refer Figure 1 In step S130, the wet state parameter of the first area is determined according to the height difference between the terrain height and the water surface height.
[0078] The height difference value may be the difference value obtained by subtracting the water surface height from the terrain height. The humidity state parameter is used to characterize the humidity state of the first area, which may be a quantitative parameter, such as a humidity degree value, or a qualitative parameter, such as a classification result of the humidity state, such as including completely dry, slightly humid, moderately humid, highly humid, completely humid, and the like.
[0079] Generally, the larger the height difference is, the farther the first area is from the water surface, and the drier it is. The smaller the height difference is, the closer the first area is to the water surface, and the more humid it is. For example, multiple intervals can be pre-set for the height difference, and they correspond to different classification results of humidity states, such as the height difference (-∞, 0] corresponds to completely wet, (0, 10] corresponds to highly wet, (10, 20] corresponds to moderately wet, (20, 30) corresponds to slightly wet, and [30, +∞] corresponds to completely dry. In step S130, the corresponding interval can be determined based on the height difference between the terrain height and the water surface height of the first area, and then the corresponding humidity state parameter can be determined.
[0080] In one embodiment, if the second water surface height corresponding to the first area has been previously determined, then determining the wetness state parameters of the first area based on the height difference between the terrain height and the water surface height may include: determining the wetness state parameters of the first area based on the height difference between the terrain height and the second water surface height.
[0081] In one embodiment, reference Figure 4 As shown, the above-mentioned determination of the wet state parameter of the first area according to the height difference between the terrain height and the water surface height may include the following steps S410 and S420:
[0082] Step S410, determining a moisture attenuation value according to the height difference between the terrain height and the water surface height and a preset moisture attenuation coefficient;
[0083] Step S420: Taking the moisture attenuation value as a variable of the second negative correlation function, the moisture state parameter of the first area is obtained according to the calculation result of the second negative correlation function.
[0084] The moisture attenuation coefficient indicates the extent to which the moisture level decreases as the height difference increases, and is used to quantify the height difference into a numerical value indicating the moisture attenuation level. The moisture attenuation coefficient can be set in advance based on experience or specific circumstances, such as 300, indicating that when the height difference reaches 300, the moisture attenuation level is the maximum, and the moisture attenuation is completely dry. The ratio of the height difference to the moisture attenuation coefficient can be calculated and used as the moisture attenuation value, or the ratio can be further calculated, such as normalized or calculated as the power value of a specific exponent, to obtain the moisture attenuation value. Exemplarily, the moisture attenuation value can be calculated using the following formula (4):
[0085] wet_decay=clamp(0,1,(Z-h2) / k3) (4)
[0086] Among them, wet_decay represents the wet attenuation value, Z represents the terrain height, h2 represents the second water surface height, which can be the sum of the first water surface height h1 and the water surface height increment Δh, k3 represents the wet attenuation coefficient, and the clamp() function is used to limit the ratio of the height difference (Z-h2) to the wet attenuation coefficient k3 within the range of 0 to 1 to obtain the wet attenuation value.
[0087] The two variables of the second negative correlation function are negatively correlated, such as functions of the form of y=1-x, y=1 / x, etc. or their variants. The second negative correlation function may be the same as or different from the first negative correlation function mentioned above. In this exemplary embodiment, the second negative correlation function is used to make the moisture attenuation value and the moisture state parameter have a negative correlation, that is, the larger the moisture attenuation value, the smaller the moisture state parameter, indicating that it is less humid. Exemplarily, the moisture attenuation value can be substituted into the second negative correlation function and used as an independent variable, and the calculation result of the second negative correlation function is output after calculation, that is, the function value corresponding to the moisture attenuation value. The calculation result can be used as the moisture state parameter of the first area, and the calculation result can also be further calculated (such as normalization) to obtain the moisture state parameter of the first area.
[0088] pass Figure 4 Determining the humidity state parameters of the first area in this way can ensure that the humidity state parameters conform to natural laws and enhance the realism of the final humidity effect.
[0089] In one embodiment, the step of obtaining the moisture state parameter of the first area according to the calculation result of the second negative correlation function may include the following steps:
[0090] The moisture state parameter of the first area is obtained according to the product of the calculation result of the second negative correlation function and the moisture coefficient corresponding to the first area; the moisture coefficient corresponding to the first area is a coefficient determined from one or more preset moisture coefficients.
[0091] In the real world, some materials are susceptible to moisture, while some materials are not. This exemplary embodiment characterizes the degree of moisture of a specific material through a moisture coefficient. One or more moisture coefficients can be pre-set to correspond to different materials. For example, a virtual scene includes different terrain materials, such as land, grass, concrete, etc., and corresponding moisture coefficients can be set for one or more of the materials, or even for each material. The moisture coefficient of each area in the virtual scene can be recorded in a mask or map, and the second mask value in the mask or map is the moisture coefficient of the corresponding position. The moisture coefficient corresponding to the first area can be determined from one or more preset moisture coefficients according to the position or material of the first area, such as the second mask value can be read from the mask recording the moisture coefficient according to the position of the first area, that is, the moisture coefficient corresponding to the first area.
[0092] Generally, the larger the moisture coefficient is, the more susceptible the corresponding material is to moisture. For example, the moisture coefficient can be set to a value of 0 to 1, where a moisture coefficient of 1 indicates that the material is most susceptible to moisture, and a moisture coefficient of 0 indicates that the material is not susceptible to moisture at all.
[0093] The calculation result of the above-mentioned second negative correlation function can be multiplied by the moisture coefficient corresponding to the first area, and the product can be used as the moisture state parameter of the first area. The product can also be further calculated, such as normalized, to obtain the moisture state parameter of the first area.
[0094] Exemplarily, the humidity state parameter includes a humidity level value, and the humidity level value of the first area can be calculated by the following formula (5):
[0095] wetness=m2(1-wet_decay k 4) (5)
[0096] Among them, wetness represents the humidity value, m2 represents the second mask value, that is, the moisture coefficient corresponding to the first area, and k2 is a calculation parameter, which is an index of the humidity attenuation value. It can be seen that the second negative correlation function is y=1-x k4 The result of the second negative correlation function is multiplied by the moisture coefficient to obtain the moisture level value.
[0097] Through the above method, in the process of calculating the moisture state parameters, the factor of moisture attenuation with height is taken into account, and the moisture coefficient is introduced to distinguish the moisture degree of different materials. The moisture state parameters calculated in this way are in line with the geographical environment and material characteristics of the first area, making the final moisture effect more realistic.
[0098] Continue to refer Figure 1In step S140, the first area is rendered based on the wet state parameter.
[0099] The first region has one or more attributes that may be affected by moisture, which may be appearance attributes, and these attributes are referred to as moisture-related attributes, such as color, roughness, smoothness, brightness, etc. The moisture-related attributes of the first region may be adjusted based on the moisture state parameter, and the first region may be rendered according to the adjusted attributes, so that the appearance of the first region can present a moisture effect.
[0100] In one embodiment, the preset attribute value of the first area can be adjusted based on the wet state parameter to obtain the target attribute value of the first area, and the first area is rendered according to the target attribute value. Among them, the preset attribute value can be a default value of the wetness-related attribute, such as an attribute value that can represent a completely dry state. When the first area is damp, the wetness-related attribute is affected, and its attribute value can change. This exemplary embodiment adjusts the preset attribute value of the first area based on the wet state parameter to obtain a target attribute value that conforms to the wet state. It should be understood that the attribute value adjustment can be performed on any one or more wetness-related attributes of the first area. In order to fully present the wetness effect, the attribute value adjustment can be performed on all the wetness-related attributes of the first area, such as adjusting the color, roughness, smoothness, brightness, etc. Each wetness-related attribute has a preset attribute value, and the preset attribute value of each wetness-related attribute can be adjusted respectively to obtain the target attribute value of each wetness-related attribute. Then the first area is rendered according to the target attribute value.
[0101] In one implementation, the rendering of the first area based on the wet state parameter may include the following steps:
[0102] Based on the wet state parameter, at least two property values corresponding to different wet states of the first region are mixed, or the property value corresponding to the dry state of the first region and at least one property value corresponding to the wet state are mixed to obtain a target property value of the first region;
[0103] The first area is rendered according to the target attribute value.
[0104] The at least two attribute values used for mixing refer to two attribute values of the same moisture-related attribute, which correspond to different moisture states, or correspond to a dry state and a wet state. For example, the at least two attribute values may include a dry color and a wet color, the dry color represents the color of the first area in a dry state (i.e., a completely dry state, a state where the moisture level is 0), and the wet color represents the color of the first area in a completely wet state. At least two preset attribute values may be pre-set for each moisture-related attribute.
[0105] In one embodiment, at least two attribute values for mixing can be obtained in the following manner: obtain a first attribute value corresponding to a dry state or a first wet state, and calculate a second attribute value corresponding to a second wet state according to the first attribute value and the coefficient corresponding to the second wet state. For example, taking the dry state as a reference, the second wet state can be a completely wet state, and the coefficient corresponding to the second wet state relative to the dry state can be preset based on experience or specific circumstances, such as 0.5, which indicates the degree of attenuation of the attribute in the second wet state compared to the dry state. The first attribute value corresponding to the dry state can be multiplied by the coefficient to obtain the second attribute value corresponding to the second wet state. In this way, only one attribute value is needed to calculate other attribute values, which is conducive to simplifying the data processing process.
[0106] The target attribute value may be calculated by mixing two or more attribute values. For example, the dry color and the wet color are mixed based on the wet state parameter to obtain a target color that matches the wet state of the first region. The wet state parameter of the first region may be between completely dry and completely wet, and the mixed target color may be between the dry color and the wet color. Exemplarily, the wet state parameter includes a wetness value, and the target color may be calculated with reference to the following formula (6):
[0107] target_color=dry_color·(1-wetness)+wet_color·wetness (6)
[0108] Among them, target_color represents the target color, dry_color represents the dry color, and wet_color represents the wet color. It can be seen that the weights of the dry color and the wet color are calculated according to the wetness value, and the two colors are mixed based on the weights to obtain the target color.
[0109] It should be understood that three or more attribute values under the same moisture-related attribute can also be obtained, and these attribute values correspond to different moisture states, or correspond to dry states or different moisture states. Similar interpolation methods can be used to mix three or more attribute values. For example, the distance between the moisture state or dry state corresponding to each attribute value and the moisture state parameter of the first area can be calculated (such as the moisture degree values can be subtracted to calculate the distance), and the mixing weight of each attribute value is determined according to the distance. The mixing weight can be negatively correlated with the distance, such as normalizing "1-distance" or "1 / distance" to obtain the mixing weight. Then, multiple attribute values are mixed using the mixing weight to obtain the target attribute value.
[0110] Based on a similar approach, target roughness, target smoothness, target brightness, etc. can also be calculated.
[0111] After determining the target attribute value of the first region, rendering the first region based on the target attribute value can make the first region appear to have a wet appearance, thereby achieving a wet effect.
[0112] Figure 5 A schematic diagram of the wetness effect is shown. It can be seen that the wetness is stronger in the land area below the water surface and very close to the water surface, and the wetness gradually decreases in the land area higher from the water surface. In the land area far from the water surface, the wetness is weak or non-existent.
[0113] The exemplary embodiment of the present disclosure also provides a virtual scene processing device. Figure 6 As shown, the virtual scene processing device 600 includes the following program modules:
[0114] A first acquisition module 610 is configured to acquire a terrain height of a first area in a virtual scene;
[0115] The second acquisition module 620 is configured to acquire the water surface height of the target water body corresponding to the first area, wherein the humidity of the first area is affected by the target water body;
[0116] A wet state parameter determination module 630 is configured to determine a wet state parameter of the first area according to a height difference between a terrain height and a water surface height;
[0117] The rendering processing module 640 is configured to render the first area based on the wet state parameter.
[0118] In one embodiment, the above-mentioned obtaining the water surface height of the target water body corresponding to the first area includes: obtaining the first water surface height of the target water body corresponding to the first area; determining the water surface height increment corresponding to the first area according to the environmental parameters of the first area; determining the second water surface height corresponding to the first area according to the first water surface height and the water surface height increment; the above-mentioned determining the wetness state parameter of the first area according to the height difference between the terrain height and the water surface height includes: determining the wetness state parameter of the first area according to the height difference between the terrain height and the second water surface height.
[0119] In one embodiment, the environmental parameters include a surface slope; the above-mentioned determination of the water surface height increment corresponding to the first area based on the environmental parameters of the first area includes: taking the surface slope of the first area as a variable of a first negative correlation function, and obtaining the water surface height increment corresponding to the first area based on the calculation result of the first negative correlation function.
[0120] In one embodiment, the above-mentioned obtaining of the first water surface height of the target water body corresponding to the first area includes: obtaining the plane coordinates of the first area on the horizontal plane of the virtual scene; sampling in the water surface height map of the virtual scene based on the plane coordinates to obtain a first mask value corresponding to the first area; and numerically converting the first mask value according to a numerical range of the terrain height to obtain the first water surface height of the target water body corresponding to the first area.
[0121] In one embodiment, the above-mentioned determination of the moisture state parameters of the first area based on the height difference between the terrain height and the water surface height includes: determining the moisture attenuation value based on the height difference between the terrain height and the water surface height and a preset moisture attenuation coefficient; taking the moisture attenuation value as the variable of the second negative correlation function, and obtaining the moisture state parameters of the first area according to the calculation result of the second negative correlation function.
[0122] In one embodiment, the moisture state parameter of the first area is obtained according to the calculation result of the second negative correlation function, including: obtaining the moisture state parameter of the first area according to the product of the calculation result of the second negative correlation function and the moisture coefficient corresponding to the first area; the moisture coefficient corresponding to the first area is a coefficient determined from one or more preset moisture coefficients.
[0123] In one embodiment, the above-mentioned rendering of the first area based on the wetness state parameter includes: based on the wetness state parameter, mixing at least two preset attribute values corresponding to different wetness states of the first area, or mixing the attribute value corresponding to the dry state of the first area and at least one attribute value corresponding to the wetness state to obtain a target attribute value of the first area; rendering the first area according to the target attribute value.
[0124] The specific details of each part of the above-mentioned device have been described in detail in the implementation method of the method part. The undisclosed details can be found in the implementation method of the method part, so they will not be repeated here.
[0125] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0126] The exemplary embodiments of the present disclosure also provide a computer program product, which includes a computer program, and the computer program implements the above method when executed by a processor.
[0127] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing a computer program. The readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing a computer program, such as a read-only memory, a NAND flash memory, and the like.
[0128] In one embodiment, the computer program product may be an intangible product including a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as a digital file storing an executable file, an installation package, etc. of the computer program.
[0129] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., an Internet connection provided by an operator).
[0130] Computer programs can be carried or transmitted through electrical, magnetic, optical, electromagnetic, infrared and other signals. Electronic devices can convert signals carrying computer programs into digital signals to run the computer programs. When a computer program runs on an electronic device, its code is used to enable the electronic device to execute (more specifically, enable the processor of the electronic device to execute) the method steps of various exemplary embodiments of the present disclosure. For example, the above method can be executed, which includes the following steps: Step S110, obtaining the terrain height of the first area in the virtual scene; Step S120, obtaining the water surface height of the target water body corresponding to the first area, wherein the humidity of the first area is affected by the target water body; Step S130, determining the humidity state parameter of the first area according to the height difference between the terrain height and the water surface height; Step S140, rendering the first area based on the humidity state parameter.
[0131] By implementing the above method steps through a computer program, on the one hand, it provides a way to achieve the wet effect through automated editing, which does not rely on manual editing, thus reducing the manpower and time costs. On the other hand, according to the height difference between the terrain height and the water surface height of the first area, the wet state parameter is determined so that the wet state parameter is adapted to the geographical environment of the first area. The first area is rendered based on the wet state parameter, which can ensure that the rendered effect conforms to the wet state of the first area, and different wet effects can be achieved for areas with different wet states, which is conducive to improving the expressiveness of the wet effect and enhancing the realism of the virtual scene. On the other hand, this solution has strong applicability and is not restricted to the shape, size, etc. of the virtual scene or the first area. For example, any area in the virtual scene can be processed to obtain a more ideal wet effect.
[0132] The exemplary embodiments of the present disclosure also provide an electronic device, such as the terminal device 110 or the server 120 described above. The electronic device may include a processor and a memory. The memory stores executable instructions of the processor, such as a computer program. The processor executes the method steps of various exemplary embodiments of the present disclosure by executing the executable instructions. In addition, the electronic device may also include a display for displaying a graphical user interface.
[0133] Reference below Figure 7 , the electronic device is exemplarily described in the form of a general-purpose computing device. It should be understood that Figure 7 The electronic device 700 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0134] like Figure 7 As shown, the electronic device 700 may include: a processor 710 , a memory 720 , a bus 730 , an I / O (input / output) interface 740 , a network adapter 750 , and a display 760 .
[0135] The memory 720 may include a volatile memory, such as a RAM 721, a cache unit 722, and may also include a non-volatile memory, such as a ROM 723. The memory 720 may also include one or more program modules 724, such program modules 724 include but are not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or a combination thereof may include the implementation of a network environment. For example, the program module 724 may include each module in the above-mentioned device.
[0136] The processor 710 may include one or more processing units. For example, the processor 710 may include an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor and / or an NPU (Neural-Network Processing Unit), etc.
[0137] The processor 710 can be used to execute executable instructions stored in the memory 720, such as the above-mentioned method, which includes the following steps: step S110, obtaining the terrain height of the first area in the virtual scene; step S120, obtaining the water surface height of the target water body corresponding to the first area, wherein the wetness of the first area is affected by the target water body; step S130, determining the wetness state parameter of the first area according to the height difference between the terrain height and the water surface height; step S140, rendering the first area based on the wetness state parameter.
[0138] By executing the above method steps through the processor 710, on the one hand, an automated editing method for achieving the wet effect is provided, which does not rely on manual editing and reduces the manpower and time costs. On the other hand, the wet state parameters are determined according to the height difference between the terrain height and the water surface height of the first area, so that the wet state parameters are adapted to the geographical environment conditions of the first area. The first area is rendered based on the wet state parameters, which can ensure that the rendered effect conforms to the wet state of the first area, and different wet effects can be achieved for areas with different wet states, which is conducive to improving the expressiveness of the wet effect and enhancing the realism of the virtual scene. On the other hand, this solution has strong applicability and is not restricted to the shape, size, etc. of the virtual scene or the first area. For example, any area in the virtual scene can be processed to obtain a more ideal wet effect.
[0139] The bus 730 is used to realize the connection between different components of the electronic device 700, and may include a data bus, an address bus, and a control bus.
[0140] The electronic device 700 can communicate with one or more external devices 800 (eg, a keyboard, a mouse, an external controller, etc.) through the I / O interface 740 .
[0141] The electronic device 700 can communicate with one or more networks through the network adapter 750. For example, the network adapter 750 can provide mobile communication solutions such as 3G / 4G / 5G, or wireless communication solutions such as wireless LAN, Bluetooth, near field communication, etc. The network adapter 750 can communicate with other modules of the electronic device 700 through the bus 730.
[0142] The electronic device 700 may display a graphical user interface through the display 760 .
[0143] although Figure 7 Not shown, other hardware and / or software modules may also be provided in the electronic device 700, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0144] As can be seen from the above, the technical solution of the present disclosure can be implemented as a method, an apparatus, a system, a computer program product, a storage medium, an electronic device, etc. Those skilled in the art can understand that various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software, such as being respectively referred to as a "circuit", "module" or "system".
[0145] It should be understood that the present disclosure is not limited to the specific method steps or structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. Those skilled in the art will easily think of other embodiments based on the specific embodiments provided by the present disclosure. Therefore, the specific embodiments provided by the present disclosure are only exemplary, and the scope and spirit of the present disclosure are indicated by the claims, and any variations, uses or adaptive changes of the present disclosure should be covered, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the technical field that are not disclosed in the present disclosure.
Claims
1. A virtual scene processing method, characterized in that: The method comprises: Obtaining the terrain height of the first area in the virtual scene; Acquire a water surface height of a target water body corresponding to the first area, wherein the humidity of the first area is affected by the target water body; determining a wetness parameter of the first area according to a height difference between the terrain height and the water surface height; The first area is rendered based on the wetness state parameter.
2. The method according to claim 1, characterized in that The obtaining the water surface height of the target water body corresponding to the first area includes: Acquire a first water surface height of a target water body corresponding to the first area; determining a water surface height increment corresponding to the first area according to environmental parameters of the first area; Determine a second water surface height corresponding to the first area according to the first water surface height and the water surface height increment; The step of determining the wetness parameter of the first area according to the height difference between the terrain height and the water surface height includes: The wetness parameter of the first area is determined according to the height difference between the terrain height and the second water surface height.
3. The method according to claim 2, characterized in that The environmental parameter includes a surface slope; and determining the water surface height increment corresponding to the first area according to the environmental parameter of the first area includes: The surface slope of the first area is used as a variable of a first negative correlation function, and the water surface height increment corresponding to the first area is obtained according to the calculation result of the first negative correlation function.
4. The method according to claim 2, characterized in that: The obtaining a first water surface height of a target water body corresponding to the first area includes: Acquire the plane coordinates of the first area on the horizontal plane of the virtual scene; Sampling in the water surface height map of the virtual scene based on the plane coordinates obtains a first mask value corresponding to the first area; The first mask value is numerically converted according to the numerical range of the terrain height to obtain a first water surface height of the target water body corresponding to the first area.
5. The method according to claim 1, characterized in that The step of determining the wetness parameter of the first area according to the height difference between the terrain height and the water surface height includes: Determining a moisture attenuation value according to a height difference between the terrain height and the water surface height and a preset moisture attenuation coefficient; The moisture attenuation value is used as a variable of a second negative correlation function, and the moisture state parameter of the first area is obtained according to a calculation result of the second negative correlation function.
6. The method according to claim 5, characterized in that The step of obtaining the moisture state parameter of the first area according to the calculation result of the second negative correlation function includes: The moisture state parameter of the first area is obtained according to the product of the calculation result of the second negative correlation function and the moisture coefficient corresponding to the first area; the moisture coefficient corresponding to the first area is a coefficient determined from one or more preset moisture coefficients.
7. The method according to claim 1, characterized in that The rendering of the first area based on the wet state parameter includes: Based on the moisture state parameter, at least two property values corresponding to different moisture states of the first region are mixed, or a property value corresponding to a dry state and at least one property value corresponding to a moisture state of the first region are mixed to obtain a target property value of the first region; The first area is rendered according to the target attribute value.
8. A virtual scene processing device, characterized in that: The device comprises: A first acquisition module is configured to acquire a terrain height of a first area in a virtual scene; A second acquisition module is configured to acquire a water surface height of a target water body corresponding to the first area, wherein the humidity of the first area is affected by the target water body; a wet state parameter determination module, configured to determine the wet state parameter of the first area according to the height difference between the terrain height and the water surface height; The rendering processing module is configured to render the first area based on the wet state parameter.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.