Simulation intracavity effusion full-permeable material generation method and device and electronic equipment
By obtaining texture maps and world coordinates, and combining target vertex coordinates and control parameters, the problem of poor rendering of transparent material in virtual surgery is solved, achieving real and approximate rendering effects.
Patent Information
- Application Number
- CN202510053849.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-13
AI Technical Summary
The prior art is difficult to render the real effusion transparent material effect in virtual surgery, resulting in poor rendering effect.
By obtaining the texture map and the world coordinates of the model to be rendered, combining the target vertex coordinates and control parameters such as texture smoothness, refractive index, and transparency, rendering is performed to generate a fully transparent material in the simulation cavity.
It realizes the rendering of the real effusion transparent material effect in virtual surgery, making the rendering effect more realistic and close, and can feedback the rendering effect under the current set parameters in real time.
Smart Images

Figure CN119991918A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method, device and electronic equipment for generating a fully transparent material for simulating intracavitary fluid accumulation. Background Art
[0002] With the development of computer graphics technology, the realization of virtual scenes has been increasingly applied. Users use corresponding devices to interact with objects in the virtual environment, thus creating an immersive perceptual experience. For example, in virtual surgery simulation, based on a virtual human model, a highly realistic virtual medical environment can be built with the help of computer graphics, biomechanics, etc., and the entire surgical process can be simulated by performing multi-faceted operations on virtual organs through specific equipment, so as to help surgeons quickly master the basic skills required during the operation.
[0003] Specifically, the software used for virtual surgery training needs to consist of multiple scenes, each of which is constructed with necessary element objects. In the software, a realistic virtual surgery environment is simulated through the combination of various elements and scene rendering.
[0004] In the prior art, the scene rendering process is relatively mature. However, since real transparent or semi-transparent materials usually have many special physical properties, it is a difficult task to render a real transparent material effect of effusion in virtual surgery, and the rendering effect is often poor. Summary of the invention
[0005] The purpose of the present application is to provide a method, device and electronic device for generating a fully transparent material for simulating intracavitary fluid accumulation, so as to render a realistic transparent material effect of fluid accumulation in virtual surgery.
[0006] To achieve the above purpose, the embodiment of the present application adopts the following technical solution:
[0007] The present invention provides a method for generating a fully transparent material for simulating fluid accumulation in a cavity, comprising the following steps:
[0008] Acquire a texture map and world coordinates of a model to be rendered; wherein the texture map is obtained by sampling a preset image according to the texture coordinates of the model to be rendered; the world coordinates are calculated according to both the world normal coordinates and the camera view coordinates; wherein the texture map and the world coordinates are multiplied to output a highlight texture map;
[0009] Obtaining target vertex coordinates of the model to be rendered; wherein the target vertex coordinates are deformable vertex coordinates obtained by multiplying the initial coordinates corresponding to each vertex of the model to be rendered by the deformation frequency parameter, and according to the deformable vertex coordinates, setting the superimposed time variation parameters, and then correcting the fluctuation variables of the vertex by the sine and cosine functions to obtain the target vertex coordinates;
[0010] Based on the highlight texture map and the target vertex coordinates, one or more control parameters of texture smoothness, refraction, and transparency of the material to be generated are integrated and linked to perform rendering, and the rendering data is output.
[0011] Furthermore, the step of performing texture sampling on the preset image according to the texture coordinates of the model to be rendered includes:
[0012] Get the texture UV coordinates of the model to be rendered;
[0013] Setting translation parameters to adjust the texture UV coordinates, and performing texture sampling on the first preset image based on the adjusted texture UV coordinates to obtain a first texture map;
[0014] Setting a proportional offset parameter to calculate the texture U coordinate, and adding the adjusted texture U coordinate to the first texture map to obtain a mask effect map;
[0015] The time variation parameter is superimposed on the mask effect map to control the map flow rate of the mask effect map, and texture sampling is performed on the second preset picture to obtain a second texture map.
[0016] Furthermore, the step of setting the scale offset parameter to calculate the texture U coordinate includes:
[0017] Create a proportional offset controller;
[0018] The texture U coordinate is used as a total input parameter of the proportional offset controller, and based on the texture U coordinate, a scaling parameter and a preset offset parameter are preset for the proportional offset controller, and a deformed texture coordinate is obtained after the proportional offset controller deforms the texture U coordinate according to the preset scaling parameter and the preset offset parameter;
[0019] The absolute value of the deformed texture coordinate is taken, and multiplied by a preset coefficient to scale the deformed texture coordinate.
[0020] Furthermore, after obtaining the second texture map, the step of post-processing the second texture map includes:
[0021] Inputting the second texture map into a saturation adjuster to obtain a color enhancement map after adjusting the color saturation;
[0022] Set the highlight control parameters and grayscale control parameters respectively;
[0023] The color enhancement map, the highlight control parameter and the grayscale control parameter are input into the same interpolator for interpolation calculation, and a linear interpolation function is output.
[0024] Furthermore, the step of calculating the world coordinates based on the world normal coordinates and the camera view coordinates comprises:
[0025] Create world normal coordinates and camera view coordinates;
[0026] Calculating the world normal coordinates and the camera view coordinates by using a dot product function to obtain a scalar product;
[0027] Input the scalar product into a power calculator, preset an Exp value of the power calculator, multiply the Exp value by the scalar product, and output a power value;
[0028] Inputting the exponentiation value into a difference calculator, presetting a difference coefficient of the difference calculator, calculating the difference coefficient and the exponentiation value, and outputting a final difference calculation value;
[0029] Inputting the final value of the difference calculation into a color enhancement controller to obtain an enhanced value;
[0030] The enhanced value is input into a subtraction processor to obtain the inverted world coordinate.
[0031] Furthermore, the step of obtaining the coordinates of the target vertex includes:
[0032] Obtaining deformation frequency parameters of the model to be rendered and initial coordinates of vertices in the model to be rendered;
[0033] Multiplying the deformation frequency parameter by the initial coordinates to obtain the coordinates of the deformable vertex;
[0034] Setting a time variation parameter, and superimposing the time variation parameter with the deformable vertex coordinates to control vertex fluctuation;
[0035] The vertex fluctuation variable sizes are controlled respectively by sine and cosine functions, and the variable sizes of the two are added together to obtain the target vertex coordinates.
[0036] Furthermore, the steps of controlling the magnitude of vertex fluctuation variables respectively by using sine and cosine functions include:
[0037] Create a cosine function to receive the coordinates of the deformable vertex to control the size of the vertex cosine value fluctuation variable, and output the deformable vertex parameters controlled by the cosine function by multiplying with the preset coefficient;
[0038] Create a cosine function to receive the deformable vertex coordinates to control the size of the vertex sine value fluctuation variable, and output the deformable vertex parameters controlled by the sine function by multiplying it with the preset coefficient.
[0039] The present invention provides a device for generating a fully transparent material for simulating intracavitary fluid accumulation, comprising:
[0040] A highlight texture mapping module, wherein the highlight texture mapping module is used to configure rendering texture parameters and color parameters of the model to be rendered;
[0041] A flow deformation control module, wherein the flow deformation control module is used to adjust the rendering texture deformation parameters of the model to be rendered;
[0042] A smoothness controller, wherein the smoothness controller is used to control the smoothness of the rendered texture;
[0043] A refraction controller, which is used to control the refraction effect occurring with the scene light source during the rendering process;
[0044] A transparency controller, wherein the transparency controller is used to control the transparency of the rendered material ball;
[0045] A rendering module, wherein the rendering module has a plurality of input ports, wherein the highlight texture mapping module, the flow deformation control module, the smoothness controller, the refraction controller and the transparency controller are respectively connected to different input ports of the rendering module in a one-to-one correspondence, and the rendering is implemented through integration and linking through the rendering module, and the rendering data is output.
[0046] An electronic device provided by the present invention includes: a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method.
[0047] The present invention provides a computer-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the aforementioned method.
[0048] The method, device and electronic device for generating a fully transparent material for simulating fluid accumulation in a cavity provided by the embodiments of the present application have at least the following beneficial effects:
[0049] Based on the generated highlight texture map and the obtained target vertex coordinate data of the model to be rendered, one or more control parameters of the texture smoothness, refraction, and transparency of the material generated by the model to be rendered are integrated and linked to implement rendering, and in this embodiment, one or more control parameters correspond to parameter controllers of smoothness, refraction, transparency, etc. The parameter controller is set to an adjustable mode at the front end, and finally the synthesized data is rendered and output; wherein, in the generated highlight texture map, the rendering texture parameters and color parameters of the model to be rendered can be configured in real time; in the process of obtaining the target vertex coordinates, the rendering texture deformation parameters of the model to be rendered can be adjusted in real time, and the deformation degree of the rendering effect can be adjusted in real time. When the texture smoothness, refraction, transparency and other control parameters of the material generated by the integrated link to the model to be rendered are implemented for real-time rendering, the texture smoothness can control the smoothness of the rendered texture in real time to make the rendering effect more realistic, and can provide real-time feedback on the rendering effect under the current setting parameters, so that the information can be processed faster and the operator can get the final rendering effect they want more quickly; the refraction control parameter can control the real-time refraction effect with the scene light source during the rendering process, making the material ball more realistic; the transparency control parameter can control the transparency of the material ball to be rendered, so that the final effect is more inclined to the real abdominal cavity internal effect, and a preset material with more realistic rendering effect is obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] 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 ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0051] Figure 1 One of the flow charts of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0052] Figure 2 The second flowchart of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0053] Figure 3 Flow chart 3 of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0054] Figure 4 One of the node schematic diagrams for implementing some steps provided in the embodiment of the present application;
[0055] Figure 5 Flow chart 4 of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0056] Figure 6 The second node diagram for implementing some steps provided in the embodiment of the present application;
[0057] Figure 7 Flow chart 5 of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0058] Figure 8 The third node diagram for implementing some steps provided in the embodiment of the present application;
[0059] Fig. 9 Flow chart six of the method for generating a fully transparent material for simulating fluid accumulation in a cavity provided in an embodiment of the present application;
[0060] Fig.10 A fourth node diagram of implementing some steps provided in an embodiment of the present application;
[0061] Fig.11 This is a flowchart of a device for generating a fully transparent material for simulating intracavitary fluid accumulation provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0063] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0065] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, or the positions or positional relationships in which the product of the invention is usually placed when in use. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0066] In addition, the terms "horizontal", "vertical", "overhanging" and the like do not mean that the components are required to be absolutely horizontal or overhanging, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", and does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0067] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" 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 it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0068] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0069] Virtual surgery is the product of the cross-integration of virtual reality technology with modern medicine, biomechanics, materials science and other disciplines. With the development of various technologies in the medical field, it has attracted more and more attention. The virtual surgery system builds a virtual surgical environment in the computer, including surgical object models, surgical instrument models, and even complex environments such as operating room scenes. With the help of the virtual environment, it can show the surgical process to relevant medical personnel and provide surgical guidance and training.
[0070] Surgery training is the most widely used application of virtual surgery in practice. The virtual surgery training system builds a system that can simulate real surgery, providing functional requirements such as surgery demonstration, simulation and training for medical staff or medical students.
[0071] To build a virtual reality 3D environment, virtual simulation is performed. Commonly used development software for virtual reality includes Java3D, Open Inventor, Con-verse3D and Unity3D. In this embodiment, Unity3D is selected as the virtual reality simulation software platform.
[0072] In the process of building a virtual abdominal surgery simulation, it is necessary to obtain relevant data to build a three-dimensional model of the abdominal tissue. This can be built by the built-in modeling system, or it can be modeled and imported by professional modeling software. Optional three-dimensional modeling tools include Solidworks, 3DMax, Maya, UG, CATIA or Blender, etc. Among them, when using Solidworks, the model established by Solidworks is a simple geometric model. In order to achieve the realism of the real image, it is necessary to perform preliminary rendering in other tools such as 3DMax, and add materials, maps, etc. to the model to increase the realism of the display.
[0073] In this embodiment, the abdominal soft tissue model is directly constructed in 3DMax, exported to FBX format, and imported into Unity3D, and subsequent operations are performed on corresponding components to achieve interactive operations.
[0074] In the virtual surgery scene, a real visual feedback system needs to be established. In addition to modeling the organ model correctly and realistically, it is also necessary to enrich its performance characteristics through various texture details of human organs. The texture images obtained from medical photos are finely and realistically attached to the surface of organ tissues to render the textures of various tissues and organs of the human body.
[0075] The following is an introduction to a method for generating a fully transparent material for simulating fluid accumulation in a cavity provided by an embodiment of the present invention.
[0076] Reference Figure 1 This embodiment provides a method for generating a fully transparent material for simulating fluid accumulation in a cavity, which specifically includes the following steps:
[0077] S10, obtaining a texture map and world coordinates of a model to be rendered; wherein the texture map is obtained by sampling a preset image according to the texture coordinates of the model to be rendered; and the world coordinates are calculated according to the world normal coordinates and the camera view coordinates; wherein the texture map and the world coordinates are multiplied to output a highlight texture map;
[0078] S20, obtaining target vertex coordinates of the model to be rendered; wherein the target vertex coordinates are deformable vertex coordinates obtained by multiplying the initial coordinates corresponding to each vertex of the model to be rendered by the deformation frequency parameter, and according to the deformable vertex coordinates, setting the superimposed time variation parameters, and then correcting the fluctuation variables of the vertex by the sine and cosine functions to obtain the target vertex coordinates;
[0079] S30, based on the highlight texture map and the target vertex coordinates, and integrating and linking one or more control parameters of the texture smoothness, refraction, and transparency of the material to be generated, rendering is performed, and the rendering data is output.
[0080] Further, the step of sampling the texture of the preset image according to the texture coordinates of the model to be rendered is as follows: Figure 2 , including:
[0081] S101, obtaining the texture UV coordinates of the model to be rendered;
[0082] S102, setting a translation parameter to adjust the texture UV coordinates, and performing texture sampling on the first preset image based on the adjusted texture UV coordinates to obtain a first texture map;
[0083] S103, setting a proportional offset parameter to calculate the texture U coordinate, and adding the adjusted texture U coordinate to the first texture map to obtain a mask effect map;
[0084] S104, superimposing the time variation parameter on the mask effect map to control the map flow rate of the mask effect map, and performing texture sampling on the second preset picture to obtain a second texture map.
[0085] In S103, the step of setting the scale offset parameter to calculate the texture U coordinate is as follows: Figure 3 , including:
[0086] S1031, creating a proportional offset controller;
[0087] S1032, using the texture U coordinate as a total input parameter of the proportional offset controller, preset a scaling parameter and a preset offset parameter for the proportional offset controller based on the texture U coordinate, and obtaining a deformed texture coordinate after the proportional offset controller deforms the texture U coordinate according to the preset scaling parameter and the preset offset parameter;
[0088] S1033, taking an absolute value of the deformed texture coordinates, and multiplying the absolute value by a preset coefficient to scale the deformed texture coordinates.
[0089] The implementation of the above steps S101 to S104 is described in detail below in Unity.
[0090] Figure 4 A node diagram for implementing the above steps S101 to S104 provided in an embodiment of the present application.
[0091] With respect to step S101 , the texture UV coordinates of the model to be rendered are obtained through the Texture Coordinates node 101 .
[0092] For step S102, the texture UV coordinates are input into the UV input port of the Panner node 102; the translation parameters are set through the Sin Time node 103 and the Scale And Offset node 104, and input into the Time input port of the Panner node 102, that is, the scale and offset parameters are limited by the translation time to control the overall translation rhythm of the Panner node 102; the adjusted texture UV coordinates are input into the Foam node 105, and the first texture map is obtained after the Foam node 105 performs texture sampling on the first preset image according to the adjusted texture UV coordinates.
[0093] For step S103, the texture U coordinates of the model to be rendered are obtained, and the texture U coordinates are input into the blank total input port of the Scale And Offset node 106, and the scaling parameters and the preset translation parameters are preset for the Scale And Offset node 106 based on the U direction coordinates; the texture coordinates after the Scale And Offset node 106 deforms the texture U coordinates according to the preset scaling parameters and the preset translation parameters; the absolute coordinates of the deformed texture coordinates are obtained through the Abs node 107; a fixed parameter is preset in the Multiply node 108; the absolute coordinates of the deformed texture coordinates are multiplied by the fixed parameter to obtain the U direction mask coordinates. The first texture map and the U direction mask coordinates obtained in step S102 are both input into the A and B input ports of the Add node 109, and the Add node 109 adds the data input from the A and B input ports to obtain the final output result, that is, the mask effect map.
[0094] For step S104, the time variation parameter is used as the output parameter through the Time Parameters node 110. Specifically, the time variation t / 20 parameter is input to the B input port of the Add node 111. The output port of the Add node 109 is connected to the A input port of the Add node 111 and output to the Texture Sample node 112. The second preset picture is preset in the Texture Sample node 112. Texture sampling is performed through the second preset picture of the Texture Sample node 112 to obtain a second texture map.
[0095] Further, see Figure 5 After obtaining the second texture map, the step of post-processing the second texture map comprises:
[0096] S105, inputting the second texture map into a saturation adjuster to obtain a color enhancement map after adjusting the color saturation;
[0097] S106, setting highlight control parameters and grayscale control parameters respectively;
[0098] S107, inputting the color enhancement map, the highlight control parameter and the grayscale control parameter into the same interpolator for interpolation calculation, and outputting a linear interpolation function.
[0099] The implementation of the above steps S105 to S107 is described in detail below in Unity.
[0100] Figure 6 This is a schematic diagram of nodes for implementing the above-mentioned steps S105 to S107 provided in an embodiment of the present application. Figure 6 As shown, the RGBA output port of the Texture Sample node 112 is connected to the Saturact node 113 to obtain a color enhancement map after adjusting the color saturation, and the color enhancement map is input to the B input port of the Lerp node 114; the A and C input ports of the Lerp node 114 are respectively connected to the Specular node 115 (i.e., highlight control parameters) and the Soap Amount node 116 (i.e., grayscale control parameters), and the color enhancement map, highlight control parameters and grayscale control parameters are interpolated through the Lerp node 114 to output a linear interpolation function.
[0101] Reference Figure 7 , the steps of calculating the world coordinates according to the world normal coordinates and the camera view coordinates include:
[0102] S108, creating world normal coordinates and camera view coordinates;
[0103] S109, calculating the world normal coordinates and the camera view coordinates by using a dot product function to obtain a scalar product;
[0104] S110, inputting the scalar product into the exponentiation calculator, presetting the Exp value of the exponentiation calculator, and multiplying the Exp value by the scalar product to output the exponentiation value;
[0105] S111, inputting the exponentiation value into the difference calculator, presetting the difference coefficient of the difference calculator, calculating the difference coefficient and the exponentiation value, and outputting the final difference calculation value;
[0106] S112, inputting the final value of the difference calculation into the color enhancement controller to obtain an enhanced value;
[0107] S113, inputting the enhanced value into a subtraction processor to obtain an inverted world coordinate.
[0108] The implementation of the above steps S108 to S113 is described in detail below in Unity.
[0109] Figure 8This is a schematic diagram of nodes for implementing the above-mentioned step S108 to step S113 provided in an embodiment of the present application. Figure 8 As shown, the world normal coordinates are created through the World Normal node 115, and the xyz coordinate values of the world normal coordinate system are input to the A input port of the Dot node 117; the camera view coordinates are created through the View Dir node 116, and the xyz coordinate values of the camera view coordinate system are input to the B input port of the Dot node 117; the Dot node 117 combines the acquired coordinate values to calculate the scalar product as the output value, and outputs it to the Base input port of the Power node 118, the EXP input port of the Power node 118 defines the Exp value and the data acquired by the Base input interface to calculate the power value, and inputs it to the A input port of the Subtract node 119; the B input port of the Subtract node 119 defines the B input port data to obtain the subtraction calculation final value of the two; the subtraction calculation final value is input to the Saturact node 120, that is, the color enhancement controller, and the data is processed to obtain the enhanced value after processing; the generated enhanced value is input to the One minus node 121, and the enhanced value is obtained and then subtracted by 1 to obtain the final inverted world coordinates.
[0110] The inverted world coordinates and the Lerp node 114 are input to the A and B input ports of the Multiply node 122 respectively. The Multiply node 122 multiplies the data input from the A and B input ports to obtain the final output result, that is, a matrix type value with map data.
[0111] In step S20, referring to Fig. 9 , the specific steps are:
[0112] S21, obtaining a deformation frequency parameter of the model to be rendered and initial coordinates of vertices in the model to be rendered;
[0113] S22, multiplying the deformation frequency parameter by the initial coordinates to obtain the coordinates of the deformable vertex;
[0114] S23, setting a time variation parameter, and superimposing the time variation parameter with the coordinates of the deformable vertex to control vertex fluctuation;
[0115] S24, respectively controlling the vertex fluctuation variable size through sine and cosine functions, and adding the variable sizes of the two to obtain the target vertex coordinates.
[0116] In step S24, the steps of controlling the magnitude of vertex fluctuation variables respectively by using sine and cosine functions specifically include:
[0117] Create a cosine function to receive the coordinates of the deformable vertex to control the size of the vertex cosine value fluctuation variable, and output the deformable vertex parameters controlled by the cosine function by multiplying with the preset coefficient;
[0118] Create a cosine function to receive the deformable vertex coordinates to control the size of the vertex sine value fluctuation variable, and output the deformable vertex parameters controlled by the sine function by multiplying it with the preset coefficient.
[0119] The implementation of the above steps S21 to S24 is described in detail below in Unity.
[0120] Fig.10 A node diagram for implementing the above-mentioned steps S21 to S24 provided in an embodiment of the present application.
[0121] like Fig.10 As shown, the deformation frequency parameter of the model to be rendered is obtained through the Deform Frequency node 201, and is input to the A input port of the Multiply node 203; the vertex coordinates of the model to be rendered are obtained through the Vertex Position node 202, and are input to the B input port of the Multiply node 203; the Multiply node 203 multiplies the A and B input port parameters to obtain the deformable vertex coordinate value, and inputs it to the A input port of the Add node 204; Parameters node 205 is a time-varying parameter. The time-varying t value is used as an output parameter. The time-varying t value is input to the B input port of Add node 204. Add node 204 adds the parameters of the A and B input ports. The vertex values with speed and deformation are received through Cos node 205 to control the size of the vertex cosine value fluctuation variable. The vertex parameters controlled by Cos node 205 are input to Multiply node 206. According to the existing effect, the value of the multiplication of the vertex parameters controlled by Multiply node 206 and Cos node 205 is defined as 0.015. Finally, the deformable vertex parameters controlled by the cosine function are obtained and input to Add. The A input port of node 209; at the same time, the vertex value with speed and deformation is received through Sin node 207 to control the size of the vertex sine value fluctuation variable, and the vertex parameters controlled by Sin node 207 are input to Multiply node 208. According to the existing effect, the value of the multiplication of the vertex parameters controlled by Multiply node 208 and Sin node 207 is defined as 0.005, and finally the deformable vertex parameters controlled by the sine function are obtained and input to the B input port of Add node 209; Add node 209 adds the parameters of A and B input ports to obtain the final value of the deformable vertex, which is connected to the local vertex rendering input port of the final renderer.
[0122] Reference Fig.11This embodiment also provides a device for generating a fully transparent material for simulating fluid accumulation in a cavity, comprising:
[0123] Highlight texture mapping module, which is used to configure the rendering texture parameters and color parameters of the model to be rendered;
[0124] A flow deformation control module, which is used to adjust the rendering texture deformation parameters of the model to be rendered;
[0125] Smoothness controller, which is used to control the smoothness of the rendered texture;
[0126] Refraction controller, which is used to control the refraction effect that occurs with the scene light source during the rendering process;
[0127] Transparency controller, which is used to control the transparency of the rendered material ball;
[0128] The rendering module has multiple input ports. The highlight texture mapping module, flow deformation control module, smoothness controller, refraction controller and transparency controller are respectively connected to different input ports of the rendering module in a one-to-one correspondence. The rendering is implemented through integration and linking through the rendering module, and the rendering data is output.
[0129] Specifically, the highlight texture mapping module, the flow deformation control module, the smoothness controller, the refraction controller and the transparency controller are respectively connected to the Specular input port, the Local Vertex Offset input port, the Smoothness input port, the Refraction input port and the Opacity input port of the rendering module in a one-to-one correspondence.
[0130] Taking the creation of the above modules and controllers in Unity as an example, the specific operations are as follows:
[0131] Create shaders;
[0132] Double-click the newly created shader to enter the editing panel, and use the method in this embodiment to create a highlight texture mapping module, a flow deformation control module, a smoothness controller, a refraction controller, and a transparency controller;
[0133] A renderer is created as the final rendering of the shader, and the highlight texture mapping module, flow deformation control module, smoothness controller, refraction controller and transparency controller are connected to different input ports of the rendering module one by one to obtain a complete rendered shader;
[0134] Import the model to be rendered;
[0135] Create a material ball;
[0136] Drag the material ball to the material interface of the model, wherein the material ball selects the edited shader for rendering.
[0137] The computer program product of the method, device and electronic device for generating a fully transparent material for simulating intracavitary fluid accumulation provided in the embodiments of the present disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0138] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, 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, which is stored in a storage medium and includes several instructions for 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 various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0139] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating a fully transparent material for simulating intracavitary fluid accumulation, characterized in that: The following steps are involved: Acquire a texture map and world coordinates of a model to be rendered; wherein the texture map is obtained by sampling a preset image according to the texture coordinates of the model to be rendered; the world coordinates are calculated according to both the world normal coordinates and the camera view coordinates; wherein the texture map and the world coordinates are multiplied to output a highlight texture map; Obtaining target vertex coordinates of the model to be rendered; wherein the target vertex coordinates are deformable vertex coordinates obtained by multiplying the initial coordinates corresponding to each vertex of the model to be rendered by the deformation frequency parameter, and according to the deformable vertex coordinates, setting the superimposed time variation parameters, and then correcting the fluctuation variables of the vertex by the sine and cosine functions to obtain the target vertex coordinates; Based on the highlight texture map and the target vertex coordinates, one or more control parameters of texture smoothness, refraction, and transparency of the material to be generated are integrated and linked to perform rendering, and the rendering data is output.
2. The method according to claim 1, characterized in that The step of sampling the texture of the preset image according to the texture coordinates of the model to be rendered includes: Get the texture UV coordinates of the model to be rendered; Setting translation parameters to adjust the texture UV coordinates, and performing texture sampling on the first preset image based on the adjusted texture UV coordinates to obtain a first texture map; Setting a proportional offset parameter to calculate the texture U coordinate, and adding the adjusted texture U coordinate to the first texture map to obtain a mask effect map; The time variation parameter is superimposed on the mask effect map to control the map flow rate of the mask effect map, and texture sampling is performed on the second preset picture to obtain a second texture map.
3. The method according to claim 2, characterized in that The step of setting the scale offset parameter to calculate the texture U coordinate comprises: Create a proportional offset controller; The texture U coordinate is used as a total input parameter of the proportional offset controller, and based on the texture U coordinate, a scaling parameter and a preset offset parameter are preset for the proportional offset controller, and a deformed texture coordinate is obtained after the proportional offset controller deforms the texture U coordinate according to the preset scaling parameter and the preset offset parameter; The absolute value of the deformed texture coordinate is taken, and multiplied by a preset coefficient to scale the deformed texture coordinate.
4. The method according to claim 2, characterized in that: After obtaining the second texture map, the step of post-processing the second texture map includes: Inputting the second texture map into a saturation adjuster to obtain a color enhancement map after adjusting the color saturation; Set the highlight control parameters and grayscale control parameters respectively; The color enhancement map, the highlight control parameter and the grayscale control parameter are input into the same interpolator for interpolation calculation, and a linear interpolation function is output.
5. The method according to claim 1, characterized in that: The step of calculating the world coordinates according to the world normal coordinates and the camera view coordinates comprises: Create world normal coordinates and camera view coordinates; Calculating the world normal coordinates and the camera view coordinates by using a dot product function to obtain a scalar product; Input the scalar product into a power calculator, preset an Exp value of the power calculator, multiply the Exp value by the scalar product, and output a power value; Inputting the exponentiation value into a difference calculator, presetting a difference coefficient of the difference calculator, calculating the difference coefficient and the exponentiation value, and outputting a final difference calculation value; Inputting the final value of the difference calculation into a color enhancement controller to obtain an enhanced value; The enhanced value is input into a subtraction processor to obtain the inverted world coordinate.
6. The method according to claim 1, characterized in that The step of obtaining the coordinates of the target vertex comprises: Obtaining deformation frequency parameters of the model to be rendered and initial coordinates of vertices in the model to be rendered; Multiplying the deformation frequency parameter by the initial coordinates to obtain the coordinates of the deformable vertex; Setting a time variation parameter, and superimposing the time variation parameter with the deformable vertex coordinates to control vertex fluctuation; The vertex fluctuation variable sizes are controlled respectively by sine and cosine functions, and the variable sizes of the two are added together to obtain the target vertex coordinates.
7. The method according to claim 6, characterized in that The steps of controlling the magnitude of vertex fluctuation variables respectively through sine and cosine functions include: Create a cosine function to receive the coordinates of the deformable vertex to control the size of the vertex cosine value fluctuation variable, and output the deformable vertex parameters controlled by the cosine function by multiplying with the preset coefficient; Create a cosine function to receive the deformable vertex coordinates to control the size of the vertex sine value fluctuation variable, and output the deformable vertex parameters controlled by the sine function by multiplying it with the preset coefficient.
8. A device for generating a fully transparent material for simulating fluid accumulation in a cavity, characterized in that: include: A highlight texture mapping module, wherein the highlight texture mapping module is used to configure rendering texture parameters and color parameters of the model to be rendered; A flow deformation control module, wherein the flow deformation control module is used to adjust the rendering texture deformation parameters of the model to be rendered; A smoothness controller, wherein the smoothness controller is used to control the smoothness of the rendered texture; A refraction controller, which is used to control the refraction effect occurring with the scene light source during the rendering process; A transparency controller, wherein the transparency controller is used to control the transparency of the rendered material ball; A rendering module, wherein the rendering module has a plurality of input ports, wherein the highlight texture mapping module, the flow deformation control module, the smoothness controller, the refraction controller and the transparency controller are respectively connected to different input ports of the rendering module in a one-to-one correspondence, and the rendering is implemented through integration and linking through the rendering module, and the rendering data is output.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method according to any one of claims 1 to 7.