Dispersion effect generation method and device and electronic equipment

By using the viewing angle direction and material normal to determine the reflection vector in the dispersion effect generation method, and combining the superposition technology of environmental map and spectral color, the problem of poor flexibility in the presentation method of dispersion effect in the existing technology is solved, significantly improving the visual expression.

CN119919554APending Publication Date: 2025-05-02NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411885169.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, the presentation method of dispersion effect is less flexible, resulting in poor visual expression.

Method used

The reflection vector is determined based on the viewing angle direction and the material normal of the target model, and the reflection color is sampled from the environment map based on the reflection vector, and multiple spectral colors are generated based on the viewing angle direction, the material normal and the dispersion effect offset. Finally, these colors are superimposed and rendered to the target model surface to generate a dispersion effect.

Benefits of technology

The display position of the dispersion effect changes with the line of sight, which improves the visual expression and flexibility of the dispersion effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919554A_ABST
    Figure CN119919554A_ABST
Patent Text Reader

Abstract

The invention provides a dispersion effect generation method and device and electronic equipment, and the method comprises the steps: determining a reflection vector of the surface of a target model based on a visual angle direction and a material normal of the target model; adding noise to the reflection vector, and sampling from a preset environment map based on the reflection vector after the noise is added to obtain a reflection color; generating a plurality of spectral colors based on the view angle direction, the material normal and a preset dispersion effect offset; and superposing the plurality of spectral colors and the reflection colors to obtain a superposed color, and rendering the superposed color to the surface of the target model to obtain a dispersion effect. In the mode, when the direction of the visual angle is changed, the reflection color sampled from the environment map is also changed, so that the display position of the dispersion effect rendered to the surface of the target model is changed, the presentation mode of the dispersion effect is more flexible, and the visual expressive force of the dispersion effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device and electronic equipment for generating a dispersion effect. Background Art

[0002] The dispersion effect refers to the rainbow-like visual effect presented by the surface of an object under the illumination of light. In the related art, the dynamic dispersion effect can be simulated in the entire area or a fixed local area of ​​the surface of an object through the dispersion algorithm or the map perturbation method, but the presentation method of the dispersion effect is less flexible, resulting in poor visual expression of the dispersion effect. Summary of the invention

[0003] In view of this, an object of the present invention is to provide a method, device and electronic device for generating a dispersion effect, so as to make the presentation of the dispersion effect more flexible and enhance the visual expressiveness of the dispersion effect.

[0004] In a first aspect, an embodiment of the present invention provides a method for generating a dispersion effect, the method comprising: determining a reflection vector of a target model surface based on a viewing direction and a material normal of the target model; wherein the reflection vector is used to: indicate a direction of reflected light on the target model surface; based on the reflection vector, sampling a reflection color from a preset environment map; based on the viewing direction, the material normal and a preset dispersion effect offset, generating multiple spectral colors; superimposing the multiple spectral colors with the reflection color to obtain a superimposed color, and rendering the superimposed color to the target model surface to obtain a dispersion effect.

[0005] In a second aspect, an embodiment of the present invention further provides a device for generating a dispersion effect, the device comprising: a reflection vector determination module, for determining a reflection vector of a target model surface based on a viewing direction and a material normal of the target model; wherein the reflection vector is used to: indicate a direction of reflected light on the target model surface; a reflection color sampling module, for sampling a reflection color from a preset environment map based on the reflection vector; a spectral color generation module, for generating multiple spectral colors based on a viewing direction, a material normal and a preset dispersion effect offset; and a superimposed color rendering module, for superimposing multiple spectral colors with the reflection color to obtain a superimposed color, and rendering the superimposed color to the target model surface to obtain a dispersion effect.

[0006] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned method for generating the dispersion effect.

[0007] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned method for generating the dispersion effect.

[0008] The embodiments of the present invention bring the following beneficial effects:

[0009] The above-mentioned method, device and electronic device for generating dispersion effect determine the reflection vector of the target model surface based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light on the target model surface; based on the reflection vector, sample the reflection color from a preset environment map; based on the viewing direction, the material normal and the preset dispersion effect offset, generate multiple spectral colors; superimpose the multiple spectral colors with the reflection color to obtain the superimposed color, and render the superimposed color to the target model surface to obtain the dispersion effect.

[0010] In this method, the reflection vector is affected by the viewing direction, and the reflection color is sampled from the environment map by the reflection vector. Therefore, the reflection color is affected by the viewing direction. Based on this, when the viewing direction changes, the reflection color sampled from the environment map will also change accordingly, which can change the display position of the dispersion effect rendered to the surface of the target model. The presentation method of the dispersion effect is more flexible, which improves the visual expressiveness of the dispersion effect.

[0011] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0012] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0014] Figure 1 A schematic diagram of the dispersion effect on the surface of a real object provided in the related art;

[0015] Figure 2A schematic diagram of the dispersion effect of a soap bubble surface provided in the related art;

[0016] Figure 3 A flow chart of a method for generating a dispersion effect provided by an embodiment of the present invention;

[0017] Figure 4 A schematic structural diagram of a device for generating a dispersion effect provided by an embodiment of the present invention;

[0018] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0020] For ease of understanding, some terms involved in the present invention are explained below:

[0021] Dispersion: Also known as the iridescence effect, it refers to the effect that some materials show a variety of different colors under different light angles.

[0022] Environment Map: Also known as cube map, the technology of using environment map is called environment mapping. When creating an environment map, you only need to paste the six faces of the environment map to the corresponding faces of the cube. Using environment map can add more realistic reflection effects to objects without the need for complex ray tracing calculations.

[0023] The dispersion effect refers to the rainbow-like visual effect presented by the surface of an object under the illumination of light, such as Figure 1 In the related art, the dynamic dispersion effect can be simulated in the entire area or a fixed local area of ​​the object surface through the dispersion algorithm or the map perturbation method. Figure 2 In the example shown, the dispersion of the soap bubble surface is simulated by reading a disturbed color noise image, but this method cannot control the position of the soap bubble surface where the dispersion effect appears to change with the movement of the line of sight.

[0024] In the above manners, the dispersion effect presentation method has poor flexibility, resulting in poor visual expression of the dispersion effect.

[0025] Based on this, a method, device and electronic device for generating a dispersion effect provided by an embodiment of the present invention can be applied to a model surface so that the display position of the dispersion effect changes with the line of sight.

[0026] To facilitate understanding of this embodiment, a method for generating a dispersion effect disclosed in an embodiment of the present invention is first introduced in detail. Figure 3 As shown, the method comprises the following steps:

[0027] Step S302, determining a reflection vector of the surface of the target model based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light of the surface of the target model;

[0028] The viewing direction may be obtained by calculating vertex data input in the vertex shader stage and camera data, for example, by normalizing the camera direction and the vertex direction of the target model.

[0029] The target model usually stores preset map data such as environment map, material roughness map, material normal map, etc. in the system.

[0030] Specifically, the built-in reflect function of the shader language can be used to calculate the reflection vector of the target model surface according to the viewing direction and the material normal, and the direction of the reflected light on the target model surface is indicated by the reflection vector; that is, when the viewing angle changes, the reflection vector also changes, that is, the reflection vector is affected by the viewing direction.

[0031] For example, the shader language may be GLSL (OpenGL Shading Language) or HLSL (High-Level Shading Language), and the built-in reflect function of the shader language may return a reflection vector of an incident light ray i in the viewing direction to a material normal n on the surface of a target model according to the viewing direction and the material normal.

[0032] Step S304, based on the reflection vector, sampling from a preset environment map to obtain the reflection color;

[0033] Specifically, the reflection vector is converted into a three-dimensional mapping coordinate space, and the converted reflection vector is projected onto the six faces of the cube corresponding to the mapping coordinate space to obtain the mapping coordinate data of the reflection vector, that is, the equilateral rectangular UV coordinate; according to the mapping coordinate data, the preset environment map mapped to the cube is sampled to obtain the reflection color.

[0034] It can be understood that the environment map is sampled through the reflection vector to obtain the reflection color, and thus the reflection color is affected by the viewing direction. When the viewing direction changes, the reflection color sampled from the environment map will also change accordingly.

[0035] In one implementation, the sampling resolution level is determined according to a preset roughness map, and the preset environment map is sampled at the sampling resolution level corresponding to the map coordinate data to obtain the reflected color; the reflected color can be further converted to a linear space to be more consistent with a physically accurate lighting model.

[0036] Optionally, before sampling the reflection color, the reflection vector is rotated along a specified dimension to simulate the change in direction of reflected light on the surface of the target model in a dynamic environment where the camera moves in the virtual space; noise is added to the rotated reflection vector to randomly perturb the reflection vector.

[0037] In the above method, the environment map is sampled through the reflection vector to obtain the reflection color, so the reflection color is affected by the viewing direction.

[0038] Step S306, generating a plurality of spectral colors based on the viewing direction, the material normal and the preset dispersion effect offset;

[0039] Specifically, the interpolation ratio is controlled according to the preset hue frequency, and the material normal and the preset default material are interpolated according to the determined interpolation ratio to obtain the surface normal of the target model. The angle of the original normal can be adjusted to affect the dispersion effect.

[0040] Then, the wavelength factor is calculated according to the surface normal, the viewing direction and the preset dispersion effect offset, and the wavelength factor is applied to the calculation of the spectral color to generate multiple spectral colors. Here, the reflection of different light wavelengths can be affected by the wavelength factor; it can be understood that when the viewing direction changes, the wavelength factor also changes accordingly, so that the target model surface presents a rainbow-like visual effect affected by the viewing direction when illuminated by light.

[0041] Step S308, superimposing the multiple spectral colors and the reflected color to obtain a superimposed color, and rendering the superimposed color to the surface of the target model to obtain a dispersion effect.

[0042] Specifically, a product operation is performed on multiple spectral color values ​​and reflective color values ​​to obtain a superimposed color result.

[0043] Optionally, the light direction is extracted from the light source data. For example, in PBR (Physically-Based Rendering), the lighting data, that is, the data of the ambient lighting in the environment where the target model is located, is pre-calculated. Here, the light direction can be directly obtained from the game engine, and then the ambient light is calculated based on the light direction.

[0044] Here, the surface of the target model can be rendered according to the overlaid color and ambient light to obtain a dispersion effect with richer artistic expression. In an example, the overlaid color is rendered to the surface of the target model to obtain a dispersion effect of a strip area, and the display position of this strip area will change with the viewing direction.

[0045] Through the above methods, specific artistic expressions can be achieved.

[0046] The above-mentioned method for generating the dispersion effect determines the reflection vector of the target model surface based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light on the target model surface; based on the reflection vector, sample the reflection color from the preset environment map; based on the viewing direction, the material normal and the preset dispersion effect offset, generate multiple spectral colors; superimpose the multiple spectral colors with the reflection color to obtain the superimposed color, and render the superimposed color to the target model surface to obtain the dispersion effect. In this method, the reflection vector is affected by the viewing direction, and the reflection color is sampled from the environment map by the reflection vector. Therefore, the reflection color is affected by the viewing direction. Based on this, when the viewing direction changes, the reflection color sampled from the environment map will also change accordingly, which can change the display position of the dispersion effect rendered to the target model surface, and the presentation method of the dispersion effect is more flexible, which improves the visual expression of the dispersion effect.

[0047] The following embodiments provide a specific implementation method for rotating the reflection vector and adding noise.

[0048] In one approach, the reflection vector is rotated along a specified dimension, and noise is added to the rotated reflection vector.

[0049] The specified dimension can generally be a vertical axis Y axis, a horizontal axis X axis, and a horizontal axis Z axis in a three-dimensional coordinate system.

[0050] Specifically, the reflection vector is rotated along the specified dimension. For example, the reflection vector is rotated around the vertical axis Y-axis through the RotateY function without deforming the reflection vector. Then, noise is added to the rotated reflection vector to obtain a randomly perturbed reflection vector.

[0051] In the above manner, the reflection vector is rotated to simulate the change in direction of the reflected light on the surface of the target model in a dynamic environment where the camera moves in the virtual space.

[0052] Furthermore, a noise vector is generated based on the input texture coordinates, the current time parameter and the preset noise parameter; and the noise vector is added to the specified component of the reflection vector after the rotation processing.

[0053] The current time parameter usually refers to the animation frame time, game match time, etc. The specified component can usually be the x-axis component, y-axis component, and z-axis component of the reflection vector. The preset noise parameters can specifically include noise tiling value, noise disturbance speed, and noise disturbance intensity. The noise parameters can usually be adjusted according to user needs.

[0054] Specifically, a two-dimensional noise vector can be generated by inputting texture coordinates, current time parameters and preset noise parameters for the target model; the noise vector is added to specified components of the reflection vector after the rotation processing, such as the x-axis component and y-axis component of the reflection vector after the rotation processing, to simulate the dynamic effect of the surface of the target model, or the reflection effect on a rough material.

[0055] The noise parameters include: a noise tiling value and a noise disturbance speed. Further, the product of the input texture coordinates and the noise tiling value is used as the first parameter component; the product of the current time parameter and the noise disturbance speed is used as the second parameter component; the sum of the first parameter component and the second parameter component is input into a preset noise function, and a noise vector is output.

[0056] For example, the input texture coordinate input.uv and the noise tiling value are multiplied to obtain the first parameter component; at the same time, the current time parameter and the noise disturbance speed are multiplied to obtain the second parameter component. Then, the first parameter component and the second parameter component are added, and the result of the addition operation is input into the preset noise function noise2 to output a two-dimensional noise vector.

[0057] In one method, a noise superposition amount is determined based on a noise vector and a preset noise disturbance intensity; and the noise superposition amount is superimposed on a specified component of the reflection vector after the rotation processing.

[0058] For example, a product operation is performed on the noise vector and the preset noise disturbance intensity to obtain a noise superposition amount, and the x-axis component and y-axis component of the reflection vector are superimposed on the noise superposition amount. For example, the noise superposition amount and the x-axis component of the rotated reflection vector are added to obtain the rotated reflection vector with a disturbed x-axis component, and the noise superposition amount and the y-axis component of the rotated reflection vector are added to obtain the rotated reflection vector with a disturbed y-axis component.

[0059] In the above method, adding the noise vector to the specified component of the reflection vector after the rotation processing can disturb the reflection vector and simulate the dynamic effect of the surface of the target model, such as a dynamic water surface or the reflection effect on a rough material.

[0060] The following embodiment provides a specific implementation method for sampling the reflection color from the environment map.

[0061] In one method, the reflection vector is converted into a texture coordinate space to obtain texture coordinate data corresponding to the reflection vector; based on the texture coordinate data, the reflection color is sampled from a preset environment map.

[0062] The mapping coordinate space usually refers to the coordinate space of the mapped cube after mapping the preset environment map to each face of the cube.

[0063] Specifically, after the system converts the reflection vector to the mapping coordinate space, it obtains the mapping coordinate data corresponding to the reflection vector in the mapping coordinate space, and obtains the UV coordinates of the equirectangular mapping, hereinafter referred to as the equirectangular UV coordinates; according to the environment map of the cube mapped to the three-dimensional scene and the equirectangular UV coordinates, the preset environment map is sampled to obtain the reflection color.

[0064] It can be understood that the reflected color is affected by the texture coordinate data corresponding to the reflection vector, and thus the reflected color is affected by the viewing angle direction corresponding to the reflection vector.

[0065] Furthermore, based on the preset roughness map, the sampling resolution level is determined; based on the map coordinate data and the sampling resolution level, the preset environment map is sampled to obtain the reflection color.

[0066] The roughness map of this preset is usually used to sample textures with different levels of detail. The sampling resolution level is usually set according to the roughness. If the roughness is higher, the sampling resolution level will be higher, that is, the resolution will be lower, resulting in a blurrier reflection effect.

[0067] Specifically, the system calculates the required sampling resolution level based on the preset roughness map, and then can sample the preset environment map according to the equirectangular UV coordinates and the sampling resolution level to obtain the reflected color, and set the resolution corresponding to the sampling resolution level for the reflected color.

[0068] In the above method, sampling the environment map according to the sampling resolution level can add a blurring effect to the reflected color.

[0069] In one method, the reflected color is converted from the current color space to linear space.

[0070] For example, the sampled reflection color is converted from the RGB color space to the linear space, that is, the reflection color is converted to a space where the color changes according to a linear gradient.

[0071] By converting the reflected color into linear space and rendering the target model, we can get a lighting effect that is closer to the real physical world.

[0072] The following embodiments provide specific implementations for generating multiple spectral colors.

[0073] In one method, the surface normal of the target model is determined based on the material normal and a preset hue frequency; the wavelength factor is determined based on the surface normal, the viewing direction, and a preset dispersion effect offset; and multiple spectral colors are generated based on the wavelength factor.

[0074] The hue frequency and dispersion effect offset can usually be adjusted according to user needs.

[0075] Specifically, the interpolation ratio is controlled according to the preset hue frequency, and the material normal and the preset default material are interpolated according to the determined interpolation ratio to obtain the surface normal of the target model. The angle of the original normal can be adjusted to affect the dispersion effect.

[0076] Then, the wavelength factor is calculated according to the surface normal, viewing angle direction and the preset dispersion effect offset, and the wavelength factor is used for spectral calculation. The wavelength factor can affect the reflection of different light wavelengths to generate multiple spectral colors.

[0077] Here, the system first initializes the spectral color. After the initialization, each pixel in the spectrum has a specified color value, making the spectrum appear black. Then, the color value of the pixel corresponding to each wavelength in the spectrum is calculated to obtain the color corresponding to each wavelength in the spectrum.

[0078] For example, the loop variable i is looped according to the specified number of times set for the loop variable i to simulate different wavelength ranges of the spectrum; the wavelength factor and the loop variable i are calculated to obtain the wavelength value, and then the wavelength value can be calculated through the spectral tool to generate the color corresponding to each wavelength and accumulate it into the spectrum.

[0079] In the above manner, the spectral color is generated according to the wavelength factor, and thus the spectral color is affected by the viewing angle direction corresponding to the wavelength factor.

[0080] Furthermore, an interpolation ratio is determined based on a preset hue frequency; and according to the interpolation ratio, the material normal and the preset default normal are interpolated to obtain the surface normal of the target model.

[0081] For example, the interpolation ratio is adjusted by the preset hue frequency control, and then the material normal and the preset default normal are interpolated using the lerp function according to the determined interpolation ratio to obtain the surface normal of the target model. The default normal can be (0.0f, 1.0f, 0.0f), where f is used to store the target factor related to the iridescence effect, and f is initialized to 0.

[0082] By performing interpolation processing in the above manner, the angle of the original normal line of the target model surface can be adjusted, thereby affecting the dispersion effect.

[0083] Furthermore, an angle factor is determined based on the surface normal and the viewing angle direction; and a wavelength factor is determined based on the angle factor and a preset dispersion effect offset.

[0084] Specifically, a dot product operation is performed on the surface normal and the viewing angle direction to obtain an angle factor; by multiplying the first specified value and the preset dispersion effect offset, the offset ratio is adjusted, and then the second specified value, the angle factor and the dispersion effect offset after the offset ratio is adjusted are multiplied to obtain a wavelength factor affected by the viewing angle direction.

[0085] In one approach, multiple spectral colors are adjusted based on a preset dispersion intensity parameter; wherein the adjusted multiple spectral colors are within a preset color range.

[0086] The dispersion intensity parameter can usually be adjusted according to user needs, and the preset range is usually between 0 and 1.

[0087] Specifically, the dispersion intensities of the multiple spectral colors are adjusted by multiplying the multiple spectral colors with the preset dispersion intensity parameter. If the adjusted dispersion intensity is greater than 1, this value is applied; if the adjusted dispersion intensity is less than or equal to 1, the dispersion intensity is maintained at 1.

[0088] Here, the saturate function can be used to operate on multiple spectral colors, limiting the values ​​of multiple spectral colors between 0 and 1 to prevent multiple spectral colors from exceeding the preset color range.

[0089] For the above method embodiments, see Figure 4 A schematic diagram of a device for generating a dispersion effect is shown; the device comprises:

[0090] The reflection vector determination module 401 is used to determine the reflection vector of the surface of the target model based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light on the surface of the target model;

[0091] A reflection color sampling module 402 is used to sample the reflection color from a preset environment map based on the reflection vector;

[0092] The spectrum color generation module 403 is used to generate multiple spectrum colors based on the viewing direction, the material normal and the preset dispersion effect offset;

[0093] The superimposed color rendering module 404 is used to superimpose multiple spectral colors with the reflected color to obtain a superimposed color, and render the superimposed color to the surface of the target model to obtain a dispersion effect.

[0094] The above-mentioned dispersion effect generation device determines the reflection vector of the target model surface based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light on the target model surface; based on the reflection vector, sample the reflection color from the preset environment map; based on the viewing direction, the material normal and the preset dispersion effect offset, generate multiple spectral colors; superimpose the multiple spectral colors with the reflection color to obtain the superimposed color, and render the superimposed color to the target model surface to obtain the dispersion effect. In this method, the reflection vector is affected by the viewing direction, and the reflection color is sampled from the environment map by the reflection vector. Therefore, the reflection color is affected by the viewing direction. Based on this, when the viewing direction changes, the reflection color sampled from the environment map will also change accordingly, which can change the display position of the dispersion effect rendered to the target model surface, and the presentation method of the dispersion effect is more flexible, which improves the visual expression of the dispersion effect.

[0095] The above-mentioned device also includes a rotation and noise adding module, which is used to rotate the reflection vector along a specified dimension and add noise to the reflection vector after the rotation processing.

[0096] The rotation and noise adding module is further used to generate a noise vector based on the input texture coordinates, current time parameters and preset noise parameters; and add the noise vector to a specified component of the reflection vector.

[0097] The above-mentioned noise parameters include: noise tiling value and noise disturbance speed; the above-mentioned rotation and noise adding module is also used to take the product of the input texture coordinates and the noise tiling value as the first parameter component; take the product of the current time parameter and the noise disturbance speed as the second parameter component; input the sum of the first parameter component and the second parameter component into a preset noise function, and output a noise vector.

[0098] The rotation and noise adding module is further used to determine the noise superposition amount based on the noise vector and the preset noise disturbance intensity; and to superimpose the noise superposition amount onto the specified component of the reflection vector.

[0099] The above-mentioned reflection color sampling module is also used to convert the reflection vector into a mapping coordinate space to obtain mapping coordinate data corresponding to the reflection vector; based on the mapping coordinate data, the reflection color is sampled from a preset environment map.

[0100] The above-mentioned reflection color sampling module is also used to determine the sampling resolution level based on the preset roughness map; based on the map coordinate data and the sampling resolution level, the preset environment map is sampled to obtain the reflection color.

[0101] The above device also includes a reflection color conversion module, which is used to convert the reflection color from the current color space to the linear space.

[0102] The above-mentioned spectral color generation module is also used to determine the surface normal of the target model based on the material normal and the preset hue frequency; determine the wavelength factor based on the surface normal, the viewing direction and the preset dispersion effect offset; and generate multiple spectral colors based on the wavelength factor.

[0103] The spectral color generation module is further used to determine an interpolation ratio based on a preset hue frequency; according to the interpolation ratio, the material normal and the preset default normal are interpolated to obtain the surface normal of the target model.

[0104] The spectral color generation module is also used to determine the angle factor based on the surface normal and the viewing angle direction; and to determine the wavelength factor based on the angle factor and a preset dispersion effect offset.

[0105] The above-mentioned device also includes a spectral color adjustment module, which is used to adjust multiple spectral colors based on a preset dispersion intensity parameter; wherein the adjusted multiple spectral colors are within a preset color range.

[0106] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned method for generating the dispersion effect. The electronic device can be a server or a terminal device.

[0107] See also Figure 5 As shown, the electronic device includes a processor 100 and a memory 101, wherein the memory 101 stores computer executable instructions that can be executed by the processor 100, and the processor 100 executes the computer executable instructions to implement the above-mentioned method for generating the dispersion effect.

[0108] Further, Figure 5 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .

[0109] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0110] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.

[0111] The processor in the electronic device can implement the following operations in the method for generating the dispersion effect by executing computer executable instructions:

[0112] Based on the viewing direction and the material normal of the target model, a reflection vector of the target model surface is determined; wherein the reflection vector is used to: indicate the direction of reflected light on the target model surface; based on the reflection vector, a reflection color is sampled from a preset environment map; based on the viewing direction, the material normal and a preset dispersion effect offset, a plurality of spectral colors are generated; the plurality of spectral colors are superimposed on the reflection color to obtain a superimposed color, and the superimposed color is rendered to the target model surface to obtain a dispersion effect.

[0113] Rotates the reflection vector along the specified dimension and adds noise to the rotated reflection vector.

[0114] A noise vector is generated based on the input texture coordinates, the current time parameters and the preset noise parameters; and the noise vector is added to the specified component of the rotated reflection vector.

[0115] The above-mentioned noise parameters include: noise tiling value and noise disturbance speed; the product of the input texture coordinates and the noise tiling value is used as the first parameter component; the product of the current time parameter and the noise disturbance speed is used as the second parameter component; the sum of the first parameter component and the second parameter component is input into a preset noise function, and a noise vector is output.

[0116] Based on the noise vector and the preset noise disturbance intensity, the noise superposition amount is determined; and the noise superposition amount is superimposed on the specified component of the reflection vector after the rotation processing.

[0117] The reflection vector is converted to the texture coordinate space to obtain the texture coordinate data corresponding to the reflection vector; based on the texture coordinate data, the reflection color is sampled from the preset environment map.

[0118] Based on the preset roughness map, the sampling resolution level is determined; based on the map coordinate data and the sampling resolution level, the preset environment map is sampled to obtain the reflection color.

[0119] Converts the reflected color from the current color space to linear space.

[0120] Based on the material normal and the preset hue frequency, the surface normal of the target model is determined; based on the surface normal, the viewing direction and the preset dispersion effect offset, the wavelength factor is determined; based on the wavelength factor, multiple spectral colors are generated.

[0121] An interpolation ratio is determined based on a preset hue frequency; according to the interpolation ratio, the material normal and the preset default normal are interpolated to obtain the surface normal of the target model.

[0122] An angle factor is determined based on the surface normal and the viewing angle direction; and a wavelength factor is determined based on the angle factor and a preset dispersion effect offset.

[0123] Based on a preset dispersion intensity parameter, multiple spectral colors are adjusted; wherein the adjusted multiple spectral colors are within a preset color range.

[0124] In the above method, the reflection vector is affected by the viewing direction, and the reflection color is sampled from the environment map by the reflection vector. Therefore, the reflection color is affected by the viewing direction. Based on this, when the viewing direction changes, the reflection color sampled from the environment map will also change accordingly, which can change the display position of the dispersion effect rendered to the surface of the target model. The presentation method of the dispersion effect is more flexible, which improves the visual expression of the dispersion effect.

[0125] This embodiment also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned method for generating the dispersion effect.

[0126] The computer executable instructions stored in the computer readable storage medium can implement the following operations in the method for generating the dispersion effect by executing the computer executable instructions:

[0127] Based on the viewing direction and the material normal of the target model, a reflection vector of the target model surface is determined; wherein the reflection vector is used to: indicate the direction of reflected light on the target model surface; based on the reflection vector, a reflection color is sampled from a preset environment map; based on the viewing direction, the material normal and a preset dispersion effect offset, a plurality of spectral colors are generated; the plurality of spectral colors are superimposed on the reflection color to obtain a superimposed color, and the superimposed color is rendered to the target model surface to obtain a dispersion effect.

[0128] Rotates the reflection vector along the specified dimension and adds noise to the rotated reflection vector.

[0129] A noise vector is generated based on the input texture coordinates, the current time parameters and the preset noise parameters; and the noise vector is added to the specified component of the rotated reflection vector.

[0130] The above-mentioned noise parameters include: noise tiling value and noise disturbance speed; the product of the input texture coordinates and the noise tiling value is used as the first parameter component; the product of the current time parameter and the noise disturbance speed is used as the second parameter component; the sum of the first parameter component and the second parameter component is input into a preset noise function, and a noise vector is output.

[0131] Based on the noise vector and the preset noise disturbance intensity, the noise superposition amount is determined; and the noise superposition amount is superimposed on the specified component of the reflection vector after the rotation processing.

[0132] The reflection vector is converted to the texture coordinate space to obtain the texture coordinate data corresponding to the reflection vector; based on the texture coordinate data, the reflection color is sampled from the preset environment map.

[0133] Based on the preset roughness map, the sampling resolution level is determined; based on the map coordinate data and the sampling resolution level, the preset environment map is sampled to obtain the reflection color.

[0134] Converts the reflected color from the current color space to linear space.

[0135] Based on the material normal and the preset hue frequency, the surface normal of the target model is determined; based on the surface normal, the viewing direction and the preset dispersion effect offset, the wavelength factor is determined; based on the wavelength factor, multiple spectral colors are generated.

[0136] An interpolation ratio is determined based on a preset hue frequency; according to the interpolation ratio, the material normal and the preset default normal are interpolated to obtain the surface normal of the target model.

[0137] An angle factor is determined based on the surface normal and the viewing angle direction; and a wavelength factor is determined based on the angle factor and a preset dispersion effect offset.

[0138] Based on a preset dispersion intensity parameter, multiple spectral colors are adjusted; wherein the adjusted multiple spectral colors are within a preset color range.

[0139] In the above method, the reflection vector is affected by the viewing direction, and the reflection color is sampled from the environment map by the reflection vector. Therefore, the reflection color is affected by the viewing direction. Based on this, when the viewing direction changes, the reflection color sampled from the environment map will also change accordingly, which can change the display position of the dispersion effect rendered to the surface of the target model. The presentation method of the dispersion effect is more flexible, which improves the visual expression of the dispersion effect.

[0140] The computer program product of the method, device and electronic device for generating dispersion effect provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method described in the previous method embodiments. The specific implementation can be found in the method embodiments and will not be repeated here.

[0141] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0142] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0143] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0144] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0145] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for generating a dispersion effect, characterized in that: The method comprises: Determine a reflection vector of the surface of the target model based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light of the surface of the target model; Based on the reflection vector, sampling from a preset environment map to obtain a reflection color; Generate a plurality of spectral colors based on the viewing direction, the material normal, and a preset dispersion effect offset; The multiple spectral colors are superimposed on the reflection color to obtain a superimposed color, and the superimposed color is rendered to the surface of the target model to obtain a dispersion effect.

2. The method according to claim 1, characterized in that Before the step of sampling the reflection color from a preset environment map based on the reflection vector, the method further includes: The reflection vector is rotated along a specified dimension, and noise is added to the rotated reflection vector.

3. The method according to claim 2, characterized in that The step of adding noise to the reflection vector after the rotation process comprises: Generate a noise vector based on the input texture coordinates, current time parameters and preset noise parameters; The noise vector is added to a specified component of the rotated reflection vector.

4. The method according to claim 3, characterized in that The noise parameters include: a noise tiling value and a noise disturbance speed; the step of generating a noise vector based on the input texture coordinates, the current time parameters and the preset noise parameters includes: Taking the product of the input texture coordinate and the noise tile value as the first parameter component; The product of the current time parameter and the noise disturbance speed is used as the second parameter component; The sum of the first parameter component and the second parameter component is input into a preset noise function, and a noise vector is output.

5. The method according to claim 3, characterized in that: The step of adding the noise vector to a specified component of the reflection vector after the rotation process comprises: Determining a noise superposition amount based on the noise vector and a preset noise disturbance intensity; The noise superposition amount is superimposed on a designated component of the reflection vector after the rotation process.

6. The method according to claim 1, characterized in that The step of sampling the reflection color from a preset environment map based on the reflection vector comprises: Convert the reflection vector to a texture coordinate space to obtain texture coordinate data corresponding to the reflection vector; Based on the map coordinate data, the reflection color is sampled from a preset environment map.

7. The method according to claim 6, characterized in that The step of sampling the reflection color from a preset environment map based on the map coordinate data comprises: Based on the preset roughness map, determine the sampling resolution level; Based on the map coordinate data and the sampling resolution level, a preset environment map is sampled to obtain a reflection color.

8. The method according to claim 6, characterized in that After the step of sampling the reflection color from a preset environment map based on the map coordinate data, the method further comprises: Converts the reflected color from the current color space to linear space.

9. The method according to claim 1, characterized in that: The step of generating a plurality of spectral colors based on the viewing direction, the material normal and a preset dispersion effect offset comprises: Determining a surface normal of the target model based on the material normal and a preset hue frequency; Determining a wavelength factor based on the surface normal, the viewing angle direction, and a preset dispersion effect offset; Based on the wavelength factors, a plurality of spectral colors are generated.

10. The method according to claim 9, characterized in that The step of determining the surface normal of the target model based on the material normal and a preset hue frequency comprises: Determine the interpolation ratio based on the preset hue frequency; The material normal and the preset default normal are interpolated according to the interpolation ratio to obtain the surface normal of the target model.

11. The method according to claim 9, characterized in that The step of determining a wavelength factor based on the surface normal, the viewing angle direction and a preset dispersion effect offset comprises: determining an angle factor based on the surface normal and the viewing direction; Based on the angle factor and a preset dispersion effect offset, a wavelength factor is determined.

12. The method according to claim 9, characterized in that After the step of generating a plurality of spectral colors based on the viewing direction, the material normal and the preset dispersion effect offset, the method further comprises: Based on a preset dispersion intensity parameter, the multiple spectral colors are adjusted; wherein the adjusted multiple spectral colors are within a preset color range.

13. A device for generating a dispersion effect, characterized in that: The device comprises: A reflection vector determination module, used to determine the reflection vector of the surface of the target model based on the viewing direction and the material normal of the target model; wherein the reflection vector is used to: indicate the direction of the reflected light of the surface of the target model; A reflection color sampling module, used for sampling the reflection color from a preset environment map based on the reflection vector; A spectral color generation module, used for generating a plurality of spectral colors based on the viewing direction, the material normal and a preset dispersion effect offset; The superimposed color rendering module is used to superimpose the multiple spectral colors with the reflected color to obtain a superimposed color, and render the superimposed color to the surface of the target model to obtain a dispersion effect.

14. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method for generating the dispersion effect according to any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method for generating the dispersion effect according to any one of claims 1 to 12.