CN116797709A - Method, system, terminal and medium for scanning three-dimensional model of Web terminal - Google Patents

Method, system, terminal and medium for scanning three-dimensional model of Web terminal Download PDF

Info

Publication number
CN116797709A
CN116797709A CN202310795673.XA CN202310795673A CN116797709A CN 116797709 A CN116797709 A CN 116797709A CN 202310795673 A CN202310795673 A CN 202310795673A CN 116797709 A CN116797709 A CN 116797709A
Authority
CN
China
Prior art keywords
pixel
dimensional model
sweeping
color
light
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310795673.XA
Other languages
Chinese (zh)
Inventor
盛建鲁
张健
魏文凤
付港
杨泉林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Intelligent Technology Co Ltd
Original Assignee
Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Intelligent Technology Co Ltd filed Critical Inspur Intelligent Technology Co Ltd
Priority to CN202310795673.XA priority Critical patent/CN116797709A/en
Publication of CN116797709A publication Critical patent/CN116797709A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Generation (AREA)

Abstract

The invention relates to the field of three-dimensional model light sweeping, and particularly discloses a Web end three-dimensional model light sweeping method, a Web end three-dimensional model light sweeping system, a Web end three-dimensional model light sweeping terminal and a Web end three-dimensional model light sweeping medium, and a three-dimensional model rendering environment is initialized; creating a shader material; defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value; transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters; and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect. The light sweeping effect can be changed by adjusting the light sweeping behavior parameters, the operation is convenient, the display color is adjusted based on the pixel position and the illumination environment, the interaction with the scene environment is realized, and the light sweeping effect is optimized.

Description

Method, system, terminal and medium for scanning three-dimensional model of Web terminal
Technical Field
The invention relates to the field of three-dimensional model light sweeping, in particular to a method, a system, a terminal and a medium for sweeping a Web end three-dimensional model.
Background
A three-dimensional model is a polygonal representation of an object, typically displayed with a computer or other video device. The displayed object may be a real world entity or an imaginary object. The three-dimensional model is displayed on a user interface, and is generally processed and displayed for achieving a better display effect, and special effects are added to the three-dimensional model under certain scenes by carrying out special effect processing on the three-dimensional model. For example adding a light sweeping effect to the three-dimensional model.
In the three-dimensional model display process of the browser Web end, in order to achieve the light sweeping effect, a gif map is generally used, however, the gif map is not easy to change, especially in the current real-time 3D model rendering, the scene environment is changed, the gif map is fixed, interaction reflection with the scene cannot be carried out, and the light sweeping effect is poor.
The related technology uses special effect maps as textures of the shader, combines the textures of the original maps, and superimposes the special effect maps and the original maps on a display interface to form a display picture so as to construct a light sweeping effect, however, the special effect maps are inconvenient to change the light sweeping effect, and are inconvenient to interact with a scene.
Disclosure of Invention
In order to solve the problems, the invention provides a three-dimensional model light sweeping method of a Web end, which is characterized in that light sweeping behaviors are defined, pixel display colors are calculated according to pixel positions, illumination environments and light sweeping behavior parameters, the light sweeping is dynamic, the pixel display colors are changed in real time, the light sweeping effect is realized, the light sweeping effect can be changed by adjusting the light sweeping behavior parameters, the operation is convenient, the display colors are adjusted based on the pixel positions and the illumination environments, the interaction with scene environments is realized, and the light sweeping effect is optimized.
In a first aspect, the present invention provides a method for scanning a three-dimensional model of a Web terminal, including the following steps:
initializing a three-dimensional model rendering environment;
creating a shader material;
defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters;
and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
In an alternative embodiment, after transmitting the sweep behavior parameter to the shader, the method further includes the step of constructing a sweep circular radius array, specifically including:
initializing a sweep circular radius array to be [0];
the light sweeping circular shape is outwards diffused from the central point at a configuration rate, and the radius of the diffused light sweeping circular shape is updated to a light sweeping circular shape radius array in real time;
when the radius of the light sweeping circular shape reaches a diffusion radius threshold value, a light sweeping circular shape is newly added from a central point, all the light sweeping circular shapes continue to diffuse outwards at a configuration rate, and the radius of all the light sweeping circular shapes after diffusion is updated to a light sweeping circular shape radius array in real time;
and when the radius of the outermost sweep circle reaches the maximum radius threshold, removing the radius of the outermost sweep circle from the sweep circle radius array.
In an alternative embodiment, the method calculates the display color of each pixel of the three-dimensional model in real time according to the pixel position, the illumination environment and the scanning behavior parameters, and specifically includes the following steps:
converting the pixel coordinates into pixel world coordinates through a world coordinate transformation matrix;
calculating the distance between the pixel and the center point based on the world coordinates of the pixel, and marking the distance as Ln;
comparing the distance Ln with each radius in the light sweeping circular radius array, and judging the current target light sweeping circular of the pixel;
calculating the color of the pixel relative to the circle according to the current radius of the target sweep circle, wherein the color of the sweep light is recorded as rgb (R0, G0 and B0), and the color of the pixel relative to the circle is recorded as rgb (R0 (Ln/L0), G0 (Ln/L0) and B0 (Ln/L0)) when the current radius of the target sweep circle is recorded as L0;
the color of the pixel with respect to the circle is taken as the display color of the pixel.
In an optional implementation manner, the display color of each pixel of the three-dimensional model is calculated in real time according to the pixel position, the illumination environment and the scanning behavior parameters, and the method specifically further comprises the following steps:
calculating the illumination superposition color of the pixel;
multiplying the illumination superposition color of the pixel, the color of the pixel about the circle and the basic color of the pixel to obtain the mixed color of the pixel;
the mixed color of the pixels is taken as the display color of the pixels.
In an alternative embodiment, calculating the illumination superposition color of the pixel includes:
multiplying the normal vector of the pixel by the parallel light direction point to obtain reflection intensity;
the reflection intensity is multiplied by the diffuse reflection color to obtain the illumination superposition color of the pixel.
In an alternative embodiment, the method specifically includes:
defining a plurality of light sweeping behaviors;
calculating a display color for each sweep pixel for each pixel;
adding all display colors of the pixels to obtain a final display color of the pixels;
and transmitting the final display color of each pixel to the canvas in real time for display to present the three-dimensional model light sweeping effect.
In an alternative embodiment, initializing the three-dimensional model rendering environment specifically includes:
the scene, camera and light source are initialized.
In a second aspect, the present invention provides a three-dimensional model scanning system for a Web terminal, including,
an environment initialization module: initializing a three-dimensional model rendering environment;
the shader creation module: creating a shader material;
the light sweeping behavior definition module: defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
a display color calculation module: transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions and the scanning behavior parameters;
a display color presentation module: and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
In a third aspect, a technical solution of the present invention provides a terminal, including:
the memory is used for storing a three-dimensional model light sweeping program of the Web terminal;
and the processor is used for realizing the steps of the three-dimensional model light sweeping method of the Web end when executing the three-dimensional model light sweeping program of the Web end.
In a fourth aspect, the present invention provides a computer readable storage medium, where a Web-side three-dimensional model light sweeping program is stored, where the Web-side three-dimensional model light sweeping program when executed by a processor implements the steps of the Web-side three-dimensional model light sweeping method according to any one of the above claims.
The method, the system, the terminal and the medium for scanning the three-dimensional model of the Web terminal have the following beneficial effects compared with the prior art: define and sweep the light behavior, calculate the pixel according to pixel position, illumination environment and sweep the light behavior parameter and show the colour, sweep the light and be dynamic, and then the pixel shows the real-time change of colour, realize sweeping the light effect, sweep the light effect accessible adjustment and sweep the light behavior parameter change, the simple operation, and show the colour and adjust based on pixel position, illumination environment, realize with the interaction of scene environment, optimize and sweep the light effect.
Drawings
For a clearer description of embodiments of the invention or of the prior art, the drawings that are used in the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a method for scanning light by a three-dimensional model of a Web terminal according to an embodiment of the present invention.
FIG. 2 is a schematic illustration of the sweep effect on a test grid model.
Fig. 3 is a schematic block diagram of a three-dimensional model scanning system of a Web terminal according to an embodiment of the present invention.
Fig. 4 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to better understand the aspects of the present invention, the present invention will be described in further detail with reference to the accompanying drawings and detailed description. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Fig. 1 is a schematic flow chart of a method for scanning light by a three-dimensional model of a Web terminal according to an embodiment of the present invention. The execution body of fig. 1 may be a Web-end three-dimensional model light scanning system. The method for scanning the three-dimensional model of the Web end is executed by computer equipment, and accordingly, the system for scanning the three-dimensional model of the Web end runs in the computer equipment. The order of the steps in the flow chart may be changed and some may be omitted according to different needs.
As shown in fig. 1, the method includes the following steps.
S1, initializing a three-dimensional model rendering environment.
S2, creating a shader material.
S3, defining a light sweeping behavior, and configuring parameters of the light sweeping behavior, wherein the parameters comprise a light sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value.
And S4, transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters.
And S5, transmitting the display colors of the pixels to the canvas in real time for display, and displaying and presenting the three-dimensional model light sweeping effect.
According to the three-dimensional model light sweeping method of the Web terminal, the light sweeping behavior is defined, the pixel display color is calculated according to the pixel position, the illumination environment and the light sweeping behavior parameters, the light sweeping is dynamic, the pixel display color changes in real time, the light sweeping effect is achieved, the light sweeping effect can be changed by adjusting the light sweeping behavior parameters, the operation is convenient and fast, the display color is adjusted based on the pixel position and the illumination environment, interaction with the scene environment is achieved, and the light sweeping effect is optimized.
In order to further understand the present invention, a specific embodiment is provided below to further explain the present invention in detail, where the specific embodiment is executed on the Web end based on the babylon. Js engine, and the material and the illumination are processed by the shader, so that the custom light sweeping color, speed and radius can be configured, and a dynamic multipoint concurrent light sweeping effect is achieved, and compared with the conventional dynamic graph making effect, the real illumination environment is reflected more easily and better.
And step 1, initializing a three-dimensional model rendering environment.
The Web graphic library is operated by using the Babylon. Js three-dimensional engine library to realize interactive 3D graphic rendering based on a Web browser, and the 3D graphic rendering of the mainstream of the Web browser takes Canvas as a rendering container at present to display the graphic calculation result of each frame.
Step 1.1, initializing a Scene.
It is understood that Scene acts as a root node to organize, calculate and manipulate 3D elements.
Step 1.2, initializing the camera.
Cameras are used for shooting the content of a three-dimensional space which a user wants to show, and are similar to the observation of eyes of people on the world, the shooting result of the cameras is a frame of image which needs to be rendered in a canvas, and in graphics, cameras are commonly used in two types: perspective camera (with the effect of near-far small) and quadrature camera, used in this embodiment is perspective camera, need indicate the visual area width, the height of camera and near-cut face and far-cut face when initializing, only can be rendered in the near-cut face of camera and far-cut face between the content, still can set up the position of camera in addition, orientation and rotation.
Step 1.2, initializing the light source.
The scene without the light source is black, the light source is added and the object reflection light is set to see the scene content, and the type, color, position and decay degree of the light source are generally set.
The three-dimensional model to be displayed may be an imported three-dimensional model or a created three-dimensional model. The graphics of a three-dimensional model are also referred to as mesh models, because 3D graphics are typically composed of multiple triangular faces, which are themselves linear mesh structures defined by three vertices. Conventional mesh models have cubes, spheres, planes, and the like. When the light sweeping effect is tested, a test grid model can be created, and fig. 2 is a schematic diagram of the light sweeping effect of the test grid model, for example, cubes are randomly generated within the size range of 400 views of length and width to reflect the effect of the light sweeping under the conditions of rugged surface, grid object overlapping and connection, and a plane with the size of 500 views is used for reflecting the effect of the light sweeping on a normal plane.
And 2, creating a shader material.
The material can be regarded as the appearance of the 3D graph, can be pure color, gradient color, texture mapping and the like, and can achieve more expression effects by modifying the material of the 3D graph.
In this embodiment, a manner of setting materials by using a loader material is mainly used, and the loader material is based on a loader (rendering pipeline) technology, so that each pixel of the 3D graphics can be accurately processed.
The rendering pipeline may be subdivided into four stages, vertex processing, surface processing, rasterization, and pixel processing, with this particular embodiment operating primarily in the vertex processing and pixel processing stages.
The babylon. Js engine is built with a commonly used transformation matrix MVP matrix world transformation matrix, which is a world transformation matrix, view (observation transformation matrix), cross multiplication of three matrices of projection transformation matrix and vertex coordinates, and in the vertex processing stage, the vertex coordinates are sequentially converted into world coordinates, observation coordinates and clipping coordinates from local coordinates of the grid model. Further normal vectors are used to calculate the illumination superimposed pixel color during the pixel processing stage.
The loader can set a unique unit type variable to transmit additional parameters for personalized configuration, and generally, different types of materials, illumination reflection intensity and the like need to be set for the grid model, so that in this embodiment, a single ShaderMaterial material is set for each grid model.
And step 3, defining a light sweeping behavior.
The sweeping action can be regarded as determining a sweeping color, starting from a central point, a circle is spread around, the radius of the circle becomes larger gradually, when the radius reaches a certain threshold value, a circle appears again in the same center, and the circle continues to spread around, and when the radius of the outermost circle from the center is large enough, the circle disappears. The pixel through which the circle passes needs to be changed to the color of the scanned light. Unlike conventional planar scanning, the planar position of the pixel in three-dimensional space with respect to the center point, i.e., a point in the same plane, should be calculated in this embodiment, and the colors should be uniform at all heights.
Specifically, the sweep behavior parameters are configured, including sweep color, center point, velocity, diffusion radius threshold, and maximum radius threshold. Note that the sweep color is determined by RGB values, for example, the sweep color is blue, and the sweep color is RGB (0,0,250).
According to the embodiment, the scanning behavior parameters are configured, the pixel display color is calculated to achieve the scanning effect, a plurality of scanning behaviors can be executed concurrently based on the scanning behavior parameters, the scanning behaviors are defined, the scanning behavior parameters are configured for each scanning behavior, the scanning behavior parameters are sequentially traversed, and the display color of the pixel is mixed and overlapped.
And 4, calculating the display color of the pixel.
And 4.1, transmitting the scanning behavior parameters to the shader.
The loader can transmit additional parameters for personalized configuration by setting unique unit type variables, and the embodiment transmits the sweep behavior parameters to the Shader through the unit type variables. It can be understood that when defining a plurality of light sweeping behaviors, a shader transmits the light sweeping behavior parameters of each light sweeping behavior.
And 4.2, constructing a sweep circular radius array.
And constructing a sweeping circular radius array according to the sweeping behavior parameters, so that the subsequent calculation of the pixel display color is facilitated. Based on the light sweeping behavior, firstly, initializing a light sweeping circular radius array to be [0], outwards diffusing the light sweeping circular from a central point at a configuration rate, updating the diffused radius of the light sweeping circular to the light sweeping circular radius array in real time, when the diffused radius of the light sweeping circular reaches a diffusion radius threshold value, adding one light sweeping circular from the central point, continuously outwards diffusing all the light sweeping circular at the configuration rate, updating the diffused radius of all the light sweeping circular to the light sweeping circular radius array in real time, and when the diffused radius of the outermost light sweeping circular reaches a maximum radius threshold value, removing the radius of the outermost light sweeping circular from the light sweeping circular radius array.
Specifically, a radius array radius is defined, initially [0], to preserve the radius distance of the circle appearing relative to the center, with the radius in radius increasing progressively over time, moving the radius out of radius as the radius increases to an upper limit. Assuming a new circle with a radius threshold of 10 (with a radius change of 10 adding an initial radius of 0 to bit number one), a radius removal threshold of 30 (with a radius change of 30 being removed from radius rr) and a radius increase of 5 over time, then radius rr will change as follows: [0],[5],[0,10],[5,15],[0,10,20],[5, 15, 25],[0,10,20]....
Step 4.3, calculate the color of the pixel with respect to the circle.
In the light sweeping circular area, different gradual change effects can be generated according to the distance from the center of the circle, and the color of the pixel relative to the circle refers to the linear relation of the color relative to the distance from the pixel to the center of the circle.
And 4.3.1, converting the pixel coordinates into pixel world coordinates through a world coordinate transformation matrix.
The conversion of pixel coordinates may be in the vertex processing stage, i.e. the pixel coordinates are processed using a vertex shader. The calculation of the pixel color may then be performed by a pixel shader.
And 4.3.2, calculating the distance between the pixel and the center point based on the world coordinates of the pixel, and recording as Ln.
And 4.3.3, comparing the distance Ln with each radius in the sweep circular radius array, and judging the current target sweep circular of the pixel.
The target sweep circle is to compare the distance Ln with each radius in the sweep circle radius array to determine which circle the pixel is located in, and this circle is the target sweep circle.
In step 4.3.4, the color of the pixel with respect to the circle is calculated according to the current radius of the target scan circle, including recording the color of the scan light as rgb (R0, G0, B0), and recording the current radius of the target scan circle as L0, where the color of the pixel with respect to the circle is rgb (R0 x (Ln/L0), G0 x (Ln/L0), B0 x (Ln/L0)).
The pixel coordinate position is converted into the world coordinate pos through the built-in world coordinate transformation matrix world, the distance diff between pos and the center point center is calculated through a two-point distance formula, the diff is compared with each radius in radius rriusrr, the pixel is judged to be positioned in which circle, meanwhile, the gradient degree is calculated according to the distance from the edge of the circle, the color radius color (linear relation of the color to the distance from the pixel to the center of the circle) of the circle is obtained, if the radius of the swept circle is 10 unit distances, the swept color is blue and expressed as rgb (0,0,250), and the color of the pixel which is 5 unit distances from the center of the circle in the circle is rgb (0,0,250 x 5/10)).
In an alternative embodiment, the color of the pixel with respect to the circle is taken as the display color of the pixel, and this pixel display color may be displayed on the canvas.
And 4.4, calculating the light superposition color of the pixel.
Generally, there is illumination in a three-dimensional scene, and for illumination, different angles of a model have different reactions, so that a corresponding illumination color lightColor needs to be calculated according to the distance and color between a normal line of a pixel and illumination: if the parallel light direction is lightdirect (three-dimensional vector), the diffuse reflection color is LightDiffuse (four-dimensional vector), the normal vector normal and lightdirect point multiplication are used to obtain the reflection Intensity, and the Intensity is multiplied by LightDiffuse to obtain the superposition color lightColor for illumination.
In an alternative embodiment, the illumination superposition color of the pixel, the color of the pixel about the circle, and the basic color of the pixel are multiplied to obtain the mixed color of the pixel, the mixed color of the pixel is used as the display color of the pixel, and the display color is displayed on a canvas, so that the display of the light source in the light sweeping is realized.
And 4.5, calculating and emitting the display color of the pixel with the scanned light.
Defining a plurality of light sweeping behaviors, calculating a display color for each pixel according to each light sweeping pixel, adding all the display colors of the pixels to obtain a final display color of the pixels, and transmitting the final display color of each pixel to a canvas in real time for display to present a three-dimensional model light sweeping effect.
For a plurality of simultaneous sweeping lights, different sweeping lights have different center points, colors and rates, when calculating pixel colors, radius rrs defined in each sweeping light behavior need to be traversed, and a mixing or superposition mode of a plurality of colors is selected in a self-defining way: for example, a pixel is in three swept circles simultaneously, and the resultColor of the three sweeps is rgb (0,10,120), rgb (10,22,22), rgb (100,11,23) in sequence, then the final color of the pixel is rgb (0,10,120) +rgb (10,22,22) +rgb (100,11,23) =rgb (110,43,165).
And 5, transmitting the display colors of the pixels to the canvas in real time for display, and displaying and presenting the three-dimensional model light sweeping effect.
After the display color of the pixel is calculated, the display color is transmitted to the canvas to display and present the three-dimensional model light sweeping effect, the data in the light sweeping circular radius array changes in real time, the display color of the pixel changing in real time is transmitted to the canvas to display, and the display of the light sweeping effect is realized. FIG. 2 is a schematic illustration of the sweep effect on a test grid model.
The embodiment of the method for scanning the three-dimensional model of the Web end is described in detail above, and based on the method for scanning the three-dimensional model of the Web end described in the embodiment, the embodiment of the invention also provides a system for scanning the three-dimensional model of the Web end corresponding to the method.
Fig. 3 is a schematic block diagram of a Web-side three-dimensional model light scanning system according to an embodiment of the present invention, where the Web-side three-dimensional model light scanning system 300 may be divided into a plurality of functional modules according to functions performed by the Web-side three-dimensional model light scanning system, as shown in fig. 3. The functional module may include: an environment initialization module 310, a shader creation module 320, a sweep behavior definition module 330, a display color calculation module 340, and a display color presentation module 350. The module referred to in the present invention refers to a series of computer program segments capable of being executed by at least one processor and of performing a fixed function, stored in a memory.
The environment initialization module 310: initializing a three-dimensional model rendering environment.
Shader creation module 320: creating shader materials.
The light sweeping behavior definition module 330: and defining a sweeping behavior, and configuring sweeping behavior parameters including a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value.
Display color calculation module 340: and transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions and the scanning behavior parameters.
The display color rendering module 350: and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
In an alternative embodiment, the display color calculation module 340 is further configured to construct a swept circular radius array, specifically including: initializing a sweep circular radius array to be [0]; the light sweeping circular shape is outwards diffused from the central point at a configuration rate, and the radius of the diffused light sweeping circular shape is updated to a light sweeping circular shape radius array in real time; when the radius of the light sweeping circular shape reaches a diffusion radius threshold value, a light sweeping circular shape is newly added from a central point, all the light sweeping circular shapes continue to diffuse outwards at a configuration rate, and the radius of all the light sweeping circular shapes after diffusion is updated to a light sweeping circular shape radius array in real time; and when the radius of the outermost sweep circle reaches the maximum radius threshold, removing the radius of the outermost sweep circle from the sweep circle radius array.
In an alternative embodiment, the display color calculation module 340 calculates the display color of each pixel of the three-dimensional model in real time according to the pixel position, the illumination environment and the sweeping behavior parameter, and specifically includes the following steps: converting the pixel coordinates into pixel world coordinates through a world coordinate transformation matrix; calculating the distance between the pixel and the center point based on the world coordinates of the pixel, and marking the distance as Ln; comparing the distance Ln with each radius in the light sweeping circular radius array, and judging the current target light sweeping circular of the pixel; calculating the color of the pixel relative to the circle according to the current radius of the target sweep circle, wherein the color of the sweep light is recorded as rgb (R0, G0 and B0), and the color of the pixel relative to the circle is recorded as rgb (R0 (Ln/L0), G0 (Ln/L0) and B0 (Ln/L0)) when the current radius of the target sweep circle is recorded as L0; the color of the pixel with respect to the circle is taken as the display color of the pixel.
In an alternative embodiment, the display color calculation module 340 calculates the display color of each pixel of the three-dimensional model in real time according to the pixel position, the illumination environment and the sweeping behavior parameter, and specifically further includes the following steps: calculating the illumination superposition color of the pixel; multiplying the illumination superposition color of the pixel, the color of the pixel about the circle and the basic color of the pixel to obtain the mixed color of the pixel; the mixed color of the pixels is taken as the display color of the pixels.
In an alternative embodiment, calculating the illumination superposition color of the pixel includes: multiplying the normal vector of the pixel by the parallel light direction point to obtain reflection intensity; the reflection intensity is multiplied by the diffuse reflection color to obtain the illumination superposition color of the pixel.
In an alternative embodiment, the light sweeping behavior definition module 330 defines a plurality of light sweeping behaviors, and the corresponding display color calculation module 340 is further configured to calculate, for each pixel, one display color for each light sweeping pixel; adding all display colors of the pixels to obtain a final display color of the pixels; and transmitting the final display color of each pixel to the canvas in real time for display to present the three-dimensional model light sweeping effect.
In an alternative embodiment, the environment initialization module 310 initializes the three-dimensional model rendering environment, specifically includes: the scene, camera and light source are initialized.
The Web-side three-dimensional model light sweeping device of the present embodiment is used to implement the foregoing Web-side three-dimensional model light sweeping method, so that the specific implementation manner in the system can be seen from the foregoing example portion of the Web-side three-dimensional model light sweeping method, so that the specific implementation manner can refer to the description of the examples of the corresponding various portions, and will not be further described herein.
In addition, since the Web-side three-dimensional model light sweeping system of the present embodiment is used to implement the foregoing Web-side three-dimensional model light sweeping method, the roles of the Web-side three-dimensional model light sweeping system correspond to those of the foregoing method, and the description thereof is omitted herein.
Fig. 4 is a schematic structural diagram of a terminal 400 according to an embodiment of the present invention, including: processor 410, memory 420, and communication unit 430. The processor 410 is configured to implement the following steps when implementing the Web-side three-dimensional model light scanning program stored in the memory 420:
initializing a three-dimensional model rendering environment;
creating a shader material;
defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters;
and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
The invention defines the light sweeping behavior, calculates the pixel display color according to the pixel position, the illumination environment and the light sweeping behavior parameters, and the light sweeping is dynamic, so that the pixel display color changes in real time, the light sweeping effect is realized, the light sweeping effect can be changed by adjusting the light sweeping behavior parameters, the operation is convenient, the display color is adjusted based on the pixel position and the illumination environment, the interaction with the scene environment is realized, and the light sweeping effect is optimized.
The terminal 400 includes a processor 410, a memory 420, and a communication unit 430. The components may communicate via one or more buses, and it will be appreciated by those skilled in the art that the configuration of the server as shown in the drawings is not limiting of the invention, as it may be a bus-like structure, a star-like structure, or include more or fewer components than shown, or may be a combination of certain components or a different arrangement of components.
The memory 420 may be used to store instructions for execution by the processor 410, and the memory 420 may be implemented by any type of volatile or nonvolatile memory terminal or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. The execution of the instructions in memory 420, when executed by processor 410, enables terminal 400 to perform some or all of the steps in the method embodiments described below.
The processor 410 is a control center of the storage terminal, connects various parts of the entire electronic terminal using various interfaces and lines, and performs various functions of the electronic terminal and/or processes data by running or executing software programs and/or modules stored in the memory 420, and invoking data stored in the memory. The processor may be comprised of an integrated circuit (Integrated Circuit, simply referred to as an IC), for example, a single packaged IC, or may be comprised of a plurality of packaged ICs connected to the same function or different functions. For example, the processor 410 may include only a central processing unit (Central Processing Unit, simply CPU). In the embodiment of the invention, the CPU can be a single operation core or can comprise multiple operation cores.
And a communication unit 430 for establishing a communication channel so that the storage terminal can communicate with other terminals. Receiving user data sent by other terminals or sending the user data to other terminals.
The invention also provides a computer storage medium, which can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (random access memory, RAM) and the like.
The computer storage medium stores a Web end three-dimensional model light sweeping program, and the Web end three-dimensional model light sweeping program realizes the following steps when being executed by a processor:
initializing a three-dimensional model rendering environment;
creating a shader material;
defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters;
and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
The invention defines the light sweeping behavior, calculates the pixel display color according to the pixel position, the illumination environment and the light sweeping behavior parameters, and the light sweeping is dynamic, so that the pixel display color changes in real time, the light sweeping effect is realized, the light sweeping effect can be changed by adjusting the light sweeping behavior parameters, the operation is convenient, the display color is adjusted based on the pixel position and the illumination environment, the interaction with the scene environment is realized, and the light sweeping effect is optimized.
It will be apparent to those skilled in the art that the techniques of embodiments of the present invention may be implemented in software plus a necessary general purpose hardware platform. Based on such understanding, the technical solution in the embodiments of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium such as a U-disc, a mobile hard disc, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk or an optical disk, etc. various media capable of storing program codes, including several instructions for causing a computer terminal (which may be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the method described in the embodiments of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The foregoing disclosure is merely illustrative of the preferred embodiments of the invention and the invention is not limited thereto, since modifications and variations may be made by those skilled in the art without departing from the principles of the invention.

Claims (10)

1. The three-dimensional model light sweeping method for the Web end is characterized by comprising the following steps of:
initializing a three-dimensional model rendering environment;
creating a shader material;
defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions, the illumination environment and the scanning behavior parameters;
and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
2. The method for scanning three-dimensional model of Web terminal according to claim 1, wherein after transmitting the scanning behavior parameters to the shader, further comprising the step of constructing a scanning circular radius array, specifically comprising:
initializing a sweep circular radius array to be [0];
the light sweeping circular shape is outwards diffused from the central point at a configuration rate, and the radius of the diffused light sweeping circular shape is updated to a light sweeping circular shape radius array in real time;
when the radius of the light sweeping circular shape reaches a diffusion radius threshold value, a light sweeping circular shape is newly added from a central point, all the light sweeping circular shapes continue to diffuse outwards at a configuration rate, and the radius of all the light sweeping circular shapes after diffusion is updated to a light sweeping circular shape radius array in real time;
and when the radius of the outermost sweep circle reaches the maximum radius threshold, removing the radius of the outermost sweep circle from the sweep circle radius array.
3. The method for scanning the three-dimensional model of the Web end according to claim 2, wherein the method is characterized in that the display color of each pixel of the three-dimensional model is calculated in real time according to the pixel position, the illumination environment and the scanning behavior parameters, and specifically comprises the following steps:
converting the pixel coordinates into pixel world coordinates through a world coordinate transformation matrix;
calculating the distance between the pixel and the center point based on the world coordinates of the pixel, and marking the distance as Ln;
comparing the distance Ln with each radius in the light sweeping circular radius array, and judging the current target light sweeping circular of the pixel;
calculating the color of the pixel relative to the circle according to the current radius of the target sweep circle, wherein the color of the sweep light is recorded as rgb (R0, G0 and B0), and the color of the pixel relative to the circle is recorded as rgb (R0 (Ln/L0), G0 (Ln/L0) and B0 (Ln/L0)) when the current radius of the target sweep circle is recorded as L0;
the color of the pixel with respect to the circle is taken as the display color of the pixel.
4. The method for scanning light on a three-dimensional model of a Web terminal according to claim 3, wherein the method for calculating the display color of each pixel of the three-dimensional model in real time according to the pixel position, the illumination environment and the scanning light behavior parameters comprises the following steps:
calculating the illumination superposition color of the pixel;
multiplying the illumination superposition color of the pixel, the color of the pixel about the circle and the basic color of the pixel to obtain the mixed color of the pixel;
the mixed color of the pixels is taken as the display color of the pixels.
5. The method for scanning light of a three-dimensional model at a Web terminal according to claim 4, wherein calculating an illumination superposition color body of a pixel comprises:
multiplying the normal vector of the pixel by the parallel light direction point to obtain reflection intensity;
the reflection intensity is multiplied by the diffuse reflection color to obtain the illumination superposition color of the pixel.
6. The method for scanning three-dimensional model of Web terminal according to claim 4, which is characterized in that the method comprises the following steps:
defining a plurality of light sweeping behaviors;
calculating a display color for each sweep pixel for each pixel;
adding all display colors of the pixels to obtain a final display color of the pixels;
and transmitting the final display color of each pixel to the canvas in real time for display to present the three-dimensional model light sweeping effect.
7. The method for scanning three-dimensional model of Web terminal according to claim 6, wherein initializing the three-dimensional model rendering environment comprises:
the scene, camera and light source are initialized.
8. A three-dimensional model light sweeping system of a Web terminal is characterized by comprising,
an environment initialization module: initializing a three-dimensional model rendering environment;
the shader creation module: creating a shader material;
the light sweeping behavior definition module: defining a sweeping behavior, and configuring sweeping behavior parameters, wherein the sweeping behavior parameters comprise a sweeping color, a center point, a speed, a diffusion radius threshold value and a maximum radius threshold value;
a display color calculation module: transmitting the scanning behavior parameters to a shader, and calculating the display color of each pixel of the three-dimensional model in real time by the shader according to the pixel positions and the scanning behavior parameters;
a display color presentation module: and transmitting the display colors of the pixels to the canvas in real time for displaying and presenting the three-dimensional model light sweeping effect.
9. A terminal, comprising:
the memory is used for storing a three-dimensional model light sweeping program of the Web terminal;
the processor is used for realizing the steps of the three-dimensional model scanning method of the Web end according to any one of claims 1-7 when the three-dimensional model scanning program of the Web end is executed.
10. A computer readable storage medium, wherein a Web-side three-dimensional model light sweeping program is stored on the readable storage medium, and when the Web-side three-dimensional model light sweeping program is executed by a processor, the steps of the Web-side three-dimensional model light sweeping method according to any one of claims 1 to 7 are implemented.
CN202310795673.XA 2023-06-30 2023-06-30 Method, system, terminal and medium for scanning three-dimensional model of Web terminal Pending CN116797709A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310795673.XA CN116797709A (en) 2023-06-30 2023-06-30 Method, system, terminal and medium for scanning three-dimensional model of Web terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310795673.XA CN116797709A (en) 2023-06-30 2023-06-30 Method, system, terminal and medium for scanning three-dimensional model of Web terminal

Publications (1)

Publication Number Publication Date
CN116797709A true CN116797709A (en) 2023-09-22

Family

ID=88036258

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310795673.XA Pending CN116797709A (en) 2023-06-30 2023-06-30 Method, system, terminal and medium for scanning three-dimensional model of Web terminal

Country Status (1)

Country Link
CN (1) CN116797709A (en)

Similar Documents

Publication Publication Date Title
US11024077B2 (en) Global illumination calculation method and apparatus
US7212207B2 (en) Method and apparatus for real-time global illumination incorporating stream processor based hybrid ray tracing
US20040181382A1 (en) Visualizing the surface of a liquid
US6567083B1 (en) Method, system, and computer program product for providing illumination in computer graphics shading and animation
US11625861B2 (en) Point cloud colorization system with real-time 3D visualization
US7173622B1 (en) Apparatus and method for generating 3D images
CN112215934A (en) Rendering method and device of game model, storage medium and electronic device
US8878849B2 (en) Horizon split ambient occlusion
WO2006083762A1 (en) Systems and methods for the real-time simulation of atmospheric lighting effects
CN112184873B (en) Fractal graph creation method, fractal graph creation device, electronic equipment and storage medium
US6445395B1 (en) Method and apparatus for radiometrically accurate texture-based lightpoint rendering technique
GB2406252A (en) Generation of texture maps for use in 3D computer graphics
CN116758208A (en) Global illumination rendering method and device, storage medium and electronic equipment
US7133052B1 (en) Morph map based simulated real-time rendering
US5793372A (en) Methods and apparatus for rapidly rendering photo-realistic surfaces on 3-dimensional wire frames automatically using user defined points
US20180005432A1 (en) Shading Using Multiple Texture Maps
Law et al. Projector placement planning for high quality visualizations on real-world colored objects
CN116797709A (en) Method, system, terminal and medium for scanning three-dimensional model of Web terminal
KR100603134B1 (en) Method and apparatus for 3 dimension rendering processing using the monochromatic lighting
EP4386685A1 (en) Method for 3d visualization of sensor data
US11961188B2 (en) Neural networks to generate appearance-responsive material map sets in digital graphical environments
JP4219090B2 (en) Method, system, and computer program product for providing lighting in computer graphics shading and animation
CN117745920A (en) Model mapping method, device, equipment and storage medium
CN118079373A (en) Model rendering method and device, storage medium and electronic device
CN117557703A (en) Rendering optimization method, electronic device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination