A physical-based virtual material editing method for lighting environment
Patent Information
- Application Number
- CN202611098252.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]为了克服现有技术的上述缺陷,本发明的实施例提供一种基于物理的光照环境虚拟材质编辑实现方法,以解决在虚拟材质实时编辑过程中,修改粗糙度参数需要重新执行环境光照积分计算所导致的响应延迟问题
其一,本发明在预计算阶段仅生成单张镜面反射基底图,该基底图在完全粗糙状态下对环境贴图执行半球面积分获得,包含了环境光照在球面上最完整的能量分布信息。实时编辑阶段通过散布采样和集中采样分别获取两个极端状态下的颜色分量,再由粗糙度驱动的混合权重进行线性混合,重构出任意中间粗糙度的镜面反射外观。整个编辑过程中不触发对环境贴图的重新积分,也不重新生成基底图,有助于减少重复计算开销,改善编辑响应速度。
Smart Images

Figure CN123015718A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics and virtual material editing, and more specifically, to a method for implementing virtual material editing based on physically based lighting environments. Background Technology
[0002] In the process of editing physically based virtual materials, the appearance of a material surface is composed of diffuse reflection and specular reflection components. The performance of the specular reflection component depends on the material roughness parameters and the scene lighting environment.
[0003] When material roughness needs to be adjusted, the renderer must re-perform importance sampling integration on the high dynamic range environment map based on the new roughness value to calculate the specular reflection result corresponding to that roughness. This integration process involves extensive sampling and weighted accumulation on the hemisphere based on the micro-facet normal distribution function corresponding to the roughness, resulting in significant computational overhead. In actual editing scenarios, artists often need to frequently adjust roughness parameters to preview material effects under different parameters. Each parameter change triggers a complete lighting integration, causing a noticeable delay in editing response, a problem that is particularly pronounced in complex lighting environments. Therefore, a physically based virtual material editing method for lighting environment is proposed to address the above problems. Summary of the Invention
[0004] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a physically based virtual material editing method for lighting environment, in order to solve the response delay problem caused by the need to re-execute the ambient lighting integral calculation when modifying roughness parameters during real-time editing of virtual materials.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A physically based virtual material editing method for lighting environment is proposed. In the pre-calculation stage, only a single specular reflection base map is generated. In the real-time editing stage, the specular reflection appearance under arbitrary roughness is reconstructed by mixing scatter sampling and concentrated sampling through dual paths. This reduces the computational overhead of editing roughness to minimal sampling and computation.
[0006] The method includes the following steps: S1: Obtain the environment map of the virtual scene. The environment map describes the emissivity distribution of incident light in the spherical direction in the virtual scene and serves as the fixed illumination input for subsequent pre-calculation and real-time sampling.
[0007] Furthermore, the virtual scene is a static scene with completed lighting design, and the environment map remains unchanged during the material editing process, ensuring the consistency of lighting conditions during material editing and avoiding interference from lighting changes on the judgment of material appearance.
[0008] S2: Based on the environment map, pre-calculate and generate a single specular reflection substrate map. During the pre-calculation, the material roughness parameter is included. Set to 1. Under this setting, with each direction on the sphere as the normal, perform cosine-weighted hemispherical surface integration on the environment map to obtain the most dispersed distribution of specular reflection energy in each direction. Store the specular reflection energy values in each direction as the specular reflection base map.
[0009] Unlike conventional methods that require pre-compiling multiple filter maps for different roughness levels, this step generates only one base map. Subsequent specular reflections of any roughness are reconstructed from this base map through dual-path sampling, which significantly reduces the amount of pre-computed data and storage overhead.
[0010] Furthermore, When the normals of the corresponding micro-element are in a completely random distribution state, the shape of the leaf petals of the specular reflection covers the entire normal hemisphere. In this state, the specular reflection contains the most complete spherical information of the ambient light. Only this one base map is needed to completely describe the specular reflection response of the lighting environment to materials with arbitrary roughness.
[0011] Furthermore, the specular reflection base map is stored in a cube map format, facilitating rapid retrieval of the corresponding energy value based on the direction vector. The specular reflection base map is regenerated only when the environment map changes; the pre-calculation is performed only once during the material editing stage, and it is continuously reused throughout the entire editing session.
[0012] S3: During the real-time material editing phase, obtain the target roughness value set by the user for the current virtual material. , The value range is from 0 to 1. The value of determines the degree of dispersion of specular reflection on the material surface.
[0013] S4: According to Performing scatter sampling specifically includes: Calculate the specular reflection direction based on the current shading point's line of sight and the surface normal direction; Depend on The spherical perturbation cone angle is determined, and the spherical perturbation cone angle follows... As the roughness increases monotonically, the scattering range widens with increasing roughness. A conical region is defined with the mirror reflection direction as the central axis and the spherical perturbation cone angle as the half-angle. A random unit vector is generated within the conical region as a random perturbation vector. The specular reflection direction is added to the random perturbation vector and normalized to obtain the scatter sampling direction; The specular reflection substrate image is sampled once using the scattering sampling direction to obtain the scattering reflection color.
[0014] Scattered sampling simulates the scattering behavior of incident light by a rough material. The scattered reflection color reflects the contribution of the rough material to scattering specular reflection energy into the imperfect specular reflection direction. This contribution, together with the concentrated reflection color obtained in step S5, constitutes the two fundamental components for reconstructing the appearance of specular reflection with arbitrary roughness.
[0015] Furthermore, the aforementioned by Determining the cone angle of the spherical perturbation includes: establishing The mapping relationship with the spherical perturbation cone angle, As the roughness increases, the spherical perturbation cone angle increases monotonically, causing the scattering range to expand with increasing roughness; the maximum value of the spherical perturbation cone angle is... The scattering range under the completely rough state covers the entire normal hemisphere.
[0016] Furthermore, the random perturbation vector causes the sampling direction to deviate from the specular reflection direction by an angle determined by... The deviation angle is controlled to be no greater than the spherical perturbation cone angle, ensuring that the directional range of the scattering sampling maintains physical consistency with the target roughness.
[0017] S5: According to Performing centralized sampling includes: performing a point sampling on the specular reflection base map in the direction of specular reflection to obtain the centralized reflection color.
[0018] Concentrated sampling captures the concentrated energy contribution of a smooth material in the direction of perfect specular reflection. This concentrated reflection color corresponds to the two extreme states of perfectly smooth and perfectly rough, respectively, with the scattered reflection color obtained in step S4, providing a complete value boundary for subsequent hybrid reconstruction.
[0019] Furthermore, in steps S4 and S5, texture filtering is not enabled for point sampling; only the value of the single nearest texel is obtained, so that the original energy value stored in the base map during the pre-calculation stage is not affected by the mixing of adjacent texels.
[0020] S6: By Calculate the mixed weights , and It exhibits a monotonically decreasing relationship. The value ranges from 0 to 1. The smoother the material... The closer the value is to 1, the more specular reflection tends to be concentrated; the rougher the material, the more... The closer to 0, the more specular reflection tends to diffuse reflection. This monotonically decreasing relationship maps the continuous physical parameter of roughness to the mixing ratio of the two-path color components, driving the specular appearance to a smooth transition between smooth and rough.
[0021] Furthermore, and The relationship is expressed as follows: ,in This is a preset constant greater than 0. By adjusting... The value of can control the response curve of the specular reflection appearance as roughness changes.
[0022] S7: Utilize The diffused reflection color and the concentrated reflection color are linearly mixed to obtain the reconstructed specular reflection color. By adjusting... The reconstructed specular reflection color changes continuously between completely smooth and completely rough, without the need to re-perform the illumination integration throughout the process.
[0023] The essence of this linear blending is to transform roughness changes into interpolation of two pre-acquired color components, thus avoiding the repetitive calculations required by traditional methods where roughness modifications necessitate re-integration.
[0024] S8: The reconstructed specular color and the independently calculated diffuse color are mixed according to the Fresnel reflection model to obtain the final colored screen pixel value. The material appearance thus simultaneously includes a specular reflection component related to roughness and a diffuse reflection component independent of roughness.
[0025] Furthermore, the diffuse color is calculated by mixing the diffuse color parameters of the virtual material with the diffuse integral result of the environment map. This calculation process is similar to... It is irrelevant; the diffuse color remains constant during the roughness parameter editing process and will not change color due to roughness adjustments.
[0026] Furthermore, during the real-time material editing stage, Update every time there is a change. Then, steps S4 and S5 are re-executed. Throughout the update process, the environment map is not re-integrated, nor is the specular reflection base map regenerated. The computational overhead is limited to two map samplings and a small number of multiply-accumulate operations, thereby achieving real-time response for roughness editing.
[0027] Furthermore, during the real-time material editing stage, When the changes are continuous, the random perturbation vector in step S4 is updated frame by frame, and in step S6... Synchronous updates within the same shader call. The continuous decrease of the perturbation vector and the frame-by-frame update of the perturbation vector affect the surface reflection appearance of the material. The continuous changes are presented in a smooth transition, without any visual abrupt changes or flickering.
[0028] The technical effects and advantages of this invention are as follows: Firstly, this invention generates only a single specular reflection base map during the pre-calculation stage. This base map is obtained by performing hemispherical surface integration on the environment map under a fully roughened state, containing the most complete energy distribution information of ambient light on the sphere. During the real-time editing stage, color components under two extreme states are obtained through scatter sampling and concentrated sampling, respectively. These components are then linearly blended using roughness-driven blending weights to reconstruct the specular reflection appearance with any intermediate roughness. Throughout the editing process, no re-integration of the environment map or regeneration of the base map is triggered, which helps reduce redundant computational overhead and improves editing response speed.
[0029] Secondly, this invention transforms the calculation of specular reflection under varying roughness into two point samplings and one mixing operation on a pre-calculated base map. The mixing weights and roughness adopt a monotonically decreasing relationship, ensuring a continuous transition in the material's reflective appearance between perfectly smooth and perfectly rough. As roughness changes continuously, the random perturbation vector is updated frame-by-frame, and the mixing weights are updated synchronously; both work together to ensure the smoothness of the appearance change, preventing visual abrupt changes or flickering. The calculation process for the diffuse reflection component is independent of the roughness parameters, further guaranteeing the stability of the material's color during editing. Attached Figure Description
[0030] Figure 1 This is a flowchart illustrating the overall implementation of the method of the present invention; Figure 2 This is a schematic diagram of signal transmission during the real-time editing stage of the present invention; Figure 3 The flowchart for step S4, the sampling sub-step, of the present invention is as follows. Detailed Implementation
[0031] 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, and 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.
[0032] Example 1 As attached Figures 1 to 3 The method shown is a physical lighting environment virtual material editing implementation method. In the pre-calculation stage, only a single specular reflection base map is generated. In the real-time editing stage, the specular reflection appearance under arbitrary roughness is reconstructed by mixing scatter sampling and concentrated sampling through dual paths.
[0033] The complete implementation process of the method of this application will be described in detail below with reference to steps S1 to S8.
[0034] Step S1: Obtain the environment map.
[0035] First, obtain the environment map of the target virtual scene, which describes the emissivity distribution of incident light in the spherical direction in the virtual scene.
[0036] As one implementation method, the environment map is generated by artists through offline rendering during the lighting design phase. After completing the light source layout in the virtual scene, artists use the renderer's panoramic baking function to emit light rays from preset sampling points in the scene in all directions towards the surrounding spherical surface, recording the emissivity values of the incident light in each direction to generate a high dynamic range image file in an equidistant rectangular projection format. This image file is loaded into memory when the material editing tool is launched, serving as the fixed lighting input for subsequent steps. This method is suitable for production stages where the scene lighting is finalized and repeated adjustments to materials are required.
[0037] As another implementation, the environment map is generated in real-time during runtime. Sampling rays are emitted from the surface position of the currently edited object outwards in spherical directions. The color of the scene surface and the intensity of the light source hitting each ray are accumulated to construct an environment map in cube map format in real time. This method is suitable for scenes where the editing viewpoint moves frequently and requires dynamic updates to ambient lighting based on the current position.
[0038] Regardless of the acquisition method used, the virtual scene is a static scene with completed lighting design, and the environment texture remains unchanged during the subsequent material editing process.
[0039] Step S2: Pre-calculate and generate a specular reflection substrate map.
[0040] Based on the environment texture obtained in step S1, a single specular reflection base map is pre-calculated and generated. During the pre-calculation, the material roughness parameters are included. Set as . Corresponding to the state where the normal of the micro-element is completely randomly distributed, in this state the shape of the leaf petals of the specular reflection covers the entire normal hemisphere, and the specular reflection energy presents the most dispersed distribution on the sphere.
[0041] In one implementation, the integration operation is performed sequentially, using discretized spherical directions as units. The sphere is divided into multiple discrete directions according to latitude and longitude, with each discrete direction corresponding to a unit direction vector. For each direction ,by For the hypothetical surface normal, in Traverse each incident light direction in the environment map within the hemisphere. The criteria for determining a normal hemisphere are: .extract Emissivity value in direction Calculate the cosine factor .Will and Multiply and add the product to the direction. The corresponding accumulator. After the traversal is complete, the value in the accumulator is the direction. Specular reflection energy value For all discrete directions After completing the above operations, the correspondence between all directions and energy values is stored as a cube map by direction mapping. This cube map is the specular reflection base map.
[0042] As another implementation, the integration operation is performed in the frequency domain using spherical harmonic transformation. Spherical harmonic transformation is a prior art technique; its input is the emissivity values of the environment map in each direction obtained in step S1, and its output is the spherical harmonic coefficients of the environment map. Simultaneously, the cosine-weighted hemispherical function is also expanded into spherical harmonic coefficients. The spherical harmonic coefficients of the environment map and the spherical harmonic coefficients of the cosine-weighted hemispherical function are multiplied sequentially to obtain the spherical harmonic coefficients of the specular reflection energy distribution. Then, using these spherical harmonic coefficients as input, an inverse spherical harmonic transformation is performed to restore a set of energy values in the spherical direction. This set of energy values is then mapped and stored as a cube map according to direction, thus obtaining the specular reflection base map. This method has higher computational efficiency when the environment map resolution is high. The specular reflection base maps produced by the two implementation methods can be used interchangeably in subsequent steps.
[0043] Regarding the storage format of the specular reflection substrate map, in one embodiment it is... Stored in cube map format. Each face corresponds to the front, back, left, right, top, and bottom of the sphere. Each direction and each face is a two-dimensional texture array. During sampling, the face to be accessed is determined based on the three components of the input direction vector, and the texel value is read based on the projection coordinates of the direction vector on the corresponding face. In another implementation, it is stored in the form of a set of spherical harmonic coefficients, storing a set of spherical harmonic coefficients with a preset expansion order. During sampling, the energy value of the corresponding direction is obtained in real time through forward spherical harmonic calculation, which consumes less memory.
[0044] The specular reflection base map is regenerated only when the environment map changes. During the material editing phase, the environment map remains unchanged, and pre-calculation is performed only once.
[0045] Step S3: Obtain the target roughness value.
[0046] After pre-calculation is complete, the real-time material editing stage begins. The target roughness value set by the user for the current virtual material is obtained. . The range of values is arrive , For completely smooth material surfaces, Corresponding to completely rough material surfaces.
[0047] As one implementation, the material editing interface provides a roughness adjustment slider, the slider's sliding stroke being linearly mapped to... The value range is determined by the system in real time based on the slider's position as the user drags the slider. Numerical values. Alternatively, users can directly enter numerical values into the input box. The system reads the input value and limits it to a specific numerical value. arrive Within the range.
[0048] Step S4: Perform scatter sampling.
[0049] According to the information obtained in step S3 Scatter sampling is performed. For rough materials, the distribution range of their micro-element normals is wide, and incident light is scattered into a cone-shaped region centered on the specular reflection direction. Scatter sampling simulates this scattering effect by randomly selecting sampling directions within this cone-shaped region.
[0050] First, based on the line of sight of the currently colored point. and surface normal direction Calculate the direction of mirror reflection :
[0051] in express and dot product operation, It is the unit direction vector from the colored point to the camera. It is the unit direction vector of the object's surface at the shaded point. (Calculated) Store it in a temporary variable for use in subsequent steps.
[0052] Then, by Determine the cone angle of the spherical perturbation, denoted as . . The maximum angular range of the random sampling direction deviating from the specular reflection direction is defined. When it increases Monotonically increasing.
[0053] As one implementation method, and A linear mapping is used between them:
[0054] Under this mapping, hour , hour , The maximum value is .
[0055] As another implementation method, a nonlinear mapping is used:
[0056] in greater than The preset constant. When hour, exist Growth is slow when it is small, near Growth accelerates over time; when hour, exist It grows faster when it is smaller. near The growth rate is slowing down. Regardless of... What value should be taken? hour Always for , The maximum value is .
[0057] Next, in Generate random perturbation vectors within a defined cone-shaped area. Specifically, with With direction as the central axis, Given a half-angle, define a conical region and generate a random unit vector within that region; this vector is... , direction and The included angle does not exceed .
[0058] As one implementation method, the cone-shaped region is generated in a uniformly distributed manner. During generation, first in arrive Generate uniform random numbers between Calculate the polar angle that satisfies a uniform distribution of solid angles:
[0059] Then in arrive Generate uniformly random numbers between them as azimuth angles. From polar angle and azimuth In for Construct a unit vector in the local coordinate system of the axis by: the vector's Components , Components , Components The vector constructed in this way is directly used as a vector in world space. ,and They exist in the same coordinate space.
[0060] As another implementation method It is generated according to a normal distribution within this conical region, with The direction is the distribution center, and the standard deviation is taken as . The preset ratio value. Under this method, the disturbance direction is more likely to be concentrated in the preset ratio value. Near the direction.
[0061] After that, and Add the results together, then normalize the sum to obtain the scatter sampling direction. .
[0062] Finally, with Perform point sampling on the specular reflection substrate map generated in step S2 to obtain the scattered reflection color. When the base map is stored in cubemap format, according to The directional component determines the corresponding face in the cube map, and the corresponding 2D texture array for that face is read. The texel value closest to the orientation. When the basis graph is stored as a set of spherical harmonic coefficients, As input, it is obtained through spherical harmonic forward calculation. The energy value corresponding to the direction is used as Texture filtering is not enabled in this sampling; for spherical harmonic storage, this constraint is also satisfied because the calculation process does not involve texture lookup.
[0063] random perturbation vector Make the sampling direction deviate from the direction of specular reflection. The angle is from Control, the deviation angle is equal to and The angle between them. Due to exist Generated within a defined conical range, the deviation angle is always no greater than [value missing]. .
[0064] Step S5: Perform centralized sampling.
[0065] According to the information obtained in step S3 Perform concentrated sampling. For smooth materials, reflected light energy is highly concentrated near the specular reflection direction. Concentrated sampling captures this concentrated contribution component by directly sampling the substrate map in the specular reflection direction.
[0066] In one implementation, steps S4 and S5 are executed in the same shader program, and step S5 directly reads the data stored in the temporary variable in step S4. To avoid duplicate calculations, step S5 is calculated independently. Alternatively, step S5 can be implemented by calculating the value separately. The calculation method is the same as in step S4, that is... The calculation result is consistent with that of step S4.
[0067] by Perform point sampling on the specular reflection substrate map generated in step S2 to obtain the concentrated reflection color. Texture filtering is also not enabled during sampling. When the base map is stored in cubemap format, according to... The directional components determine the corresponding surface and texture coordinates and read the texel values; when the base map is stored as a set of spherical harmonic coefficients, As input, it is obtained through spherical harmonic forward calculation. The energy value corresponding to the direction is used as .
[0068] Steps S4 and S5 are based on the same specular reflection substrate image. The difference between the two lies in their sampling strategies: Step S4 applies a random perturbation to the sampling direction to obtain the energy value in the scattering direction. Step S5, without applying any perturbation, yields the energy value in the direction of mirror reflection. .
[0069] Step S6: Calculate the mixed weights.
[0070] Obtained from step S3 Calculate the mixed weights . and It satisfies a monotonically decreasing relationship. The smaller the size, the smoother the material. The closer ; The larger the size, the rougher the material. The closer . The range of values is arrive .
[0071] As one implementation method, and The relationship is expressed as follows:
[0072] in greater than The default constant. In one example, Values ,Right now , Follow Linearly decreasing. In another example, Values , exist The decay is slower when the size is smaller. near The decay is relatively rapid. In yet another example, The value is 0.5. exist The decay is faster when the size is smaller. near The decay is relatively slow. The value can be selected according to the actual art requirements.
[0073] As another implementation method and The relationships are defined through a predefined lookup table. The lookup table is a table of length [length missing]. A one-dimensional array, the first 1 element storage Time corresponding Value, of which When editing in real time, the current... Multiply Get the floating-point index value and take its integer part. and decimal part Calculated by linear interpolation :
[0074] Here, Table represents an array of lookup tables. The contents of the lookup tables can be customized by the user to implement arbitrary monotonically decreasing curves that are difficult to describe using formulaic methods. The larger the value, the higher the accuracy of the lookup table.
[0075] Step S7: Linear blending yields the reconstructed specular reflection color.
[0076] Using the mixed weights obtained in step S6 ,right and Linear blending is performed to obtain the reconstructed specular reflection color. :
[0077] The calculation is performed channel by channel, that is, the above multiplication and addition operations are performed on the red, green and blue color channels respectively.
[0078] when hour, equal This corresponds to the mirror-like reflective appearance of a completely smooth material; when hour, equal This corresponds to the mirror-like reflective appearance of a completely rough material; when exist arrive In between, This represents a transitional state between the two, corresponding to the specular reflective appearance of materials with medium roughness.
[0079] Step S8: Fresnel mixing yields the final screen pixel values.
[0080] First, calculate the diffuse color. Diffuse reflection refers to the component of light that is scattered multiple times after incident light enters the interior of a material and then re-emerges, regardless of the viewing direction or roughness.
[0081] As one implementation method, the environment map obtained in step S1 is processed with the surface normal direction of the current shading point. Performing a cosine-weighted hemispherical surface integral along the axis yields the diffuse irradiance value. .Will Multiplying the diffuse color parameter of the virtual material channel by channel, we obtain This calculation process does not involve ,and Completely unrelated.
[0082] As another implementation method, diffuse reflectance irradiance value The irradiance map is pre-calculated and stored as an independent map. This irradiance map is generated synchronously during the pre-calculation stage of step S2. The generation method is as follows: using each direction on the sphere as an imaginary surface normal, a cosine-weighted hemispherical surface integral is performed on the environment map obtained in step S1, and the integral results in each direction are stored as a cube map. During real-time editing, the surface normal direction of the current shading point is used as the reference point. As input, according to The directional component determines the corresponding surface and texture coordinates of the irradiance map, and sampling is used to obtain... Irradiance value corresponding to direction .Will Multiplying the diffuse color parameter of the virtual material channel by channel, we obtain This method moves the integration work to the pre-computation stage, requiring only one texture sample during real-time editing.
[0083] get Then, it is compared with the result obtained in step S7. Mixing is performed according to the Fresnel reflection model. Fresnel reflection coefficient. The calculation method is as follows: based on the basic reflectivity parameters of the virtual material. and line of sight With surface normal The included angle As input, the Schlick approximation formula from the existing technology is used:
[0084] in . The output is arrive A scalar value within a range, representing the proportion of incident light that is specularly reflected. Follow It increases as it grows.
[0085] Final screen pixel values The calculation method is as follows:
[0086] This calculation is performed channel by channel. The output is sent to the screen pixel buffer as the final display color of the current shading point. All pixels on the screen belonging to this virtual material independently execute the above steps S1 to S8, and each pixel independently calculates the shading result based on its own surface normal direction and viewing direction.
[0087] The update mechanism during the real-time editing phase.
[0088] When the user modifies hour, Each change triggers a complete coloring calculation. The system adjusts the coloring based on the new... Value update mixed weights Repeat steps S4 and S5, then repeat steps S7 and S8 in sequence, and output the updated result. The entire update process does not trigger the re-integration of the environment map, nor does it regenerate the specular reflection base map.
[0089] When the user continuously drags the roughness slider, When there are continuous changes between frames, each frame reads the current... Value. Based on this The value is obtained sequentially within the same shader call: Step S4. Step S5 obtains Step S6 obtains Then output through steps S7 and S8. Both steps S4 and S5 depend on the calculations obtained in step S4. Step S6 depends on the information obtained in step S3. .
[0090] As one implementation method, the random perturbation vector of each frame Each is generated independently, and the two adjacent frames are... There is no correlation between them. Calculation and The generation is completed in the same shader call, in the next frame. When changing and Simultaneous updates. This method is simple to implement, with no correlation between perturbations between frames, and the specular noise pattern of rough materials changes naturally between frames, making it suitable for typical real-time material editing scenarios.
[0091] As another implementation method The frame-by-frame update uses a pseudo-random sequence generated based on the frame number. A pseudo-random seed value bound to the frame number is defined. Each frame, a pseudo-random number is generated based on this seed value, and then updated accordingly. Construction within a defined conical area The same method applies. Same as the frame sequence number generated This ensures that the rendering results remain consistent across multiple playbacks, making it suitable for material review and version comparison scenarios where the editing process needs to be accurately reproduced.
[0092] Through the above update mechanism, users continuously change... At that time, the reflective appearance of the material surface presents a smooth transition from rough to smooth. The continuous decrease makes exist and There is no abrupt transition between them. The frame-by-frame updates cause the specular noise pattern in the rough state to change continuously between frames.
[0093] The above description is merely an illustration of different embodiments of the technical features of this application. Those skilled in the art can make appropriate combinations or substitutions to the various embodiments based on the disclosure of this application, and all such combinations and substitutions should fall within the protection scope of this application.
Claims
1. A method for implementing virtual material editing of a physically based lighting environment, characterized in that, Includes the following steps: S1: Obtain the environment map of the virtual scene, which describes the emissivity distribution of incident light in the spherical direction in the virtual scene; S2: Based on the environment map, pre-calculate and generate a single specular reflection base map, including material roughness parameters during the pre-calculation. Set to 1. Under this setting, with each direction on the sphere as the normal, perform cosine-weighted hemispherical surface integral on the environment map to obtain the most dispersed distribution of specular reflection energy in each direction. Store the specular reflection energy values in each direction as the specular reflection base map. S3: During the real-time material editing phase, obtain the target roughness value set by the user for the current virtual material. , The value range is from 0 to 1; S4: According to Performing scatter sampling includes: Calculate the specular reflection direction based on the current shading point's line of sight and the surface normal direction; Depend on The spherical perturbation cone angle is determined, and the spherical perturbation cone angle follows... It increases monotonically; A conical region is defined with the mirror reflection direction as the central axis and the spherical perturbation cone angle as the half-angle. A random unit vector is generated within the conical region as a random perturbation vector. The specular reflection direction is added to the random perturbation vector and normalized to obtain the scatter sampling direction; Perform a point sampling on the specular reflection substrate map in the scattering sampling direction to obtain the scattering reflection color; S5: According to Perform centralized sampling, including: A point sample is performed on the specular reflection base map along the specular reflection direction to obtain the concentrated reflection color; S6: By Calculate the mixed weights , and It exhibits a monotonically decreasing relationship. The value range is from 0 to 1; S7: Utilize The dispersed reflection color and the concentrated reflection color are linearly mixed to obtain the reconstructed specular reflection color; S8: The reconstructed specular reflection color and the independently calculated diffuse reflection color are mixed according to the Fresnel reflection model to obtain the final colored screen pixel value.
2. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S1, the virtual scene is a static scene with completed lighting design, and the environment map remains unchanged during material editing; in step S2, the specular reflection base map is regenerated only when the environment map changes.
3. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S2, Setting it to 1 corresponds to a state where the micro-surface element normals are completely randomly distributed, at which point the shape of the leaf petals reflected by the mirror covers the entire normal hemisphere.
4. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S4, the... Determining the cone angle of the spherical perturbation includes: establishing The mapping relationship with the spherical perturbation cone angle, As the angle increases, the spherical perturbation cone angle increases monotonically, and the maximum value of the spherical perturbation cone angle is... .
5. The method for implementing virtual material editing of a physically based lighting environment according to claim 4, characterized in that, In step S4, the random perturbation vector causes the sampling direction to deviate from the specular reflection direction by an angle determined by... The deviation angle is controlled to be no greater than the spherical disturbance cone angle.
6. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S6, and The relationship is expressed as follows: ,in It is a preset constant that is greater than 0.
7. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S2, the specular reflection substrate map is stored in cube map format; in steps S4 and S5, texture filtering is not enabled for point sampling.
8. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, During the real-time material editing stage Update every time there is a change. Then, steps S4 and S5 are re-executed. During the entire update process, the re-integration of the environment map is not triggered, nor is the specular reflection base map regenerated.
9. The method for implementing virtual material editing of a physically based lighting environment according to claim 1, characterized in that, In step S8, the diffuse color is calculated by mixing the diffuse color parameters of the virtual material with the diffuse integral result of the environment map. The calculation process of this diffuse color is similar to... Irrelevant.
10. The method for implementing virtual material editing of a physically based lighting environment according to claim 6, characterized in that, During the real-time material editing stage When the changes are continuous, the random perturbation vector in step S4 is updated frame by frame, and in step S6... Update synchronously within the same shader call.
