A game translucent material rendering method, device, equipment and medium
By defining the above-water and underwater portions of the semi-transparent material in the game and combining it with PBR lighting models and underwater visibility and refractive index for rendering, the problem of poor rendering effect of the semi-transparent material above and below water was solved, and the realistic texture of the semi-transparent material in different states was restored.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-11-17
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies struggle to effectively render the realistic texture of semi-transparent materials in different states above and below water in games, especially the rendering effect of semi-transparent materials is poor when they are above or below water.
By determining the above-water and underwater portions of the translucent material in the game screen, an initial rendering was performed using a PBR lighting model, and the underwater portion was rendered again by combining underwater visibility and refractive index to achieve the target rendering effect of the translucent material.
It effectively restores the boundary between the translucent material above and below water, and improves the rendering effect of the translucent material in different states, enhancing the realistic texture.
Smart Images

Figure CN115761104B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics processing technology, and in particular to a method, apparatus, device and medium for rendering semi-transparent materials in games. Background Technology
[0002] With the continuous improvement of game rendering technology, most game rendering effects are now achieved through physically based rendering (PBR) rendering workflow. The PBR rendering workflow aims to reproduce the behavior of light and objects interacting in the real world based on the principles of physics and microplanes, so as to reproduce the material properties of most real-world substances in the game.
[0003] However, even though the PBR rendering process is now quite mature, rendering realistic semi-transparent materials in games remains a challenge due to the many unique physical properties they typically possess, such as reflection, refraction, total internal reflection, and thickness. This is especially true when a semi-transparent material is partially above water and partially underwater, making it difficult to render the true texture of the material in both its above-water and underwater states, often resulting in poor rendering quality. Summary of the Invention
[0004] This application provides a method, apparatus, device, and medium for rendering semi-transparent materials in games, in order to solve the problem of poor rendering effect of semi-transparent materials in different states above and below water in the prior art.
[0005] The technical solutions provided in this application are as follows:
[0006] On one hand, embodiments of this application provide a method for rendering semi-transparent materials in games, including:
[0007] Determine the game scene to be rendered; the game scene includes semi-transparent materials and water.
[0008] Based on the positional relationship between the semi-transparent material and the water in the game screen, the first part of the semi-transparent material is located on the water and the second part is located inside the water.
[0009] The PBR lighting model was used to render the semi-transparent material to obtain the original rendering effect;
[0010] Based on the original rendering effect of the second part of the semi-transparent material, underwater visibility and underwater refractive index, the second part of the semi-transparent material is rendered to obtain the underwater rendering effect of the second part of the semi-transparent material;
[0011] Based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material, the target rendering effect of the semi-transparent material is obtained.
[0012] On the other hand, embodiments of this application provide a device for rendering semi-transparent materials in games, including:
[0013] The image determination unit is used to determine the game image to be rendered; the game image includes semi-transparent materials and water.
[0014] The segmentation determination unit is used to determine the first part of the semi-transparent material located on the water body and the second part located inside the water body based on the positional relationship between the semi-transparent material and the water body in the game screen.
[0015] The initial rendering unit is used to render the semi-transparent material using the PBR lighting model to obtain the original rendering effect;
[0016] The underwater rendering unit is used to render the second part of the semi-transparent material based on the original rendering effect, underwater visibility, and underwater refractive index to obtain the underwater rendering effect of the second part of the semi-transparent material.
[0017] The integrated rendering unit is used to obtain the target rendering effect of the semi-transparent material based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material.
[0018] On the other hand, embodiments of this application provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the semi-transparent material rendering method in games provided in embodiments of this application.
[0019] On the other hand, embodiments of this application also provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the semi-transparent material rendering method in games provided in embodiments of this application.
[0020] The beneficial effects of the embodiments of this application are as follows:
[0021] In this embodiment, by determining the first part of the semi-transparent material located on the water and the second part located inside the water based on the positional relationship between the semi-transparent material and the water in the game screen, the boundary between the semi-transparent material above and below the water can be effectively restored when the water flows. Moreover, after initially rendering the semi-transparent material in the game screen using the PBR lighting model, the second part of the semi-transparent material is further rendered based on the original rendering effect, underwater visibility, and underwater refractive index. This can also effectively restore the realistic texture of the semi-transparent material underwater, thereby effectively distinguishing the rendering effect of the semi-transparent material in different states above and below the water, and thus improving the rendering effect of the semi-transparent material in different states above and below the water.
[0022] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0024] Figure 1 This is a schematic diagram outlining the process of rendering semi-transparent materials in a game, as illustrated in the embodiments of this application.
[0025] Figure 2a This is a schematic diagram showing the horizontal plane segmentation range of the water body on the translucent material in the embodiments of this application;
[0026] Figure 2b This is a schematic diagram showing the range of water surface undulations on a translucent material in an embodiment of this application;
[0027] Figure 2c This is a schematic diagram of the target underwater and above-water segmentation range of the translucent material in an embodiment of this application;
[0028] Figure 3 This is a schematic diagram illustrating the specific process of rendering semi-transparent materials in the game as described in this application embodiment;
[0029] Figure 4 This is a functional structure diagram of the glass model rendering device in the embodiments of this application;
[0030] Figure 5 This is a schematic diagram of the hardware structure of the electronic device in the embodiments of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and beneficial effects of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0032] This application provides a method for rendering semi-transparent materials in games. This method can be applied to electronic devices such as computing devices and user terminals. The computing devices include, but are not limited to, servers and virtual machines, while the user terminals include, but are not limited to, mobile phones, tablets, PDAs, laptops, and desktop computers. See also... Figure 1 As shown in the embodiments of this application, the general flow of the semi-transparent material rendering method in games is as follows:
[0033] Step 101: Determine the game scene to be rendered; the game scene includes semi-transparent materials and water.
[0034] In practical applications, electronic devices can determine all game scenes, including those with translucent materials and water, as the game scenes to be rendered, or they can determine only certain parts of the game scenes, including those with translucent materials and water, as the game scenes to be rendered, depending on actual needs.
[0035] Step 102: Based on the positional relationship between the semi-transparent material and the water in the game screen, determine the first part of the semi-transparent material located on the water and the second part located inside the water.
[0036] In practical applications, when electronic devices determine the first part of the translucent material located on the water and the second part located within the water based on the positional relationship between the translucent material and the water in the game screen, the steps may include, but are not limited to, the following:
[0037] Step a: The electronic device determines the horizontal plane segmentation range of the water body on the semi-transparent material based on the water surface height in the game screen. In specific implementation, the electronic device can determine the horizontal plane segmentation range of the water body on the semi-transparent material based on the relationship between the coordinate height of each pixel in the game screen and the water surface height. For example, the electronic device can use the following formula (1) to obtain... Figure 2a The water body shown is divided into horizontal planes on a translucent material.
[0038] inOutOcean=step(oceanHeight, input.positionWS.y)...Formula (1)
[0039] Wherein, inOutOcean represents the horizontal plane segmentation range, oceanHeight represents the water surface height, input.positionWS.y represents the coordinate height (i.e., y-axis coordinate) of each pixel corresponding to the semi-transparent material in the game screen, and step() represents the output of 0 when input.positionWS.y is less than oceanHeight and the output of 1 when input.positionWS.y is greater than oceanHeight.
[0040] Step b: Based on the scene depth map and water surface undulation control parameters of the game screen, the electronic device determines the water surface undulation segmentation range on the semi-transparent material. In specific implementation, the electronic device may adopt, but is not limited to, the following methods:
[0041] First, the electronic device samples the scene depth map based on the pixel coordinates of the game screen to obtain the scene depth map of the game screen. For example, the electronic device can use the following formula (2) to obtain the scene depth map of the game screen.
[0042] sceneDepth=SAMPLE_DEPTH_TEXTURE_LOD(CameraDepthTexture,samplerCameraDepthTexture,screenUV,0)...Formula (2)
[0043] Among them, sceneDepth represents the scene depth map, SAMPLE_DEPTH_TEXTURE_LOD() represents the depth map sampling function, CameraDepthTexture represents the scene depth map, samplerCameraDepthTexture represents the depth map sampling method, and screenUV represents the pixel coordinates of the game screen.
[0044] Secondly, the electronic device performs a perspective transformation on the scene depth map of the game screen to obtain the target scene depth map of the game screen. For example, the electronic device can use the following formula (3) to obtain the target scene depth map of the game screen.
[0045] sceneZ=LinearEyeDepth(sceneDepth)...Formula (3)
[0046] Here, sceneZ represents the target scene depth map, sceneDepth represents the scene depth map, and LinearEyeDepth() represents the viewpoint transformation function.
[0047] Then, the electronic device performs perspective division correction on the target scene depth map of the game screen to obtain the corrected scene depth map of the game screen.
[0048] Finally, the electronic device determines the range of water surface undulations on the translucent material based on the water surface undulation control parameters, the target scene depth map, and the corrected scene depth map. For example, the electronic device can use the following formula (4) to obtain... Figure 2b The water body shown is depicted as exhibiting the range of surface undulations on a translucent material.
[0049] waveRange=1–saturate(sceneZ-screenPosition.w)*Range…Formula (4)
[0050] Among them, waveRange represents the range of water surface undulation, sceneZ represents the target scene depth map, screenPosition.w represents the corrected scene depth map, Range represents the water surface undulation control parameter, and saturate() represents limiting the difference between sceneZ and screenPosition.w to [0, 1].
[0051] Step c: The electronic device determines the target above-water and underwater segmentation range of the translucent material based on the horizontal plane segmentation range and the water surface undulation segmentation range. For example, the electronic device can use the following formula (5) to obtain... Figure 2c The target underwater and above-water segmentation range is shown as a semi-transparent material.
[0052] oceanRange=max(inoutOcean,waveRange)...Formula (5)
[0053] Among them, oceanRange represents the target water surface and underwater segmentation range, inoutOcean represents the horizontal plane segmentation range, waveRange represents the water surface undulation range, and max() represents taking the maximum value of inoutOcean and waveRange.
[0054] Step d: Based on the target above-water and underwater segmentation range of the translucent material, the electronic device determines the first part of the translucent material located on the water body and the second part located inside the water body.
[0055] Step 103: Use the PBR lighting model to render the semi-transparent material to obtain the original rendering effect.
[0056] In practical applications, PBR rendering can usually reproduce the behavior of light interacting with objects in the real world. Therefore, in the embodiments of this application, electronic devices can also use the PBR lighting model to perform preliminary rendering of semi-transparent materials to obtain the original rendering effect of semi-transparent materials.
[0057] Step 104: Based on the original rendering effect of the second part of the semi-transparent material, underwater visibility, and underwater refractive index, render the second part of the semi-transparent material to obtain the underwater rendering effect of the second part of the semi-transparent material.
[0058] In practical applications, before rendering the second part of the semi-transparent material based on its original rendering effect, underwater visibility, and underwater refractive index to obtain the underwater rendering effect, electronic devices can first determine the underwater visibility and underwater refractive index of the semi-transparent material. Specifically, electronic devices can use, but are not limited to, the following methods:
[0059] First, the electronic device obtains the underwater visibility of the second part of the translucent material by simulating fog, based on the scene depth map and fog color values of the game screen. For example, the electronic device can obtain the underwater visibility of the second part of the translucent material using the following formula (6).
[0060] oceanFog=FogColor*sceneDepht...Formula (6)
[0061] Among them, oceanFog represents underwater visibility, FogColor represents fog color value, and sceneDepht represents scene depth map.
[0062] Secondly, the electronic device performs a refraction offset on the first texture coordinates of the second part of the semi-transparent material based on the noise map of the semi-transparent material to obtain the second texture coordinates of the second part of the semi-transparent material. For example, the electronic device can use the following formula (7) to obtain the second texture coordinates of the second part of the semi-transparent material.
[0063] refractionOffset=SAMPLE_TEXTURE2D(RefractionMap,samplerRefractionMap,input.uv.xy).x...Formula (7)
[0064] Among them, refractionOffset represents the second texture coordinates of the second part of the semi-transparent material, SAMPLE_TEXTURE2D() represents the texture sampling function, RefractionMap represents the noise map of the semi-transparent material, samplerRefractionMap represents the sampling method of the noise map, and input.uv.xy represents the first texture coordinates of the second part of the semi-transparent material.
[0065] Then, the electronic device samples the opaque map of the water body based on the second map coordinates of the second part of the semi-transparent material to obtain the underwater refractive index of the second part of the semi-transparent material. For example, the electronic device can obtain the underwater refractive index of the second part of the semi-transparent material using the following formula (8).
[0066] refraction=SAMPLE_TEXTURE2D(CameraOpaqueTexture,samplerCameraOpaqueTexture,screenUV uv+refractionOffset).rgb...Formula (8)
[0067] Here, refraction represents the underwater refractive index of the second part of the semi-transparent material, SAMPLE_TEXTURE2D() represents the texture sampling function, CameraOpaqueTexture represents the opaque texture of the water body, samplerCameraOpaqueTexture represents the sampling method of the opaque texture, screenUV uv represents the pixel coordinates of the semi-transparent material, and refractionOffset represents the second texture coordinates of the second part of the semi-transparent material.
[0068] Finally, based on the original rendering effect of the second part of the semi-transparent material, underwater visibility, and underwater refractive index, the electronic device performs linear interpolation on the scene depth map of the game screen to obtain the underwater rendering effect of the second part of the semi-transparent material. For example, the electronic device can use the following formula (9) to obtain the underwater rendering effect of the second part of the semi-transparent material.
[0069] underSeaGlass=lerp(refraction,oriGlass+oceanFog,sceneDepht)
[0070] ...Formula (9)
[0071] Among them, underSeaGlass represents the underwater rendering effect of the second part of the semi-transparent material, refraction represents the underwater refractive index of the second part of the semi-transparent material, oriGlass represents the original rendering effect of the semi-transparent material, oceanFog represents the underwater visibility, sceneDepht represents the scene depth map of the game screen, and lerp() represents linear interpolation.
[0072] Step 105: Based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material, obtain the target rendering effect of the semi-transparent material.
[0073] In practical applications, electronic devices can perform linear interpolation on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material based on the target underwater segmentation range of the semi-transparent material to obtain the target rendering effect of the semi-transparent material. For example, electronic devices can use the following formula (10) to obtain the target rendering effect of the semi-transparent material.
[0074] finalGlass=lerp(oriGlass,underSeaGlass,oceanRange)...Formula (10)
[0075] Among them, finalGlass represents the target rendering effect of the semi-transparent material, oriGlass represents the original rendering effect of the semi-transparent material, underSeaGlass represents the underwater rendering effect of the second part of the semi-transparent material, oceanRange represents the target underwater segmentation range, and lerp() represents linear interpolation.
[0076] In this embodiment, by determining the first part of the semi-transparent material located on the water and the second part located inside the water based on the positional relationship between the semi-transparent material and the water in the game screen, the boundary between the semi-transparent material above and below the water can be effectively restored when the water flows. Moreover, after initially rendering the semi-transparent material in the game screen using the PBR lighting model, the second part of the semi-transparent material is further rendered based on the original rendering effect, underwater visibility, and underwater refractive index. This can also effectively restore the realistic texture of the semi-transparent material underwater, thereby effectively distinguishing the rendering effect of the semi-transparent material in different states above and below the water, and thus improving the rendering effect of the semi-transparent material in different states above and below the water.
[0077] In most games, there are often various semi-transparent materials that need to be rendered, such as glass on buildings. Since glass usually has physical properties such as reflection, refraction, total internal reflection, and thickness, it is often difficult to render the realistic texture of glass in different states above and below water using existing PBR lighting models. Therefore, when rendering glass, the semi-transparent material rendering method in the game provided in this application embodiment can be used to realize the rendering effect of glass in different states above and below water, thereby improving the overall rendering effect of glass in different states above and below water.
[0078] The following section uses glass as an example to illustrate the rendering method for semi-transparent materials in games provided in this application. Please refer to [link / reference]. Figure 3 As shown in the embodiments of this application, the specific process of the semi-transparent material rendering method in games is as follows:
[0079] Step 301: The electronic device determines the game scene to be rendered; wherein, the game scene includes glass material and water body.
[0080] Step 302: The electronic device determines the horizontal plane segmentation range of the water body on the glass material based on the water surface height in the game screen using the above formula (1).
[0081] Step 303: The electronic device samples the scene depth map based on the pixel coordinates of the game screen and uses the above formula (2) to obtain the scene depth map of the game screen.
[0082] Step 304: The electronic device uses the above formula (3) to perform a perspective transformation on the scene depth map of the game screen to obtain the target scene depth map of the game screen.
[0083] Step 305: The electronic device performs perspective division correction on the target scene depth map of the game screen to obtain the corrected scene depth map of the game screen.
[0084] Step 306: The electronic device uses the above formula (4) to determine the range of water surface undulation on the glass material based on the water surface undulation control parameters, the target scene depth map and the corrected scene depth map.
[0085] Step 307: The electronic device determines the target water surface and underwater segmentation range of the glass material based on the horizontal plane segmentation range and the water surface undulation segmentation range using the above formula (5).
[0086] Step 308: The electronic device determines the first part of the glass material located on the water body and the second part located inside the water body based on the target above-water and underwater segmentation range of the glass material.
[0087] Step 309: The electronic device uses a PBR lighting model to render the glass material to obtain the original rendering effect.
[0088] Step 310: The electronic device uses the above formula (6) to simulate fog based on the scene depth map and fog color value of the game screen to obtain the underwater visibility of the second part of the glass material.
[0089] Step 311: Based on the noise map of the glass material, the electronic device uses the above formula (7) to refract and offset the first texture coordinates of the second part of the glass material to obtain the second texture coordinates of the second part of the glass material.
[0090] Step 312: The electronic device samples the opaque texture of the water body based on the second map coordinates of the second part of the glass material using the above formula (8) to obtain the underwater refractive index of the second part of the glass material.
[0091] Step 313: Based on the original rendering effect of the second part of the glass material, underwater visibility and underwater refractive index, the electronic device uses the above formula (9) to linearly interpolate the scene depth map of the game screen to obtain the underwater rendering effect of the second part of the glass material.
[0092] Step 314: Based on the target underwater and above-water segmentation range of the glass material, the electronic device uses the above formula (10) to linearly interpolate the original rendering effect of the glass material and the underwater rendering effect of the second part of the glass material to obtain the target rendering effect of the glass material.
[0093] Based on the above embodiments, this application provides a glass model rendering device, see below. Figure 4 As shown, the semi-transparent material rendering device 400 in the game provided in this application embodiment includes at least:
[0094] The image determination unit 401 is used to determine the game image to be rendered; wherein, the game image includes semi-transparent materials and water.
[0095] The segmentation determination unit 402 is used to determine, based on the positional relationship between the semi-transparent material and the water in the game screen, the first part of the semi-transparent material located on the water and the second part located inside the water;
[0096] Initial rendering unit 403 is used to render the semi-transparent material using the PBR lighting model to obtain the original rendering effect;
[0097] The underwater rendering unit 404 is used to render the second part of the semi-transparent material based on the original rendering effect, underwater visibility and underwater refractive index of the second part of the semi-transparent material to obtain the underwater rendering effect of the second part of the semi-transparent material.
[0098] The integrated rendering unit 405 is used to obtain the target rendering effect of the semi-transparent material based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material.
[0099] In one possible implementation, when determining the first part of the translucent material located on the water and the second part located within the water based on the positional relationship between the translucent material and the water in the game screen, the segmentation determination unit 402 is specifically used for:
[0100] Based on the water surface height in the game screen, determine the horizontal plane segmentation range of the water body on the semi-transparent material;
[0101] Based on the scene depth map and water surface undulation control parameters of the game screen, the water surface undulation segmentation range on the semi-transparent material is determined.
[0102] Based on the horizontal plane segmentation range and the water surface undulation segmentation range, the target above-water and underwater segmentation range of the semi-transparent material is determined;
[0103] Based on the target above-water and underwater segmentation range of the semi-transparent material, the first part of the semi-transparent material located on the water body and the second part located inside the water body are determined.
[0104] In one possible implementation, when determining the horizontal plane segmentation range of the water body on the semi-transparent material based on the water surface height in the game screen, the segmentation determination unit 402 is specifically used for:
[0105] Based on the relationship between the coordinate height of each pixel in the game screen and the water surface height, the horizontal plane segmentation range of the water body on the semi-transparent material is determined.
[0106] In one possible implementation, when determining the water surface undulation segmentation range on the translucent material based on the scene depth map of the game screen and water surface undulation control parameters, the segmentation determination unit 402 is specifically used for:
[0107] The scene depth map of the game screen is obtained by sampling the scene depth map based on the pixel coordinates of the game screen.
[0108] The perspective of the scene depth map in the game screen is transformed to obtain the target scene depth map of the game screen;
[0109] Perspective division correction is performed on the target scene depth map of the game screen to obtain the corrected scene depth map of the game screen.
[0110] Based on the water surface undulation control parameters, the target scene depth map, and the corrected scene depth map, the range of water surface undulation on the semi-transparent material is determined.
[0111] In one possible implementation, the game semi-transparent material rendering device 400 provided in this application embodiment further includes:
[0112] The visibility determination unit 406 is used to obtain the underwater visibility of the second part of the semi-transparent material through fog simulation based on the scene depth map and fog color value of the game screen.
[0113] The refractive index determination unit 407 is used to perform refractive offset on the first texture coordinates of the second part of the semi-transparent material based on the noise map of the semi-transparent material to obtain the second texture coordinates of the second part of the semi-transparent material; and to sample the opaque texture of the water body based on the second texture coordinates of the second part of the semi-transparent material to obtain the underwater refractive index of the second part of the semi-transparent material.
[0114] In one possible implementation, when rendering the second part of the semi-transparent material based on its original rendering effect, underwater visibility, and underwater refractive index to obtain an underwater rendering effect of the second part of the semi-transparent material, the underwater rendering unit 404 is specifically used for:
[0115] Based on the original rendering effect of the second part of the semi-transparent material, underwater visibility, and underwater refractive index, linear interpolation is performed on the scene depth map of the game screen to obtain the underwater rendering effect of the second part of the semi-transparent material.
[0116] In one possible implementation, when obtaining the target rendering effect of the semi-transparent material based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material, the comprehensive rendering unit 405 is specifically used for:
[0117] Based on the target underwater and above-water segmentation range of the semi-transparent material, linear interpolation is performed on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material to obtain the target rendering effect of the semi-transparent material.
[0118] It should be noted that the principle of the semi-transparent material rendering device 400 in the game provided in this application embodiment to solve the technical problem is similar to the semi-transparent material rendering method in the game provided in this application embodiment. Therefore, the implementation of the semi-transparent material rendering device 400 in the game provided in this application embodiment can refer to the implementation of the semi-transparent material rendering method in the game provided in this application embodiment, and the repeated parts will not be described again.
[0119] After introducing the semi-transparent material rendering method and apparatus in games provided in the embodiments of this application, the electronic device provided in the embodiments of this application will be briefly introduced next.
[0120] See Figure 5 As shown, the electronic device 500 provided in this application embodiment includes at least: a processor 501, a memory 502, and a computer program stored on the memory 502 and executable on the processor 501. When the processor 501 executes the computer program, it implements the semi-transparent material rendering method in the game provided in this application embodiment.
[0121] The electronic device 500 provided in this application embodiment may further include a bus 503 connecting different devices (including processor 501 and memory 502). The bus 503 represents one or more types of bus structures, including memory bus, peripheral bus, local area bus, etc.
[0122] The memory 502 may include a readable medium in the form of volatile memory, such as random access memory (RAM) 5021 and / or cache memory 5022, and may further include read-only memory (ROM) 5023.
[0123] The memory 502 may also include a program tool 5025 having a set (at least one) of program modules 5024, including but not limited to: an operating subsystem, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0124] Electronic device 500 can also communicate with one or more external devices 504 (e.g., keyboard, remote control, etc.), and with one or more devices that enable a user to interact with electronic device 500 (e.g., mobile phone, computer, etc.), and / or with any device that enables electronic device 500 to communicate with one or more other electronic devices 500 (e.g., router, modem, etc.). This communication can be performed through input / output (I / O) interface 505. Furthermore, electronic device 500 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) through network adapter 506. Figure 5 As shown, network adapter 506 communicates with other modules of electronic device 500 via bus 503. It should be understood that, although... Figure 5 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) subsystems, tape drives, and data backup storage subsystems.
[0125] It should be noted that, Figure 5 The electronic device 500 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0126] The following describes the computer-readable storage medium provided in the embodiments of this application. The computer-readable storage medium provided in the embodiments of this application stores computer instructions, which, when executed by a processor, implement the semi-transparent material rendering method in the game provided in the embodiments of this application. Specifically, the computer instructions can be built into or installed in the processor, so that the processor can implement the semi-transparent material rendering method in the game provided in the embodiments of this application by executing the built-in or installed computer instructions.
[0127] Furthermore, the semi-transparent material rendering method in games provided in this application embodiment can also be implemented as a computer program product, which includes program code. The program code implements the semi-transparent material rendering method in games provided in this application embodiment when it runs on a processor.
[0128] The computer program product provided in this application embodiment can be any combination of one or more readable storage media, wherein the readable storage media can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or any combination thereof. Specifically, more specific examples of readable storage media (a non-exhaustive list) include: electrical connections with one or more wires, portable disks, hard disks, RAM, ROM, erasable programmable read-only memory (EPROM), optical fibers, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0129] The computer program product provided in this application embodiment can be a CD-ROM and include program code, and can also run on electronic devices such as computing devices and user terminals. However, the computer program product provided in this application embodiment is not limited to this. In this application embodiment, the readable storage medium can be any tangible medium that contains or stores program code, which can be used by or in conjunction with an instruction execution system, device, or apparatus.
[0130] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0131] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0132] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0133] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of the embodiments of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims of this application and their equivalents, this application also intends to include these modifications and variations.
Claims
1. A method for rendering semi-transparent materials in games, characterized in that, include: Determine the game scene to be rendered; wherein, the game scene includes semi-transparent materials and water. Based on the positional relationship between the translucent material and the water body in the game screen, the first part of the translucent material located on the water body and the second part located inside the water body are determined. The original rendering effect is obtained by rendering the semi-transparent material using the PBR lighting model; Based on the original rendering effect of the second part of the semi-transparent material, underwater visibility, and underwater refractive index, linear interpolation is performed on the scene depth map of the game screen to obtain the underwater rendering effect of the second part of the semi-transparent material. Based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material, the target rendering effect of the semi-transparent material is obtained.
2. The method for rendering semi-transparent materials in games as described in claim 1, characterized in that, Based on the positional relationship between the translucent material and the water body in the game screen, the first part of the translucent material located on the water body and the second part located within the water body are determined, including: Based on the water surface height of the water body in the game screen, determine the horizontal plane segmentation range of the water body on the translucent material; Based on the scene depth map and water surface undulation control parameters of the game screen, the water surface undulation segmentation range on the translucent material is determined. Based on the horizontal plane segmentation range and the water surface undulation segmentation range, the target above-water and underwater segmentation range of the translucent material is determined; Based on the target above-water and underwater segmentation range of the translucent material, the first part of the translucent material located on the water body and the second part located inside the water body are determined.
3. The method for rendering semi-transparent materials in games as described in claim 2, characterized in that, Based on the water level in the game screen, the horizontal plane segmentation range of the water body on the translucent material is determined, including: Based on the relationship between the coordinate height of each pixel in the game screen and the water surface height, the horizontal plane segmentation range of the water body on the translucent material is determined.
4. The method for rendering semi-transparent materials in games as described in claim 2, characterized in that, Based on the scene depth map and water surface undulation control parameters of the game screen, the water surface undulation segmentation range on the translucent material is determined, including: The scene depth map of the game screen is obtained by sampling the scene depth map based on the pixel coordinates of the game screen. The perspective of the scene depth map of the game screen is transformed to obtain the target scene depth map of the game screen; Perspective division correction is performed on the target scene depth map of the game screen to obtain the corrected scene depth map of the game screen; Based on the water surface undulation control parameters, the target scene depth map, and the corrected scene depth map, the range of water surface undulation on the translucent material is determined.
5. The method for rendering semi-transparent materials in games as described in claim 1, characterized in that, Before obtaining the underwater rendering effect of the second part of the semi-transparent material by linear interpolating the scene depth map of the game screen based on the original rendering effect of the second part of the semi-transparent material, the following steps are also included: Based on the scene depth map and fog color value of the game screen, the underwater visibility of the second part of the translucent material is obtained through fog simulation; Based on the noise map of the semi-transparent material, the first texture coordinates of the second part of the semi-transparent material are refracted and offset to obtain the second texture coordinates of the second part of the semi-transparent material; Based on the second map coordinates of the second part of the translucent material, the opaque map of the water body is sampled to obtain the underwater refractive index of the second part of the translucent material.
6. The method for rendering translucent materials in games as described in any one of claims 2-5, characterized in that, Based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material, the target rendering effect of the semi-transparent material is obtained, including: Based on the target underwater and above-water segmentation range of the semi-transparent material, linear interpolation is performed on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material to obtain the target rendering effect of the semi-transparent material.
7. A device for rendering translucent materials in games, characterized in that, include: A scene determination unit is used to determine the game scene to be rendered; wherein, the game scene includes semi-transparent materials and water. The segmentation determination unit is used to determine, based on the positional relationship between the translucent material and the water body in the game screen, the first part of the translucent material located on the water body and the second part located within the water body; The initial rendering unit is used to render the translucent material using a PBR lighting model to obtain the original rendering effect; The underwater rendering unit is used to perform linear interpolation on the scene depth map of the game screen based on the original rendering effect of the second part of the semi-transparent material, underwater visibility and underwater refractive index, to obtain the underwater rendering effect of the second part of the semi-transparent material. The integrated rendering unit is used to obtain the target rendering effect of the semi-transparent material based on the original rendering effect of the semi-transparent material and the underwater rendering effect of the second part of the semi-transparent material.
8. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the semi-transparent material rendering method in a game as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the semi-transparent material rendering method in a game as described in any one of claims 1-6.