High-light rendering method, device, medium and electronic equipment

By adjusting the texture offset of the highlight position in the target coordinate space of the hair model, the problem of unstable highlight shape in cartoon character hair rendering is solved, achieving efficient and accurate highlight rendering effect and improving animation quality.

CN114693860BActive Publication Date: 2025-12-30BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210386625.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-13
Publication Date
2025-12-30
Estimated Expiration
2042-04-13

AI Technical Summary

Technical Problem

Existing technologies struggle to guarantee the stability and accuracy of highlight shapes in cartoon character hair rendering, especially when the light source and viewing angle change, resulting in poor highlight rendering effects.

Method used

By transforming the light source direction and viewing direction in world space to the target coordinate space of the hair model, and adjusting the texture offset of the highlight position only in the vertical direction, anisotropic specular rendering effect is achieved, simplifying the rendering process and improving accuracy.

Benefits of technology

While preserving the shape of the highlights, the efficiency and accuracy of highlight rendering have been improved, thus enhancing the viewing experience of the animation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114693860B_ABST
    Figure CN114693860B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a high light rendering method, device, medium and electronic equipment, the method comprising: obtaining a high light image to be rendered, a high light shape to be rendered being drawn in the high light image; determining a light source vector in a target coordinate space corresponding to the hair model according to a light source direction in a world space; for each pixel point to be rendered in the hair model, determining a line of sight vector corresponding to the pixel point in the target coordinate space according to a line of sight direction in the world space; for each pixel point, determining a texture offset in a vertical direction corresponding to a horizontal direction of the pixel point in the high light image according to the light source vector and the line of sight vector corresponding to the pixel point; and sampling from the high light image according to the texture offset corresponding to each pixel point to render the pixel point, to obtain a rendered high light rendering image. Thus, the rendering of anisotropic high light can be realized while ensuring the rendering of a high light shape.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing, and more specifically, to a specular rendering method, apparatus, medium, and electronic device. Background Technology

[0002] In cartoon character hair rendering, unlike realistic hair highlight rendering, the highlights are usually blocky in shape, such as... Figure 1 Point A in the image shows a realistic highlight image of hair. Figure 1 Point B in the image shows the hair highlight image rendered in a cartoon style.

[0003] In realistic hair scenes, different angles of light shining on the hair will result in different highlight representations in the viewer's field of vision. Related technologies typically employ anisotropic algorithms to render hair highlights, allowing the highlights in rendered cartoon animations to change with the light source and viewer's perspective. However, this rendering method involves real-time calculation of highlights by overlaying perturbation textures onto the lighting model, making it difficult to guarantee the shape of the highlights in the rendered image. Summary of the Invention

[0004] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0005] In a first aspect, this disclosure provides a specular rendering method, the method comprising:

[0006] Obtain a specular image to be rendered, wherein the specular image contains the specular shapes to be rendered;

[0007] The light source vector in the target coordinate space corresponding to the hair model is determined based on the light source direction in world space.

[0008] For each pixel to be rendered in the hair model, the gaze vector corresponding to that pixel in the target coordinate space is determined based on the gaze direction in world space.

[0009] For each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image is determined based on the light source vector and the viewing vector corresponding to the pixel.

[0010] Sampling is performed on the specular image based on the texture offset corresponding to each pixel to render the pixel and obtain the rendered specular image.

[0011] Secondly, this disclosure provides a specular rendering apparatus, the apparatus comprising:

[0012] An acquisition module is used to acquire a specular image to be rendered, wherein the specular image contains a specular shape to be rendered.

[0013] The first processing module is used to determine the light source vector in the target coordinate space corresponding to the hair model based on the light source direction in world space.

[0014] The second processing module is used to determine the gaze vector corresponding to each pixel to be rendered in the hair model in the target coordinate space based on the gaze direction in the world space.

[0015] The determining module is used to determine, for each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image, based on the light source vector and the viewing vector corresponding to the pixel.

[0016] The rendering module is used to sample from the specular image according to the texture offset corresponding to each pixel point, so as to render the pixel point and obtain the rendered specular image.

[0017] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.

[0018] Fourthly, this disclosure provides an electronic device, comprising:

[0019] A storage device on which computer programs are stored;

[0020] A processing device for executing the computer program in the storage device to implement the steps of the method described in the first aspect.

[0021] Therefore, in the above technical solution, the light source direction and viewing direction in world space can be transformed to the target coordinate space corresponding to the hair model, thereby determining the influence of the viewing direction and light source direction on the specular position within the same model space. Furthermore, in this embodiment, only the offset of the specular position in the vertical direction corresponding to the horizontal direction is considered. For the same pixel in the hair model, based on the viewing direction and light source direction, its texture sampling position from the specular image can be changed, causing the rendered color value obtained from the same pixel to change. This allows for the offset of the specular position while maintaining the specular shape, achieving anisotropic specular rendering effects, simplifying the specular rendering process, improving specular rendering efficiency, and enhancing the accuracy of animation specular rendering, thus improving the user's viewing experience of the rendered animation.

[0022] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description

[0023] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:

[0024] Figure 1 This is a comparative illustration of the highlights in realistic and cartoon hair.

[0025] Figure 2 This is a flowchart of a specular rendering method based on the implementation scheme of this disclosure;

[0026] Figure 3 This is a schematic diagram of a highlight image provided based on an embodiment of this disclosure;

[0027] Figure 4 and Figure 5 This is a schematic diagram of a specular rendering image provided based on an embodiment of this disclosure;

[0028] Figure 6 This is a block diagram of a specular rendering apparatus based on an embodiment of the present disclosure;

[0029] Figure 7 A schematic diagram of the structure of an electronic device suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation

[0030] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0031] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0032] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0033] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0034] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0035] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0036] All actions involving the acquisition of signals, information, or data in this disclosure are carried out in accordance with the relevant data protection laws and policies of the country where the location is situated, and with the authorization granted by the owner of the relevant device.

[0037] Figure 2 The diagram shows a flowchart of a specular rendering method based on an embodiment of this disclosure. The method may include:

[0038] In step 11, a specular image to be rendered is obtained, wherein the specular image contains the specular shape to be rendered.

[0039] For example, when rendering specular highlights on a hair model based on a specular image, the correspondence between pixels in the hair model and sampling positions in the specular image is usually established using UV coordinates. The UV coordinates can be percentage coordinates of the specular image, with the horizontal direction denoted as U and the vertical direction as V, such as... Figure 3 The image shown is a specular image. The white area represents the shape of the specular highlights to be rendered. When rendering the hair model based on this specular image, the specular image is mapped onto the surface of the hair model to achieve specular rendering.

[0040] In step 12, the light source vector in the target coordinate space corresponding to the hair model is determined based on the light source direction in world space.

[0041] In step 13, for each pixel to be rendered in the hair model, the gaze vector corresponding to that pixel in the target coordinate space is determined based on the gaze direction in world space.

[0042] Rendering can be performed using commonly used rendering models in this field, such as Unity Shader for specular rendering. In this rendering model, parameters such as the light source direction and viewing direction in world space can be obtained. In this embodiment, these parameters can be converted from world space to the model space corresponding to the hair model, i.e., the target coordinate space, to better represent the impact of changes in the light source direction and viewing direction on the specular position. It should be noted that... Figure 2 The execution order shown is illustrative. Steps 12 and 13 can be executed sequentially or in parallel. This disclosure does not limit this.

[0043] In step 14, for each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the specular image is determined based on the light source vector and the viewing vector corresponding to the pixel.

[0044] In anisotropic specular changes, when the light source or viewing direction moves relative to the hair model in any direction (up, down, left, or right), the position of the specular highlight typically shifts accordingly, making it difficult to maintain the specular shape during the change process. Therefore, in this embodiment, to ensure the fixed shape of the specular highlight on the hair, when the light source or viewing direction changes, only the texture corresponding to the specular shape can be shifted vertically. This achieves anisotropic changes while maintaining the specular shape.

[0045] In step 15, samples are taken from the specular image based on the texture offset corresponding to each pixel to render the pixel and obtain the rendered specular image.

[0046] As shown above, the influence of changes in the viewing direction and the light source direction on the vertical position of the specular shape can be determined. Thus, based on the texture offset, the specular image can be sampled from the offset position. That is, the color value of the corresponding position in the specular image can be sampled from the offset position for rendering, so that the rendered color matches the current light source direction and viewing direction.

[0047] Therefore, in the above technical solution, the light source direction and viewing direction in world space can be transformed to the target coordinate space corresponding to the hair model, thereby determining the influence of the viewing direction and light source direction on the specular position within the same model space. Furthermore, in this embodiment, only the offset of the specular position in the vertical direction corresponding to the horizontal direction is considered. For the same pixel in the hair model, based on the viewing direction and light source direction, its texture sampling position from the specular image can be changed, causing the rendered color value obtained from the same pixel to change. This allows for the offset of the specular position while maintaining the specular shape, achieving anisotropic specular rendering effects, simplifying the specular rendering process, improving specular rendering efficiency, and enhancing the accuracy of animation specular rendering, thus improving the user's viewing experience of the rendered animation.

[0048] In one possible embodiment, an exemplary implementation of determining the light source vector in the target coordinate space corresponding to the hair model based on the light source direction in world space is as follows:

[0049] The direction of the light source in world space is obtained and transformed using a transformation matrix to obtain the light source vector in the target coordinate space. For example, this can be determined using the following formula:

[0050] lightDir_O=mul((float3×3)unity_WorldToObject,LightDirection.xyz)

[0051] Here, `mul(M,v)` is used to perform matrix multiplication of matrix M and vector v for matrix transformation; `unity_WorldToObject` represents the matrix used to transform from world space to object space (i.e., target coordinate space); `LightDirection.xyz` represents the coordinates of the light source direction in world space; and `lightDir_O` represents the light source vector in the target coordinate space. The calculations of the `mul()` function and `unity_WorldToObject` are standard practices in this field and will not be elaborated further.

[0052] In one possible embodiment, an exemplary implementation of determining the gaze vector corresponding to each pixel to be rendered in the hair model based on the gaze direction in world space is as follows: This step may include:

[0053] Determine the camera position in the world space and its coordinates in the target coordinate space.

[0054] The camera position in world space can be obtained using _WorldSpaceCameraPos(). Similarly, the camera position can be transformed to the target coordinate space using a transformation matrix, as shown in the following formula:

[0055] mul(unity_WorldToObject,float4(_WorldSpaceCameraPos.xyz,1))

[0056] Here, unity_WorldToObject represents the transformation matrix corresponding to the transformation from world space to target coordinate space, and _WorldSpaceCameraPos.xyz represents the coordinates of the camera position in world space.

[0057] For each pixel, the vector obtained by subtracting the pixel's position coordinates from the camera's position coordinates is standardized and then used as the viewing vector corresponding to that pixel.

[0058] For example, the direction from the camera position to a pixel, i.e., the viewing direction, can be determined by vector subtraction. Normalization can be performed, and the viewing vector corresponding to a pixel can be determined using the following formula:

[0059] viewDir_O=

[0060] normalize(mul(unity_WorldToObject,

[0061] float4(_WorldSpaceCameraPos.xyz,1)).xyz-v.vertex.xyz)

[0062] Here, v.vertex.xyz represents the position coordinates of the pixel vertex in the hair model v, normalize is used to normalize the vector, and viewDir_O is used to represent the gaze vector corresponding to the pixel.

[0063] Therefore, through the above technical solution, the gaze direction of each pixel in the hair model can be determined in the space corresponding to the hair model, thereby transforming the representation of the hair model and the representation of the gaze direction into the same space. This allows the influence of the gaze direction on specular reflection to be obtained based on the same spatial standard, providing reliable data support for subsequent specular texture sampling.

[0064] In one possible embodiment, an exemplary implementation of determining the texture offset of each pixel in the vertical direction corresponding to the horizontal direction in the specular image, based on the light source vector and the gaze vector corresponding to the pixel, is as follows: This step may include:

[0065] Determine the light source component of the light source vector in the vertical direction.

[0066] For each pixel, the gaze component of the gaze vector corresponding to the pixel in the vertical direction is determined.

[0067] As described above, in this disclosure, changes in the light source direction or viewing direction only affect the vertical offset of the highlight shape. Therefore, in this embodiment, it is only necessary to determine the vertical components of the light source vector and the viewing vector. Based on the target coordinate space corresponding to the hair model, the vertical component is the y-component of the vector in that target coordinate space. Therefore, in this embodiment, the y-component of the determined light source vector is defined as the light source component, and the y-component of each viewing vector is defined as the corresponding viewing component.

[0068] The texture offset corresponding to each pixel is determined based on the light source component and the viewing component corresponding to each pixel.

[0069] Specifically, the light source component and the viewing component can be mapped to texture offsets according to a preset correspondence. For example, for each pixel, the average value of the light source component and the viewing component corresponding to that pixel can be determined as the texture offset for that pixel, i.e.:

[0070] speTexUVOffset=0.5*(lightDir_O.y+viewDir_O.y)

[0071] Here, speTexUVOffset represents the texture offset, lightDir_O.y represents the light source component, and viewDir_O.y represents the view component.

[0072] As another example, the offset influence parameters of the light source direction and the viewing direction on the specular position can be set according to the actual application scenario. In this way, the light source component and the viewing component can be weighted based on their respective offset influence parameters to obtain the corresponding texture offset.

[0073] Therefore, through the above technical solution, the effects of the light source direction on the specular position offset and the viewing direction on the specular position offset can be determined respectively. This allows us to determine the direction and amount of the specular offset that should be made under the current light source direction and viewing direction, so that the specular shape is offset and matches the viewing direction and light source direction. By controlling the specular position, an anisotropic effect is achieved, improving the accuracy of specular rendering in animation, simplifying the specular rendering process, and improving specular rendering efficiency.

[0074] In one possible embodiment, an exemplary implementation of sampling from the specular image based on the texture offset corresponding to each pixel to render the pixel and obtain the rendered specular image is as follows, which may include:

[0075] Obtain the base texture coordinate value corresponding to each pixel in the specular image, wherein the base texture coordinate value is the coordinate value corresponding to the light source vector and the view vector when there is no offset.

[0076] The basic texture coordinates of each pixel in the specular image can be obtained in advance. For example, they can be the UV values ​​obtained by sampling based on the texture sampler when the y-components of the light source vector and the view vector are 0.

[0077] Then, based on the texture offset corresponding to each pixel and the basic texture coordinate value, the texture sampling coordinate value corresponding to that pixel is determined.

[0078] Once the texture offset corresponding to a pixel is determined, the pixel can be offset based on the base texture coordinates to control the offset of the highlight shape.

[0079] Then, the texture color value corresponding to the texture sampling coordinate value is sampled from the highlight image and used as the color value corresponding to the pixel.

[0080] Once the texture sampling coordinates corresponding to a pixel are determined, the sampler can sample from the corresponding position in the specular image based on these coordinates to obtain the color value corresponding to the texture sampling coordinates. The sampling method used by the sampler from the specular image can be set based on the actual application scenario, such as constant interpolation or linear interpolation to handle image enlargement or reduction; this disclosure does not limit this approach.

[0081] The pixel is rendered based on the color value corresponding to each pixel to obtain the specular rendering image.

[0082] For example, such as Figure 4 and Figure 5As shown, this is a specular rendering image obtained under different viewing directions and light source directions. The position of the specular shape G is different, achieving an anisotropic rendering effect.

[0083] Therefore, through the above technical solution, the texture sampling coordinates of the pixels in the hair model can be determined from the specular image based on the texture offset, so as to obtain the corresponding color value from the specular image for rendering the pixel. For the same pixel in the hair model, the texture sampling coordinates in the specular image are determined in real time, so that the rendering color value obtained by sampling the same pixel changes, thereby achieving the mobility of the surface texture of the hair model, i.e. the specular shape, and fitting the rendering scene of the animation specular.

[0084] In one possible embodiment, an exemplary implementation of determining the texture sampling coordinates of a pixel based on the texture offset and the base texture coordinates of each pixel is as follows, and this step may include:

[0085] Determine the sub-coordinate value of the base texture coordinates of each pixel in the vertical direction. For example, the sub-coordinate value in the vertical direction can be a value in the V direction of the base texture coordinates (UV coordinates).

[0086] For each pixel, the coordinate value obtained by subtracting the texture offset corresponding to the pixel from the sub-coordinate value is used as the updated coordinate value in the vertical direction, and the sub-coordinate value corresponding to the pixel is updated to the updated coordinate value to obtain the texture sampling coordinate value corresponding to the pixel.

[0087] As described above, in this embodiment of the disclosure, it is necessary to ensure the fixity of the highlight shape. Therefore, during the offset change of the highlight, only the highlight is offset in the vertical direction. Correspondingly, when determining the texture sampling coordinate value corresponding to the pixel based on the texture offset, the texture offset also only adjusts the vertical component of the basic texture coordinate value.

[0088] As an example, the texture offset can be directly superimposed on the vertical sub-coordinates of the base texture coordinates to move the specular coordinates in the vertical direction. This updated coordinate value then replaces the vertical coordinates in the base texture coordinates to generate the corresponding texture sampling coordinates. Therefore, the color obtained by sampling based on the texture sampling coordinates can be determined according to the real-time viewing direction and light source direction. By adjusting the sampled texture coordinates, the colorability of the same pixel in the hair model can be changed, thus controlling the movement of the specular highlight.

[0089] In one possible embodiment, another exemplary implementation of determining the texture sampling coordinate value corresponding to each pixel based on the texture offset and the base texture coordinate value is as follows, and this step may include:

[0090] Determine the sub-coordinate value of the base texture coordinate value of each pixel in the vertical direction. Similarly, the sub-coordinate value in the vertical direction can be a value in the V direction of the base texture coordinate value (UV coordinates).

[0091] For each pixel, the target offset is determined based on the texture offset corresponding to the pixel and a preset offset adjustment parameter.

[0092] The preset offset adjustment parameters can be set according to the actual application scenario. For example, these offset adjustment parameters may include an offset degree parameter and an offset position parameter. The offset degree parameter controls the magnitude of the offset, and the offset position parameter controls the readjustment of the offset position. For example, the target offset amount can be represented as follows:

[0093] speTexUVOffset'=_DisScale*speTexUVOffset+_SpecularShift

[0094] Here, 'speTexUVOffset' represents the target offset, _DisScale represents the degree of offset, speTexUVOffset represents the texture offset, and _SpecularShift represents the offset position parameter.

[0095] For each pixel, the subtraction of the target offset corresponding to the pixel into the sub-coordinate value is used as the updated coordinate value in the vertical direction, and the sub-coordinate value corresponding to the pixel is updated to the updated coordinate value to obtain the texture sampling coordinate value corresponding to the pixel.

[0096] The method of generating texture sampling coordinates based on the base texture coordinates after determining the target offset is similar to that described above, and will not be repeated here.

[0097] After determining the texture sampling coordinates, sampling can be performed from the highlight image based on these coordinates. For example, sampling can be performed using the following algorithm:

[0098] specularTex =

[0099] SAMPLE_TEXTURE2D(_ShadingTex,sampler_ShadingTex,

[0100] i.uv.xy-float2(0,_DisScale*speTexUVOffset+_SpecularShift))

[0101] The texture sampling syntax SAMPLE_TEXTURE2D(Tex, sampler_Tex, uv) takes the texture (i.e., the specular image), the texture sampler, and the UV coordinates corresponding to the sampled texture, respectively.

[0102] i.uv.xy represents the base texture coordinate values;

[0103] float2(0,_DisScale*speTexUVOffset+_SpecularShift) represents the target offset. As mentioned above, only the offset of the highlight in the vertical direction is considered, that is, the offset in the V direction. The offset in the U direction is 0.

[0104] Therefore, by using the above technical solution, when determining the offset of the specular position, the offset position can be further controlled based on the offset adjustment parameters, so that the offset movement of the specular spot is more in line with the rendering scenario it is applied to, and the diversity of specular rendering can be improved, further broadening the application scenarios of specular rendering methods.

[0105] This disclosure also provides a specular rendering apparatus, such as Figure 6 As shown, the device 10 includes:

[0106] The acquisition module 100 is used to acquire a specular image to be rendered, wherein the specular image contains a specular shape to be rendered.

[0107] The first processing module 200 is used to determine the light source vector in the target coordinate space corresponding to the hair model based on the light source direction in world space.

[0108] The second processing module 300 is used to determine the gaze vector corresponding to each pixel to be rendered in the hair model in the target coordinate space based on the gaze direction in the world space.

[0109] The determining module 400 is used to determine, for each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image, based on the light source vector and the viewing vector corresponding to the pixel.

[0110] The rendering module 500 is used to sample from the specular image according to the texture offset corresponding to each pixel point, so as to render the pixel point and obtain the rendered specular rendering image.

[0111] Optionally, the determining module includes:

[0112] The first determining submodule is used to determine the light source component of the light source vector in the vertical direction;

[0113] The second determining submodule is used to determine the viewing component of the viewing vector corresponding to each pixel in the vertical direction.

[0114] The third determining submodule is used to determine the texture offset corresponding to the pixel based on the light source component and the viewing component corresponding to each pixel.

[0115] Optionally, the second processing module includes:

[0116] The fourth determining submodule is used to determine the camera position coordinates in the target coordinate space in the world space;

[0117] The processing submodule is used to, for each pixel, standardize the vector obtained by subtracting the pixel's position coordinates from the camera's position coordinates and use the resulting vector as the viewing vector corresponding to the pixel.

[0118] Optionally, the rendering module includes:

[0119] The acquisition submodule is used to acquire the basic texture coordinate value corresponding to each pixel in the highlight image, wherein the basic texture coordinate value is the coordinate value corresponding to the light source vector and the viewing vector when there is no offset;

[0120] The fifth determining submodule is used to determine the texture sampling coordinate value corresponding to each pixel based on the texture offset corresponding to each pixel and the basic texture coordinate value.

[0121] The sampling submodule is used to sample the texture color value corresponding to the texture sampling coordinate value from the highlight image, and use it as the color value corresponding to the pixel.

[0122] The rendering submodule is used to render the pixel based on the color value corresponding to each pixel to obtain the specular rendering image.

[0123] Optionally, the fifth determining submodule includes:

[0124] The sixth determining submodule is used to determine the sub-coordinate value of the basic texture coordinate value of each pixel in the vertical direction;

[0125] The seventh determining submodule is used to, for each pixel, subtract the texture offset corresponding to the pixel from the sub-coordinate value corresponding to the pixel to obtain the updated coordinate value in the vertical direction, and update the sub-coordinate value corresponding to the pixel to the updated coordinate value, so as to obtain the texture sampling coordinate value corresponding to the pixel.

[0126] Optionally, the fifth determining submodule includes:

[0127] The eighth determining submodule is used to determine the sub-coordinate value of the basic texture coordinate value of each pixel in the vertical direction;

[0128] The ninth determining submodule is used to determine the target offset corresponding to each pixel based on the texture offset corresponding to the pixel and a preset offset adjustment parameter.

[0129] The tenth determining submodule is used to, for each pixel, subtract the target offset corresponding to the pixel from the sub-coordinate value corresponding to the pixel to obtain the updated coordinate value in the vertical direction, and update the sub-coordinate value corresponding to the pixel to the updated coordinate value, so as to obtain the texture sampling coordinate value corresponding to the pixel.

[0130] The following is for reference. Figure 7 This diagram illustrates a structural schematic of an electronic device 600 suitable for implementing embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0131] like Figure 7 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0132] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0133] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.

[0134] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0135] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0136] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0137] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: acquire a specular image to be rendered, wherein the specular image contains a specular shape to be rendered; determine a light source vector in the target coordinate space corresponding to the hair model based on the light source direction in world space; for each pixel to be rendered in the hair model, determine a viewing vector corresponding to that pixel in the target coordinate space based on the viewing direction in world space; for each pixel, determine a texture offset in the vertical direction corresponding to the horizontal direction in the specular image based on the light source vector and the viewing vector corresponding to the pixel; and sample from the specular image based on the texture offset corresponding to each pixel to render the pixel and obtain a rendered specular image.

[0138] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0139] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0140] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a module does not necessarily limit the module itself; for example, an acquisition module can also be described as "a module for acquiring a specular image to be rendered".

[0141] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0142] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0143] According to one or more embodiments of this disclosure, Example 1 provides a specular rendering method, wherein the method includes:

[0144] Obtain a specular image to be rendered, wherein the specular image contains the specular shapes to be rendered;

[0145] The light source vector in the target coordinate space corresponding to the hair model is determined based on the light source direction in world space.

[0146] For each pixel to be rendered in the hair model, the gaze vector corresponding to that pixel in the target coordinate space is determined based on the gaze direction in world space.

[0147] For each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image is determined based on the light source vector and the viewing vector corresponding to the pixel.

[0148] Sampling is performed on the specular image based on the texture offset corresponding to each pixel to render the pixel and obtain the rendered specular image.

[0149] According to one or more embodiments of this disclosure, Example 2 provides the method of Example 1, wherein, for each pixel, determining the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image based on the light source vector and the gaze vector corresponding to the pixel includes:

[0150] Determine the light source component of the light source vector in the vertical direction;

[0151] For each pixel, determine the viewing component of the viewing vector corresponding to the pixel in the vertical direction;

[0152] The texture offset corresponding to each pixel is determined based on the light source component and the viewing component corresponding to each pixel.

[0153] According to one or more embodiments of this disclosure, Example 3 provides the method of Example 1, wherein determining the gaze vector corresponding to the pixel in the target coordinate space based on the gaze direction in world space for each pixel to be rendered in the hair model includes:

[0154] Determine the camera position in the world space and its coordinates in the target coordinate space;

[0155] For each pixel, the vector obtained by subtracting the pixel's position coordinates from the camera's position coordinates is standardized and then used as the viewing vector corresponding to that pixel.

[0156] According to one or more embodiments of this disclosure, Example 4 provides the method of Example 1, wherein sampling from the specular image based on the texture offset corresponding to each pixel point to render the pixel points and obtain a rendered specular image includes:

[0157] Obtain the basic texture coordinate value corresponding to each pixel in the highlight image, wherein the basic texture coordinate value is the coordinate value corresponding to the light source vector and the viewing vector without offset;

[0158] The texture sampling coordinate value corresponding to each pixel is determined based on the texture offset corresponding to each pixel and the basic texture coordinate value.

[0159] The texture color value corresponding to the texture sampling coordinate value is sampled from the highlight image and used as the color value corresponding to the pixel.

[0160] The pixel is rendered based on the color value corresponding to each pixel to obtain the specular rendering image.

[0161] According to one or more embodiments of this disclosure, Example 5 provides the method of Example 4, wherein determining the texture sampling coordinate value corresponding to the pixel point based on the texture offset corresponding to each pixel point and the basic texture coordinate value includes:

[0162] Determine the sub-coordinate values ​​in the vertical direction of the base texture coordinate values ​​of each pixel;

[0163] For each pixel, the coordinate value obtained by subtracting the texture offset corresponding to the pixel from the sub-coordinate value is used as the updated coordinate value in the vertical direction, and the sub-coordinate value corresponding to the pixel is updated to the updated coordinate value to obtain the texture sampling coordinate value corresponding to the pixel.

[0164] According to one or more embodiments of this disclosure, Example 6 provides the method of Example 4, wherein determining the texture sampling coordinate value corresponding to the pixel point based on the texture offset corresponding to each pixel point and the basic texture coordinate value includes:

[0165] Determine the sub-coordinate values ​​in the vertical direction of the base texture coordinate values ​​of each pixel;

[0166] For each pixel, the target offset corresponding to the pixel is determined based on the texture offset corresponding to the pixel and the preset offset adjustment parameters.

[0167] For each pixel, the subtraction of the target offset corresponding to the pixel into the sub-coordinate value is used as the updated coordinate value in the vertical direction, and the sub-coordinate value corresponding to the pixel is updated to the updated coordinate value to obtain the texture sampling coordinate value corresponding to the pixel.

[0168] According to one or more embodiments of this disclosure, Example 7 provides a specular rendering apparatus, wherein the apparatus includes:

[0169] An acquisition module is used to acquire a specular image to be rendered, wherein the specular image contains a specular shape to be rendered.

[0170] The first processing module is used to determine the light source vector in the target coordinate space corresponding to the hair model based on the light source direction in world space.

[0171] The second processing module is used to determine the gaze vector corresponding to each pixel to be rendered in the hair model in the target coordinate space based on the gaze direction in the world space.

[0172] The determining module is used to determine, for each pixel, the texture offset of the pixel in the vertical direction corresponding to the horizontal direction in the highlight image, based on the light source vector and the viewing vector corresponding to the pixel.

[0173] The rendering module is used to sample from the specular image according to the texture offset corresponding to each pixel point, so as to render the pixel point and obtain the rendered specular image.

[0174] According to one or more embodiments of this disclosure, Example 8 provides the apparatus of Example 7, wherein the determining module includes:

[0175] The first determining submodule is used to determine the light source component of the light source vector in the vertical direction;

[0176] The second determining submodule is used to determine the viewing component of the viewing vector corresponding to each pixel in the vertical direction.

[0177] The third determining submodule is used to determine the texture offset corresponding to the pixel based on the light source component and the viewing component corresponding to each pixel.

[0178] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-6.

[0179] According to one or more embodiments of this disclosure, Example 10 provides an electronic device, which includes:

[0180] A storage device on which computer programs are stored;

[0181] A processing device for executing the computer program in the storage device to implement the steps of any one of the methods in Examples 1-6.

[0182] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0183] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0184] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.

Claims

1. A high light rendering method, characterized by, The method comprises: acquiring a highlight image to be rendered, wherein the highlight image has a highlight shape to be rendered drawn therein; determining a light vector in a target coordinate space corresponding to a hair model according to a light source direction in a world space; for each pixel point to be rendered in the hair model, determining a view line vector corresponding to the pixel point in the target coordinate space according to a view line direction in the world space; determining a light component of the light vector in a vertical direction corresponding to a horizontal direction in the highlight image, wherein the vertical direction is a vertical direction in the target coordinate space; for each pixel point, determining a view line component of the view line vector corresponding to the pixel point in the vertical direction; determining a texture offset corresponding to the pixel point according to the light component and the view line component corresponding to each pixel point; sampling from the highlight image according to the texture offset corresponding to each pixel point to render the pixel point, and obtaining a highlight rendering image after rendering.

2. The method of claim 1, wherein, The method comprises: determining a camera position coordinate in the target coordinate space according to a camera position in the world space; for each pixel point, taking a vector obtained by subtracting a position coordinate of the pixel point from the camera position coordinate as the view line vector corresponding to the pixel point after normalization processing.

3. The method of claim 1, wherein, The method comprises: acquiring a basic texture coordinate value corresponding to each pixel point in the highlight image, wherein the basic texture coordinate value is a coordinate value corresponding to the light vector and the view line vector without offset; determining a texture sampling coordinate value corresponding to the pixel point according to the texture offset corresponding to each pixel point and the basic texture coordinate value; sampling a texture color value corresponding to the texture sampling coordinate value from the highlight image as a color value corresponding to the pixel point; rendering the pixel point based on the color value corresponding to each pixel point to obtain the highlight rendering image.

4. The method of claim 3, wherein, The method comprises: determining a sub-coordinate value of the basic texture coordinate value of each pixel point in the vertical direction; for each pixel point, taking a coordinate value obtained by subtracting the texture offset corresponding to the pixel point from the sub-coordinate value corresponding to the pixel point as an updated coordinate value in the vertical direction, and updating the sub-coordinate value corresponding to the pixel point to the updated coordinate value to obtain the texture sampling coordinate value corresponding to the pixel point.

5. The method of claim 3, wherein, The method comprises: determining a sub-coordinate value of the basic texture coordinate value of each pixel point in the vertical direction; For each of the pixel points, a target offset of the pixel point is determined according to a texture offset corresponding to the pixel point and a preset offset adjustment parameter; For each of the pixel points, a coordinate value obtained by subtracting the target offset corresponding to the pixel point from the sub-coordinate value corresponding to the pixel point is taken as an updated coordinate value in the vertical direction, and the sub-coordinate value corresponding to the pixel point is updated to the updated coordinate value, so as to obtain a texture sampling coordinate value corresponding to the pixel point.

6. A high light rendering apparatus characterized by comprising: The device comprises: An acquisition module configured to acquire a highlight image to be rendered, wherein the highlight image has a highlight shape to be rendered drawn therein; A first processing module configured to determine a light vector in a target coordinate space corresponding to a hair model according to a light direction in a world space; A second processing module configured to, for each pixel point to be rendered in the hair model, determine a view vector corresponding to the pixel point in the target coordinate space according to a view direction in the world space; A determination module configured to, for each of the pixel points, determine a texture offset in a vertical direction corresponding to a horizontal direction of the pixel point in the highlight image according to the light vector and the view vector corresponding to the pixel point, wherein the vertical direction is a vertical direction in the target coordinate space; A rendering module configured to sample the highlight image according to the texture offset corresponding to each of the pixel points to render the pixel points, so as to obtain a rendered highlight rendering image. The determination module comprises: A first determination submodule configured to determine a light component of the light vector in the vertical direction; A second determination submodule configured to, for each of the pixel points, determine a view component of the view vector corresponding to the pixel point in the vertical direction; A third determination submodule configured to determine the texture offset corresponding to each of the pixel points according to the light component and the view component corresponding to each of the pixel points.

7. A computer readable medium having stored thereon a computer program, characterized in that The program is executed by the processing device to implement the steps of the method of any one of claims 1-5.

8. An electronic device, comprising: Comprise: A storage device having a computer program stored thereon; A processing device configured to execute the computer program in the storage device to implement the steps of the method of any one of claims 1-5.

Citation Information

Patent Citations

  • Method for rendering contour edges of models

    CN102708585A

  • Virtual hair processing method and device, readable storage medium and electronic equipment

    CN113379885A

  • Hair highlight rendering method, device and equipment and storage medium

    CN113763526A