Frosted glass object rendering method and device, vehicle, storage medium and program product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING CHANGAN AUTOMOBILE CO LTD
- Filing Date
- 2026-07-08
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]本发明提供了一种毛玻璃物体渲染方法、装置、车辆、存储介质及程序产品,以解决现有技术无法模拟毛玻璃的物理特性,渲染效果较差的问题
本发明基于屏幕空间中所有毛玻璃物体的深度信息,定位待渲染的目标毛玻璃物体,确保目标毛玻璃物体与其他场景不透明物体以及毛玻璃物体的遮挡关系准确,避免透明层级排序混乱和画面穿模。接着,利用目标毛玻璃物体的表面属性信息和渲染场景信息进行物理光照渲染,得到物理渲染像素值,提升毛玻璃物体的渲染真实感。并且,通过目标毛玻璃物体的表面属性信息以及对光线的折射扭曲参数确定折射偏移量,利用折射偏移量对毛玻璃背后的屏幕背景进行采样,模拟毛玻璃的背景模糊、折射扭曲特性,得到模糊背景像素值。最后,混合物理渲染像素值和模糊背景像素值得到目标像素值,对目标毛玻璃物体进行渲染,从而增强毛玻璃物体的渲染效果。
Smart Images

Figure CN122530408A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image rendering technology, specifically to methods, apparatus, vehicles, storage media, and program products for rendering frosted glass objects. Background Technology
[0002] In driving, parking, and stationary scenario reconstruction and lane-level navigation systems, in addition to displaying the vehicle's status, it is also necessary to display the surrounding environment representation (SR), such as other vehicles, pedestrians, and obstacles, reflecting information including their position, distance, and movement trend, so that the driver can identify potential collision risk factors from a global perspective.
[0003] To avoid overemphasizing the vehicle's surroundings and obscuring its status, existing technologies typically use white-model rendering to weaken the rendering effect (SR). However, besides serious occlusion issues, the white-model effect is also prone to appearing rough and rudimentary when observing the vehicle at close range, causing visual disharmony. Therefore, using a frosted glass rendering effect combines translucency and a matte texture, enhancing image quality while preserving background information. This allows the driver to see objects obscured by the frosted glass object, offering higher practical and visual value.
[0004] With the development of rendering technology, physically based rendering (PBR) has become the mainstream rendering solution in fields such as automotive human-computer interaction and games. For rendering transparent materials such as glass, related technologies typically sample diffuse and specular colors and mix them, then render based on the obtained target pixel values to achieve a basic transparent blending effect. However, this approach cannot simulate the physical properties of frosted glass, such as background blur and refraction distortion. Furthermore, when facing rendering scenes with complex occlusion relationships, transparent rendering is prone to issues like disordered transparency levels and clipping, resulting in poor scene rendering quality. Summary of the Invention
[0005] This invention provides a method, apparatus, vehicle, storage medium, and program product for rendering frosted glass objects, in order to solve the problem that existing technologies cannot simulate the physical properties of frosted glass and have poor rendering effects.
[0006] In a first aspect, the present invention provides a method for rendering frosted glass objects, the method comprising: Based on the depth information of all frosted glass objects in the screen space, the target frosted glass object to be rendered is determined; and the surface attribute information, rendering scene information, refraction distortion parameters, and screen background behind the target frosted glass object are obtained; among them, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. Physical lighting rendering is performed based on surface attribute information and rendering scene information to obtain the physical rendering pixel values of the target frosted glass object. Based on surface property information and refraction distortion parameters, the refraction offset corresponding to the target frosted glass object is determined. Based on the refraction offset, the screen background is blurred and sampled to obtain the blurred background pixel value after refraction by the target frosted glass object. The physical rendering pixel values and the blurred background pixel values are mixed to obtain the target pixel values. The target frosted glass object is then rendered using the target pixel values to obtain the rendering result.
[0007] This invention locates the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space, ensuring accurate occlusion relationships between the target frosted glass object and other opaque objects in the scene, avoiding disordered transparency levels and clipping. Next, physically based lighting rendering is performed using the surface attribute information of the target frosted glass object and the rendering scene information to obtain physically based rendering pixel values, enhancing the realism of the frosted glass object rendering. Furthermore, a refraction offset is determined using the surface attribute information of the target frosted glass object and the refraction distortion parameters of light. This refraction offset is then used to sample the screen background behind the frosted glass, simulating the background blur and refraction distortion characteristics of the frosted glass, obtaining blurred background pixel values. Finally, the physically based rendering pixel values and blurred background pixel values are mixed to obtain the target pixel value, which is then used to render the target frosted glass object, thereby enhancing the rendering effect of the frosted glass object.
[0008] In some optional implementations, the refractive offset corresponding to the target frosted glass object is determined based on surface property information and refractive distortion parameters, including: Based on surface property information, determine the world space normal vector corresponding to the target frosted glass object; Based on the world space normal vector and the refraction distortion parameter, the refraction offset corresponding to the target frosted glass object is calculated.
[0009] This invention combines the world space normal vector of the target frosted glass object with the refraction distortion parameters of light to calculate the refraction offset of the target frosted glass object to light. This characterizes the effect of the uneven structure of the frosted glass surface on the refraction distortion of light, allowing for offset sampling of the screen background behind the frosted glass object based on the refraction offset. This simulates the refraction deformation effect of frosted glass, enhancing the rendering effect. Furthermore, the refraction distortion parameters can be adjusted to adapt to the visual rendering needs of different frosted glass types.
[0010] In some optional implementations, the screen background is blurred based on the refraction offset to obtain blurred background pixel values after refraction by the target frosted glass object, including: Determine the blur parameters corresponding to the screen background; whereby the blur parameters are used to characterize the degree of blur of the screen background. The screen background is blurred by sampling based on the refraction offset and blur parameters to obtain the blurred background pixel values.
[0011] This invention combines blur parameters and refraction offset to perform blur sampling on the screen background, integrates the refraction deformation and blur effect of frosted glass, fully simulates the physical properties of frosted glass, and improves the rendering effect of frosted glass objects.
[0012] In some optional implementations, the screen background is blurred and sampled based on the refraction offset and blur parameters to obtain blurred background pixel values, including: Determine the original pixel in the screen background that corresponds to the target frosted glass object, and perform coordinate offset on the original pixel based on the refraction offset to obtain the target pixel; If the detected blur parameter is less than the blur threshold, diagonal sampling is performed on the surrounding area of the target pixel to obtain the blurred background pixel value; If the detected blur parameter is not less than the blur threshold, diagonal and axial sampling are performed on the surrounding area of the target pixel to obtain the blurred background pixel value.
[0013] This invention employs a diagonal sampling scheme to obtain blurred background pixel values when the blur parameter is less than the blur threshold, thereby reducing rendering overhead and adapting to hardware platforms with limited computing power. When the blur parameter is not less than the blur threshold, it combines axial and diagonal sampling to obtain blurred background pixel values, improving the smoothness and realism of the image in scenes with high blur levels, thus enhancing rendering quality. By setting the blur threshold, the sampling mode can be dynamically switched, adaptively matching the corresponding sampling precision according to the blur parameter. Furthermore, it can simulate the light refraction and distortion characteristics of a frosted glass surface, achieving a balance between rendering performance and visual effects in different blur-requirement scenarios, exhibiting stronger scene adaptability and hardware compatibility.
[0014] In some optional implementations, diagonal sampling is performed on the surrounding area of the target pixel to obtain blurred background pixel values, including: The first offset is obtained based on the preset pixel size and the first preset distance coefficient; wherein, the first preset distance coefficient is used to characterize the distance between the sampling point and the target pixel; Based on the first offset, diagonal sampling is performed on the surrounding area of the target pixel to obtain multiple first sampling points. Based on the pixel information of the multiple first sampling points, the blurred background pixel value is obtained.
[0015] When the blur parameter is less than the blur threshold, this invention calculates a first offset based on a first preset distance coefficient and a preset pixel size. Based on the target pixel obtained by superimposing the refraction offset, the first offset is further superimposed on different diagonal directions of the target pixel's screen coordinates for diagonal sampling, resulting in multiple first sampling points. These points are then used to calculate the blurred background pixel value, simulating the refraction offset caused by the minute bumps and unevenness of a frosted glass surface. This effectively balances visual effect and rendering overhead in scenarios with small blur parameters.
[0016] In some optional implementations, diagonal and axial sampling are performed on the surrounding area of the target pixel to obtain blurred background pixel values, including: The second offset is obtained based on the preset pixel size; The third offset is obtained based on the preset pixel size and the second preset distance coefficient; wherein, the second preset distance coefficient is used to characterize the distance between the sampling point and the target pixel, and the third offset is smaller than the second offset; Axial sampling is performed on the surrounding area of the target pixel based on the second offset, and diagonal sampling is performed on the surrounding area of the target pixel based on the third offset to obtain multiple second sampling points; The blurred background pixel value is obtained based on the target pixel and the pixel information of multiple second sampling points.
[0017] When the blur parameter is not less than the blur threshold, this invention combines axial sampling with diagonal sampling corrected by a second preset distance coefficient to make the distribution of multiple second sampling points approximate a circular Gaussian distribution, thus avoiding stretching and distortion of the blurred image. Therefore, based on the target pixel and the pixel information of multiple second sampling points, a weighted value for the blurred background pixel is obtained, resulting in smoother and more natural color transitions in scenes with large blur parameters, conforming to the physical characteristics of diffuse scattering from frosted glass, thereby improving the rendering effect of frosted glass objects.
[0018] In some optional implementations, physically based lighting rendering is performed on surface attribute information and rendering scene information to obtain the physically rendered pixel values of the target frosted glass object, including: Based on surface attribute information and rendering scene information, the indirect lighting pixel value and direct lighting pixel value of the target frosted glass object are determined; wherein, the indirect lighting pixel value is used to characterize the pixel value of the target frosted glass object under indirect lighting, and the direct lighting pixel value is used to characterize the pixel value of the target frosted glass object under direct lighting. The physical rendering pixel values of the target frosted glass object are determined based on indirect lighting pixel values, direct lighting pixel values, and surface attribute information.
[0019] This invention first calculates the color of the target frosted glass object under indirect and direct lighting by using the surface attribute information and rendering scene information of the target frosted glass object. Then, it mixes the above colors with the surface attribute information to obtain the final physical rendering pixel value, ensuring that the rendering of the frosted glass object is consistent with the environment.
[0020] In some optional implementations, the rendering scene information includes scene lighting information, a preset reflection map, and global reflection information of the rendering pipeline; based on surface attribute information and rendering scene information, the indirect lighting pixel values of the target frosted glass object are determined, including: The ambient diffuse reflection pixel value is obtained based on surface attribute information and scene lighting information; Determine the reflection vector corresponding to the target frosted glass object, and sample the global reflection information and the preset reflection map based on the reflection vector to obtain the mixed reflection pixel value; The indirect lighting pixel values are obtained based on the ambient diffuse reflection pixel values and the mixed reflection pixel values.
[0021] This invention calculates the ambient diffuse reflection pixel values using the surface attribute information and scene lighting information of the target frosted glass object. Then, based on the reflection vector, it performs mixed sampling of global reflection information and a preset reflection map to generate mixed reflection pixel values. Finally, based on the ambient diffuse reflection pixel values and the mixed reflection pixel values, the indirect lighting pixel values are obtained, thereby improving the visual realism and scene adaptability of the frosted glass object.
[0022] In some optional implementations, the rendered scene information includes scene lighting information; based on surface attribute information and the rendered scene information, the direct lighting pixel values of the target frosted glass object are determined, including: Based on scene lighting information, the first diffuse reflection pixel value corresponding to the main light source and the second diffuse reflection pixel values corresponding to multiple secondary light sources are determined; wherein, the number of multiple secondary light sources is less than a preset number. The direct illumination pixel value is obtained based on the first diffuse reflection pixel value and the second diffuse reflection pixel value.
[0023] This invention obtains the direct illumination pixel value by calculating the diffuse reflection components of the main light source and multiple secondary light sources, and limits the number of secondary light sources involved in the calculation by setting a preset number to avoid excessive light sources in the scene that would lead to a decrease in rendering performance, thus achieving a balance between rendering quality and system performance.
[0024] In some optional implementations, surface attribute information includes self-illuminating pixel values; based on indirect lighting pixel values, direct lighting pixel values, and surface attribute information, the physically rendered pixel values of the target frosted glass object are determined, including: The physical rendering pixel values of the target frosted glass object are obtained by mixing the indirect lighting pixel values, direct lighting pixel values, and self-illuminating pixel values.
[0025] This invention obtains the physical rendering pixel values of the target frosted glass object by mixing direct lighting pixel values, indirect lighting pixel values, and self-illuminating pixel values. This makes the physical rendering pixel values of the frosted glass object consistent with the scene lighting changes and the material characteristics of the frosted glass, thereby improving the visual realism of the frosted glass object rendering.
[0026] In some optional implementations, surface attribute information includes transparency; blending physically rendered pixel values and blurred background pixel values to obtain target pixel values includes: The target pixel value is obtained by blending physically rendered pixel values and blurred background pixel values based on transparency; where transparency is used to characterize the blending ratio of physically rendered pixel values.
[0027] This invention uses transparency as the mixing weight to linearly interpolate and mix physically rendered pixel values with blurred background pixel values. This allows the frosted glass to retain the reflection information of ambient light and the screen background after refraction blurring, simulating the visual characteristics of frosted glass and improving the rendering effect of frosted glass objects. Furthermore, by adjusting the transparency of the frosted glass, it can adapt to the rendering needs of frosted glass of different materials.
[0028] In a second aspect, the present invention provides a frosted glass object rendering apparatus, the apparatus comprising: The first processing module is used to determine the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space; and to obtain the surface attribute information, rendering scene information, refraction distortion parameters and the screen background behind the target frosted glass object; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. The second processing module is used to perform physical lighting rendering based on surface attribute information and rendering scene information to obtain the physical rendering pixel values of the target frosted glass object. The third processing module is used to determine the refraction offset corresponding to the target frosted glass object based on surface property information and refraction distortion parameters, and to perform blur sampling on the screen background based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object. The fourth processing module is used to mix the physically rendered pixel values and the blurred background pixel values to obtain the target pixel values, and then use the target pixel values to render the target frosted glass object to obtain the rendering result.
[0029] Thirdly, the present invention provides a vehicle comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the frosted glass object rendering method of the first aspect or any corresponding embodiment described above.
[0030] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the frosted glass object rendering method of the first aspect or any corresponding embodiment thereof.
[0031] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the frosted glass object rendering method of the first aspect or any corresponding embodiment described above.
[0032] The beneficial effects of this invention are as follows: This invention locates the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space, ensuring accurate occlusion relationships between the target frosted glass object and other opaque objects in the scene, avoiding disordered transparency levels and clipping. Next, physically based lighting rendering is performed using the surface attribute information of the target frosted glass object and the rendering scene information to obtain physically based rendering pixel values, enhancing the realism of the frosted glass object rendering. Furthermore, a refraction offset is determined using the surface attribute information of the target frosted glass object and the refraction distortion parameters of light. This refraction offset is then used to sample the screen background behind the frosted glass, simulating the background blur and refraction distortion characteristics of the frosted glass, obtaining blurred background pixel values. Finally, the physically based rendering pixel values and blurred background pixel values are mixed to obtain the target pixel value, which is then used to render the target frosted glass object, thereby enhancing the rendering effect of the frosted glass object. Attached Figure Description
[0033] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram of the first process of rendering a frosted glass object according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the second process of rendering a frosted glass object according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the parameter configuration interface according to an embodiment of the present invention; Figure 4A This is a schematic diagram illustrating the rendering effect of an opaque material according to an embodiment of the present invention; Figure 4B This is a schematic diagram illustrating the rendering effect of a transparent material according to an embodiment of the present invention; Figure 5AThis is a schematic diagram illustrating the rendering effect of the frosted glass blur effect according to an embodiment of the present invention; Figure 5B This is a schematic diagram illustrating the rendering effect of the frosted glass occlusion effect according to an embodiment of the present invention; Figure 5C This is a schematic diagram illustrating the rendering effect of frosted glass refraction according to an embodiment of the present invention; Figure 5D This is a schematic diagram illustrating the rendering effect of frosted glass environmental reflection according to an embodiment of the present invention; Figure 6 This is a schematic diagram of a vehicle-mounted system rendering scene according to an embodiment of the present invention; Figure 7 This is a structural block diagram of a frosted glass object rendering apparatus according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the hardware structure of a vehicle according to an embodiment of the present invention. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0037] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0038] The existing technologies can only achieve basic transparent blending rendering and cannot simulate the physical properties of frosted glass, such as background blurring and refraction distortion. When faced with complex scenes, they are prone to problems such as disordered transparency layer ordering and clipping issues. In addition, they generally suffer from high performance overhead, making it difficult to run stably on computing-limited platforms such as automotive and mobile devices, and they have poor cross-platform compatibility.
[0039] To address the aforementioned issues, this invention provides a method for rendering frosted glass objects. By using depth information of objects in screen space, the method locates the target frosted glass object to be rendered, ensuring accurate occlusion relationships between the target frosted glass object and other scene objects, thus avoiding disordered transparency levels and clipping issues. Next, using the surface attribute information of the frosted glass object and rendering scene information, the direct and indirect lighting pixel values are calculated and combined with the surface attribute information to synthesize physically rendered pixel values, enhancing the realism of the frosted glass object rendering. Furthermore, the screen background behind the target frosted glass is sampled using a refraction offset to simulate the background blur and refraction distortion characteristics of frosted glass, obtaining blurred background pixel values. Finally, the physically rendered pixel values and blurred background pixel values are mixed to obtain the target pixel value, which is then used to render the target frosted glass object, thereby enhancing the rendering effect. It can switch sampling modes based on blur parameters and is adaptable to different computing power platforms.
[0040] According to an embodiment of the present invention, a method for rendering frosted glass objects is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0041] This embodiment provides a method for rendering frosted glass objects, which can be used in image rendering devices, such as vehicle infotainment systems, tablet computers, and other devices. Figure 1 This is a flowchart of a frosted glass object rendering method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps: Step S101: Based on the depth information of all frosted glass objects in the screen space, determine the target frosted glass object to be rendered; and obtain the surface attribute information, rendering scene information, refraction distortion parameters, and screen background behind the target frosted glass object; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object.
[0042] Specifically, frosted glass can diffuse, scatter, refract, and soften light. Also known as matte glass or frosted glass, it is a semi-transparent glass with a rough surface created through specific processing. Its uneven surface causes diffuse reflection of light, producing a blurred effect that allows light to pass through but not through, and it can also refract light. For ease of understanding, the following embodiments use Unity's Universal Render Pipeline (URP) as an example to illustrate the frosted glass object rendering process of this invention. First, in the Unity project, ensure that the URP rendering pipeline is used and that the corresponding Shader keywords are enabled to support core functions such as normal mapping, metallicity, and smoothness control.
[0043] In this embodiment, the enabled shader keywords may include Depth_Pass, Normal Map, Emission, Main_Light_Shadows, Main_Light_Shadows_Cascade, Main_Light_Shadows_Screen, Additional_Lights, Additional_Light_Shadows, Shadows_soft, and Screen_Space_Occlusion, etc. The specific keywords can be adjusted according to the actual scene, and this invention is not limited thereto.
[0044] The shader in this embodiment contains two core rendering channels: DepthPrepass and FrostedGlassPBR. DepthPrepass is used to implement the depth pre-rendering function, and FrostedGlassPBR is used to render frosted glass objects.
[0045] Specifically, screen-space objects include opaque objects (such as backgrounds and obstacles) and frosted glass objects that are to be rendered with a frosted glass effect (such as pedestrians and vehicles), which can be further categorized according to object type. By obtaining the vertex information of all screen-space objects, the vertex shader is used to perform spatial transformation of the vertex coordinates of each object, thereby obtaining the depth information of all screen-space objects, and the depth information of each object is written into the depth buffer.
[0046] Furthermore, this invention assigns a shader to the material sphere of the frosted glass object that needs to achieve a frosted glass effect, and sets the rendering queue of this material sphere to Transparent (e.g., queue value 3000). This ensures that the frosted glass object is drawn according to the rendering rules, maintaining a reasonable rendering order with other opaque objects in the scene. The rendering queue includes material spheres of multiple objects, and the rendering rule is that material spheres with smaller queue values are rendered first. For example, if the queue value is less than a preset queue value (e.g., 3000), it is rendered as an opaque object. Objects with queue values not less than the preset queue value (e.g., 3000) are rendered as frosted glass objects, allowing the frosted glass object to be rendered on top of other opaque scene elements with higher queue values, thus forming the correct occlusion relationship.
[0047] In this embodiment, the DepthPrepass channel determines the depth value of the frosted glass object to be rendered based on the depth information of the screen-space object, while setting the ColorMask to 0 to disable color writing. That is, the DepthPrepass channel only writes the depth information of the frosted glass object and does not output color. Then, using the depth values recorded in the DepthPrepass channel, the occlusion relationship between multiple frosted glass objects is determined, and the target frosted glass object to be rendered is located. This ensures that the frosted glass object can correctly participate in the depth test in the subsequent main rendering channel, avoiding interleaving errors and ensuring reasonable occlusion relationships. It should be noted that the target frosted glass object to be rendered can be a pixel or a pixel region.
[0048] During rendering, related technologies typically write the object's depth and color together in the main channel of the rendering pipeline. When rendering transparent objects (such as glass), because transparent objects cannot easily cover another transparent object, the rendering engine usually forces ZWrite to be turned off to ensure correct transparency blending. However, in the standard rendering pipeline, when rendering transparent objects, the GPU often cannot record the depth of the transparent object itself because ZWrite is turned off. This can easily lead to the rendering order of transparent objects with occlusion relationships depending on the order in which rendering tasks are submitted. In scenes with complex occlusion relationships among multiple transparent objects, visual errors can easily occur, such as different parts of the same transparent object overlapping each other, resulting in poor rendering effects.
[0049] In this embodiment, before executing the complete main rendering process, the depth information of all frosted glass objects is recorded through the depth pre-rendering channel, but no color is written. This allows the target frosted glass object to be rendered to be correctly located based on the depth pre-rendering channel, ensuring the correct rendering order among multiple frosted glass objects.
[0050] In this embodiment, after determining the target frosted glass object to be rendered, the main rendering channel FrostedGlassPBR uses the vertex shader to complete the coordinate transformation and data transfer of the target frosted glass object. Specifically, it determines the vertex coordinates and other information of the target frosted glass object in world space, and transforms the vertex coordinates of the frosted glass object to screen space to obtain screen coordinates. The above data, along with the GPU instance index number (InstanceID) associated with the target frosted glass object, is then passed to the fragment shader. The coordinate transformation of the target frosted glass object can be performed using Unity built-in functions such as TransformObjectToHClip and TransformObjectToWorld, and macros such as UNITY_TRANSFER_INSTANCE_ID are used to support GPU instantiation rendering and static constant buffer batching. For details, please refer to the relevant technical descriptions. For example, the material properties of the target frosted glass object are wrapped in CBUFFER, and the InstanceID is passed to ensure batch processing compatibility. CBUFFER_START(UnityPerMaterial) float4 _BaseMap_ST; float4 _BaseColor; / / ...other attributes CBUFFER_END struct Attributes { float4 positionOS : POSITION; float2 uv : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; void vert(Attributes input, out Varyings output) { UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); / / ...other logic } Furthermore, the fragment shader samples the input texture of the target frosted glass object by calling the InitializeSurfaceData function of the rendering pipeline, obtaining the surface attribute information SurfaceData of the frosted glass object. This surface attribute information includes: the material's intrinsic color Albedo, transparency Alpha, metallicity Metallic, smoothness, normal map, normal map intensity Scale, ambient occlusion strength, and emissive pixel value (i.e., the emissive color represented by the RGB channels). Additionally, parameters such as BlurAmount, Distortion, and Reflection Blend can be set. BlurAmount characterizes the degree of blurriness of the screen background; a larger BlurAmount results in a more blurred background. Distortion characterizes the degree of refraction distortion of light by the target frosted glass object; a larger Distortion parameter results in more significant refraction distortion of light by the frosted glass.
[0051] In this embodiment, the rendering scene information includes scene lighting information (including main light source and secondary light source data), preset reflection maps (e.g., custom reflection cube maps), and global reflection information of the rendering pipeline. The screen background behind the target frosted glass object, i.e., the background image located behind the frosted glass object in front of it (including opaque objects or other frosted glass objects rendered before the target frosted glass object), changes in real time according to the rendering process and can be obtained by capturing a screen space snapshot at the start of the rendering process for the target frosted glass object.
[0052] Step S102: Perform physical lighting rendering based on surface attribute information and rendering scene information to obtain the physical rendering pixel values of the target frosted glass object.
[0053] Specifically, PBR rendering is performed on the target frosted glass object based on the collected surface attribute information and rendering scene information to obtain the physically rendered pixel values of the target frosted glass object. It should be noted that the pixel value is used to represent the color and brightness of the pixel, and in a color image, the pixel value is composed of the values of the R, G, and B channels.
[0054] Step S103: Based on surface property information and refraction distortion parameters, determine the refraction offset corresponding to the target frosted glass object, and perform blurred sampling on the screen background based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object.
[0055] Specifically, based on surface attribute information, the world space normal vector corresponding to the target frosted glass object is obtained. Then, based on the world space normal vector and refraction distortion parameters, the refraction offset corresponding to the frosted glass object is calculated to simulate the light refraction deformation effect caused by the unevenness of the frosted glass surface. The refraction offset is applied to the screen background pixels, and the blurred background pixel value after refraction distortion is output.
[0056] Step S104: Mix the physically rendered pixel values and the blurred background pixel values to obtain the target pixel values. Use the target pixel values to render the target frosted glass object to obtain the rendering result.
[0057] Specifically, the physically rendered pixel values and the blurred background pixel values are linearly interpolated and transparently blended to obtain the target pixel values of the frosted glass object. These target pixel values are then used as the final output of the fragment shader, and combined with depth testing to complete the rendering of the target frosted glass object, yielding the final rendering result.
[0058] The frosted glass object rendering method provided in this embodiment locates the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space. This ensures accurate occlusion relationships between the target frosted glass object and other opaque objects in the scene, avoiding disordered transparency levels and clipping issues. Next, physically based lighting rendering is performed using the surface attribute information of the target frosted glass object and the rendering scene information to obtain physically based rendering pixel values, enhancing the realism of the frosted glass object rendering. Furthermore, a refraction offset is determined using the surface attribute information of the target frosted glass object and the refraction distortion parameters of light. This refraction offset is then used to sample the screen background behind the frosted glass, simulating the background blur and refraction distortion characteristics of the frosted glass to obtain blurred background pixel values. Finally, the physically based rendering pixel values and blurred background pixel values are mixed to obtain the target pixel value, which is then used to render the target frosted glass object, thereby enhancing the rendering effect of the frosted glass object.
[0059] This embodiment provides a method for rendering frosted glass objects, which can be used in image rendering devices, such as vehicle infotainment systems, tablet computers, and other devices. Figure 2 This is a flowchart of a frosted glass object rendering method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps: Step S201: Based on the depth information of all frosted glass objects in the screen space, determine the target frosted glass object to be rendered; and obtain the surface attribute information, rendering scene information, refraction distortion parameters, and the screen background behind the target frosted glass object; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. See details for further information. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0060] Step S202: Perform physical lighting rendering based on surface attribute information and rendering scene information to obtain the physical rendering pixel values of the target frosted glass object.
[0061] Specifically, step S202 includes: Step S2021: Based on surface attribute information and rendering scene information, determine the indirect lighting pixel value and direct lighting pixel value of the target frosted glass object; wherein, the indirect lighting pixel value is used to characterize the pixel value of the target frosted glass object under indirect lighting, and the direct lighting pixel value is used to characterize the pixel value of the target frosted glass object under direct lighting.
[0062] Specifically, based on surface attribute information and rendering scene information, indirect lighting such as indirect diffuse reflection and indirect specular highlights is determined, and the indirect lighting pixel values of the frosted glass object under indirect lighting are calculated. Furthermore, scene lighting information from the rendering scene information is read, and using the main light source and secondary light source data, the direct lighting pixel values of the frosted glass object under direct lighting are calculated.
[0063] In some optional implementations, step S2021 above includes: Step a1: Obtain the ambient diffuse reflection pixel value based on surface attribute information and scene lighting information.
[0064] Specifically, the fragment shader, based on the world space position and screen coordinates of the target frosted glass object transmitted from the vertex shader, and combined with scene lighting information, constructs the input data InputData of the frosted glass object by calling the InitializeInputData function. This input data InputData includes the world space normal vector N, the view direction vector V, the global illumination GI, the tangent space matrix TBN, and shadow coordinates. Then, it calls the InitializeBRDFData function of the URP pipeline to convert the surface attribute information SurfaceData into dual reflection data BRDFData. For details, please refer to the description of relevant technologies, which will not be elaborated here.
[0065] Furthermore, the global illumination (GI) can be a spherical harmonic function. Based on the world space normal vector, the spherical harmonic coefficients are sampled to obtain the ambient diffuse irradiance. Combined with the inherent color Albedo, metallicity Metallic of the frosted glass object and the ambient occlusion strength, the ambient diffuse pixel value is obtained. Ambient diffuse pixel value = Ambient diffuse irradiance × Albedo × (1-Metallic) × Occlusion strength. For details, please refer to the description of the relevant technology, which will not be elaborated here.
[0066] Step a2: Determine the reflection vector corresponding to the target frosted glass object, and sample the global reflection information and the preset reflection map based on the reflection vector to obtain the mixed reflection pixel value.
[0067] Specifically, based on the viewpoint direction vector V and the world space normal vector N, according to The reflection vector R corresponding to the target frosted glass object is calculated. Based on the reflection vector R, the global reflection information (including scene reflection probes and skybox reflection data) of the URP rendering pipeline is sampled using Unity's built-in GlossyEnvironmentReflection function to obtain the global reflection color. Then, based on the reflection vector R, a custom reflection color is obtained by sampling from a preset reflection map (e.g., a custom reflection cube map). Finally, the global reflection color and the custom reflection color are linearly interpolated using the Reflection Blend parameter (linearly interpolating the RGB components of both) to obtain the blended reflection pixel value. The Reflection Blend parameter ranges from 0 to 1, representing the weight of the custom reflection color; a value of 0 uses the global reflection color entirely, and a value of 1 uses the custom reflection color entirely.
[0068] In some embodiments, multiple preset reflection maps can be set, each corresponding to a different roughness. By determining the roughness of the target frosted glass object, the preset reflection map that matches the roughness is sampled based on the reflection vector R to obtain a custom reflection color.
[0069] Step a3: Obtain the indirect lighting pixel value based on the ambient diffuse reflection pixel value and the mixed reflection pixel value.
[0070] Specifically, Fresnel terms are calculated based on the world space normal vector, the viewing direction, and the basic reflectivity of the material corresponding to the frosted glass object to simulate the changes in reflection intensity under different viewing angles. Simultaneously, based on the roughness of the frosted glass object and the dot product between the world space normal vector and the viewing direction, a pre-calculated environment BRDF integral lookup table is consulted to obtain BRDF coefficients (including scaling and offset coefficients). The mixed reflection pixel values are adjusted based on the BRDF coefficients and the basic material reflectivity to obtain the indirect specular color; details can be found in the descriptions of relevant technologies and will not be elaborated upon here.
[0071] Furthermore, the ambient diffuse pixel value and the RGB components of the indirect specular color are added together sequentially to obtain the indirect lighting pixel value.
[0072] This invention calculates the ambient diffuse reflection pixel values using the surface attribute information and scene lighting information of the target frosted glass object. Then, based on the reflection vector, it performs mixed sampling of global reflection information and a preset reflection map to generate mixed reflection pixel values. Finally, based on the ambient diffuse reflection pixel values and the mixed reflection pixel values, the indirect lighting pixel values are obtained, thereby improving the visual realism and scene adaptability of the frosted glass object.
[0073] Step a4: Based on the scene lighting information, determine the first diffuse reflection pixel value corresponding to the main light source and the second diffuse reflection pixel value corresponding to multiple secondary light sources; wherein, the number of multiple secondary light sources is less than a preset number.
[0074] Specifically, the main light source data in the scene lighting information is read, including the main light source's incident direction, color, and intensity. The first diffuse pixel value corresponding to the main light source is then calculated using the following formula:
[0075] Where L_Color1 is the first diffuse pixel value, and diffuseColor is the diffuse color of the material corresponding to the target frosted glass object. The color and intensity of the main light source are represented by N, where N is the world space normal vector. The incident direction of the main light source .
[0076] Furthermore, the main light source data in the scene lighting information is read, including the incident direction, color, and intensity of the secondary light sources. The first diffuse pixel value corresponding to multiple secondary light sources is calculated according to the following formula:
[0077] Where L_Color2 is the second diffuse pixel value, This represents the color and intensity of the i-th secondary light source. This indicates the incident direction of the i-th secondary light source, M1 is the preset quantity, and M is the actual total number of secondary light sources.
[0078] In some embodiments, when the total number M of secondary light sources in the scene is greater than a preset number M1, the preset number M1 secondary light sources closest to the target frosted glass object are selected to participate in the lighting calculation, reducing the computational load. This limits the maximum number of secondary light sources that can be calculated, avoiding excessive performance overhead. The relevant pseudocode is as follows: uint lightCount = min(GetAdditionalLightsCount(), _MaxAdditionalLights); for (uint i = 0; i <lightCount; i++) { Light light = GetAdditionalLight(i, InputData.positionWS); half3 diffuse = light.color* light.distanceAttenuation *light.shadowAttenuation * DotClamped(InputData.normalWS, light.directionWS); color += diffuse * brdfData.diffuse; } Step a5: Obtain the direct illumination pixel value based on the first diffuse reflection pixel value and the second diffuse reflection pixel value.
[0079] Specifically, the first diffuse reflection pixel value corresponding to the main light source is summed with the second diffuse reflection pixel values corresponding to all effective secondary light sources by adding their RGB components to obtain the direct illumination pixel value of the target frosted glass object. The calculation formula is as follows:
[0080] in, This represents the pixel value of direct illumination.
[0081] This invention obtains the direct illumination pixel value by calculating the diffuse reflection components of the main light source and multiple secondary light sources, and limits the number of secondary light sources involved in the calculation by setting a preset number to avoid excessive light sources in the scene that would lead to a decrease in rendering performance, thus achieving a balance between rendering quality and system performance.
[0082] Step S2022: Determine the physical rendering pixel values of the target frosted glass object based on the indirect lighting pixel values, direct lighting pixel values, and surface attribute information.
[0083] Specifically, the surface attribute information includes the self-illuminating pixel values of the target frosted glass object. The physically rendered pixel values of the target frosted glass object are obtained by mixing the indirect lighting pixel values, direct lighting pixel values, and self-illuminating pixel values. Finally, the physically rendered pixel values of the frosted glass object are obtained by superimposing the indirect lighting pixel values with the direct lighting pixel values (adding the RGB components of the color sequentially), and then superimposing the self-illuminating pixel values of the material (adding the RGB components of the color sequentially).
[0084] This invention obtains the physical rendering pixel values of the target frosted glass object by mixing direct lighting pixel values, indirect lighting pixel values, and self-illuminating pixel values. This makes the physical rendering pixel values of the frosted glass object consistent with the scene lighting changes and the material characteristics of the frosted glass, thereby improving the visual realism of the frosted glass object rendering.
[0085] In the above embodiments, the colors of the target frosted glass object under indirect and direct lighting are first calculated using the surface attribute information and rendering scene information of the target frosted glass object. The colors are then mixed with the surface attribute information to obtain the final physical rendering pixel value, ensuring that the rendering of the frosted glass object matches the environment.
[0086] Step S203: Based on surface property information and refraction distortion parameters, determine the refraction offset corresponding to the target frosted glass object, and perform blurred sampling on the screen background based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object.
[0087] Specifically, step S203 includes: Step S2031: Based on surface attribute information, determine the world space normal vector corresponding to the target frosted glass object; calculate the refractive offset corresponding to the target frosted glass object based on the world space normal vector and refraction distortion parameters.
[0088] Specifically, sampling and coordinate space transformation can be performed based on the normal map in the surface attribute information to calculate the world space normal vector corresponding to the target frosted glass object. For details, please refer to the description of the relevant technology. Then, the refractive offset corresponding to the target frosted glass object can be calculated using the following formula: uv= (InputData.Nx, InputData.Nz) * _Distortion Where uv represents the refraction offset, which includes the horizontal offset u and the vertical offset v, InputData.Nx is the x-component of the world space normal vector, InputData.Nz is the z-component of the world space normal vector, and Distortion is the refraction distortion parameter.
[0089] This invention combines the world space normal vector of the target frosted glass object with the refraction distortion parameters of light to calculate the refraction offset of the target frosted glass object to light. This characterizes the effect of the uneven structure of the frosted glass surface on the refraction distortion of light, allowing for offset sampling of the screen background behind the frosted glass object based on the refraction offset. This simulates the refraction deformation effect of frosted glass, enhancing the rendering effect. Furthermore, the refraction distortion parameters can be adjusted to adapt to the visual rendering needs of different frosted glass types.
[0090] Step S2032: Determine the blur parameter corresponding to the screen background; wherein, the blur parameter is used to characterize the blur degree of the screen background; perform blur sampling on the screen background based on the refraction offset and the blur parameter to obtain the blurred background pixel value.
[0091] This invention combines blur parameters and refraction offset to perform blur sampling on the screen background, integrates the refraction deformation and blur effect of frosted glass, fully simulates the physical properties of frosted glass, and improves the rendering effect of frosted glass objects.
[0092] In some optional implementations, step S2032 above includes: Step b1: Determine the original pixel in the screen background that corresponds to the target frosted glass object, and perform coordinate offset on the original pixel based on the refraction offset to obtain the target pixel.
[0093] Specifically, the screen coordinates corresponding to the frosted glass object are determined, and the pixel corresponding to the position of the screen coordinates in the CameraColorTexture of the screen background is determined as the original pixel (i.e., the refraction offset is applied). Then, the refraction offset is superimposed on the coordinates of the original pixel to obtain the target pixel.
[0094] In this embodiment, the fragment shader selects the sampling mode based on the blur amount parameter BlurAmount. If the blur amount parameter BlurAmount is detected to be less than the blur amount threshold (e.g., 2), it indicates that the blur of the screen background by the frosted glass is low, and step b2 is executed; otherwise, step b3 is executed, thereby balancing performance and image quality.
[0095] Step b2: If the detected blur parameter is less than the blur threshold, diagonal sampling is performed on the surrounding area of the target pixel to obtain the blurred background pixel value.
[0096] Specifically, if the blur amount parameter BlurAmount is less than the blur amount threshold (i.e., high-performance mode), four diagonal offset samples are used, along with bilinear interpolation to expand the coverage area to obtain the first sampling point. Then, the pixel information of multiple first sampling points is accumulated and averaged to obtain the blurred background pixel value, which is suitable for mobile devices or scenarios with low blur levels. Here, the pixel information refers to the pixel value of the sampling point, which is used to characterize the color and brightness of the sampling point.
[0097] In this embodiment, step b2 includes: Step b21: Obtain the first offset based on the preset pixel size and the first preset distance coefficient; wherein the first preset distance coefficient is used to characterize the distance between the sampling point and the target pixel.
[0098] For example, the first offset is obtained by multiplying the preset pixel size texelSize by the first preset distance coefficient. Here, the preset pixel size is the size of a single pixel, and the first preset distance coefficient can be 0.5.
[0099] Step a22: Diagonally sample the surrounding area of the target pixel based on the first offset to obtain multiple first sampling points, and obtain the blurred background pixel value based on the pixel information of the multiple first sampling points.
[0100] For example, the target pixel is obtained by superimposing a refraction offset on the original pixel coordinates, which can simulate the refraction offset of frosted glass, but has not yet incorporated the blurring effect of frosted glass. Using the first offset, four first sampling points are sampled around the target pixel. The pixel information of the four sampling points is then weighted and averaged to obtain the blurred background pixel value. The weights of the four sampling points can be equal. The above process can be represented in pseudocode as follows: if (BlurAmount < 2.0) { / / Define 4 diagonal sampling offsets float2 offset = texelSize * 0.5; float3 col = 0; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(-offset.x, -offset.y)).rgb; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(offset.x, -offset.y)).rgb; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(-offset.x, offset.y)).rgb; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(offset.x, offset.y)).rgb; return col * 0.25; / / The weight of each of the 4 sampling points is 0.25. } When the blur parameter is less than the blur threshold, this invention calculates a first offset based on a first preset distance coefficient and a preset pixel size. Based on the target pixel obtained by superimposing the refraction offset, the first offset is further superimposed on different diagonal directions of the target pixel's screen coordinates for diagonal sampling, resulting in multiple first sampling points. These points are then used to calculate the blurred background pixel value, simulating the refraction offset caused by the minute bumps and unevenness of a frosted glass surface. This effectively balances visual effect and rendering overhead in scenarios with small blur parameters.
[0101] Step b3: If the detected blur parameter is not less than the blur threshold, perform diagonal and axial sampling on the surrounding area of the target pixel to obtain the blurred background pixel value.
[0102] Specifically, if the blur amount parameter BlurAmount is not less than the blur amount threshold, i.e., high quality mode, a fixed 9-point sampling is used to perform a weighted average of the pixel information of multiple second sampling points to obtain the blurred background pixel value, which is suitable for high-end PCs or scenarios with high requirements for blur quality.
[0103] In this embodiment, step b3 includes: Step b31: Obtain the second offset based on the preset pixel size.
[0104] For example, the second offset off1 is the preset pixel size texelSize.
[0105] Step b32: Obtain the third offset based on the preset pixel size and the second preset distance coefficient; wherein the second preset distance coefficient is used to characterize the distance between the sampling point and the target pixel, and the third offset is less than the second offset.
[0106] For example, the third offset off2 is calculated based on the product of a preset pixel size texelSize and a second preset distance coefficient. The second preset distance coefficient can be 0.8, and is greater than the first preset distance coefficient.
[0107] Step b33: Axial sampling is performed on the surrounding area of the target pixel based on the second offset, and diagonal sampling is performed on the surrounding area of the target pixel based on the third offset to obtain multiple second sampling points; based on the pixel information of the target pixel and the multiple second sampling points, the blurred background pixel value is obtained.
[0108] For example, taking the target pixel as the center point, four axial extension points (two horizontally and two vertically) are sampled around the target pixel based on a second offset off1, and four diagonal points are sampled around the target pixel based on a third offset off2, resulting in multiple second sampling points. A weighted average is then performed on the pixel information of these multiple second sampling points (including the four diagonal points and four axial extension points) and the target pixel (i.e., one center point) to obtain the blurred background pixel value. The weight of the center point can be 0.25, and the weights of the diagonal points and axial extension points can be 0.125. This process can be represented in pseudocode as follows: if (BlurAmount ≥ 2.0) { / / Define 9 sampling offsets: center + diagonal + axial float3 col = 0; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv).rgb * 0.25; float2 off1 = texelSize; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(off1.x, 0)).rgb * 0.125; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(-off1.x, 0)).rgb * 0.125; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(0, off1.y)).rgb * 0.125; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(0, -off1.y)).rgb * 0.125; float2 off2 = texelSize * 0.8; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(off2.x, off2.y)).rgb * 0.0625; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(-off2.x, off2.y)).rgb * 0.0625; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(off2.x, -off2.y)).rgb * 0.0625; col+=SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + float2(-off2.x, -off2.y)).rgb * 0.0625; return col; } It should be noted that since the preset pixel size includes pixel length and pixel width (the length and width can be the same), the above-mentioned first offset, second offset and third offset all include horizontal components and vertical components.
[0109] When the blur parameter is not less than the blur threshold, this invention combines axial sampling with diagonal sampling corrected by a second preset distance coefficient to make the distribution of multiple second sampling points approximate a circular Gaussian distribution, thus avoiding stretching and distortion of the blurred image. Therefore, based on the target pixel and the pixel information of multiple second sampling points, a weighted value for the blurred background pixel is obtained, resulting in smoother and more natural color transitions in scenes with large blur parameters, conforming to the physical characteristics of diffuse scattering from frosted glass, thereby improving the rendering effect of frosted glass objects.
[0110] The above embodiments employ a diagonal sampling scheme to obtain blurred background pixel values when the blur parameter is less than the blur threshold, thereby reducing rendering costs and adapting to hardware platforms with limited computing power. When the blur parameter is not less than the blur threshold, axial sampling and diagonal sampling are combined to obtain blurred background pixel values, improving the smoothness and realism of the image in scenes with high blur levels, and enhancing rendering quality. Thus, by setting the blur threshold, dynamic switching of the sampling mode is achieved, adaptively matching the corresponding sampling precision according to the blur parameter, and simulating the light refraction and distortion characteristics of a frosted glass surface. This achieves a balance between rendering performance and visual effects in different blur-requirement scenarios, exhibiting stronger scene adaptability and hardware compatibility.
[0111] Step S204: Mix the physically rendered pixel values and the blurred background pixel values to obtain the target pixel values. Use the target pixel values to render the target frosted glass object to obtain the rendering result.
[0112] Specifically, the surface attribute information includes transparency. The target pixel value is obtained by blending physically rendered pixel values and blurred background pixel values based on the transparency. Transparency is used to characterize the blending ratio of physically rendered pixel values.
[0113] Specifically, the linear interpolation formula is used: finalColor = lerp(background, color,SurfaceData.alpha) to obtain the target pixel value, where background is the blurred background pixel value, color is the physically rendered pixel value, and SurfaceData.alpha is the transparency in SurfaceData.
[0114] This invention uses transparency as the mixing weight to linearly interpolate and mix physically rendered pixel values with blurred background pixel values. This allows the frosted glass to retain the reflection information of ambient light and the screen background after refraction blurring, simulating the visual characteristics of frosted glass and improving the rendering effect of frosted glass objects. Furthermore, by adjusting the transparency of the frosted glass, it can adapt to the rendering needs of frosted glass of different materials.
[0115] In some embodiments, to preserve specular details, physically rendered pixel values can be decomposed into ambient diffuse pixel values and indirect specular color components. The ambient diffuse pixel values are then blended, while the indirect specular colors are directly superimposed. Simultaneously, the blur level changes with transparency; when the alpha value is 0, there is no blur; when the alpha value is 1, the blur level corresponds to the blur amount parameter BlurAmount.
[0116] In some embodiments, multiple Level of Detail (LOD) levels are defined in the SubShader, and the material LOD can be automatically switched through Unity's LOD group or manually set, allowing developers to choose according to the platform. For example, LOD level 300 executes the full rendering pipeline in the main rendering pipeline (including 9-point sampling, full lighting, and full reflection); LOD level 200 executes simplified rendering (limiting the number of secondary light sources and executing 4-point sampling); LOD level 100 executes only basic rendering (only blur and distortion calculations, no lighting calculations).
[0117] The frosted glass object rendering method provided in this embodiment writes the depth value of the frosted glass object into the depth pre-rendering channel to ensure correct occlusion relationships; performs physical rendering to obtain physically rendered pixel values; performs blur sampling and distortion on the screen background to simulate the refraction effect of frosted glass, obtaining blurred background pixel values; and mixes the blurred background pixel values with the physically rendered pixel values according to transparency. Furthermore, it dynamically adjusts the computational load according to the target platform performance to achieve adaptive performance optimization. This achieves a frosted glass effect with realistic lighting response, dynamic refraction distortion, and flexible environmental reflection, significantly improving the visual realism of the frosted glass material. Simultaneously, through performance optimization techniques such as dynamic sampling control, lighting simplification, and LOD, it can adapt to different hardware platforms, balancing image quality and performance, and is suitable for real-time rendering scenarios such as games and virtual reality.
[0118] The frosted glass object rendering scheme of the present invention will be described below with reference to a specific application example.
[0119] like Figure 3 As shown, through the parameter setting interface, you can set parameters such as inherent color, normal map intensity, normal map strength, metallicity, smoothness, ambient occlusion intensity, self-illumination color, blur parameters, refraction distortion parameters, reflection cubemap, and reflection blending coefficient.
[0120] like Figure 4A As shown, the relevant technology is based on normal maps and global environment reflections to perform PBR physical rendering on opaque materials, which is not conducive to highlighting the differences in perceived vehicle style. Figure 4B This is a schematic diagram of the related technology using PBR physical rendering of transparent materials. The transparent areas do not have a blur function, the order of the transparent rendering layers is disordered (for example, the rendering layers of the rearview mirror and the rear wheel overlap), and the environment reflection does not support customization.
[0121] like Figure 5A As shown, this embodiment simulates the blurring effect of frosted glass by performing blur sampling on the screen background based on refraction offset. Figure 5BAs shown, this embodiment solves the rendering sorting problem caused by self-occlusion of complex geometry through a depth pre-rendering channel (and...). Figure 5A (Comparison shows the rearview mirror and tires have a correct front-to-rear obstruction relationship.) Figure 5C As shown, this embodiment, by increasing the refractive effect, can simulate the refraction of frosted glass (and...). Figure 5B In contrast, the cones behind the vehicle clearly exhibit refraction, shift, and blurring. (For example...) Figure 5D As shown, this embodiment adds a custom environment reflection function, highlighting the differences in perceived vehicle style.
[0122] By applying frosted glass rendering to vehicles, pedestrians, and other elements in the scene, the resulting rendering effect is as follows: Figure 6 As shown, when a perceived object (such as another vehicle) in the vehicle's rendered scene obscures other perceived objects, the driver can still see the obscured object through the transparent and blurred frosted glass material, achieving a balance between practicality and aesthetics.
[0123] This invention introduces the PBR lighting model into frosted glass rendering, enabling the frosted glass surface to correctly respond to material properties such as metallicity and smoothness, accurately simulating the lighting characteristics of real frosted glass, and significantly enhancing the realism of the rendering effect.
[0124] This invention uses the world space normal vector to achieve dynamic distortion calculation, which produces a natural refraction deformation of the background observed through frosted glass, conforming to the laws of real physics, effectively improving the visual immersion, and providing a natural distortion effect in real time; it supports fine offset of the tangent space normal, and the accuracy of the distortion effect can be adjusted according to needs.
[0125] This invention supports the mixed adjustment of custom reflection cube maps and global environment reflections, which can flexibly control the reflection appearance of glass according to scene requirements, adapt to different rendering scenes and artistic needs, and make environmental reflections flexible and controllable.
[0126] This invention ensures the correct occlusion relationship between frosted glass objects and other objects in the scene through a depth pre-rendering channel, effectively solving common problems such as sorting errors and chaotic interleaving in traditional transparent rendering, and improving the overall harmony of the image.
[0127] This invention employs multi-level optimization strategies, including fuzzy sampling downgrade, lighting simplification, LOD level switching, and batch processing optimization, to dynamically adjust the computational load based on the target platform's performance. This enables adaptive performance optimization, achieving smooth rendering performance on both mobile devices and high-end PCs, balancing image quality and efficiency, and adapting to various hardware platforms.
[0128] This invention is based on Unity's URP (Universal Render Pipeline), with a clear code structure, rigorous logic, and easy integration into modern rendering engine workflows. It also facilitates subsequent feature expansion and secondary development.
[0129] This embodiment also provides a frosted glass object rendering apparatus, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0130] This embodiment provides a frosted glass object rendering device, such as... Figure 7 As shown, it includes: The first processing module 701 is used to determine the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space; and to obtain the surface attribute information, rendering scene information, refraction distortion parameters and the screen background behind the target frosted glass object; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. The second processing module 702 is used to perform physical lighting rendering based on surface attribute information and rendering scene information to obtain the physical rendering pixel values of the target frosted glass object. The third processing module 703 is used to determine the refraction offset corresponding to the target frosted glass object based on surface property information and refraction distortion parameters, and to perform blur sampling on the screen background based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object. The fourth processing module 704 is used to mix the physically rendered pixel values and the blurred background pixel values to obtain the target pixel values, and then use the target pixel values to render the target frosted glass object to obtain the rendering result.
[0131] In some optional implementations, the second processing module 702 is further configured to: Based on surface attribute information and rendering scene information, the indirect lighting pixel value and direct lighting pixel value of the target frosted glass object are determined; wherein, the indirect lighting pixel value is used to characterize the pixel value of the target frosted glass object under indirect lighting, and the direct lighting pixel value is used to characterize the pixel value of the target frosted glass object under direct lighting. The physical rendering pixel values of the target frosted glass object are determined based on indirect lighting pixel values, direct lighting pixel values, and surface attribute information.
[0132] In some optional implementations, the rendering scene information includes scene lighting information, preset reflection maps, and global reflection information of the rendering pipeline; the second processing module 702 is further configured to: The ambient diffuse reflection pixel value is obtained based on surface attribute information and scene lighting information; Determine the reflection vector corresponding to the target frosted glass object, and sample the global reflection information and the preset reflection map based on the reflection vector to obtain the mixed reflection pixel value; The indirect lighting pixel values are obtained based on the ambient diffuse reflection pixel values and the mixed reflection pixel values.
[0133] In some optional implementations, the scene rendering information includes scene lighting information; the second processing module 702 is further configured to: Based on scene lighting information, the first diffuse reflection pixel value corresponding to the main light source and the second diffuse reflection pixel values corresponding to multiple secondary light sources are determined; wherein, the number of multiple secondary light sources is less than a preset number. The direct illumination pixel value is obtained based on the first diffuse reflection pixel value and the second diffuse reflection pixel value.
[0134] In some optional implementations, the surface attribute information includes self-illuminating pixel values; the third processing module 703 is also used for: The physical rendering pixel values of the frosted glass object are obtained by mixing the indirect lighting pixel values, direct lighting pixel values, and self-illuminating pixel values.
[0135] In some alternative implementations, the third processing module 703 is further configured to: Based on surface property information, determine the world space normal vector corresponding to the target frosted glass object; Based on the world space normal vector and the refraction distortion parameter, the refraction offset corresponding to the target frosted glass object is calculated.
[0136] In some alternative implementations, the third processing module 703 is further configured to: Determine the blur parameters corresponding to the screen background; whereby the blur parameters are used to characterize the degree of blur of the screen background. The screen background is blurred by sampling based on the refraction offset and blur parameters to obtain the blurred background pixel values.
[0137] In some alternative implementations, the third processing module 703 is further configured to: Determine the original pixel in the screen background that corresponds to the target frosted glass object, and perform coordinate offset on the original pixel based on the refraction offset to obtain the target pixel; If the detected blur parameter is less than the blur threshold, diagonal sampling is performed on the surrounding area of the target pixel to obtain the blurred background pixel value; If the detected blur parameter is not less than the blur threshold, diagonal and axial sampling are performed on the surrounding area of the target pixel to obtain the blurred background pixel value.
[0138] In some optional implementations, the third processing module 703 is further configured to: The first offset is obtained based on the preset pixel size and the first preset distance coefficient; wherein, the first preset distance coefficient is used to characterize the distance between the sampling point and the target pixel; Based on the first offset, diagonal sampling is performed on the surrounding area of the target pixel to obtain multiple first sampling points. Based on the pixel information of the multiple first sampling points, the blurred background pixel value is obtained.
[0139] In some optional implementations, the third processing module 703 is further configured to: The second offset is obtained based on the preset pixel size; The third offset is obtained based on the preset pixel size and the second preset distance coefficient; wherein, the second preset distance coefficient is used to characterize the distance between the sampling point and the target pixel, and the third offset is smaller than the second offset; Axial sampling is performed on the surrounding area of the target pixel based on the second offset, and diagonal sampling is performed on the surrounding area of the target pixel based on the third offset to obtain multiple second sampling points; The blurred background pixel value is obtained based on the target pixel and the pixel information of multiple second sampling points.
[0140] In some optional implementations, the surface attribute information includes transparency; the fourth processing module 704 is also used for: The target pixel value is obtained by blending physically rendered pixel values and blurred background pixel values based on transparency; where transparency is used to characterize the blending ratio of physically rendered pixel values.
[0141] The frosted glass object rendering apparatus provided in this embodiment of the invention can execute the frosted glass object rendering method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as in the corresponding embodiments described above, and will not be repeated here.
[0142] Figure 8 This is a structural schematic diagram of a vehicle provided in an embodiment of the present invention.
[0143] The following is a detailed reference. Figure 8 The diagram illustrates a structural schematic suitable for implementing a vehicle according to an embodiment of the present invention. The vehicle may include a processor (e.g., a central processing unit, graphics processor, etc.) 801, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 802 or a program loaded from memory 808 into random access memory (RAM) 803. The RAM 803 also stores various programs and data required for vehicle operation. The processor 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0144] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; memory devices 808 including, for example, magnetic tape, hard disk, etc.; and communication devices 809. Communication device 809 allows the vehicle to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 Vehicles with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0145] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a memory 808, or installed from a ROM 802. When the computer program is executed by the processor 801, it performs the functions defined in the frosted glass object rendering method of the embodiments of the present invention.
[0146] Figure 8 The vehicle shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0147] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the frosted glass object rendering method shown in the above embodiments is implemented.
[0148] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0149] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for rendering frosted glass objects, characterized in that, The method includes: Based on the depth information of all frosted glass objects in the screen space, the target frosted glass object to be rendered is determined; and the surface attribute information, rendering scene information, refraction distortion parameters, and screen background behind the target frosted glass object are obtained; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. Physical lighting rendering is performed based on the surface attribute information and the rendering scene information to obtain the physical rendering pixel values of the target frosted glass object. Based on the surface property information and the refraction distortion parameter, the refraction offset corresponding to the target frosted glass object is determined, and the screen background is blurred based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object. The physical rendering pixel value and the blurred background pixel value are mixed to obtain the target pixel value. The target frosted glass object is then rendered using the target pixel value to obtain the rendering result.
2. The frosted glass object rendering method according to claim 1, characterized in that, Determining the refractive offset corresponding to the target frosted glass object based on the surface property information and the refractive distortion parameter includes: Based on the surface attribute information, determine the world space normal vector corresponding to the target frosted glass object; The refractive offset corresponding to the target frosted glass object is calculated based on the world space normal vector and the refractive distortion parameter.
3. The frosted glass object rendering method according to claim 1, characterized in that, Based on the refraction offset, the screen background is blurred and sampled to obtain blurred background pixel values after refraction by the target frosted glass object, including: Determine the blur parameter corresponding to the screen background; wherein the blur parameter is used to characterize the degree of blur of the screen background; The screen background is blurred by performing blur sampling based on the refraction offset and the blur parameter to obtain blurred background pixel values.
4. The frosted glass object rendering method according to claim 3, characterized in that, The step of performing blur sampling on the screen background based on the refraction offset and the blur parameter to obtain blurred background pixel values includes: Determine the original pixel in the screen background that corresponds to the target frosted glass object, and perform coordinate offset on the original pixel based on the refraction offset to obtain the target pixel; If the detected blur parameter is less than the blur threshold, diagonal sampling is performed on the surrounding area of the target pixel to obtain the blurred background pixel value; If the detected blur parameter is not less than the blur threshold, diagonal and axial sampling are performed on the surrounding area of the target pixel to obtain the blurred background pixel value.
5. The frosted glass object rendering method according to claim 4, characterized in that, The step of diagonally sampling the surrounding area of the target pixel to obtain the blurred background pixel value includes: A first offset is obtained based on a preset pixel size and a first preset distance coefficient; wherein, the first preset distance coefficient is used to characterize the distance between the sampling point and the target pixel; Based on the first offset, diagonal sampling is performed on the surrounding area of the target pixel to obtain multiple first sampling points. Based on the pixel information of the multiple first sampling points, the blurred background pixel value is obtained.
6. The frosted glass object rendering method according to claim 4, characterized in that, The step of performing diagonal and axial sampling on the surrounding area of the target pixel to obtain the blurred background pixel value includes: The second offset is obtained based on the preset pixel size; A third offset is obtained based on the preset pixel size and the second preset distance coefficient; wherein the second preset distance coefficient is used to characterize the distance between the sampling point and the target pixel, and the third offset is less than the second offset; Based on the second offset, the surrounding area of the target pixel is sampled axially, and based on the third offset, the surrounding area of the target pixel is sampled diagonally to obtain multiple second sampling points; The blurred background pixel value is obtained based on the target pixel and the pixel information of the plurality of second sampling points.
7. The frosted glass object rendering method according to claim 1, characterized in that, The step of performing physically based lighting rendering on the surface attribute information and the rendering scene information to obtain the physically rendered pixel values of the target frosted glass object includes: Based on the surface attribute information and the rendering scene information, the indirect lighting pixel value and the direct lighting pixel value of the target frosted glass object are determined; wherein, the indirect lighting pixel value is used to characterize the pixel value of the target frosted glass object under indirect lighting, and the direct lighting pixel value is used to characterize the pixel value of the target frosted glass object under direct lighting. Based on the indirect lighting pixel values, the direct lighting pixel values, and the surface attribute information, the physical rendering pixel values of the target frosted glass object are determined.
8. The frosted glass object rendering method according to claim 7, characterized in that, The rendered scene information includes scene lighting information, preset reflection maps, and global reflection information of the rendering pipeline; Based on the surface attribute information and the rendering scene information, the indirect lighting pixel value of the target frosted glass object is determined, including: Based on the surface attribute information and the scene lighting information, the ambient diffuse reflection pixel value is obtained; Determine the reflection vector corresponding to the target frosted glass object, and sample the global reflection information and the preset reflection map based on the reflection vector to obtain the mixed reflection pixel value; The indirect illumination pixel value is obtained based on the ambient diffuse reflection pixel value and the mixed reflection pixel value.
9. The method for rendering frosted glass objects according to claim 7, characterized in that, The rendered scene information includes scene lighting information; Based on the surface attribute information and the rendering scene information, the direct illumination pixel value of the target frosted glass object is determined, including: Based on the scene lighting information, the first diffuse reflection pixel value corresponding to the main light source and the second diffuse reflection pixel values corresponding to multiple secondary light sources are determined; wherein, the number of the multiple secondary light sources is less than a preset number; The direct illumination pixel value is obtained based on the first diffuse reflection pixel value and the second diffuse reflection pixel value.
10. The method for rendering frosted glass objects according to claim 7, characterized in that, The surface attribute information includes self-illuminating pixel values; determining the physical rendering pixel values of the target frosted glass object based on the indirect lighting pixel values, the direct lighting pixel values, and the surface attribute information includes: The indirect lighting pixel values, the direct lighting pixel values, and the self-illuminating pixel values are mixed to obtain the physical rendering pixel values of the target frosted glass object.
11. The method for rendering frosted glass objects according to any one of claims 1-10, characterized in that, The surface attribute information includes transparency; the process of mixing the physically rendered pixel value and the blurred background pixel value to obtain the target pixel value includes: The physically rendered pixel value and the blurred background pixel value are blended based on the transparency to obtain the target pixel value; wherein, the transparency is used to characterize the blending ratio of the physically rendered pixel value.
12. A frosted glass object rendering device, characterized in that, The device includes: The first processing module is used to determine the target frosted glass object to be rendered based on the depth information of all frosted glass objects in the screen space; and to obtain the surface attribute information, rendering scene information, refraction distortion parameters and the screen background behind the target frosted glass object; wherein, the refraction distortion parameters are used to characterize the degree of refraction distortion of light by the target frosted glass object. The second processing module is used to perform physical lighting rendering based on the surface attribute information and the rendering scene information to obtain the physical rendering pixel value of the target frosted glass object. The third processing module is used to determine the refraction offset corresponding to the target frosted glass object based on the surface attribute information and the refraction distortion parameter, and to perform blur sampling on the screen background based on the refraction offset to obtain the blurred background pixel value after refraction by the target frosted glass object. The fourth processing module is used to mix the physical rendering pixel value and the blurred background pixel value to obtain the target pixel value, and use the target pixel value to render the target frosted glass object to obtain the rendering result.
13. A vehicle, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the frosted glass object rendering method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the frosted glass object rendering method according to any one of claims 1 to 11.
15. A computer program product, characterized in that, Includes computer instructions for causing a computer to perform the frosted glass object rendering method according to any one of claims 1 to 11.