Lighting rendering method and system for animation scene picture

CN123015768APending Publication Date: 2026-10-30SHENZHEN MENGXIANG CULTURE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611059161.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-16
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]现有的实时渲染技术在有限计算时间内对三维场景、二维图像元素、材质属性、光照信息、相机视角、屏幕像素结果进行即时计算和显示时,常规运行重点偏向画面快速成像和基础明暗呈现,像素边缘处理容易围绕屏幕空间差异、固定采样半径、统一颜色输出展开,三维表面曲率、屏幕空间深度、辐射度亮度数值、反照率色彩参量之间缺少连贯约束,导致动漫场景中同一角色在近景和远景之间出现线条粗细不协调,曲面转折位置和轮廓边界位置缺少可控层次;在光照强度变化明显的画面中,统一线宽容易造成受光区域描边过重,暗部区域描边又可能与背景混叠,影响角色轮廓辨识

Benefits of technology

本发明通过调用G-Buffer法线数据、屏幕空间深度数据并提取曲率变动参量,像素轮廓不再仅依赖屏幕边缘差异,而是能够按照三维表面弯折程度形成线宽变化基础,曲率变动参量再结合屏幕空间深度数据进行透视衰减运算,能够抑制远景轮廓过度扩张,增强近景角色边缘、物体转折区域、遮挡边界之间的线宽层次一致性;通过屏幕UV坐标参量叠加程序化高频噪声序列,并结合坐标位移计算周期扰动值,能够让描边采样偏移呈现细微变化,减少固定轮廓线在动漫画面中产生的机械感,像素微观震荡矩阵同线宽映射系数相乘后,扰动幅度受到曲率和深度共同约束,能够避免噪声扰动破坏主体轮廓稳定性;通过读取光照累积缓冲数据中的辐射度亮度数值,建立亮度负相关衰减乘数,并按像素位置坐标收束扰动轮廓线宽矩阵,能够在受光区域减少描边厚重感,在暗部区域保留轮廓识别度;通过光照方向参量、三维表面法线参量、反照率色彩参量、黑色基底像素参量之间的运算,能够让边缘色彩融合量随受光面材质色彩和光照朝向变化,生成兼具线宽控制、微观扰动、亮度收束、边缘色彩融合的光影描边图像数据,提升动漫场景实时画面的手绘质感。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015768A_ABST
    Figure CN123015768A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of real-time rendering, in particular to a light and shadow rendering method and system for an animation scene picture, comprising the following steps: calling G-Buffer normal data and screen space depth data in a rendering pipeline to obtain a curvature variation parameter; performing perspective attenuation operation on the curvature variation parameter by using the screen space depth data to establish a line width mapping coefficient.In the present application, the line width matrix of the perturbed contour line is bundled according to the pixel position coordinates, which can reduce the thick and heavy feeling of the line in the light receiving area and retain the contour recognition degree in the dark area; through the operation among the light direction parameter, the three-dimensional surface normal parameter, the albedo color parameter and the black base pixel parameter, the edge color fusion amount can be changed with the light receiving surface material color and the light direction, the light and shadow line drawing image data with line width control, microscopic disturbance, brightness convergence and edge color fusion is generated, and the hand-drawn quality of the real-time picture of the animation scene is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of real-time rendering technology, and in particular to a method and system for rendering light and shadow in animation scenes. Background Technology

[0002] Real-time rendering technology mainly involves the instant calculation and display of 3D scenes, 2D image elements, material properties, lighting information, camera viewpoints, and screen pixel results within a limited computing time.

[0003] Existing real-time rendering technologies, when performing instant calculations and displays of 3D scenes, 2D image elements, material properties, lighting information, camera perspective, and screen pixel results within a limited computation time, typically prioritize rapid image formation and basic brightness and darkness rendering. Pixel edge processing tends to revolve around screen space differences, fixed sampling radii, and uniform color output. There is a lack of consistent constraints between 3D surface curvature, screen space depth, radiance brightness values, and albedo color parameters. This results in inconsistent line thickness for the same character in animation scenes between foreground and background, and a lack of controllable levels at surface transitions and contour boundaries. In scenes with significant changes in lighting intensity, uniform line width can easily lead to overly heavy outlines in illuminated areas, while outlines in dark areas may blend with the background, affecting character silhouette recognition. Therefore, improvements are needed. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing technologies by proposing a method and system for rendering light and shadow in animation scenes.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: a method for rendering light and shadow in animation scenes, comprising the following steps: The curvature variation parameter is obtained by calling the G-Buffer normal data and screen space depth data in the rendering pipeline; the curvature variation parameter is then subjected to perspective attenuation calculation using the screen space depth data to establish the line width mapping coefficient. The screen UV coordinate parameters are extracted, and a programmed high-frequency noise sequence is retrieved according to a preset sampling frequency and superimposed on the screen UV coordinate parameters. The periodic perturbation value of the rendering sampling offset is calculated in combination with the coordinate displacement to obtain the pixel micro oscillation matrix. The pixel micro oscillation matrix is ​​multiplied with the line width mapping coefficient to obtain a fusion product term. The fusion product term is used to perform a mixing operation on the outline operator mesh in the pixel array to generate a perturbation contour line width matrix. The deferred rendering pipeline is invoked and the cumulative illumination buffer data is read. The radiance brightness values ​​in the cumulative illumination buffer data are extracted, and a brightness negative correlation attenuation multiplier is established. The brightness negative correlation attenuation multiplier and the perturbation contour linewidth matrix are calculated according to the pixel position coordinates to obtain the illumination convergence linewidth set. Extract the illumination direction parameter and the three-dimensional surface normal parameter to obtain the albedo feature of the illuminated surface; combine the albedo feature of the illuminated surface with the black base pixel parameter to calculate the edge color fusion amount; substitute the edge color fusion amount into the corresponding coordinate point of the illumination convergence line width set to generate light and shadow outline image data.

[0006] Preferably, the step of obtaining the linewidth mapping coefficient is as follows: The process involves calling the G-Buffer normal data and screen space depth data in the rendering pipeline, reading the 3D normal components from the G-Buffer normal data according to the pixel position, retaining the depth value of the same pixel position in the screen space depth data, inputting the 3D normal components into the fragment shader partial derivative instruction, calculating the screen horizontal normal difference and the screen vertical normal difference respectively, and merging and measuring the screen horizontal normal difference and the screen vertical normal difference to obtain the normal variation rate. Based on the normal variation rate, the distribution of normal variation rate of adjacent pixels is retrieved according to the pixel position. The normal variation amplitude in different directions around the center pixel is statistically analyzed. Adjacent pixels whose normal variation amplitude does not satisfy the continuous variation relationship are filtered out. The local curvature of the three-dimensional surface corresponding to the center pixel is extracted. The local curvature of the three-dimensional surface is arranged according to the screen pixel position to obtain the curvature variation parameter. The depth values ​​of the same pixel position in the screen space depth data are called, and perspective attenuation is performed on the curvature variation parameter according to the depth values ​​to obtain the scaling value. The scaling value is input into the preset width-narrow mapping formula, and the sampling radius of the stroke operator is adjusted according to the scaling value so that the sampling radius changes accordingly with the curvature variation parameter and the depth value, thus establishing the line width mapping coefficient.

[0007] Preferably, the step of obtaining the pixel micro-oscillation matrix is ​​as follows: Extract the screen UV coordinate parameters, read the programmed high-frequency noise sequence according to the preset sampling frequency, and superimpose the perturbation sampling value in the programmed high-frequency noise sequence onto the screen UV coordinate parameters pixel by pixel. Record the coordinate displacement of the screen UV coordinate parameters in the horizontal and vertical coordinate directions, calculate the offset amplitude of the rendering sampling offset in different sampling periods based on the coordinate displacement, and form a pixel micro oscillation matrix.

[0008] Preferably, the step of obtaining the perturbation profile linewidth matrix is ​​as follows: The linewidth adjustment amount corresponding to the pixel position in the linewidth mapping coefficient is called, and the horizontal oscillation component and the vertical oscillation component in the pixel micro oscillation matrix are multiplied with the linewidth adjustment amount pixel by pixel. The product amplitude, product direction and sampling radius change relationship of each pixel position are retained to obtain the fusion product term. Based on the fusion product term, the position of the center pixel of the stroke operator grid within the pixel array is located. The distribution of the fusion product term of the adjacent pixels around the center pixel is read. The adjacent pixels are weighted and mixed according to the sampling arrangement order of the stroke operator grid. Isolated line width changes that do not satisfy the stroke continuity are filtered out, and line width changes that satisfy the contour direction consistency are retained to generate a perturbation contour line width matrix.

[0009] Preferably, the step of obtaining the brightness negative correlation attenuation multiplier is as follows: Call the deferred rendering pipeline, read the cumulative lighting buffer data in the deferred rendering pipeline, parse the radiance and brightness channels in the cumulative lighting buffer data according to the pixel position, extract the radiance and brightness value corresponding to each pixel position, exclude the radiance and brightness records that do not correspond to valid pixel positions, and obtain the radiance and brightness value. The radiance value of each pixel is input into the inverse exponential decay formula. The radiance value is then processed in reverse order of increasing value. The line width decay amplitude corresponding to each pixel is calculated. The correspondence between the line width decay amplitude and the pixel is retained, and a negative correlation decay multiplier for brightness is established.

[0010] Preferably, the step of obtaining the illumination convergence linewidth set is as follows: The contour linewidth values ​​at the same pixel position in the perturbation contour linewidth matrix are called, and the brightness negative correlation attenuation multiplier is multiplied point-to-point with the contour linewidth value according to the pixel position coordinate. Based on the multiplied linewidth value, the line width value at the corresponding pixel position is converged to obtain the illumination convergence linewidth set.

[0011] Preferably, the step of obtaining the albedo characteristics of the light-receiving surface is as follows: The illumination direction parameter and the 3D surface normal parameter are extracted. The illumination direction parameter and the 3D surface normal parameter are matched according to the pixel position. The dot product value of the illumination direction component and the normal direction component is calculated pixel by pixel. The dot product value is compared with the preset illumination threshold. For the pixel position where the dot product value is greater than the preset illumination threshold, the albedo color parameter of the corresponding pixel is read. The color distribution information and brightness response information in the albedo color parameter are retained to obtain the albedo characteristics of the illuminated surface.

[0012] Preferably, the step of acquiring the light and shadow outline image data is as follows: Read the color component of the pixel position corresponding to the light-receiving surface albedo feature, read the base color component of the pixel position corresponding to the black base pixel parameter, perform linear interpolation mixing operation according to the same pixel position, adjust the color participation ratio of the light-receiving surface albedo feature in the edge region item by item, adjust the color participation ratio of the black base pixel parameter in the edge region item by item, calculate the edge color transition result of each pixel position, and obtain the edge color fusion amount. Read the line width values ​​of each pixel position in the illumination convergence line width set, substitute the edge color fusion amount into the corresponding coordinate point of the illumination convergence line width set according to the pixel position coordinates, write the edge color fusion amount for the pixel position with line width value, and keep the original coordinate content unchanged for the pixel position without line width value, so as to complete the corresponding integration of line width distribution and edge color distribution and generate light and shadow outline image data.

[0013] The present invention also provides a system comprising: The curvature linewidth mapping module is used to call the G-Buffer normal data and screen space depth data in the rendering pipeline to obtain the curvature variation parameter, and use the screen space depth data to perform perspective attenuation calculation on the curvature variation parameter to establish the linewidth mapping coefficient. The perturbation contour generation module is used to extract the screen UV coordinate parameters, retrieve a programmed high-frequency noise sequence according to a preset sampling frequency and superimpose it into the screen UV coordinate parameters, calculate the periodic perturbation value of the rendering sampling offset in combination with the coordinate displacement, obtain the pixel micro oscillation matrix, multiply the pixel micro oscillation matrix with the line width mapping coefficient to obtain the fusion product term, and perform a mixing operation on the outline operator mesh in the pixel array according to the fusion product term to generate the perturbation contour line width matrix. The illumination linewidth convergence module is used to call the deferred rendering pipeline and read the illumination accumulation buffer data, extract the radiance brightness values ​​in the illumination accumulation buffer data, establish a brightness negative correlation attenuation multiplier, and calculate the illumination convergence linewidth set by combining the brightness negative correlation attenuation multiplier with the perturbation contour linewidth matrix according to the pixel position coordinates. The light and shadow outlining and blending module is used to extract the illumination direction parameters and the three-dimensional surface normal parameters, obtain the reflection features of the illuminated surface, combine the reflection features of the illuminated surface with the black base pixel parameters to calculate the edge color fusion amount, and substitute the edge color fusion amount into the corresponding coordinate points of the illumination convergence line width set to generate light and shadow outlining image data.

[0014] Compared with the prior art, the advantages and positive effects of the present invention are as follows: This invention utilizes G-Buffer normal data and screen space depth data, extracting curvature variation parameters. Pixel outlines no longer solely rely on screen edge differences but instead form a basis for linewidth variations based on the degree of curvature of the three-dimensional surface. The curvature variation parameters, combined with screen space depth data, perform perspective attenuation calculations, suppressing excessive expansion of distant outlines and enhancing the consistency of linewidth layers between foreground character edges, object transition areas, and occlusion boundaries. By superimposing a programmed high-frequency noise sequence onto screen UV coordinate parameters and combining it with coordinate displacement calculations of periodic perturbation values, subtle changes in stroke sampling offset are achieved, reducing the mechanical feel of fixed outlines in animation. The pixel micro-oscillation matrix is ​​mapped to the linewidth coefficient. After multiplication, the perturbation amplitude is constrained by both curvature and depth, which can prevent noise perturbation from damaging the stability of the main outline. By reading the radiance brightness value in the cumulative illumination buffer data, a brightness negative correlation attenuation multiplier is established, and the perturbation outline linewidth matrix is ​​converged according to the pixel position coordinates. This can reduce the heaviness of the outline in the illuminated area and retain the outline recognition in the dark area. Through the operation between the illumination direction parameter, the three-dimensional surface normal parameter, the albedo color parameter, and the black base pixel parameter, the edge color fusion amount can be made to change with the color of the illuminated surface material and the illumination direction. This generates light and shadow outline image data that combines linewidth control, micro-perturbation, brightness convergence, and edge color fusion, improving the hand-drawn texture of the real-time animation scene. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the steps of the present invention; Figure 2 This is a graph showing the change in the negative correlation attenuation multiplier of brightness. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0017] Please see Figure 1-2 This invention provides a technical solution for rendering light and shadow in animation scenes, comprising the following steps: The curvature variation parameter is obtained by calling the G-Buffer normal data and screen space depth data in the rendering pipeline; the perspective attenuation calculation is performed on the curvature variation parameter using the screen space depth data to establish the line width mapping coefficient. Extract the screen UV coordinate parameters, retrieve the programmed high-frequency noise sequence according to the preset sampling frequency and superimpose it into the screen UV coordinate parameters, calculate the periodic perturbation value of the rendering sampling offset in combination with the coordinate displacement, and obtain the pixel micro oscillation matrix; multiply the pixel micro oscillation matrix with the line width mapping coefficient to obtain the fusion product term, and perform a mixing operation on the outline operator mesh in the pixel array according to the fusion product term to generate the perturbation contour line width matrix. The deferred rendering pipeline is invoked and the cumulative illumination buffer data is read. The radiance brightness values ​​in the cumulative illumination buffer data are extracted, and a brightness negative correlation attenuation multiplier is established. The brightness negative correlation attenuation multiplier and the perturbation contour linewidth matrix are calculated according to the pixel position coordinates to obtain the illumination convergence linewidth set. Extract the illumination direction parameter and the three-dimensional surface normal parameter to obtain the albedo features of the illuminated surface; combine the albedo features of the illuminated surface with the black base pixel parameter to calculate the edge color fusion amount; substitute the edge color fusion amount into the corresponding coordinate points of the illumination convergence line width set to generate the light and shadow outline image data.

[0018] The steps to obtain the linewidth mapping coefficient are as follows: The process involves calling the G-Buffer normal data and screen space depth data in the rendering pipeline, reading the 3D normal components from the G-Buffer normal data according to the pixel position, retaining the depth value of the same pixel position in the screen space depth data, inputting the 3D normal components into the fragment shader partial derivative instruction, calculating the screen horizontal normal difference and the screen vertical normal difference respectively, and merging and measuring the screen horizontal normal difference and the screen vertical normal difference to obtain the normal variation rate. Based on the normal variation rate, the distribution of the normal variation rate of adjacent pixels is retrieved according to the pixel position. The normal variation amplitude in different directions around the center pixel is statistically analyzed. Adjacent pixels whose normal variation amplitude does not satisfy the continuous variation relationship are filtered out. The local curvature of the three-dimensional surface corresponding to the center pixel is extracted. The local curvature of the three-dimensional surface is arranged according to the screen pixel position to obtain the curvature variation parameter. The depth values ​​of the same pixel position in the screen space depth data are called, and perspective attenuation is performed on the curvature variation parameter according to the depth values ​​to obtain the scaling value. The scaling value is input into the preset width-narrow mapping formula, and the sampling radius of the stroke operator is adjusted according to the scaling value so that the sampling radius changes accordingly with the curvature variation parameter and the depth value, thus establishing the line width mapping coefficient.

[0019] Specifically, the process calls the G-Buffer normal data and screen-space depth data already generated in the rendering pipeline. For each pixel on the screen, it reads the 3D normal component stored in the G-Buffer. This component is a 3D vector containing three floating-point numbers (Nx, Ny, Nz). Simultaneously, it retains the pixel's depth value in the screen-space depth data for later use. Then, it passes the 3D normal component of each pixel as input to the partial derivative function built into the fragment shader. Specifically, it uses... The instruction calculates the rate of change of the normal vector along the x-axis (horizontal) direction in screen space, obtaining the horizontal normal difference. This difference is also a three-dimensional vector, representing the difference in normal vectors between the current pixel and its horizontally adjacent pixels. Similarly, it uses... The instruction calculates the rate of change of the normal vector along the y-axis (vertical) of the screen space, obtaining the vertical normal difference. This difference represents the difference in the normal vector between the current pixel and its vertically adjacent pixels. Then, the horizontal and vertical normal differences are combined and measured. This measurement process involves calculating the Euclidean length of the two difference vectors separately, that is, summing the squares of each component of the vector and then taking the square root. The two length values ​​are then added together, and the sum is defined as the degree of change in the geometric features of the current pixel. The calculation results of all pixels on the screen are combined into a two-dimensional array to obtain the rate of change of the normal.

[0020] Based on the normal variation rate obtained in the previous step, an analysis window is set for each pixel p(u, v) on the screen, such as a 5x5 pixel matrix centered on that pixel. The normal variation rate values ​​of all 25 pixels within this window are retrieved, forming a local dataset. Then, statistical analysis is performed on this local dataset to calculate the mean and standard deviation of these 25 normal variation rate values. Based on the statistical results, a continuity judgment threshold is set. This threshold is set by adding 1.5 times the standard deviation to the normal variation rate of the center pixel. For example, if the normal variation rate of the center pixel is 0.2 and the standard deviation within the window is 0.05, then the threshold is 0.2 + 1.5 * 0.05 = 0.275. Iterates through each adjacent pixel in the analysis window and compares its normal variation rate with this continuity judgment threshold. If the normal variation rate of an adjacent pixel is greater than the threshold, it is determined that the surface normal change of the pixel is discontinuous with that of the center pixel, possibly belonging to different geometric surfaces or located at a sharp edge. Therefore, it is removed from the local dataset. After the removal operation is completed, the normal variation rates of the remaining adjacent pixels in the local dataset that satisfy the continuous change relationship are weighted and averaged. The weight allocation can use a Gaussian function, that is, the closer the pixel is to the center pixel, the higher the weight. The calculated weighted average value is regarded as the accurate estimate of the local curvature of the three-dimensional surface corresponding to the center pixel. The local curvature values ​​of the three-dimensional surface calculated for all pixels are arranged according to their original pixel positions on the screen to form a two-dimensional data map with the same resolution as the screen, thus obtaining the curvature variation parameter.

[0021] Call the screen space depth data that is the same as the pixel position of the curvature variation parameter, for each pixel. Read its depth value With curvature variation parameter To simulate the perspective effect of near objects appearing larger and distant objects appearing smaller as observed by the human eye, perspective attenuation calculations need to be performed on the curvature variation parameter. This calculation involves determining an attenuation factor. To achieve this, its calculation method is as follows: ,in, It is the depth value of the current pixel. This is the distance to the far clipping plane of the rendering camera, a preset value, such as 1000.0 units. The `max` function ensures that the attenuation factor is not negative. Through this calculation, pixels farther away from the camera will have a lower attenuation factor. The closer the value is to 0, the stronger the attenuation effect; the calculated attenuation factor... Curvature variation parameter of the corresponding pixel Multiplying them yields a scaling value adjusted for depth. ,Right now Then, the scaling value The input is given to a preset width-to-width mapping formula, and the sampling radius of the stroke operator is adjusted according to the scaling value. The adjustment process can be described by the following relationship: in, It is the final calculated stroke sampling radius. This is the base line width, ensuring that all outlines have a minimum width. Its value is set empirically, for example, 1.2 pixels. This is a curvature influence coefficient used to adjust the contribution of curvature to line width. Its value is also adjusted according to the desired artistic style, for example, set to 50.0. It is a scaling value calculated in the previous step, combining curvature and depth. and These are the minimum and maximum limits for line width, for example, 1.0 pixels and 8.0 pixels respectively, used to prevent lines from being too thin or too thick. The function is a standard function that will... The value is limited to Within the interval, this formula causes the sampling radius to change accordingly with the curvature parameter and depth value, thus calculating the sampling radius for all pixels. Collect them together and establish linewidth mapping coefficients.

[0022] The steps to obtain the pixel micro-oscillation matrix are as follows: Extract the screen UV coordinate parameters, read the programmed high-frequency noise sequence according to the preset sampling frequency, and superimpose the perturbation sampling value in the programmed high-frequency noise sequence onto the screen UV coordinate parameters pixel by pixel. Record the coordinate displacement of the screen UV coordinate parameters in the horizontal and vertical coordinate directions, calculate the offset amplitude of the rendering sampling offset in different sampling periods based on the coordinate displacement, and form a pixel micro oscillation matrix.

[0023] Specifically, the UV coordinates of each pixel in screen space are extracted; this parameter is a two-dimensional vector. Its component range is Meanwhile, a programmed high-frequency noise sequence is prepared, specifically generated using a two-dimensional Perlin noise function. This noise function is sampled according to a preset sampling frequency, for example, by multiplying the UV coordinates by a scaling factor of 32.0. This process can be represented as follows: ,in This is a Perlin noise function, whose output is a... The pseudo-random values ​​within the range are sampled twice in two different noise spaces to obtain horizontal and vertical perturbation sample values, forming a perturbation vector. This two-dimensional perturbation sample value vector is then superimposed pixel-by-pixel onto the original screen UV coordinate parameters to form a new, perturbed UV coordinate. Simultaneously, a time variable is introduced as a third dimension of the noise function, for example... ,in The time represents the current animation frame, causing the perturbation to change over time. The difference between the original UV coordinates and the perturbed UV coordinates is recorded. This difference is the coordinate displacement of the pixel in the current frame. It is a two-dimensional vector containing the displacement in the horizontal and vertical coordinate directions. Based on this coordinate displacement that changes over time, the offset of the rendering sampling offset in the continuous sampling period (i.e., continuous frames) is calculated. This offset is the coordinate displacement vector itself. The offset amplitude vectors of all pixels on the screen are collected to form a two-dimensional vector field with the same size as the screen resolution, i.e., the pixel micro-oscillation matrix.

[0024] The steps to obtain the perturbation contour linewidth matrix are as follows: The linewidth adjustment amount corresponding to the pixel position in the linewidth mapping coefficient is called, and the horizontal oscillation component and the vertical oscillation component in the pixel micro oscillation matrix are multiplied with the linewidth adjustment amount pixel by pixel. The product amplitude, product direction and sampling radius change relationship of each pixel position are retained to obtain the fusion product term. Based on the fusion product term, the position of the center pixel of the stroke operator grid within the pixel array is located. The distribution of the fusion product term of the neighboring pixels around the center pixel is read. The neighboring pixels are weighted and mixed according to the sampling arrangement order of the stroke operator grid. Isolated line width changes that do not meet the stroke continuity are filtered out, and line width changes that meet the contour direction consistency are retained to generate a perturbation contour line width matrix.

[0025] Specifically, the linewidth mapping coefficients generated in the previous steps are called, where a linewidth adjustment amount R(p) is stored for each pixel position p. This adjustment amount is a scalar value. At the same time, the pixel micro-oscillation matrix generated in the previous step is called, and the two-dimensional oscillation vector of the corresponding pixel position p is read from it. This vector contains the lateral oscillation component. and longitudinal oscillation components , will the horizontal oscillation component The horizontal blending component is obtained by multiplying the linewidth adjustment amount R(p) of the pixel pixel by pixel. Similarly, the longitudinal oscillation component Multiplying this by the linewidth adjustment R(p) yields the longitudinal fusion component. These two components and Together they form a new two-dimensional vector, the magnitude of which (i.e., the vector length) This reflects the oscillation intensity and vector direction after linewidth adjustment. This indicates the direction of the oscillation in the screen space, and the relationship of the change in the sampling radius is implicit in the amplitude of this vector. That is, the larger the amplitude, the greater the change in the original stroke sampling radius in this direction. This two-dimensional vector containing the product amplitude and product direction, which is calculated for each pixel position on the screen, is retained to obtain the fused product term.

[0026] Based on the fusion product term calculated in the previous step, which is a two-dimensional vector field covering the entire screen, a 3x3 stroke operator grid is defined centered on each pixel in the screen. The center pixel position of this grid is located, and the fusion product term vectors of the center pixel and its eight surrounding neighboring pixels are read, forming a local set containing nine two-dimensional vectors. To filter out noise and align the perturbation with the contour direction, neighboring pixel weighted mixing is required. First, the direction of the local contour is calculated, which can be obtained by rotating the normal gradient direction calculated from the G-Buffer normal data by 90 degrees. Let the fusion product term vector of the center pixel be... The vectors of adjacent pixels are The local contour direction vector is Calculate the dot product of each adjacent pixel vector and the center pixel vector, and set a continuity threshold, for example, 0.5. If the perturbation direction of the adjacent pixel is discontinuous with the center, it is considered an isolated linewidth change, and its weight is set to 0 in subsequent blending. For adjacent pixels that satisfy continuity, their relationship with the local contour direction vector is calculated. The absolute value of the dot product, i.e. This is used as the mixing weight of the adjacent pixel. This weight reflects the consistency between the perturbation direction and the contour direction. The fusion product vectors of all 9 pixels are weighted and averaged according to this weight to calculate a new fusion product vector of the center pixel. This process preserves the line width change that is consistent with the contour direction. The calculation results of all pixels are then integrated to generate the perturbation contour line width matrix.

[0027] The steps to obtain the brightness negative correlation attenuation multiplier are as follows: Call the deferred rendering pipeline, read the cumulative lighting buffer data in the deferred rendering pipeline, parse the radiance and brightness channels in the cumulative lighting buffer data according to the pixel position, extract the radiance and brightness value corresponding to each pixel position, exclude the radiance and brightness records that do not correspond to valid pixel positions, and obtain the radiance and brightness value. The radiance value of each pixel is input into the inverse exponential decay formula. The radiance value is then processed in reverse order of increasing value. The line width decay amplitude corresponding to each pixel is calculated. The correspondence between the line width decay amplitude and the pixel position is retained, and a negative correlation decay multiplier for brightness is established.

[0028] Specifically, the deferred rendering pipeline is invoked, and the accumulated illumination buffer data within it is read. This buffer data is a texture stored in floating-point format (e.g., RGBA16F), containing the combined illumination contribution of all light sources in the scene to each pixel. Based on the position coordinates of each pixel on the screen, the corresponding color value is read from the accumulated illumination buffer data. This color value is typically an HDR color vector containing R, G, and B components. Next, to convert this color vector into a single luminance scalar, a luminance conversion calculation based on human visual perception is used. Specifically, the luminance formula defined in the BT.709 standard is applied, and the radiance value is calculated by weighted summation of the R, G, and B color components. For example, if the color value of a pixel is (R, G, B), then its radiance value L is calculated as L = 0.2126 * R + 0.7152 * G + 0.0722 * B. This calculation is performed pixel by pixel. Then, during the processing, pixels that do not correspond to valid geometry in the scene need to be excluded. This is achieved by querying the depth buffer or material ID buffer in the G-Buffer. If the depth value of a pixel is equal to the distance of the camera from the clipping plane, or its material ID is marked as a skybox or background, then the pixel is considered invalid, and its corresponding radiance value is discarded or assigned a default very low value (e.g., 0.0). After traversing all pixels on the screen and completing the above parsing and filtering process, a two-dimensional floating-point array with the same size as the screen resolution is obtained, which is the radiance value.

[0029] The radiance value of each pixel obtained in the previous step is input into a preset inverse exponential decay formula. This formula generates a decreasing multiplier in reverse order as the radiance value increases. Its specific mathematical expression is as follows: in, This is the final linewidth attenuation calculated for pixel p. It is the radiance and brightness value of the corresponding pixel p obtained from the previous step. It is the base of the natural logarithm. It is a non-negative attenuation coefficient, an adjustable parameter preset according to the artistic style requirements. It controls the rate at which the line width thins as brightness increases. For example, if you want the line width to attenuate to 30% of its original width when the brightness reaches 1.5, you can solve for it in reverse. By adjusting The value controls the fading effect of the stroke in the bright areas. and These are the minimum and maximum clamping values ​​for the attenuation amplitude. These two values ​​are also preset and are used to limit the range of the attenuation effect. For example, setting... Set to 0.1 to prevent lines from disappearing completely in extremely bright areas. Setting it to 1.0 ensures that the line width is not affected in pure black areas. The function will calculate the result. Forced constraints Within the specified range, this calculation is performed for every pixel on the screen, and the resulting linewidth attenuation magnitude is calculated. It is associated with and stored with its pixel position coordinates, and a brightness negative correlation attenuation multiplier is established.

[0030] The steps for obtaining the width set of the illumination convergence line are as follows: The contour line width values ​​at the same pixel position in the perturbation contour line width matrix are called. The brightness negative correlation attenuation multiplier is multiplied point-to-point with the contour line width value according to the pixel position coordinate. Based on the multiplied line width value, the line width value at the corresponding pixel position is converged to obtain the illumination convergence line width set.

[0031] Specifically, the perturbation contour linewidth matrix generated in the previous step is invoked, and the contour linewidth value at the same position as the currently processed pixel is read from it. This contour linewidth value is the magnitude of the vector at the corresponding position in the perturbation contour linewidth matrix, representing the basic line width after combining curvature, depth, and micro-oscillations. At the same time, the brightness negative correlation attenuation multiplier established in the previous step is invoked to obtain the attenuation multiplier value at the same pixel position. According to the pixel's screen coordinates, these two values ​​are multiplied point-to-point. That is, for any pixel p on the screen, its final linewidth value is... Its outline width value Negative correlation with brightness attenuation multiplier Multiplying them together yields the result, i.e. Due to the negative correlation attenuation multiplier of brightness The range of values ​​is clamped to, for example... Within the specified interval, the effect of this multiplication operation is: in darker areas of the scene, Approaching 1.0, the multiplied line width remains essentially unchanged; however, in brighter areas of the scene, The smaller value causes the line width value after multiplication to be proportionally reduced, thus achieving the effect of the line automatically thinning on the illuminated surface. The new line width values ​​obtained after this multiplication operation of all pixel positions are summarized to form a two-dimensional floating-point set consistent with the screen resolution, and the illumination convergence line width set is obtained.

[0032] The steps for obtaining the albedo characteristics of the illuminated surface are as follows: The illumination direction parameter and the 3D surface normal parameter are extracted. The illumination direction parameter and the 3D surface normal parameter are matched according to the pixel position. The dot product value of the illumination direction component and the normal direction component is calculated pixel by pixel. The dot product value is compared with the preset illumination threshold. For the pixel position where the dot product value is greater than the preset illumination threshold, the albedo color parameter of the corresponding pixel is read. The color distribution information and brightness response information in the albedo color parameter are retained to obtain the albedo characteristics of the illuminated surface.

[0033] Specifically, the lighting direction parameter of the main parallel light source in the scene is extracted. This parameter is a constant unit 3D vector throughout the scene. Simultaneously, the 3D surface normal parameter corresponding to each pixel is extracted from the G-Buffer of the rendering pipeline. This parameter is also a unit 3D vector. Based on the position coordinates of each pixel on the screen, the lighting direction parameter is matched with the 3D surface normal parameter of that pixel, and a dot product operation is performed pixel by pixel to calculate the illuminance factor in the Lambert lighting model. The result of this dot product value ranges from -1 to 1. Subsequently, each calculated dot product value is compared with a preset lighting threshold. This preset lighting threshold is an empirical value set according to the artistic style to distinguish between lit and shadowed surfaces, and its value ranges from -1 to 1. For example, setting it to 0.05 means that as long as the angle between the surface normal and the lighting direction is less than about 87 degrees, the surface is considered a lit surface. This setting avoids unstable stroke colors when light shines on the surface at a very oblique angle. For pixel positions with a dot product value greater than this preset lighting threshold of 0.05, they are identified as lit surfaces, and the albedo color parameter corresponding to the pixel is read from the G-Buffer, which is the inherent color of the object itself. The RGB color distribution information in this albedo color parameter, as well as the brightness response information reflected by its brightness value, are retained and stored in a new cache. For pixels with a dot product value not greater than this threshold, an invalid mark is recorded at the corresponding position in the cache. The final cache is the albedo feature of the lit surface.

[0034] The steps for obtaining the light and shadow outline image data are as follows: Read the color component of the pixel position corresponding to the reflective feature of the illuminated surface, read the base color component of the pixel position corresponding to the black base pixel parameter, perform linear interpolation and mixing operation according to the same pixel position, adjust the color participation ratio of the reflective feature of the illuminated surface in the edge region item by item, adjust the color participation ratio of the black base pixel parameter in the edge region item by item, calculate the edge color transition result of each pixel position, and obtain the edge color fusion amount. Read the line width values ​​of each pixel position in the illumination convergence line width set, substitute the edge color blending amount into the corresponding coordinate point of the illumination convergence line width set according to the pixel position coordinates, write the edge color blending amount for the pixel position with the line width value, and keep the original coordinate content unchanged for the pixel position without the line width value, and complete the corresponding integration of the line width distribution and the edge color distribution to generate light and shadow outline image data.

[0035] Specifically, the process reads the albedo features generated in the previous step, which store the color components of each pixel on all lit surfaces in the scene. It also defines a black base pixel parameter, a preset color value by the artist, typically pure black (R=0, G=0, B=0), as the base color for the stroke. Linear interpolation is then performed on each pixel at the same position coordinates on the screen. Specifically, for a pixel p, it first checks if a valid color component is recorded in the albedo features. If so, its stroke color is a mixture of the surface color and the base color. The mixing ratio is determined by a preset color participation ratio coefficient, a floating-point number between 0 and 1. For example, setting it to 0.4 means the final stroke color is a mixture of 40% surface color and 60% black base color. This ratio determines the degree to which the stroke blends into the background; a higher value results in a stroke color closer to the surface color and a smoother effect. The edge color transition result for this pixel is calculated as follows: ,in It is a parameter of the black base pixel. The color components are read from the albedo features of the illuminated surface. If pixel p is not effectively recorded in the albedo features of the illuminated surface, it means that it is located in the backlight or shadow. Its edge color transition result directly uses the black base pixel parameter. The edge color transition results calculated from all pixel positions are summarized to obtain the edge color fusion amount.

[0036] The process reads the final calculated lighting convergence linewidth set from the previous steps, storing the line width value for each pixel position on the screen. This value is a floating-point number representing the "density" or width of that pixel as part of the contour line. Simultaneously, a scene image with basic lighting and shading already completed is prepared as the underlying layer for rendering. Then, at each pixel coordinate on the screen, the edge color blending amount calculated in the previous step is substituted into the corresponding coordinate point of the lighting convergence linewidth set. This process is performed by setting a linewidth judgment threshold, for example, setting this threshold to 0.01. This value is used to filter out lines with extremely low widths caused by calculation errors. For pixels with a line width value greater than 0.01 in the width concentration, the pixel is determined to be part of the stroke outline, and its color in the final output image is set to the color value of the corresponding coordinate in the edge color blending amount. For pixels with a line width value of no more than 0.01 in the width concentration of the lighting convergence line, the pixel is determined not to belong to the stroke outline, and its color in the final output image remains unchanged as the original color content of the underlying scene shading image. By performing this judgment and writing operation on all pixels on the screen, the final correspondence and integration of line width distribution and edge color distribution is completed, generating light and shadow stroke image data containing complete stylized light and shadow and stroke effects.

[0037] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A method for rendering light and shadow in anime scenes, characterized in that, Includes the following steps: The curvature variation parameter is obtained by calling the G-Buffer normal data and screen space depth data in the rendering pipeline; the curvature variation parameter is then subjected to perspective attenuation calculation using the screen space depth data to establish the line width mapping coefficient. The screen UV coordinate parameters are extracted, and a programmed high-frequency noise sequence is retrieved according to a preset sampling frequency and superimposed on the screen UV coordinate parameters. The periodic perturbation value of the rendering sampling offset is calculated in combination with the coordinate displacement to obtain the pixel micro oscillation matrix. The pixel micro oscillation matrix is ​​multiplied with the line width mapping coefficient to obtain a fusion product term. The fusion product term is used to perform a mixing operation on the outline operator mesh in the pixel array to generate a perturbation contour line width matrix. Call the deferred rendering pipeline and read the cumulative illumination buffer data, extract the radiance brightness values ​​in the cumulative illumination buffer data, and establish a brightness negative correlation attenuation multiplier; The brightness negative correlation attenuation multiplier and the perturbation contour linewidth matrix are calculated according to pixel position coordinates to obtain the illumination convergence linewidth set; Extract the illumination direction parameter and the three-dimensional surface normal parameter to obtain the albedo feature of the illuminated surface; combine the albedo feature of the illuminated surface with the black base pixel parameter to calculate the edge color fusion amount; substitute the edge color fusion amount into the corresponding coordinate point of the illumination convergence line width set to generate light and shadow outline image data.

2. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the linewidth mapping coefficient are as follows: The process involves calling the G-Buffer normal data and screen space depth data in the rendering pipeline, reading the 3D normal components from the G-Buffer normal data according to the pixel position, retaining the depth value of the same pixel position in the screen space depth data, inputting the 3D normal components into the fragment shader partial derivative instruction, calculating the screen horizontal normal difference and the screen vertical normal difference respectively, and merging and measuring the screen horizontal normal difference and the screen vertical normal difference to obtain the normal variation rate. Based on the normal variation rate, the distribution of normal variation rate of adjacent pixels is retrieved according to the pixel position. The normal variation amplitude in different directions around the center pixel is statistically analyzed. Adjacent pixels whose normal variation amplitude does not satisfy the continuous variation relationship are filtered out. The local curvature of the three-dimensional surface corresponding to the center pixel is extracted. The local curvature of the three-dimensional surface is arranged according to the screen pixel position to obtain the curvature variation parameter. The depth values ​​of the same pixel position in the screen space depth data are called, and perspective attenuation is performed on the curvature variation parameter according to the depth values ​​to obtain the scaling value. The scaling value is input into the preset width-narrow mapping formula, and the sampling radius of the stroke operator is adjusted according to the scaling value so that the sampling radius changes accordingly with the curvature variation parameter and the depth value, thus establishing the line width mapping coefficient.

3. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the pixel micro-oscillation matrix are as follows: Extract the screen UV coordinate parameters, read the programmed high-frequency noise sequence according to the preset sampling frequency, and superimpose the perturbation sampling value in the programmed high-frequency noise sequence onto the screen UV coordinate parameters pixel by pixel. Record the coordinate displacement of the screen UV coordinate parameters in the horizontal and vertical coordinate directions, calculate the offset amplitude of the rendering sampling offset in different sampling periods based on the coordinate displacement, and form a pixel micro oscillation matrix.

4. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the perturbation contour linewidth matrix are as follows: The linewidth adjustment amount corresponding to the pixel position in the linewidth mapping coefficient is called, and the horizontal oscillation component and the vertical oscillation component in the pixel micro oscillation matrix are multiplied with the linewidth adjustment amount pixel by pixel. The product amplitude, product direction and sampling radius change relationship of each pixel position are retained to obtain the fusion product term. Based on the fusion product term, the position of the center pixel of the stroke operator grid within the pixel array is located. The distribution of the fusion product term of the adjacent pixels around the center pixel is read. The adjacent pixels are weighted and mixed according to the sampling arrangement order of the stroke operator grid. Isolated line width changes that do not satisfy the stroke continuity are filtered out, and line width changes that satisfy the contour direction consistency are retained to generate a perturbation contour line width matrix.

5. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the brightness negative correlation attenuation multiplier are as follows: Call the deferred rendering pipeline, read the cumulative lighting buffer data in the deferred rendering pipeline, parse the radiance and brightness channels in the cumulative lighting buffer data according to the pixel position, extract the radiance and brightness value corresponding to each pixel position, exclude the radiance and brightness records that do not correspond to valid pixel positions, and obtain the radiance and brightness value. The radiance value of each pixel is input into the inverse exponential decay formula. The radiance value is then processed in reverse order of increasing value. The line width decay amplitude corresponding to each pixel is calculated. The correspondence between the line width decay amplitude and the pixel is retained, and a negative correlation decay multiplier for brightness is established.

6. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the beamwidth set of the illumination convergence line are as follows: The contour linewidth values ​​at the same pixel position in the perturbation contour linewidth matrix are called, and the brightness negative correlation attenuation multiplier is multiplied point-to-point with the contour linewidth value according to the pixel position coordinate. Based on the multiplied linewidth value, the line width value at the corresponding pixel position is converged to obtain the illumination convergence linewidth set.

7. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the albedo features of the light-receiving surface are as follows: The illumination direction parameter and the 3D surface normal parameter are extracted. The illumination direction parameter and the 3D surface normal parameter are matched according to the pixel position. The dot product value of the illumination direction component and the normal direction component is calculated pixel by pixel. The dot product value is compared with the preset illumination threshold. For the pixel position where the dot product value is greater than the preset illumination threshold, the albedo color parameter of the corresponding pixel is read. The color distribution information and brightness response information in the albedo color parameter are retained to obtain the albedo characteristics of the illuminated surface.

8. The method for rendering light and shadow in anime scenes according to claim 1, characterized in that, The steps for obtaining the light and shadow outline image data are as follows: Read the color component of the pixel position corresponding to the light-receiving surface albedo feature, read the base color component of the pixel position corresponding to the black base pixel parameter, perform linear interpolation mixing operation according to the same pixel position, adjust the color participation ratio of the light-receiving surface albedo feature in the edge region item by item, adjust the color participation ratio of the black base pixel parameter in the edge region item by item, calculate the edge color transition result of each pixel position, and obtain the edge color fusion amount. Read the line width values ​​of each pixel position in the illumination convergence line width set, substitute the edge color fusion amount into the corresponding coordinate point of the illumination convergence line width set according to the pixel position coordinates, write the edge color fusion amount for the pixel position with line width value, and keep the original coordinate content unchanged for the pixel position without line width value, so as to complete the corresponding integration of line width distribution and edge color distribution and generate light and shadow outline image data.

9. A system for rendering light and shadow in an animation scene according to any one of claims 1-8, characterized in that, include: The curvature linewidth mapping module is used to call the G-Buffer normal data and screen space depth data in the rendering pipeline to obtain the curvature variation parameter, and use the screen space depth data to perform perspective attenuation calculation on the curvature variation parameter to establish the linewidth mapping coefficient. The perturbation contour generation module is used to extract the screen UV coordinate parameters, retrieve a programmed high-frequency noise sequence according to a preset sampling frequency and superimpose it into the screen UV coordinate parameters, calculate the periodic perturbation value of the rendering sampling offset in combination with the coordinate displacement, obtain the pixel micro oscillation matrix, multiply the pixel micro oscillation matrix with the line width mapping coefficient to obtain the fusion product term, and perform a mixing operation on the outline operator mesh in the pixel array according to the fusion product term to generate the perturbation contour line width matrix. The illumination linewidth convergence module is used to call the deferred rendering pipeline and read the illumination accumulation buffer data, extract the radiance brightness values ​​in the illumination accumulation buffer data, establish a brightness negative correlation attenuation multiplier, and calculate the illumination convergence linewidth set by combining the brightness negative correlation attenuation multiplier with the perturbation contour linewidth matrix according to the pixel position coordinates. The light and shadow outlining and blending module is used to extract the illumination direction parameters and the three-dimensional surface normal parameters, obtain the reflection features of the illuminated surface, combine the reflection features of the illuminated surface with the black base pixel parameters to calculate the edge color fusion amount, and substitute the edge color fusion amount into the corresponding coordinate points of the illumination convergence line width set to generate light and shadow outlining image data.