A method, system, device and medium for real-time rendering of a game hair strand sky
By combining reflection probes and sky sphere harmonic functions, the lighting data of the hair model is obtained and multiple corrections are made. This solves the stability and realism issues of hair sky lighting rendering in extreme environments, and achieves stable rendering effects of the hair model under extreme lighting and scene switching.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI ZHULONG INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2026-05-09
- Publication Date
- 2026-07-31
AI Technical Summary
Existing methods for rendering hair under ambient light are not capable of adapting to exposure in dynamically changing ambient light environments. This results in harsh color transitions and abrupt hue changes in hair, making it impossible to maintain stability and realism under extreme lighting conditions and when switching between indoor and outdoor scenes.
The radiance of the reflected probe is obtained by emitting a sampling ray to the world space location of the hair model. The illumination is then calculated by combining the sky sphere harmonic function coefficients. The illumination data is corrected based on the indoor and outdoor labels and the radiance of the reflected probe. The ambient color curve is then fitted with the four-way ambient color sampling data to achieve the rendering of the hair model.
It achieves stability and realism in rendering hair strands under extreme lighting and indoor/outdoor scene switching, avoiding the bottom of the hair being completely black, lacking light and dark levels, and hue distortion, thus improving the realism of hair rendering and its ability to adapt to different environments.
Smart Images

Figure CN122479409A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of real-time rendering of hair and skylight in games, and specifically relates to a real-time rendering method, system, device and medium for hair and skylight in games. Background Technology
[0002] With the development of real-time rendering technology for games and the industrialization system of digital art, physically based realistic rendering technology has been widely used. This technology can greatly improve the realism of rendering three-dimensional virtual scenes and character models by simulating the light transmission law of the real world, and also makes the realistic rendering of character hair a core direction for upgrading the quality of game art.
[0003] In traditional techniques, three main processing paths have emerged in the industry for rendering hair and sky lighting. The first is an environment reflection sampling method based on reflection probes. This method pre-baks the scene's ambient lighting and reflection information by pre-deploying spatial sampling units within the game scene. During rendering, the pre-baked data is read using the reflection direction of the hair as an index, enabling real-time calculation of the hair's ambient lighting. The second is a global illumination sampling method based on sky spherical harmonics. This method encodes the lighting information of the 3D sky environment in a low-dimensional way using spherical harmonic functions. During rendering, it quickly completes the sampling calculation of sky lighting using direction indexes, providing the basic global sky lighting data for the hair. The third is a screen-space color shading method. This method directly extracts pixel color information within the screen space and assigns the corresponding ambient color to the hair model, achieving color adaptation for the hair environment with extremely low performance overhead.
[0004] However, sampling methods based on reflection probes can only acquire pre-baked reflection information for local scenes, failing to adapt to the lighting requirements of the inner layers of hair clusters and the hair roots. This easily leads to problems such as completely black hair at the bottom and a lack of tonal gradation, and it also cannot achieve real-time brightness adaptation to dynamic sky lighting. Sampling methods based on sky spherical harmonics can only represent global sky lighting information, lacking the ability to identify and determine scene spatial occlusion, and cannot distinguish between indoor and outdoor environments where the hair model is located. In enclosed indoor scenes, this easily results in rendering errors such as excessively bright skylight on the hair and light leaks. Furthermore, screen-space-based coloring methods have low sampling accuracy and cannot accurately reproduce the true color tendencies of the scene environment, easily leading to hue shifts and color distortion, failing to meet the quality requirements of realistic game rendering.
[0005] Existing traditional methods suffer from insufficient exposure adaptation in dynamically changing lighting environments, resulting in harsh color transitions in hair strands and abrupt hue changes. Under complex conditions such as extreme light intensity, day-night cycles, and indoor-outdoor scene transitions, the stability and realism of the rendering effects cannot be guaranteed. Summary of the Invention
[0006] Based on this, it is necessary to provide a real-time rendering method, system, device, and medium for game hair and sky lighting that can achieve more reliable and stable real-time rendering effects under various extreme exposure, extreme light intensity, extreme skylight intensity, and indoor and outdoor environments, in order to address the above-mentioned technical problems.
[0007] Firstly, this application provides a real-time rendering method for the lighting of hair strands in a game, including:
[0008] Starting from the world space position of the hair model, a reflection probe sampling ray is emitted directly upwards to obtain the reflection probe radiance corresponding to the world space position above, and indoor and outdoor labels of the hair model are set based on the reflection probe radiance.
[0009] Using the normal reflection direction of the hair model as an index, sky illumination sampling calculation is performed based on the sky spherical harmonic function coefficients to obtain the original sky spherical harmonic sampling data. Then, the original sky spherical harmonic sampling data is corrected based on the radiance of indoor and outdoor labels and reflective probes to obtain the corrected sky spherical harmonic sampling data.
[0010] Using the normal reflection direction of the hair model as an index, environmental reflection sampling calculation is performed on the reflection probe to obtain environmental reflection sampling data. Then, based on the corrected sky spherical harmonic sampling data, brightness correction is performed on the environmental reflection sampling data to obtain corrected environmental reflection sampling data.
[0011] The average brightness of the sky light is obtained, and exposure correction is performed on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the sky light to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data;
[0012] The average double scattering energy value of the hair model is obtained, and the brightness is corrected for the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value to obtain the triple-corrected sky spherical harmonic sampling data and the triple-corrected environmental reflection sampling data.
[0013] Starting from the world spatial location, four reflection probe sampling rays are emitted in the forward, backward, left and right directions to obtain four-directional ambient color sampling data. Based on the four-directional ambient color sampling data, an ambient color curve fitting function is obtained. Based on the ambient color curve fitting function, the hue of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data are restored to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0014] The hair model is rendered based on quadruple-corrected sky spherical harmonic sampling data and quadruple-corrected environmental reflection sampling data.
[0015] Secondly, this application also provides a real-time rendering system for game hair and skylight effects, including:
[0016] The indoor / outdoor label determination module is used to emit a reflection probe sampling ray directly upward from the world space position of the hair model, obtain the reflection probe radiance of the reflection probe above the world space position, and set the indoor / outdoor label of the hair model based on the reflection probe radiance.
[0017] The Sky Harmonic Sampling Correction Module is used to calculate the sky illumination sampling based on the sky harmonic function coefficients, using the normal reflection direction of the hair model as an index, to obtain the original sky harmonic sampling data. Then, it corrects the original sky harmonic sampling data based on the radiance of indoor and outdoor labels and reflection probes to obtain the corrected sky harmonic sampling data.
[0018] The environmental reflection sampling correction module is used to perform environmental reflection sampling calculations on the reflection probe using the normal reflection direction of the hair model as an index, to obtain environmental reflection sampling data, and to perform brightness correction on the environmental reflection sampling data based on the corrected sky spherical harmonic sampling data, to obtain corrected environmental reflection sampling data.
[0019] The average brightness exposure correction module is used to obtain the average brightness of the sky light, and to perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the sky light, so as to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data.
[0020] The sampling data brightness correction module is used to obtain the average double scattering energy value of the hair model, and to perform brightness correction on the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value, so as to obtain triple-corrected sky spherical harmonic sampling data and triple-corrected environmental reflection sampling data.
[0021] The sampling data hue correction module is used to emit four reflection probe sampling rays forward, backward, left, and right from the world spatial location to obtain four-directional ambient color sampling data. The four-directional ambient color sampling data is input into the ambient color curve fitting function to generate ambient color reference data. Based on the ambient color reference data, the hue of the triple-corrected sky sphere harmonic sampling data and triple-corrected ambient reflection sampling data is restored to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0022] The real-time rendering module for hair models is used to render hair models based on quadruple-corrected sky spherical harmonic sampling data and quadruple-corrected environmental reflection sampling data.
[0023] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method as described in any of the first aspects of this application.
[0024] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any of the first aspects of this application.
[0025] The aforementioned real-time rendering method, system, device, and medium for game hair skylights obtains the radiance of the reflection probe by emitting a reflection probe sampling ray upwards and setting indoor and outdoor labels. Then, using the normal reflection direction as an index, it performs sky spherical harmonic sampling and combines the indoor and outdoor labels with the radiance to correct the lighting data. This enables the adaptation calibration of sky spherical harmonic sampling data to environmental conditions, improving the numerical rationality of sky spherical harmonic sampling data under different environments and avoiding rendering errors such as overly bright hair and light leaks caused by abnormally high sky spherical harmonic sampling data in indoor enclosed scenes. By using the normal reflection direction as an index for environmental reflection sampling and combining it with the corrected sky spherical harmonic sampling data, it completes the brightness correction of environmental reflection sampling data. Then, based on the global skylight average brightness, it performs synchronous exposure correction of the two sets of sampling data. This can completely restore the reflected lighting information of the hair model, supplement the basic lighting intensity of the inner layer and hair root of the hair model cluster, and establish the inner and outer layers of hair lighting. A smooth transition system for illumination intensity avoids completely black areas at the bottom of hair strands and a lack of tonal gradation, improving the stability and realism of hair rendering. By correcting brightness based on the average double scattering energy value, global illumination scattering energy information of the hair model cluster can be extracted, and the global occlusion data of the hair model cluster hidden in the double scattering energy can be mined, restoring the natural tonal gradation of the hair material, preserving the fluffy and soft texture of the hair fiber cluster, and enhancing the physical realism of the hair material. By acquiring four-dimensional ambient color sampling data, fitting and generating an ambient color curve fitting function, and performing mechanical energy hue repair, it can cover the ambient color information of the entire horizontal space where the hair model is located, avoiding hue jumps, color banding, and color distortion, improving the consistency of the hue performance of the hair rendering with the scene's ambient color, and allowing the hair skylight rendering to remain stable under complex conditions such as indoor and outdoor scene switching and extreme lighting intensity, improving the realism, stability, and environmental adaptability of the game's hair skylight rendering. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A flowchart illustrating a real-time rendering method for game hair and skylight effects provided in one embodiment of this application. Figure 1 ;
[0028] Figure 2 A flowchart illustrating a real-time rendering method for game hair and skylight effects provided in one embodiment of this application. Figure 2 ;
[0029] Figure 3 This is a schematic diagram of the structure of a real-time rendering system for game hair and sky lighting, provided as an embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0031] In one exemplary embodiment of this application, such as Figure 1 As shown, a real-time rendering method for hair and skylight effects in games is provided. This embodiment illustrates the method by applying it to a rendering terminal. It is understood that this method can also be applied to a rendering server, or to a rendering system including both a rendering terminal and a rendering server, and is implemented through the interaction between the rendering terminal and the rendering server. In this embodiment, the method includes the following steps:
[0032] Step S101: Starting from the world space position of the hair model, emit a reflection probe sampling ray directly upwards to obtain the reflection probe radiance corresponding to the world space position above, and set the indoor and outdoor labels of the hair model based on the reflection probe radiance.
[0033] Optionally, the rendering terminal can perform skeletal node and model data binding verification on the character model in the game scene, identify the skeletal hierarchy structure corresponding to each hair model in the character model, locate the root node of each hair model, and obtain the world space position of the root node of each hair model in the game world space coordinate system. The rendering terminal can use the world space position of each hair model as the starting origin of the reflection probe sampling ray emission, and emit a reflection probe sampling ray in the direction directly above the game world space coordinate system. The rendering terminal can query the reflection probes within the range directly above the world space position based on the reflection probe spatial index structure. The rendering terminal can calculate the sweep range of the ray in the three-dimensional world space based on the emission origin and ray direction of the reflection probe sampling ray, determine all three-dimensional space mesh units covered within the ray sweep range, read the relevant information of all reflection probes stored in these three-dimensional space mesh units from the reflection probe spatial index structure, and add these reflection probes to the candidate reflection probe list. The rendering terminal can obtain the reflection probe radiance of the corresponding reflection probe from the candidate reflection probe list. The rendering terminal can statistically determine the number of reflection probes in the candidate reflection probe list. If there is only one reflection probe in the list, the rendering terminal can directly read the pre-baked radiance data of that reflection probe and obtain its corresponding radiance. If there are multiple reflection probes in the candidate list, the rendering terminal can obtain the fixed configuration weight and sampling ray distance of each reflection probe. Based on these weights, it calculates the overall weight of each reflection probe and obtains the radiance of the reflection probe with the highest overall weight. The rendering terminal can then set indoor / outdoor labels for the hair model based on the obtained radiance.
[0034] To illustrate, when a character model undergoes spatial transformations such as displacement or rotation within the game scene, the rendering terminal can simultaneously acquire the updated world space position of the hair root node.
[0035] Optionally, the rendering terminal can set a collision detection level for the reflection probe sampling ray to avoid collision detection interference between the reflection probe sampling ray and other objects in the scene, such as static models, dynamic characters, and scene objects. The rendering terminal can verify the emission status of the reflection probe sampling ray. If problems such as data anomalies or detection range overflowing the scene boundary occur during ray emission, the rendering terminal can re-execute the ray emission operation.
[0036] Optionally, the spatial index structure of the reflection probe can adopt a three-dimensional spatial grid index structure or an octree spatial index structure. The rendering terminal can divide the three-dimensional world space of the game scene into several continuous three-dimensional spatial grid units according to the spatial size. Each three-dimensional spatial grid unit stores the unique identification information, spatial coordinate information, probe configuration parameter information and probe sampling data storage address information of all reflection probes within the grid unit.
[0037] For example, the rendering terminal can pre-set fixed configuration weights for each reflection probe in the scene. The value of the fixed configuration weight can be set according to the baking accuracy, coverage, update frequency, and scene importance of the reflection probe. For reflection probes that cover the core game scene, have higher baking accuracy, and faster update frequency, the rendering terminal can set higher fixed configuration weights. For reflection probes that cover the edge scene, have lower baking accuracy, and slower update frequency, the rendering terminal can set lower fixed configuration weights. The rendering terminal can calculate the shortest straight-line distance between the spatial coordinates of each reflection probe and the reflection probe sampling ray, obtaining the reflection probe sampling ray distance corresponding to that reflection probe. The reflection probe sampling ray distance can be used to characterize the spatial distance between the reflection probe and the reflection probe sampling ray. The smaller the reflection probe sampling ray distance, the higher the spatial correlation between the reflection probe and the location of the hair model, and the greater the impact on the ambient lighting of the hair model. The rendering terminal can calculate the comprehensive weight of each reflection probe based on the fixed configuration weight of each reflection probe and the reflection probe sampling ray distance. The rendering terminal can sort all reflection probes in the candidate reflection probe list in descending order of their overall weights, select the reflection probe with the highest overall weight as the target sampling reflection probe, read the pre-baked radiance data of the target sampling reflection probe, and obtain the radiance of the reflection probe corresponding to the reflection probe.
[0038] Optionally, the indoor / outdoor labels can include indoor and outdoor labels. The indoor label can correspond to the hair model being in a closed indoor environment, while the outdoor label can correspond to the hair model being in an open outdoor environment. The rendering terminal can obtain the global average skylight brightness of the game scene and the corresponding outdoor reference threshold reduction factor. Based on the average skylight brightness and the outdoor reference threshold reduction factor, the rendering terminal can calculate the outdoor reference threshold. When the reflection probe radiance value is greater than or equal to the outdoor reference threshold, the rendering terminal can set the indoor / outdoor label of the hair model to the outdoor label; when the reflection probe radiance value is less than the outdoor reference threshold, the rendering terminal can set the indoor / outdoor label of the hair model to the indoor label.
[0039] Furthermore, the rendering terminal can set a lag buffer for switching between indoor and outdoor labels to avoid frequent switching of indoor and outdoor labels in a short period of time due to dynamic lighting changes in the scene, slight fluctuations in reflection probe sampling data, or small movements of the character model. The rendering terminal can set time thresholds and numerical thresholds for label switching to ensure the stability and continuity of hair rendering effects.
[0040] Step S102: Using the normal reflection direction of the hair model as an index, sky illumination sampling calculation is performed based on the sky sphere harmonic function coefficients to obtain the original sky sphere harmonic sampling data. Then, the original sky sphere harmonic sampling data is corrected based on the radiance of indoor and outdoor labels and reflective probes to obtain the corrected sky sphere harmonic sampling data.
[0041] Optionally, the rendering terminal can acquire the normal vector data of each hair fragment in model space, and convert the normal vector in model space to normal vector in world space using a transformation matrix from model space to world space, thus completing the spatial transformation of the normal vector. Based on the normal vector in world space and the corresponding view direction vector of the hair fragment, the rendering terminal can calculate the normal reflection direction of the hair fragment. The normal reflection direction can be the reflection direction of the view direction vector relative to the normal vector, representing the reflection direction of the hair fragment to ambient light. The rendering terminal can use the normal reflection direction of the hair fragment as an index to perform sky lighting sampling calculations based on the sky harmonic function coefficients, obtaining native sky harmonic sampling data. The rendering terminal can then correct the native sky harmonic sampling data based on the radiance of indoor and outdoor labels and reflection probes, obtaining corrected sky harmonic sampling data.
[0042] For example, after the game scene is loaded, the rendering terminal can perform spherical harmonic function baking on the global sky environment of the game scene, encode the lighting information of the sky environment into sky spherical harmonic function coefficients, and store the sky spherical harmonic function coefficients in the global parameter buffer of the rendering pipeline, which can be read and called in real time during the rendering process. The rendering terminal can convert the normal reflection direction of the hair fragment into a unit direction vector in the spherical harmonic coordinate system, and substitute this unit direction vector into the pre-baked sky spherical harmonic function to complete the sampling calculation of sky lighting, obtain the linear space value of the RGB three channels of sky lighting corresponding to the normal reflection direction of each hair fragment, and obtain the native sky spherical harmonic sampling data corresponding to each hair fragment.
[0043] Indicatively, the sky spherical harmonic function corresponding to the sky spherical harmonic function coefficients can be an orthogonal basis function that can convert the ambient lighting distribution information in three-dimensional space into low-dimensional spherical harmonic coefficients. While ensuring lighting accuracy, it can significantly reduce the computational overhead of ambient lighting sampling and fully adapt to the performance requirements of real-time game rendering.
[0044] Optionally, when the indoor / outdoor label is an indoor label, the rendering terminal can calculate the shading attenuation coefficient based on the radiance of the reflection probe and the average brightness of the skylight, and attenuate the brightness of the original sky spherical harmonic sampling data based on the shading attenuation coefficient to obtain the corrected sky spherical harmonic sampling data.
[0045] To illustrate, the rendering terminal can obtain the average brightness of the skylight across the entire game scene. The ratio of the obtained reflective probe radiant brightness to the average skylight brightness is used as the basis for calculating the occlusion attenuation coefficient. Using a preset attenuation coefficient calculation formula, the corresponding occlusion attenuation coefficient is calculated. When the hair model is in an indoor environment, the radiant brightness of the reflective probe directly above the hair model will be significantly reduced due to the occlusion caused by buildings and other obstructions. The occlusion attenuation coefficient will also decrease accordingly. The rendering terminal can multiply the RGB channel values of the native sky harmonic sampling data of each hair fragment by the occlusion attenuation coefficient to complete the brightness attenuation processing of the native sky harmonic sampling data, obtaining the corrected sky harmonic sampling data for the indoor environment.
[0046] Optionally, when the indoor / outdoor label is an outdoor label, the rendering terminal can perform brightness consistency calibration on the original sky spherical harmonic sampling data based on the radiance of the reflection probe to obtain corrected sky spherical harmonic sampling data.
[0047] To illustrate, when the hair model is in an open outdoor environment, the radiant brightness of the reflection probe directly above the hair model can accurately reflect the actual ambient light intensity of the scene. The rendering terminal can calculate the brightness calibration coefficient of the native sky spherical harmonic sampling data based on the ratio of the radiant brightness of the reflection probe to the brightness channel value of the native sky spherical harmonic sampling data. Based on the brightness calibration coefficient, the rendering terminal can synchronously linearly scale the RGB three-channel values of the native sky spherical harmonic sampling data to complete the brightness consistency calibration of the native sky spherical harmonic sampling data and obtain the corrected sky spherical harmonic sampling data in the outdoor environment.
[0048] Furthermore, the rendering terminal can clamp the numerical range of the corrected sky sphere harmonic sampling data, strictly clamping the RGB three-channel values of the corrected sky sphere harmonic sampling data within the valid numerical range supported by the rendering pipeline. The rendering terminal can store the corrected sky sphere harmonic sampling data in the temporary register of the fragment shader for subsequent rendering correction steps to read and call in real time.
[0049] Step S103: Using the normal reflection direction of the hair model as an index, perform environmental reflection sampling calculation on the reflection probe to obtain environmental reflection sampling data, and perform brightness correction on the environmental reflection sampling data based on the corrected sky sphere harmonic sampling data to obtain corrected environmental reflection sampling data.
[0050] Optionally, the rendering terminal can use the normal reflection direction of each hair fragment of each hair model as an index to perform environmental reflection sampling calculations on the reflection probe, thereby obtaining environmental reflection sampling data for each hair fragment of each hair model. The rendering terminal can then perform brightness correction on the environmental reflection sampling data based on the corrected sky spherical harmonic sampling data to obtain corrected environmental reflection sampling data.
[0051] Schematic illustration: A reflection probe can bake a cubemap of the scene environment within its coverage area, storing the reflection information of the scene environment in a six-sided cubemap. Different mipmap levels of the cubemap correspond to different roughness reflection effects; the higher the mipmap level, the more blurred the reflection effect, adapting to the reflection requirements of materials with different roughness. The rendering terminal can select the mipmap level corresponding to the reflection probe's cubemap based on the roughness parameters of the hair material. The rendering terminal can use the normal reflection direction of the hair fragment as the sampling direction and perform texture sampling at the selected mipmap level to obtain the environmental reflection sampling data of the hair fragment. The environmental reflection sampling data can be used to reconstruct the reflected lighting information of the surrounding environment of the hair fragment.
[0052] To illustrate, the reason why traditional reflection probe sampling schemes suffer from excessively dark areas at the base of hair strands is that fragments within the hair cluster and at the hair root cannot receive direct reflected light from the surrounding environment. The ambient reflection sampling data obtained solely through reflection probe sampling has extremely low brightness, resulting in large areas of dead black at the base of the hair strands, severely impacting rendering quality. In contrast, the technical solution provided in this application allows the rendering terminal to correct the brightness of the ambient reflection sampling data based on corrected sky spherical harmonic sampling data, supplementing the ambient reflection sampling data with sufficient brightness and resolving the problem of excessively dark areas at the base of the hair strands.
[0053] Step S104: Obtain the average brightness of the skylight, and perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the skylight to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data.
[0054] Optionally, the rendering terminal can obtain the global average sky brightness of the game scene. Based on the obtained average sky brightness, the rendering terminal can calculate the exposure correction factor corresponding to the average sky brightness, and perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected ambient reflection sampling data based on the exposure correction factor corresponding to the average sky brightness, to obtain double-corrected sky spherical harmonic sampling data and double-corrected ambient reflection sampling data.
[0055] Furthermore, the rendering terminal can calculate the exposure correction factor corresponding to the average sky brightness based on the obtained average sky brightness using the mapping curve of the exposure correction factor. The rendering terminal can multiply the RGB three-channel values of the corrected sky spherical harmonic sampling data of each hair-sized element by the exposure correction factor to complete the exposure correction processing, obtaining double-corrected sky spherical harmonic sampling data. The rendering terminal can also multiply the RGB three-channel values of the corrected ambient reflection sampling data of each hair-sized element by the exposure correction factor to complete the exposure correction processing, obtaining double-corrected ambient reflection sampling data.
[0056] For example, the rendering terminal can perform integral calculations on the sky illumination across the entire solid angle based on the scene's sky spherical harmonic function coefficients to obtain the scene's global average sky brightness. The average sky brightness can be used to characterize the global average illumination intensity of the scene's sky environment. The average sky brightness can be updated synchronously with the scene's day-night cycle, weather changes, and adjustments to global illumination settings, serving as a stable baseline value for the scene's global illumination. The rendering terminal can store the average sky brightness in the global parameter buffer of the rendering pipeline, which can be read and accessed in real time during the rendering process.
[0057] Step S105: Obtain the average double scattering energy value of the hair model, and perform brightness correction on the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value to obtain triple-corrected sky spherical harmonic sampling data and triple-corrected environmental reflection sampling data.
[0058] Specifically, the rendering terminal can render to texture (RTT) based on the original resolution of each hair model, render the double scattering energy map of each hair model, and downsample the double scattering energy map at multiple levels starting from the original resolution RTT to obtain the average double scattering energy value.
[0059] Schematic illustration: As a semi-transparent fibrous material, the light transmission of hair includes not only direct specular and diffuse reflection, but also multiple scatterings of light between hair fibers, i.e., the double scattering effect. The double scattering effect is the core factor contributing to the soft, fluffy visual effect of hair. Simultaneously, the double scattering energy implicitly contains local occlusion information of the hair clusters, providing a precise basis for brightness correction. During the pre-rendering stage of the rendering pipeline, the rendering terminal can generate a double scattering energy map for each hair model at its original rendering resolution using render-to-texture technology. Each pixel in the double scattering energy map can store the double scattering energy value of the corresponding hair model. This value characterizes the energy intensity of light after multiple scatterings within the fiber clusters of the hair model at that location, accurately reflecting the local density, occlusion level, and light energy distribution of the hair model clusters. The rendering terminal can downsample the original resolution double scattering energy map at multiple levels to obtain the average double scattering energy value. The average double scattering energy value can globally characterize the overall light scattering energy level and occlusion level of the hair model. The rendering terminal can convert double-corrected sky harmonic sampling data and double-corrected ambient reflection sampling data to a luminance-color difference space, resulting in luminance-color difference double sky harmonic sampling data and luminance-color difference double ambient reflection sampling data. Based on the average double scattering energy value, the rendering terminal can perform luminance correction on the luminance channels of the luminance-color difference double sky harmonic sampling data and luminance-color difference double ambient reflection sampling data, resulting in triple-corrected sky harmonic sampling data and triple-corrected ambient reflection sampling data.
[0060] Optionally, the rendering terminal can downsample the original resolution double scattering energy map based on Gaussian filtering and average sampling. The rendering terminal can start from the original resolution and gradually reduce the texture resolution until it obtains 1x1 resolution texture data, which is the global average double scattering energy value of the hair model.
[0061] Indicatively, a lightness / chroma difference color space is a color space that separates the lightness and chroma information of a color. In this color space, the lightness channel and the chroma channel are independent of each other, and modifications to the lightness channel do not affect the hue and saturation information of the color. Lightness / chroma difference color space can also be called a lightness / chroma separation space.
[0062] To illustrate, traditional hair rendering schemes rely solely on single sampled data for brightness control, resulting in insufficient brightness precision. This fails to accurately reproduce the fluffiness and softness of hair fiber clusters, often leading to harsh transitions between light and dark areas and a lack of depth. This brightness correction step utilizes the occlusion information implicit in double scattering energy to precisely correct the brightness of the sampled data, improving the accuracy and realism of the brightness rendering. When the average double scattering energy value is low, it indicates a high degree of occlusion by the hair model clusters, resulting in insufficient light scattering energy. The rendering terminal can appropriately increase the brightness channel values of the sampled data using the brightness correction coefficient to prevent the hair model from being too dark. Conversely, when the average double scattering energy value is high, it indicates a low degree of occlusion by the hair model clusters, resulting in sufficient light scattering energy. The rendering terminal can fine-tune the brightness channel values of the sampled data using the brightness correction coefficient to ensure a natural transition between light and dark areas in the hair.
[0063] Step S106: Starting from the world spatial location, four reflection probe sampling rays are emitted in the forward, backward, left, and right directions to obtain four-directional ambient color sampling data. An ambient color curve fitting function is obtained based on the four-directional ambient color sampling data. The hue of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data are then restored based on the ambient color curve fitting function to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0064] Specifically, the rendering terminal can use the world space position of each hair model as a starting point and emit four reflection probe sampling rays in four horizontally orthogonal directions (front, back, left, and right) to obtain four-directional ambient color sampling data. The rendering terminal can then fit an ambient color curve fitting function based on this data, calculate ambient color reference data for each horizontal direction based on the fitting function, and convert this reference data to a luminance difference space to obtain ambient hue reference data for each horizontal direction. Based on the ambient hue reference data for each horizontal direction of normal reflection, the rendering terminal can perform hue restoration on the chromaticity channels of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data for each horizontal direction of normal reflection, resulting in luminance difference four-fold corrected sky sphere harmonic sampling data and luminance difference four-fold corrected ambient reflection sampling data. The rendering terminal can convert the luminance-color difference quadruple-corrected sky sphere harmonic sampling data and the luminance-color difference quadruple-corrected ambient reflection sampling data into the red-green-blue color space to obtain quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0065] Optionally, the rendering terminal can use the world space position of the hair model determined in step S101 as the common emission origin of the four reflection probe sampling rays, and emit an independent reflection probe sampling ray in each of the four horizontally orthogonal directions in the game world space coordinate system.
[0066] For example, forward and backward can correspond to the positive and negative X-axis directions of the game world coordinate system, and right and left can correspond to the positive and negative Y-axis directions of the game world coordinate system. Forward, backward, right, and left can also be other four directions on the horizontal plane. Forward, backward, right, and left can be orthogonally distributed on the horizontal plane, or other distribution methods that can cover the environmental information of the horizontal space where the hair model is located can be used, which is not limited here.
[0067] Optionally, the rendering terminal can query each reflection probe within the sweep range of each reflection probe sampling ray based on the reflection probe spatial index structure, identify the target sampling reflection probe corresponding to each reflection probe sampling ray, and read the ambient color sampling data of the target sampling reflection probe corresponding to each reflection probe sampling ray in the direction of the reflection probe sampling ray. This yields forward ambient color sampling data, right ambient color sampling data, backward ambient color sampling data, and left ambient color sampling data. The rendering terminal can then generate four-way ambient color sampling data based on these four-way ambient color sampling data. The four-way ambient color sampling data can be three-channel values in a linear RGB color space, accurately reflecting the ambient color information of the horizontal space where the hair model is located.
[0068] For example, the ambient color curve fitting function can be a second-order Fourier series fitting function that adapts to the circumferential periodicity of the horizontal axis. This function can fit a continuous ambient color distribution function across the entire horizontal axis based on discrete sampling data in four orthogonal directions, completing the ambient color change trend in the blank directions between the four sampling points and generating a smooth, continuous omnidirectional ambient color distribution curve. The rendering terminal can calculate the ambient color reference data corresponding to the horizontal direction of the normal reflection of each hair fragment in each hair model based on the ambient color curve fitting function of each hair model. The rendering terminal can convert the ambient color reference data from the linear RGB color space to the luminance difference space, separating the luminance channel data and the chrominance channel data. The chrominance channel data is the ambient hue reference data corresponding to that horizontal direction.
[0069] To illustrate, traditional hair rendering schemes, whether using sky spherical harmonic sampling or reflection probe sampling, are prone to hue errors. Sky spherical harmonic sampling only reflects the hue of the sky environment and cannot match the hue changes of the surrounding scene environment. Reflection probe sampling only obtains ambient color information in discrete directions, which can easily lead to hue jumps, color shifts, and color banding in the directions between sampling points, severely affecting the color realism of the hair rendering. The hue repair operation applied in this embodiment can accurately repair the chromaticity channels of the sampled data based on continuous ambient hue reference data obtained by curve fitting, thus solving the hue error problem.
[0070] Step S107: Render the hair model based on the quadruple-corrected sky spherical harmonic sampling data and the quadruple-corrected environmental reflection sampling data.
[0071] Schematic illustration: The rendering terminal can render each hair model based on quadruple-corrected sky spherical harmonic sampling data and quadruple-corrected environmental reflection sampling data. The rendering terminal can fuse and calculate the quadruple-corrected sky spherical harmonic sampling data and quadruple-corrected environmental reflection sampling data according to the physical property parameters of the hair material, including roughness, metallicity, transmittance, and refractive index, to obtain the lighting color values of each hair fragment in each hair model. The rendering terminal can then combine the calculated lighting color values with the material texture data of each hair model, such as the base color texture, normal texture, and roughness texture, to complete the shading calculation of each hair fragment and generate the rendered image of each hair model. The rendering terminal can then synthesize the rendered images of each hair model with the rendered images of other models in the game scene and output them to the display window, completing the real-time rendering process of the hair and sky lighting.
[0072] In the aforementioned real-time rendering method for game hair lighting, a reflection probe sampling ray is emitted upwards to obtain the radiance of the reflection probe and complete the indoor / outdoor label setting. Then, sky spherical harmonic sampling is performed using the normal reflection direction as an index, and the lighting data is corrected by combining the indoor / outdoor labels and radiance. This method can achieve adaptive calibration of sky spherical harmonic sampling data with environmental conditions, improve the numerical rationality of sky spherical harmonic sampling data under different environments, and avoid rendering errors such as overly bright hair and light leakage caused by abnormally high sky spherical harmonic sampling data in indoor enclosed scenes. By sampling environmental reflections using the normal reflection direction as an index, and combining the corrected sky spherical harmonic sampling data, the brightness of environmental reflection sampling data is corrected. Then, based on the global sky light average brightness, the exposure correction of the two sets of sampling data is completed synchronously. This method can completely restore the reflected lighting information of the hair model, supplement the basic lighting intensity of the inner layer and hair root position of the hair model cluster, and establish the lighting intensity of the inner and outer layers of the hair. A smooth transition system avoids completely black areas at the bottom of hair strands and a lack of tonal gradation, improving the stability and realism of hair rendering. By correcting brightness based on the average double scattering energy value, it can extract global illumination scattering energy information of the hair model cluster, uncover the global occlusion level data of the hair model cluster hidden in the double scattering energy, restore the natural tonal gradation of the hair material, preserve the fluffy and soft texture of the hair fiber cluster, and enhance the physical realism of the hair material. By acquiring four-dimensional ambient color sampling data, fitting and generating an ambient color curve fitting function and mechanical energy hue repair, it can cover the ambient color information of the entire horizontal space where the hair model is located, avoiding hue jumps, color banding, and color distortion, improving the consistency of the hue performance of the hair rendering with the scene's ambient color, and allowing the hair skylight rendering to remain stable under complex conditions such as indoor and outdoor scene switching and extreme lighting intensity, improving the realism, stability, and environmental adaptability of the game's hair skylight rendering.
[0073] In an optional embodiment of this application, please refer to Figure 1 and Figure 2 Step S101: Starting from the world space position of the hair model, emit a reflection probe sampling ray directly upwards to obtain the reflection probe radiance corresponding to the world space position above. Based on the reflection probe radiance, set indoor and outdoor labels for the hair model, which may include:
[0074] Step S201: Obtain the world space position of the root node of the hair model, and launch a reflection probe sampling ray directly upward from the world space position of the hair model. Based on the reflection probe spatial index structure, query all reflection probes within the range directly above the world space position to generate a candidate reflection probe list.
[0075] Specifically, the rendering terminal can use the world space location of the hair model as the fixed emission origin of the reflection probe sampling ray, generating a reflection probe sampling ray with a clear direction and detection range along the direction directly above the game world coordinate system. The rendering terminal can configure ray detection distance parameters for the reflection probe sampling ray to avoid missing effective reflection probes due to insufficient ray detection distance. The rendering terminal can set a collision detection level for the reflection probe sampling ray, including all spatial data nodes corresponding to all reflection probes in the scene within the detection object range of this collision detection level, excluding interference from non-target detection objects such as static models, dynamic characters, scene decorations, and terrain features, thus improving the detection accuracy and effectiveness of the reflection probe sampling ray. After the game scene is loaded, the rendering terminal can pre-organize all configured reflection probes in the scene spatially, constructing a reflection probe spatial index structure. The reflection probe spatial index structure is an index system that stores reflection probes in the scene using a three-dimensional spatial mesh partitioning, enabling rapid location of all reflection probes within a specified spatial area, significantly improving the query efficiency of reflection probes. The rendering terminal can calculate the sweep area of the reflection probe sampling ray in 3D world space based on the origin coordinates of the ray's emission point and the direction directly above the ray. The rendering terminal can traverse all spatial mesh cells within the reflection probe's spatial index structure to filter out all reflection probes completely within the sweep area of the reflection probe sampling ray. The rendering terminal can then aggregate all filtered reflection probes that meet the spatial location requirements to generate a candidate reflection probe list.
[0076] Furthermore, the rendering terminal can perform layer-by-layer validity checks on the reflection probes in the candidate reflection probe list, eliminating abnormal reflection probes that are inactive, whose sampling data has not been baked and updated, or whose spatial coordinates exceed the detection distance of the reflection probe sampling ray. This ensures that all reflection probes in the candidate reflection probe list are compliant reflection probes that can provide valid sampling data, laying a stable foundation for the subsequent acquisition of reflection probe radiance.
[0077] Step S202: If the number of reflective probes in the candidate reflective probe list is one, obtain the reflective probe radiance of the reflective probe in the candidate reflective probe list.
[0078] Step S203: If there are multiple reflection probes in the candidate reflection probe list, obtain the fixed configuration weight and the reflection probe sampling ray distance of each reflection probe in the candidate reflection probe list, calculate the comprehensive weight of each reflection probe based on the fixed configuration weight and the reflection probe sampling ray distance, and obtain the reflection probe radiance of the reflection probe with the highest comprehensive weight in the candidate reflection probe list.
[0079] Optionally, the distance of the reflected probe sampling ray is used to characterize the distance between the reflected probe and the reflected probe sampling ray.
[0080] For example, the overall weight can be calculated by weighting the inverse of the distance of the ray sampled by the reflection probe and the fixed configuration weight.
[0081] To illustrate, when the distance of the sampled ray from the reflective probe is used as the denominator to calculate the overall weight, a fixed positive real number can be added to the distance of the sampled ray from the reflective probe to prevent the denominator from being zero.
[0082] Step S204: Obtain the average brightness of the skylight and the corresponding outdoor reference threshold reduction factor. Based on the average brightness of the skylight and the outdoor reference threshold reduction factor, calculate the outdoor reference threshold and set the indoor and outdoor labels of the hair model based on the reflective probe radiance and the outdoor reference threshold.
[0083] For example, the outdoor reference threshold can be calculated by multiplying the average skylight brightness and the outdoor reference threshold reduction factor. The rendering terminal can set the range of values for the outdoor reference threshold reduction factor based on the global scene type. After setting the range of values for the outdoor reference threshold reduction factor, the rendering terminal can obtain the outdoor reference threshold reduction factor based on the average skylight brightness mapping. The global scene type can include, but is not limited to, sunny, cloudy, partly cloudy, dusk, dawn, noon, night, bright light, weak light, and moonlight.
[0084] For example, if the radiance of the reflection probe is greater than the outdoor reference threshold, the rendering terminal can set the indoor / outdoor label of the hair model to the outdoor label. If the radiance of the reflection probe is less than the outdoor reference threshold, the rendering terminal can set the indoor / outdoor label of the hair model to the indoor label.
[0085] In an optional embodiment of this application, the indoor and outdoor tags may include indoor tags and outdoor tags. Illumination data correction is performed on the original sky spherical harmonic sampling data based on the indoor and outdoor tags and the radiance of the reflective probe to obtain corrected sky spherical harmonic sampling data. This correction may include:
[0086] Specifically, if the indoor and outdoor labels are indoor labels, the rendering terminal can calculate the shading attenuation coefficient based on the radiance of the reflection probe and the average brightness of the skylight, and then perform brightness attenuation on the original sky spherical harmonic sampling data based on the shading attenuation coefficient to obtain the corrected sky spherical harmonic sampling data.
[0087] For example, the rendering terminal can calculate the occlusion attenuation coefficient based on the radiance of the reflection probe divided by the average brightness of the skylight.
[0088] Specifically, if the indoor and outdoor labels are outdoor labels, the rendering terminal can perform brightness consistency calibration on the original sky spherical harmonic sampling data based on the radiance of the reflection probe to obtain corrected sky spherical harmonic sampling data.
[0089] In an optional embodiment of this application, environmental reflection sampling calculations are performed on the reflection probe using the normal reflection direction of the hair model as an index to obtain environmental reflection sampling data. Then, brightness correction is applied to the environmental reflection sampling data based on corrected sky spherical harmonic sampling data to obtain corrected environmental reflection sampling data. This may include:
[0090] Specifically, the rendering terminal can use the normal reflection direction of each hair fragment of the hair model as an index, and perform environmental reflection sampling calculation based on the reflection probe to obtain the environmental reflection sampling data of each hair fragment.
[0091] Specifically, the rendering terminal can obtain the layer depth of each hair fragment and set the layer depth weight coefficient of each hair fragment based on the layer depth.
[0092] Optionally, the layer depth can be used to characterize the relative position of a fragment from the outer to the inner layer of a hair cluster, and from the tip to the root. The rendering terminal can obtain the layer depth of each hair fragment through the pre-baked vertex color data of the hair model. During the art production stage of the hair model, the layer depth information of the hair model can be pre-baked into the alpha channel of the vertex color. The rendering terminal can read the vertex color alpha channel data of each vertex of the hair model during the vertex shader stage, and in the rasterization stage, perform linear smooth interpolation on the layer depth values of the three vertices within the triangle to generate a layer depth value for each hair fragment within the triangle. The rendering terminal can calculate the layer depth weight coefficient corresponding to each hair fragment based on the layer depth weight coefficient calculation formula and the layer depth value of each hair fragment.
[0093] Specifically, the rendering terminal can perform brightness correction on the environmental reflection sampling data of each hair fragment based on the layer depth weight coefficient of each hair fragment and the corrected sky sphere harmonic sampling data of each hair fragment, so as to obtain the corrected environmental reflection sampling data of each hair fragment.
[0094] In an optional embodiment of this application, please refer to Figure 1 and Figure 2 Step S106 involves obtaining the average double scattering energy value of the hair model, and performing brightness correction on the double-corrected sky harmonic sampling data and double-corrected environmental reflection sampling data based on the average double scattering energy value to obtain triple-corrected sky harmonic sampling data and triple-corrected environmental reflection sampling data. This may include:
[0095] Step S208: Render the double scattering energy map of the hair model from the original resolution to the texture rendering, and then downsample the double scattering energy map from the original resolution to the texture rendering to obtain the average double scattering energy value.
[0096] Step S209: Convert the double-corrected sky sphere harmonic sampling data and the double-corrected ambient reflection sampling data to the luminance-color difference space to obtain luminance-color difference double sky sphere harmonic sampling data and luminance-color difference double ambient reflection sampling data.
[0097] Step S210: Based on the average double scattering energy value, perform brightness correction on the brightness channels of the brightness-color difference dual sky sphere harmonic sampling data and the brightness-color difference dual environmental reflection sampling data to obtain triple-corrected sky sphere harmonic sampling data and triple-corrected environmental reflection sampling data.
[0098] In an optional embodiment of this application, four reflection probe sampling rays are emitted forward, backward, left, and right from the starting point of the world spatial location to acquire four-directional ambient color sampling data. An ambient color curve fitting function is obtained based on the four-directional ambient color sampling data. Hue restoration is then performed on the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data based on the ambient color curve fitting function to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data. This may include:
[0099] Specifically, the rendering terminal can use the world space position of the hair model as the starting point and emit four reflection probe sampling rays in four horizontally orthogonal directions (front, back, left, and right) to obtain four-directional ambient color sampling data obtained from the sampling of the four reflection probe sampling rays emitted in the four horizontally orthogonal directions.
[0100] Specifically, the rendering terminal can obtain an ambient color curve fitting function based on the four-way ambient color sampling data, calculate the ambient color reference data in each horizontal direction based on the ambient color curve fitting function, and convert the ambient color reference data to the luminance difference space to obtain the ambient hue reference data in each horizontal direction.
[0101] Specifically, the rendering terminal can perform hue restoration on the chromaticity channels of the triple-corrected sky sphere harmonic sampling data and the triple-corrected environmental reflection sampling data in each horizontal direction based on the environmental hue reference data in each horizontal direction of normal reflection, to obtain the luminance difference quadruple-corrected sky sphere harmonic sampling data and the luminance difference quadruple-corrected environmental reflection sampling data.
[0102] Optionally, the rendering terminal can perform weighted fusion hue restoration on the chroma channels of the triple-corrected sky spherical harmonic sampling data and the triple-corrected environmental reflection sampling data based on the environmental hue reference data corresponding to the horizontal direction of each normal reflection of each hair fragment. While preserving the original hue information of the sampling data, the hue deviation is calibrated through the environmental hue reference data to eliminate problems such as color cast and hue jump. The rendering terminal can merge the restored chroma channel data with the original lightness channel data to obtain the light color difference quadruple-corrected sky spherical harmonic sampling data and the light color difference quadruple-corrected environmental reflection sampling data, respectively.
[0103] Specifically, the rendering terminal can convert the luminance-color difference quadruple-corrected sky sphere harmonic sampling data and the luminance-color difference quadruple-corrected environmental reflection sampling data into the red-green-blue color space to obtain quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected environmental reflection sampling data.
[0104] In an optional embodiment of this application, the rendering terminal may set the horizontal angle of the forward ambient color sampling data to 0, and the rendering terminal may set the horizontal angle of the right ambient color sampling data to... The rendering terminal can set the horizontal angle of the back ambient color sampling data to 1. The rendering terminal can set the horizontal angle of the left-side ambient color sampling data to... At this point, the expression for the ambient color curve fitting function can be set as follows:
[0105]
[0106]
[0107]
[0108]
[0109]
[0110] In the formula, This is the function for fitting the ambient color curve. This is the horizontal angle corresponding to the horizontal direction. , , and These are the average ambient color coefficient, the front-to-back color difference coefficient, the left-to-right color difference coefficient, and the diagonal color interaction coefficient, respectively. , , and These are the forward ambient color sampling data, right ambient color sampling data, backward ambient color sampling data, and left ambient color sampling data from the four-way ambient color sampling data.
[0111] Schematic representation of average ambient color coefficient It can be the arithmetic mean of the four-directional ambient color sampling data, which can be used to characterize the global baseline ambient color of the scene; the color difference coefficient in the forward and backward directions. Forward ambient color sampling data With back ambient color sampling data Half of the difference can be used to characterize the ambient color difference along the horizontal front and rear axes; the color difference coefficient in the left and right directions... It can be used for right-side ambient color sampling data Compared with left-side ambient color sampling data Half of the difference can be used to characterize the ambient color difference along the horizontal left and right axes; the color interaction coefficient in the diagonal direction... Forward ambient color sampling data With back ambient color sampling data The sum, minus the right-side ambient color sampling data Compared with left-side ambient color sampling data The sum, then take one-quarter of it, as the color interaction coefficient in the diagonal direction. It can be used to characterize the ambient color interaction and smooth transition characteristics in the four diagonal directions.
[0112] In one exemplary embodiment of this application, such as Figure 2 As shown, a real-time rendering method for the lighting of hair strands in a game is provided, including:
[0113] Step S201: Obtain the world space position of the root node of the hair model, and launch a reflection probe sampling ray directly upward from the world space position of the hair model. Based on the reflection probe spatial index structure, query all reflection probes within the range directly above the world space position to generate a candidate reflection probe list.
[0114] Step S202: If the number of reflective probes in the candidate reflective probe list is one, obtain the reflective probe radiance of the reflective probe in the candidate reflective probe list.
[0115] Step S203: If there are multiple reflection probes in the candidate reflection probe list, obtain the fixed configuration weight and the reflection probe sampling ray distance of each reflection probe in the candidate reflection probe list, calculate the comprehensive weight of each reflection probe based on the fixed configuration weight and the reflection probe sampling ray distance, and obtain the reflection probe radiance of the reflection probe with the highest comprehensive weight in the candidate reflection probe list.
[0116] Step S204: Obtain the average brightness of the skylight and the corresponding outdoor reference threshold reduction factor. Based on the average brightness of the skylight and the outdoor reference threshold reduction factor, calculate the outdoor reference threshold and set the indoor and outdoor labels of the hair model based on the reflective probe radiance and the outdoor reference threshold.
[0117] Step S205: Using the normal reflection direction of the hair model as an index, sky illumination sampling calculation is performed based on the sky sphere harmonic function coefficients to obtain the original sky sphere harmonic sampling data. Then, the original sky sphere harmonic sampling data is corrected based on the radiance of indoor and outdoor labels and reflective probes to obtain the corrected sky sphere harmonic sampling data.
[0118] Step S206: Using the normal reflection direction of the hair model as an index, perform environmental reflection sampling calculation on the reflection probe to obtain environmental reflection sampling data, and perform brightness correction on the environmental reflection sampling data based on the corrected sky spherical harmonic sampling data to obtain corrected environmental reflection sampling data.
[0119] Step S207: Obtain the average brightness of the skylight, and perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the skylight to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data.
[0120] Step S208: Render the double scattering energy map of the hair model from the original resolution to the texture rendering, and then downsample the double scattering energy map from the original resolution to the texture rendering to obtain the average double scattering energy value.
[0121] Step S209: Convert the double-corrected sky sphere harmonic sampling data and the double-corrected ambient reflection sampling data to the luminance-color difference space to obtain luminance-color difference double sky sphere harmonic sampling data and luminance-color difference double ambient reflection sampling data.
[0122] Step S210: Based on the average double scattering energy value, perform brightness correction on the brightness channels of the brightness-color difference dual sky sphere harmonic sampling data and the brightness-color difference dual environmental reflection sampling data to obtain triple-corrected sky sphere harmonic sampling data and triple-corrected environmental reflection sampling data.
[0123] Step S211: Starting from the world spatial location, four reflection probe sampling rays are emitted in the forward, backward, left, and right directions to obtain four-directional ambient color sampling data. An ambient color curve fitting function is obtained based on the four-directional ambient color sampling data. The hue of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data are then restored based on the ambient color curve fitting function to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0124] Step S212: Render the hair model based on the quadruple-corrected sky spherical harmonic sampling data and the quadruple-corrected environmental reflection sampling data.
[0125] In the aforementioned real-time rendering method for skylight on game hair strands, the indoor and outdoor environmental conditions of the hair model are determined, sky lighting sampling is performed, and the original sky spherical harmonic sampling data is corrected by combining indoor and outdoor labels and reflection probe radiance. This can eliminate the light leakage problem caused by abnormally bright sky spherical harmonic sampling data in indoor environments. Environmental reflection sampling is performed on the reflection probe, and brightness correction is completed by correcting the sky spherical harmonic sampling data. This can supplement the light intensity of the inner layer of the hair and the hair root to solve the problem of the hair bottom being too dark. Exposure correction is performed on the two sets of corrected data based on the average skylight brightness, which can adapt the sampled data to the global skylight brightness changes in the scene to avoid rendering errors. Overexposed or underexposed hair is addressed by rendering to a texture and generating an average double scattering energy map through multi-level downsampling. The double-corrected data is then converted to a light-color difference space to complete the brightness correction, which improves the brightness accuracy of the sampled data and restores the natural light and dark levels of the hair strands. By acquiring four-way ambient color sampling data and fitting an ambient color curve fitting function, hue repair is performed, which eliminates hue errors and color jumps caused by discrete sampling. Based on the two sets of sampled data after quadruple correction, the hair strand model is rendered, which can achieve stable and realistic hair and skylight rendering effects under various scenes and lighting conditions, while meeting the performance requirements of real-time game rendering.
[0126] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0127] Based on the same inventive concept, this application also provides a real-time rendering system for game hair and sky lighting to implement the aforementioned real-time rendering method for game hair and sky lighting. The solution provided by this system is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of a real-time rendering system for game hair and sky lighting provided below can be found in the limitations of the real-time rendering method for game hair and sky lighting described above, and will not be repeated here.
[0128] In one exemplary embodiment, such as Figure 3 As shown, a real-time rendering system 300 for game hair and sky lighting is provided, including:
[0129] The indoor / outdoor label determination module 301 can be used to emit a reflection probe sampling ray directly upward from the world space position of the hair model, obtain the reflection probe radiance of the reflection probe above the world space position, and set the indoor / outdoor label of the hair model based on the reflection probe radiance.
[0130] The sky sphere harmonic sampling correction module 302 can be used to calculate the sky illumination based on the sky sphere harmonic function coefficients, using the normal reflection direction of the hair model as an index, to obtain the original sky sphere harmonic sampling data. Then, it corrects the original sky sphere harmonic sampling data based on the radiance of indoor and outdoor labels and reflective probes to obtain the corrected sky sphere harmonic sampling data.
[0131] The environmental reflection sampling correction module 303 can be used to perform environmental reflection sampling calculations on the reflection probe using the normal reflection direction of the hair model as an index, to obtain environmental reflection sampling data, and to perform brightness correction on the environmental reflection sampling data based on the corrected sky sphere harmonic sampling data, to obtain corrected environmental reflection sampling data.
[0132] The average brightness exposure correction module 304 can be used to obtain the average brightness of the skylight, and perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the skylight, so as to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data.
[0133] The sampling data brightness correction module 305 can be used to obtain the average double scattering energy value of the hair model, and perform brightness correction on the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value, to obtain triple-corrected sky spherical harmonic sampling data and triple-corrected environmental reflection sampling data.
[0134] The sampling data hue correction module 306 can be used to emit four reflection probe sampling rays forward, backward, left, and right from the world spatial location to obtain four-directional ambient color sampling data. The four-directional ambient color sampling data is input into the ambient color curve fitting function to generate ambient color reference data. Based on the ambient color reference data, the hue of the triple-corrected sky sphere harmonic sampling data and triple-corrected ambient reflection sampling data is restored to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data.
[0135] The real-time rendering module 307 for hair models can be used to render hair models based on quadruple-corrected sky spherical harmonic sampling data and quadruple-corrected environmental reflection sampling data.
[0136] In an optional embodiment of this application, the indoor / outdoor label determination module 301 can also be used for:
[0137] Obtain the world space position of the root node of the hair model, and emit a reflection probe sampling ray directly upward from the world space position of the hair model. Based on the reflection probe spatial index structure, query all reflection probes within the range directly above the world space position to generate a candidate reflection probe list.
[0138] If the candidate reflective probe list contains only one reflective probe, obtain the reflective probe radiance of that probe. If the candidate reflective probe list contains multiple reflective probes, obtain the fixed configuration weight and the reflective probe sampling ray distance for each reflective probe. Calculate the comprehensive weight of each reflective probe based on these weights and ray distances, and obtain the reflective probe radiance of the reflective probe with the highest comprehensive weight. The reflective probe sampling ray distance characterizes the distance between reflective probes and their sampling rays.
[0139] Obtain the average skylight brightness and the corresponding outdoor reference threshold reduction factor. Based on the average skylight brightness and the outdoor reference threshold reduction factor, calculate the outdoor reference threshold. Then, set the indoor and outdoor labels for the hair model based on the reflective probe radiance and the outdoor reference threshold.
[0140] In an optional embodiment of this application, the sky sphere harmonic sampling correction module 302 can also be used for:
[0141] If the indoor and outdoor labels are indoor labels, the shading attenuation coefficient is calculated based on the radiance of the reflected probe and the average brightness of the skylight. The original sky spherical harmonic sampling data is then attenuated based on the shading attenuation coefficient to obtain the corrected sky spherical harmonic sampling data.
[0142] If the indoor / outdoor label is an outdoor label, the original sky spherical harmonic sampling data is calibrated for brightness consistency based on the radiance of the reflective probe to obtain corrected sky spherical harmonic sampling data.
[0143] In an optional embodiment of this application, the environmental reflection sampling correction module 303 can also be used for:
[0144] Using the normal reflection direction of each hair element in the hair model as an index, environmental reflection sampling calculation is performed based on the reflection probe to obtain the environmental reflection sampling data of each hair element.
[0145] Obtain the layer depth of each hair fragment, and set the layer depth weight coefficient of each hair fragment based on the layer depth.
[0146] The brightness of the environmental reflection sampling data of each hair fractal is corrected based on the hierarchical depth weight coefficient of each hair fractal and the corrected sky sphere harmonic sampling data of each hair fractal, thus obtaining the corrected environmental reflection sampling data of each hair fractal.
[0147] In an optional embodiment of this application, the sampling data brightness correction module 305 can also be used for:
[0148] The double scattering energy map of the hair model is rendered from the original resolution to the texture rendering, and then the double scattering energy map is downsampled at multiple levels from the original resolution to the texture rendering to obtain the average double scattering energy value.
[0149] The double-corrected sky sphere harmonic sampling data and the double-corrected ambient reflection sampling data are converted to the luminance-color difference space to obtain luminance-color difference double sky sphere harmonic sampling data and luminance-color difference double ambient reflection sampling data.
[0150] Luminance correction is performed on the luminance channels of the luminance-color difference dual sky harmonic sampling data and the luminance-color difference dual environmental reflection sampling data based on the average double scattering energy value, resulting in triple-corrected sky harmonic sampling data and triple-corrected environmental reflection sampling data.
[0151] In an optional embodiment of this application, the sampling data hue correction module 306 can also be used for:
[0152] Starting from the world space position of the hair model, four reflective probe sampling rays are emitted in four horizontally orthogonal directions (front, back, left, and right) to obtain four-directional ambient color sampling data.
[0153] An ambient color curve fitting function is obtained by fitting the four-way ambient color sampling data. Ambient color reference data in each horizontal direction is calculated based on the ambient color curve fitting function. The ambient color reference data is then converted to the luminance difference space to obtain ambient hue reference data in each horizontal direction.
[0154] Based on the ambient hue reference data of each normal reflection horizontal direction, the hue of the chromaticity channels of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data of each horizontal direction are restored to obtain the luminance difference quadruple-corrected sky sphere harmonic sampling data and the luminance difference quadruple-corrected ambient reflection sampling data.
[0155] The luminance-color difference quadruple-corrected sky sphere harmonic sampling data and the luminance-color difference quadruple-corrected environmental reflection sampling data are converted into the red-green-blue color space to obtain quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected environmental reflection sampling data.
[0156] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of a real-time rendering method for game hair and sky lighting as described above.
[0157] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0158] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The components described as separate parts may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0159] The above-described embodiments are merely illustrative of several implementation methods of the embodiments of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the embodiments of this application, and these modifications and improvements all fall within the protection scope of the embodiments of this application.
Claims
1. A real-time rendering method for hair and sky lighting in games, characterized in that, The method includes: Starting from the world space position of the hair model, a reflection probe sampling ray is emitted directly upwards to obtain the reflection probe radiance of the reflection probe above the world space position, and indoor and outdoor labels of the hair model are set based on the reflection probe radiance. Using the normal reflection direction of the hair model as an index, sky illumination sampling calculation is performed based on the sky spherical harmonic function coefficients to obtain original sky spherical harmonic sampling data. Then, the original sky spherical harmonic sampling data is corrected for illumination data based on the radiance of the indoor and outdoor labels and the reflective probe to obtain corrected sky spherical harmonic sampling data. Using the normal reflection direction of the hair model as an index, environmental reflection sampling calculation is performed on the reflection probe to obtain environmental reflection sampling data. Based on the corrected sky spherical harmonic sampling data, brightness correction is performed on the environmental reflection sampling data to obtain corrected environmental reflection sampling data. The average brightness of the sky light is obtained, and the exposure is corrected based on the average brightness of the sky light on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data. The average double scattering energy value of the hair model is obtained, and the brightness of the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data is corrected based on the average double scattering energy value to obtain triple-corrected sky spherical harmonic sampling data and triple-corrected environmental reflection sampling data. Starting from the world spatial location, four reflection probe sampling rays are emitted in the forward, backward, left, and right directions to obtain four-directional ambient color sampling data. An ambient color curve fitting function is obtained based on the four-directional ambient color sampling data, and hue restoration is performed on the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data based on the ambient color curve fitting function to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data. The hair model is rendered based on the quadruple-corrected sky spherical harmonic sampling data and the quadruple-corrected environmental reflection sampling data.
2. The method of claim 1, wherein, Starting from the world spatial location of the hair model, a reflective probe sampling ray is emitted directly upwards to obtain the reflective probe radiance corresponding to the world spatial location above. Based on the reflective probe radiance, indoor and outdoor labels are set for the hair model, including: Obtain the world space position of the root node of the hair model, and take the world space position of the hair model as the starting point to emit the reflection probe sampling ray directly upward. Based on the reflection probe spatial index structure, query all the reflection probes within the range directly above the world space position to generate a candidate reflection probe list. If the number of reflection probes in the candidate reflection probe list is one, obtain the radiance of the reflection probe in the candidate reflection probe list; If there are multiple reflection probes in the candidate reflection probe list, obtain the fixed configuration weight and the reflection probe sampling ray distance of each reflection probe in the candidate reflection probe list. Calculate the comprehensive weight of each reflection probe based on the fixed configuration weight and the reflection probe sampling ray distance, and obtain the reflection probe radiance of the reflection probe with the highest comprehensive weight in the candidate reflection probe list; wherein, the reflection probe sampling ray distance is used to characterize the distance between the reflection probe and the reflection probe sampling ray. Obtain the average brightness of the skylight and the corresponding outdoor reference threshold reduction factor. Calculate the outdoor reference threshold based on the average brightness of the skylight and the outdoor reference threshold reduction factor. Set the indoor and outdoor labels of the hair model based on the radiance of the reflective probe and the outdoor reference threshold.
3. The method of claim 1, wherein, The indoor and outdoor labels include indoor labels and outdoor labels. The step of correcting the original sky spherical harmonic sampling data based on the indoor and outdoor labels and the radiance of the reflective probe to obtain corrected sky spherical harmonic sampling data includes: If the indoor / outdoor label is the indoor label, the shading attenuation coefficient is calculated based on the radiance of the reflected probe and the average brightness of the skylight, and the brightness of the original sky spherical harmonic sampling data is attenuated based on the shading attenuation coefficient to obtain the corrected sky spherical harmonic sampling data; If the indoor / outdoor label is the outdoor label, the original sky spherical harmonic sampling data is calibrated for brightness consistency based on the radiance of the reflected probe to obtain the corrected sky spherical harmonic sampling data.
4. The method of claim 1, wherein, The process of performing environmental reflection sampling calculations on the reflection probe using the normal reflection direction of the hair model as an index to obtain environmental reflection sampling data, and then performing brightness correction on the environmental reflection sampling data based on the corrected sky spherical harmonic sampling data to obtain corrected environmental reflection sampling data, includes: Using the normal reflection direction of each hair element of the hair model as an index, environmental reflection sampling calculation is performed based on the reflection probe to obtain the environmental reflection sampling data of each hair element; Obtain the layer depth of each hair strand element, and set the layer depth weight coefficient of each hair strand element based on the layer depth; The brightness of the environmental reflection sampling data of each hair element is corrected based on the layer depth weight coefficient of each hair element and the corrected sky sphere harmonic sampling data of each hair element, so as to obtain the corrected environmental reflection sampling data of each hair element.
5. The method according to claim 1, characterized in that, The process of obtaining the average double scattering energy value of the hair model, and performing brightness correction on the double-corrected sky harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value to obtain triple-corrected sky harmonic sampling data and triple-corrected environmental reflection sampling data includes: The hair model is rendered from its original resolution to a texture, and the double scattering energy map of the hair model is rendered from the original resolution to the texture. The double scattering energy map is then downsampled at multiple levels from the original resolution to the texture to obtain the average double scattering energy value. The double-corrected sky sphere harmonic sampling data and the double-corrected environmental reflection sampling data are converted to luminance-color difference space to obtain luminance-color difference double sky sphere harmonic sampling data and luminance-color difference double environmental reflection sampling data; The brightness channels of the luminance channels of the luminance-color difference dual sky harmonic sampling data and the luminance-color difference dual environmental reflection sampling data are corrected based on the average double scattering energy value to obtain the triple-corrected sky harmonic sampling data and the triple-corrected environmental reflection sampling data.
6. The method according to claim 5, characterized in that, Starting from the stated world spatial location, four reflection probe sampling rays are emitted forward, backward, left, and right to acquire four-directional ambient color sampling data. An ambient color curve fitting function is obtained based on the four-directional ambient color sampling data. Then, based on the ambient color curve fitting function, hue restoration is performed on the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data, including: Starting from the world space position of the hair model, four reflection probe sampling rays are emitted in four horizontally orthogonal directions (front, back, left, and right) to obtain the four-directional ambient color sampling data obtained by sampling the four reflection probe sampling rays emitted in the four horizontally orthogonal directions (front, back, left, and right). The ambient color curve fitting function is obtained by fitting the four-way ambient color sampling data. The ambient color reference data of each horizontal direction is calculated based on the ambient color curve fitting function. The ambient color reference data is then converted to the luminance difference space to obtain the ambient hue reference data of each horizontal direction. Based on the ambient hue reference data of each normal reflection horizontal direction, the hue of the triple-corrected sky sphere harmonic sampling data of each normal reflection horizontal direction and the triple-corrected ambient reflection sampling data of each horizontal direction are restored to obtain the luminance difference quadruple-corrected sky sphere harmonic sampling data and the luminance difference quadruple-corrected ambient reflection sampling data. The luminance-color difference quadruple-corrected sky sphere harmonic sampling data and the luminance-color difference quadruple-corrected environmental reflection sampling data are converted to the red-green-blue color space to obtain the quadruple-corrected sky sphere harmonic sampling data and the quadruple-corrected environmental reflection sampling data.
7. The method according to claim 6, characterized in that, The expression for the ambient color curve fitting function is: In the formula, The function is the fitting function for the ambient color curve. The horizontal angle corresponding to the horizontal direction. , , and These are the average ambient color coefficient, the front-to-back color difference coefficient, the left-to-right color difference coefficient, and the diagonal color interaction coefficient, respectively. , , and These are the forward ambient color sampling data, right ambient color sampling data, backward ambient color sampling data, and left ambient color sampling data, respectively, in the four-directional ambient color sampling data.
8. A real-time rendering system for hair and sky lighting in games, characterized in that, The system includes: The indoor / outdoor label determination module is used to emit a reflection probe sampling ray directly upward from the world space position of the hair model, obtain the reflection probe radiance of the reflection probe above the world space position, and set the indoor / outdoor label of the hair model based on the reflection probe radiance. The sky spherical harmonic sampling correction module is used to calculate the sky illumination sampling based on the sky spherical harmonic function coefficients, using the normal reflection direction of the hair model as an index, to obtain the original sky spherical harmonic sampling data. The original sky spherical harmonic sampling data is then corrected based on the radiance of the indoor and outdoor labels and the reflective probe to obtain the corrected sky spherical harmonic sampling data. An environmental reflection sampling correction module is used to perform environmental reflection sampling calculations on the reflection probe using the normal reflection direction of the hair model as an index to obtain environmental reflection sampling data, and to perform brightness correction on the environmental reflection sampling data based on the corrected sky spherical harmonic sampling data to obtain corrected environmental reflection sampling data. An average brightness exposure correction module is used to obtain the average brightness of the skylight, and to perform exposure correction on the corrected sky spherical harmonic sampling data and the corrected environmental reflection sampling data based on the average brightness of the skylight, so as to obtain double-corrected sky spherical harmonic sampling data and double-corrected environmental reflection sampling data. The sampling data brightness correction module is used to obtain the average double scattering energy value of the hair model, and to perform brightness correction on the double-corrected sky spherical harmonic sampling data and the double-corrected environmental reflection sampling data based on the average double scattering energy value, so as to obtain triple-corrected sky spherical harmonic sampling data and triple-corrected environmental reflection sampling data. The sampling data hue correction module is used to emit four reflection probe sampling rays forward, backward, left, and right from the world spatial location as the starting point to obtain four-directional ambient color sampling data. The four-directional ambient color sampling data is input into the ambient color curve fitting function to generate ambient color reference data. Based on the ambient color reference data, the hue of the triple-corrected sky sphere harmonic sampling data and the triple-corrected ambient reflection sampling data is corrected to generate quadruple-corrected sky sphere harmonic sampling data and quadruple-corrected ambient reflection sampling data. The real-time rendering module for the hair model is used to render the hair model based on the quadruple-corrected sky spherical harmonic sampling data and the quadruple-corrected environmental reflection sampling data.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.