Simulation method and device for mixing of multiple layers of liquid in container, medium and product
By accumulating the color contribution of liquid layer by layer in the CMYK color model and converting the result to the RGB model, the problem of color accumulation and attenuation during liquid layer fusion is solved, and a realistic visual effect of liquid mixing is achieved.
Patent Information
- Application Number
- CN202511255656.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-12-12
AI Technical Summary
The simulation of liquid color mixing is unrealistic and fails to accurately represent the process of color accumulation and decay during the layering and blending of liquids.
The CMYK color model is used for color mixing calculations, accumulating the color contribution of the liquid to be mixed layer by layer. By converting CMYK to RGB, the optical superposition and subtractive mixing effect of liquid layer fusion is simulated, avoiding the saturation reduction and color distortion caused by direct mixing of RGB color models.
It achieves a realistic simulation of liquid mixing visual effects, maintaining a natural sense of layering and color authenticity, and improving the visual realism and accuracy of liquid mixing.
Smart Images

Figure CN121120908A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer rendering, and more particularly to a method, apparatus, medium, and product for simulating the mixing of multiple liquids within a container. Background Technology
[0002] In the field of computer graphics, the simulation of multi-layer liquid mixing effects is widely used in film and television special effects, game development, and virtual simulation.
[0003] In terms of liquid color mixing, some indie games use a spray-painting mixing scheme, which calculates color overlay based on the three primary colors of red, blue, and yellow: by spraying different colored liquids onto the same location, they are mixed in preset proportions to generate secondary colors such as green, purple, and orange, and if mixed again, they tend towards black. This scheme usually only supports a limited number of preset input colors, which are converted into target colors through fixed proportion calculations to achieve basic color mixing effects.
[0004] However, the inventors discovered at least the following technical problems in the related technology: the simulation effect of liquid color mixing is not realistic and it is difficult to accurately present the process of color accumulation and decay when liquid layers are blended. Summary of the Invention
[0005] One objective of this application is to provide a method, apparatus, medium, and product for simulating the mixing of multiple layers of liquid in a container, at least to solve the technical problem in the related art that the simulation effect of liquid color mixing is not realistic and it is difficult to accurately present the color accumulation and decay process when liquid layers are blended.
[0006] To achieve the above objectives, some embodiments of this application provide the following aspects:
[0007] In a first aspect, some embodiments of this application also provide a method for simulating the mixing of multiple layers of liquids within a container. The method includes: determining a target mixed color state based on an initial reference color and color parameters of at least one liquid to be mixed; wherein the target mixed color state is obtained in a CMYK color model and is used to simulate the color mixing effect of liquid layer fusion by accumulating color contributions layer by layer; and converting the target mixed color state from the CMYK color model to the RGB color model to obtain mixed RGB color values.
[0008] Secondly, some embodiments of this application also provide an electronic device, the electronic device comprising: one or more processors; and a memory storing computer program instructions, which, when executed, cause the processor to perform the steps of the method described above.
[0009] Thirdly, some embodiments of this application also provide a computer-readable medium having computer program instructions stored thereon, which can be executed by a processor to implement the method described above.
[0010] Fourthly, some embodiments of this application also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the method described above.
[0011] Compared with related technologies, the solution provided in this application places the color mixing calculation in the CMYK color model and accumulates the color contribution of the liquid to be mixed layer by layer based on the initial reference color. Therefore, it can more accurately simulate the optical superposition and subtractive mixing effect when real liquids are layered and fused, effectively avoiding the problems of saturation reduction and color distortion that occur when directly mixing in the traditional RGB color model. Furthermore, by converting the obtained target mixed color state back to the RGB color model, the mixed color value that can be directly used for display and processing can be output while retaining the natural sense of mixing hierarchy and color authenticity. This is conducive to achieving realistic and efficient simulation of liquid mixing visual effects. Attached Figure Description
[0012] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0013] Figure 1 An exemplary flowchart of a method for simulating multilayer liquid mixing within a container, provided for some embodiments;
[0014] Figure 2 Exemplary schematic diagrams of an RGB color model and a CMYK color model provided for some embodiments;
[0015] Figure 3 An exemplary schematic diagram of a different liquid separation state provided for some embodiments;
[0016] Figure 4 Exemplary effect comparison diagrams of a simulation method for mixing multiple liquids in a container provided for some embodiments;
[0017] Figure 5 An exemplary schematic diagram illustrating the basic states of liquids with different physical properties, provided for some embodiments;
[0018] Figure 6 An exemplary schematic diagram of the front and rear halves provided for some embodiments of this application;
[0019] Figure 7 An exemplary schematic diagram illustrating the processing effect of color space coordinate system transformation provided in some embodiments of this application;
[0020] Figure 8 An exemplary schematic diagram illustrating the difference in liquid disturbance effect based on polar coordinate sampling noise, provided for some embodiments of this application;
[0021] Figure 9 An exemplary schematic diagram illustrating the basic visual state of different surfaces of a liquid inside a container, provided for some embodiments of this application;
[0022] Figure 10 An exemplary schematic diagram illustrating the effect of a virtual liquid surface partition on realism in some embodiments of this application;
[0023] Figure 11 An exemplary schematic diagram illustrating the difference in effect between rendering liquid inside a container with and without refraction processing in the final rendering stage, provided for some embodiments of this application;
[0024] Figure 12 This is an exemplary structural diagram of an electronic device provided for some embodiments of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0026] The following terms are used in this document.
[0027] The CMYK color model is a color model used in the printing industry. Based on the subtractive color mixing principle, it generates colors by mixing four inks: cyan, magenta, yellow, and key / black. Specifically, the ink absorbs some light and reflects the remaining spectrum, thus forming the color perceived by the human eye. This differs from the additive color model, which uses red, green, and blue as primary colors and is mainly used to describe the color composition of self-luminous materials.
[0028] PBR, or Physically Based Rendering, is a computer graphics rendering technique that follows real-world optical principles. It generates highly realistic images by simulating the physical interaction between light and object surfaces. Its core feature is ensuring the physical accuracy of material representation and the consistency of lighting environment.
[0029] Noise: In computer graphics, noise refers to functions, algorithms, or texture maps used to generate pseudo-random numerical variations. It is commonly used in procedural texturing, terrain simulation, and detail rendering to enhance the realism of graphics by adding a sense of naturalness and randomness to object surfaces and visual effects. A noise gradient is a gradual effect created by applying a regular transition process to the noise values. This gradient retains the randomness of the noise itself while presenting a smooth transition through continuous numerical changes.
[0030] Polar coordinates: a planar coordinate system. It uses the origin as the pole and a reference ray as the polar axis. The position of a point on a plane is uniquely determined by the distance from the point to the pole (i.e., radius r) and the angle between the line connecting the point to the pole and the polar axis (i.e., angle θ).
[0031] Containers: In liquid rendering, different rendering strategies are required for liquids of different sizes (from the ocean to the liquid inside a crystal ball). This application is mainly used for rendering small-scale liquids inside containers.
[0032] UV: UV is the two-dimensional texture coordinate of the surface of a 3D model, used to accurately map a two-dimensional texture image onto the surface of a 3D model.
[0033] First Embodiment
[0034] The first embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid within a container. For example... Figure 1 As shown, the method may include the following steps:
[0035] Step S101: Determine the target mixed color state based on the initial reference color and the color parameters of at least one liquid to be mixed; wherein, the target mixed color state is obtained in the CMYK color model and is used to simulate the color mixing effect of liquid layer fusion by accumulating color contributions layer by layer.
[0036] Step S102: Convert the target mixed color state from the CMYK color model to the RGB color model to obtain the mixed RGB color value.
[0037] The following sections will provide a detailed explanation of each of the above steps.
[0038] Specifically, step S101 aims to convert the color mixing calculation from the conventional RGB color model to the CMYK color model in order to solve the color distortion and saturation loss problems caused by traditional RGB linear mixing.
[0039] For example, the base color of the container can be initially mixed with the existing liquid color (if any) in the CMYK space to form an initial color reference. This initial color reference characterizes the overall color state within the container. Subsequently, the RGB color parameters of each newly added liquid to be mixed can be converted to the CMYK color model. Through the four CMYK channels, the physical process of color accumulation layer by layer is dynamically simulated, continuously updating the current mixing state until the target mixed color state is generated. This target mixed color state can reproduce the realistic visual effect of liquid layering and blending.
[0040] For step S102, for example, the target mixed color state obtained after the mixing calculation can be converted back to the RGB color model through inverse color model transformation to obtain the mixed color value. Then, the color difference of different liquid layer states can be rendered through the mixed color value to enhance the visual realism.
[0041] It should be noted that, as Figure 2 As shown, the RGB color model and the CMYK color model have fundamental differences: the RGB model on the left is an additive color mixing system, using red, green, and blue as basic colors. Color changes are produced through the superposition of light, and white is produced when the intensity of the three primary colors reaches its maximum. It is commonly used in electronic display devices. The CMYK color model on the right is a subtractive color mixing system, composed of four basic colors: cyan, magenta, yellow, and black. Colors are formed through the selective absorption and reflection of light by pigments. The superposition of the four colors approaches black, and it is commonly used in the printing and publishing industry. This difference provides a theoretical basis for the color model conversion in steps S101 and S102: considering that the subtractive color characteristics are more in line with the optical performance of liquid superposition, this embodiment simulates the physical mixing process of liquid layering and fusion using the CMYK model, and then converts back to the RGB model to adapt to the display requirements of electronic devices, thus achieving the goal of balancing simulation realism and display compatibility.
[0042] For example, the implementation of different liquid stratification states may include: determining the property characteristics of the upper and lower liquid layers by inputting liquid physical parameters (such as density, viscosity, transparency, etc.), and then determining the corresponding interface stratification mode based on the property matching results. Figure 3As shown, from left to right, the three images sequentially present the layering of different liquid types: the first image shows the layering between transparent and clear liquids, where the two transparent liquids form a clear and relatively thin interface; the second image shows the layering between a transparent and clear liquid and a viscous liquid, where the viscous liquid, due to its weak fluidity, presents a softer and more transitional interface with the transparent liquid; the third image shows the layering between viscous liquids, where, due to its viscous nature, the boundaries between the liquid layers retain a certain degree of fusion and transition while exhibiting a thicker and more textured separation effect.
[0043] like Figure 4 The image shows an exemplary effect comparison of a simulation method for mixing multiple layers of liquid in a container, provided by some embodiments: the left side shows the color state when multiple liquid layers are layered, and the right side shows the mixed color state after multi-layer color mixing by converting the target mixed color state from the CMYK color model to the RGB color model based on the color state when the liquid layers are layered on the left side.
[0044] It is not difficult to see that, compared with related technologies, the solution provided in this application places the color mixing calculation in the CMYK color model, and accumulates the color contribution of the liquid to be mixed layer by layer based on the initial reference color. This can more accurately simulate the optical superposition and subtractive mixing effect when real liquids are layered and fused, effectively avoiding the problems of saturation reduction and color distortion that occur when directly mixing in the traditional RGB color model. Then, the obtained target mixed color state is converted back to the RGB color model, so as to retain the natural sense of mixing hierarchy and color authenticity, while outputting mixed color values that can be directly used for display and processing, which is conducive to achieving realistic and efficient simulation of liquid mixing visual effects.
[0045] Second Embodiment
[0046] The second embodiment of this application relates to a method for simulating the mixing of multiple liquids within a container. The second embodiment is an improvement upon the first embodiment, specifically in that it provides a method for determining the target mixed color state in the CMYK color model based on an initial reference and color parameters of at least one liquid to be mixed.
[0047] Specifically, determining the target mixed color state based on the initial reference color and the color parameters of at least one liquid to be mixed, i.e., step S101 may include the following steps:
[0048] Step S1011: Determine the current accumulated color state based on the initial reference color;
[0049] Step S1012: Determine the updated cumulative color state sequentially based on the color parameters of each liquid to be mixed and the current cumulative color state;
[0050] Step S1013: Determine the target mixed color state based on the cumulative color state after all liquid layers have been processed.
[0051] Specifically, after determining the initial reference color, the color parameters of each layer of liquid to be mixed and the current cumulative color state can be fused according to the order in which the liquids are poured into the container, so as to obtain the target mixed color state that simulates the superposition effect of multiple liquids.
[0052] For example, suppose in step S1011, the initial base color of a transparent container is white, corresponding to CMYK(0,0,0,0), that is, the current accumulated color state is initialized to CMYK(0,0,0,0). Then proceed to step S1012: first process the first layer of liquid to be mixed (red juice), its color parameters are converted to CMYK(0,100,100,0), and this CMYK value is merged with the current accumulated state (white). Since it is the first layer of liquid, the updated accumulated color state is CMYK(0,100,100,0) (i.e., red); then process the second layer of liquid to be mixed (blue syrup), its color parameters are converted to CMYK(100,100,0,0), and so on, until step S1013 is entered, where the target mixed color state is determined based on the accumulated color state after all liquid layers have been processed.
[0053] Optionally, in some embodiments, the step of sequentially determining the updated cumulative color state based on the color parameters of each liquid to be mixed and the current cumulative color state, i.e., step S1012, may include:
[0054] Step S1012A: Determine the corresponding CMYK color value of the liquid based on the RGB color value of the liquid to be mixed.
[0055] Step S1012B: Determine a new cumulative color state based on the liquid CMYK color value, the first mixing weight of the current liquid layer, and the current cumulative color state; the first mixing weight is used to quantify the contribution ratio of the current liquid layer color in the mixing process.
[0056] Step S1012C: Determine the current accumulated color state based on the new accumulated color state.
[0057] Specifically, for step S1012A, it is necessary to first convert the color of the liquid to be mixed, originally defined in the RGB color model, into its equivalent representation in the CMYK color model. For example, if the RGB color value of the liquid to be mixed is (R:255, G:0, B:0) (pure red), then the corresponding color value of the liquid to be mixed in the CMYK space (e.g., C:0%, M:100%, Y:100%, K:0%) can be obtained through conversion calculation.
[0058] Specifically, in step S1012B, the liquid CMYK color values can be fused with the previously accumulated color states according to the first mixing weight of the current liquid layer. For example, if the current accumulated color state is (C: 50%, M: 30%, Y: 40%, K: 10%), the CMYK value of the newly added liquid is (C: 0%, M: 100%, Y: 100%, K: 0%), and the first mixing weight of the current liquid layer is 0.3, indicating that the contribution of this liquid layer to the final color is 30%, then the weighted average of each CMYK channel can be calculated to obtain a new, fused four-channel color value as the new accumulated color state.
[0059] Specifically, step S1012C updates the mixing state through iteration. The new color state calculated in step S1012B is set as the current cumulative color state, preparing for the mixing calculation of the next liquid layer. For example, after calculating the mixing of the above liquid layers, the new cumulative color state (e.g., C: 35%, M: 51%, Y: 58%, K: 7%) immediately overwrites the old state. If a new liquid layer is added subsequently, the mixing calculation can continue based on this updated state, thereby achieving a layer-by-layer, cumulative color overlay effect.
[0060] Optionally, in some embodiments, the method for determining the first mixing weight may include: determining the first mixing weight based on the height parameter of the liquid to be mixed.
[0061] For example, the height parameter is used to characterize the position of the liquid in the Y-axis direction within the container. The first mixing weight can be determined by converting the relative height of the liquid in the container into a volume ratio, and is used to measure the degree of influence of the liquid layer on the final mixed color. The larger the volume ratio of the liquid layer, the higher its weight, and the more significant its influence on the mixing result. For example, if the total height of the container is 10 cm, the first liquid layer is 6 cm high, and its volume ratio is 60%, then the mixing weight of this liquid layer is 0.6; the second liquid layer is 4 cm high, and its volume ratio is 40%, with a mixing weight of 0.4. In this case, because the first liquid layer has a higher weight, its color will be more pronounced in the final mixing result than that of the second layer.
[0062] Optionally, in some embodiments, before determining the target mixed color state, the method may further include: determining whether to perform darkening processing on the color parameters of the liquid to be mixed based on the color parameters of the liquid to be mixed and the current cumulative color state.
[0063] Specifically, the similarity between the color parameters of the liquid to be mixed and the current accumulated color state can be determined. Based on the determination result, it can be determined whether to perform darkening processing on the color of the liquid to be mixed, thereby enhancing the visual distinction of the mixing edge of different liquid layers and avoiding blurring of the mixing boundary due to the colors being too similar.
[0064] For example, if the color parameters of the liquid to be mixed are RGB = (180, 200, 220), and the current cumulative color state is RGB = (170, 190, 210), calculations show that the color difference between the two is small. Based on this judgment, the color parameters of the liquid to be mixed can be darkened (brightness reduced) to RGB = (150, 170, 190); simultaneously, the current cumulative color state is also darkened accordingly to RGB = (140, 160, 180). After the darkening process, the edges of the two originally similar colors will show a more obvious transition when mixed, thus effectively solving the problem of blurred mixing boundaries caused by colors being too similar.
[0065] It should be noted that this embodiment can also be an improvement based on the second embodiment.
[0066] It is not difficult to see that in the embodiments of this application, by determining the current accumulated color state starting from the initial reference color, a unified and clear basis is provided for the mixing process, which can avoid mixing deviations caused by the ambiguity of the initial state; by processing the liquids to be mixed layer by layer, and updating the accumulated results sequentially according to the color parameters of each liquid and the current accumulated state, the color contribution of each liquid layer can be included in the mixing process, which can ensure the logical rigor of layer superposition; by determining the target mixed color state with the complete accumulated state after all liquid layers have been processed, it is beneficial to achieve accurate simulation of the real liquid layer fusion process, which can not only ensure the accuracy of color mixing, but also reflect the influence of different liquid layers on the sense of layering of the final color.
[0067] Third Embodiment
[0068] The third embodiment of this application relates to a method for simulating the mixing of multiple layers of liquids in a container. The third embodiment is an improvement upon the second embodiment, specifically in that it provides a method for determining the corresponding CMYK color value of the liquid based on the RGB color value of the liquid to be mixed.
[0069] Optionally, in some embodiments, determining the corresponding CMYK color value of the liquid based on the RGB color value of the current liquid to be mixed, i.e., step S1012A, may include:
[0070] Step SA1: Determine the complementary color components based on the components of the RGB color values; the complementary color components are used to characterize the theoretical base values of cyan, magenta, and yellow required to reproduce the liquid color without introducing the black component;
[0071] Step SA2: Determine the black component based on the complementary color components;
[0072] Step SA3: Determine the CMYK color value of the liquid based on the black component and the complementary color component.
[0073] Specifically, for step SA1, the red (R), green (G), and blue (B) primary color component values of the liquid layer to be mixed can be obtained as the raw input data for color model conversion. Complementary colors can be calculated based on the correspondence between RGB primary colors and CMYK complementary colors: that is, the complementary color of red is cyan, the complementary color of green is magenta, and the complementary color of blue is yellow. The base values of cyan (C), magenta (M), and yellow (Y) are calculated accordingly. For example:
[0074] Cyan component C = 1 - Red component R;
[0075] Magenta component M = 1 - Green component G;
[0076] Yellow component Y = 1 - Blue component B.
[0077] For example, if the RGB value of the liquid to be mixed is (0.2, 0.5, 0.8), then:
[0078] The cyan component C = 1 - 0.2 = 0.8;
[0079] The magenta component M = 1 - 0.5 = 0.5;
[0080] The yellow component Y = 1 - 0.8 = 0.2;
[0081] The complementary color components are (C = 0.8, M = 0.5, Y = 0.2).
[0082] Specifically, in step SA2, the black component is used to optimize color reproduction efficiency and reduce deviations caused by primary color superposition. The black component can be determined based on the baseline values of the cyan component C, magenta component M, and yellow component Y.
[0083] For example, the black component can be represented by K, and can be calculated by obtaining the minimum value among the complementary color components (C, M, Y) and taking the minimum value as the black component, i.e., K = min(C, M, Y). For example, assuming the complementary color components are (0.8, 0.5, 0.2) and the minimum value is 0.2, therefore, the black component K = 0.2.
[0084] Specifically, regarding step SA3, determining the liquid CMYK color value based on the black component and the complementary color component may include:
[0085] If the black component is equal to 1, then the CMYK color value of the liquid is determined to be pure black;
[0086] If the black component is less than 1, then the cyan, magenta, and yellow components in the liquid CMYK color value are determined based on the black component and the complementary color component.
[0087] Specifically, the complementary color components can be normalized by combining the black component K to obtain the CMYK color value of the liquid:
[0088] If K = 1 (i.e., C = M = Y = 1, corresponding to RGB as (0,0,0)), then the CMYK value of the liquid is pure black (0,0,0,1);
[0089] If K < 1, then normalize C, M, and Y:
[0090] The normalized cyan C' = (CK) / (1-K);
[0091] The normalized magenta color M' = (MK) / (1-K);
[0092] The normalized yellow value Y' = (YK) / (1-K);
[0093] The CMYK color values of the liquid are obtained as (C', M', Y', K).
[0094] For example, taking the results of steps SA1 and SA2 (C = 0.8, M = 0.5, Y = 0.2, K = 0.2) as an example, since K = 0.2 < 1, therefore:
[0095] The normalized cyan C' = (0.8 - 0.2) / (1 - 0.2) = 0.6 / 0.8 = 0.75;
[0096] The normalized magenta color M' = (0.5-0.2) / 0.8 = 0.3 / 0.8 = 0.375;
[0097] The normalized value of yellow Y' is (0.2-0.2) / 0.8 = 0;
[0098] Therefore, the CMYK color value of the liquid is (0.75, 0.375, 0, 0.2).
[0099] It should be noted that this embodiment can also be an improvement based on the first embodiment.
[0100] It is not difficult to see that in this embodiment, by calculating the complementary color components, namely the theoretical base values of cyan, magenta, and yellow, based on each component of the liquid RGB color value, and then determining the required black component based on the complementary color components, the overall amount of CMY three-color ink can be effectively replaced and reduced. Furthermore, by jointly determining the liquid CMYK color value through the black component and the complementary color components, the color distortion and brightness deviation that are easily caused when directly converting from RGB to CMYK can be effectively avoided, which is conducive to improving the accuracy and physical authenticity of subsequent color mixing calculations.
[0101] Fourth embodiment
[0102] The fourth embodiment of this application relates to a method for simulating the mixing of multiple liquids within a container. The fourth embodiment is an improvement upon the second embodiment, specifically in that it provides a method for determining a new cumulative color state based on the liquid's CMYK color values, a first mixing weight of the current liquid layer, and the current cumulative color state.
[0103] Optionally, in some embodiments, determining a new cumulative color state based on the liquid CMYK color value, the first mixing weight of the current liquid layer, and the current cumulative color state, i.e., step S1012B, may include:
[0104] Step SB1: Determine the first weighted component based on each channel component of the liquid CMYK color value and the first mixing weight;
[0105] Step SB2: Determine the second weighted component based on the channel components and compensation weights of the current accumulated color state; wherein the compensation weights are determined based on the first mixing weights.
[0106] Step SB3: Determine each channel component of the new cumulative color value based on the first weighted component and the second weighted component.
[0107] Specifically, for step SB1, the first weighted component is used to quantify the color contribution of the current liquid layer to be mixed to the final mixing result. Specifically, the four channel components of the liquid's CMYK color value—cyan (C), magenta (M), yellow (Y), and black (K)—can be multiplied by the first mixing weight of the liquid layer to obtain the first weighted component.
[0108] For example, if the current liquid to be mixed, CMYK, is (1,1,0,0), and the first mixing weight is 0.3, then:
[0109] The first weighted component C = 1 × 0.3 = 0.3;
[0110] The first weighted component M = 1 × 0.3 = 0.3;
[0111] The first weighted component Y = 0 × 0.3 = 0;
[0112] The first weighted component K = 0 × 0.3 = 0;
[0113] Specifically, for step SB2, the second weighted component is used to quantify the remaining contribution of the currently accumulated color state to the mixing result. Specifically, each CMYK channel component of the currently accumulated color state can be multiplied by a compensation weight (compensation weight = 1 - mixing weight) to balance the contribution ratio of the current liquid layer.
[0114] For example, if the current cumulative color state's CMYK value is (0, 0.5, 0.5, 0), and the first blending weight is 0.3 (compensation weight = 1 - 0.3 = 0.7), then:
[0115] The second weighted component C = 0 × 0.7 = 0;
[0116] The second weighted component M = 0.5 × 0.7 = 0.35;
[0117] The second weighted component Y = 0.5 × 0.7 = 0.35;
[0118] The second weighted component K = 0 × 0.7 = 0;
[0119] Specifically, for step SB3, the corresponding channel components of the first weighted component and the second weighted component can be added together to obtain a new cumulative color value, so as to realize the weighted fusion of the current liquid layer and the previous cumulative color to form a new cumulative color state.
[0120] For example, combining the results of steps SB1 and SB2, the components of each channel in the new cumulative color state are:
[0121] C = First weighted component C + Second weighted component C = 0.3 + 0 = 0.3;
[0122] M = First weighted component M + Second weighted component M = 0.3 + 0.35 = 0.65;
[0123] Y = First weighted component Y + Second weighted component Y = 0 + 0.35 = 0.35;
[0124] K = First weighted component K + Second weighted component K = 0 + 0 = 0;
[0125] Therefore, the new cumulative color state is (0.3, 0.65, 0.35, 0).
[0126] It should be noted that this embodiment may also be an improvement based on the first embodiment and / or the third embodiment.
[0127] It is not difficult to see that in the embodiments of this application, the color contribution of the current liquid layer to the mixing result (i.e., the first weighted component) is quantified by the channel components of the liquid CMYK color value and the first mixing weight, providing a numerical basis for the influence of each liquid layer; by the channel components of the current accumulated color state and the compensation weight (determined by the first mixing weight), the remaining contribution of the existing accumulated state (i.e., the second weighted component) can be calculated, ensuring the balance of the total color during the mixing process; by adding the corresponding channels of the first weighted component and the second weighted component, the smooth fusion of the current liquid layer and the previous accumulated state can be achieved, which can ensure that the color influence of each liquid layer is included in the mixing result proportionally, and maintain the continuity of the color transition between layers, thereby effectively improving the accuracy and naturalness of multi-layer liquid color mixing.
[0128] Fifth Embodiment
[0129] The fifth embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid in a container. The fifth embodiment is an improvement on the first embodiment, specifically in that: in this embodiment, based on the RGB color values obtained by color model conversion in the first embodiment, a height parameter and a noise map are further introduced to control the gradual transition of the interlayer mixing region, thereby optimizing the calculation of the target pixel value and improving the realism of liquid layer fusion.
[0130] Optionally, in some embodiments, the method may further include:
[0131] Step S201: Determine the second mixing weight based on the height parameters of the liquid to be mixed and the noise map; the second mixing weight is used to control the gradual transition of the interlayer mixing region of the liquid.
[0132] Step S202: Determine the target pixel value based on the second mixing weight and the RGB color value.
[0133] Specifically, regarding step S201, the height parameter is used to determine the basic range of the mixing area (such as the height range at the boundary between two liquid layers). The noise map can add irregular fluctuations to the mixing ratio within the basic range to simulate the edge blurring characteristics of real liquid flow. For example, suppose the lower layer in the container is red liquid (height 0-5cm) and the upper layer is blue liquid (height 5-10cm), and the liquid to be mixed is the upper blue liquid with a height parameter range of 5-10cm. First, determine the base blending ratio based on the height parameter: at 5cm (the boundary between the two layers), the base ratio is 0.5 (red and blue each occupy half), at 7.5cm, the base ratio is 0.75 (blue accounts for a higher proportion), and at 10cm, the base ratio is 1 (pure blue). Then, fine-tune the base ratio by combining it with the noise map (e.g., at 5.2cm, the random value obtained by sampling the noise map changes the ratio from 0.52 to 0.48), so that the second blending weight at this position is 0.48, which is used to control the gradual transition of red and blue at this point.
[0134] Specifically, in step S202, based on the second mixing weight, the RGB color values of the current liquid to be mixed and the RGB color values of the lower liquid are weighted and mixed to calculate the target pixel value, thereby presenting a visual effect of natural transition between layers. The second mixing weight directly determines the proportion of the two colors: the higher the weight value, the more prominent the color of the current liquid in the pixel; the lower the weight value, the more obvious the color of the lower liquid. This continuous weighted calculation provided in this embodiment avoids harsh boundaries between layers.
[0135] For example, following step S201, if the RGB color value of the blue liquid to be mixed is (0,0,255), and the RGB color value of the lower red liquid is (255,0,0), and the second mixing weight of a certain pixel is calculated to be 0.48 in S201, then the target pixel value of that pixel is calculated as: blue RGB × 0.48 + red RGB × (1 - 0.48), i.e., (255 × 0.52, 0, 255 × 0.48) ≈ (132, 0, 122), presenting a reddish purple. At the pixel with a weight of 0.75, the target pixel value is (255 × 0.25, 0, 255 × 0.75) ≈ (64, 0, 191), presenting a bluish purple. Through the continuous change of different weights, the boundary area between the two liquid layers presents a smooth gradient from red to blue, simulating the natural transition effect of real liquid mixing.
[0136] Optionally, in some embodiments, determining the second mixing weight based on the current height parameter and noise map of the liquid to be mixed, i.e., step S201, may include:
[0137] Step S2011: Determine the basic fusion ratio based on the current height parameters of the liquid to be mixed, the preset starting value, and the preset ending value;
[0138] Step S2012: Determine the second mixing weight based on the basic fusion ratio.
[0139] Specifically, for step S2011, the height parameter of the liquid to be mixed can be converted into a basic fusion ratio between 0 and 1. The conversion rule is defined by a preset start value and a preset end value to achieve a smooth transition of the mixing effect.
[0140] In some examples, when the liquid height is below a preset starting value, the basic fusion ratio is 0 (meaning that the liquid layer does not participate in mixing and fully displays the color of the lower liquid layer); when the liquid height is above a preset ending value, the basic fusion ratio is 1 (meaning that the liquid layer fully participates in mixing and mainly displays its own color); when the liquid height is between the starting and ending values, the ratio is calculated using a smooth curve (such as linear interpolation or easing function) so that the basic fusion ratio gradually transitions from 0 to 1 as the height increases, providing basic parameters for interlayer gradation.
[0141] For example, assuming the total height of the container is 0-30 cm, and the liquid to be mixed is the upper layer, a preset starting value of 10 cm (the lower limit of the boundary between the lower and upper layers) and a preset ending value of 20 cm (the upper limit of complete coverage by the upper layer) are set. When the liquid height is 8 cm (below the starting value), the basic blending ratio is 0; when the height is 15 cm (between the starting and ending values), the basic blending ratio is calculated to be 0.5 through linear interpolation; and when the height is 25 cm (above the ending value), the basic blending ratio is 1. This calculation method allows the basic ratio to change continuously with height.
[0142] Specifically, for step S2012, the obtained basic fusion ratio can be directly determined as the second mixing weight, or a simple adjustment can be made based on the basic fusion ratio to obtain the second mixing weight. The second mixing weight inherits the 0-1 range characteristic of the basic fusion ratio, directly reflecting the color proportion relationship between the current liquid to be mixed and the lower layer liquid at a certain position: the closer the weight is to 1, the higher the proportion of the current liquid color in the mixture; the closer it is to 0, the higher the proportion of the lower layer liquid color, thereby achieving a smooth transition of colors between layers.
[0143] Optionally, in some embodiments, determining the mixing weight based on the basic mixing ratio, i.e., step S2012, may include:
[0144] Step S20121: Determine the first sampling result based on the height parameter and the noise map;
[0145] Step S20122: Determine the first noise factor based on the first sampling result and the noise intensity parameter;
[0146] Step S20123: Determine the second mixing weight based on the basic fusion ratio and the first noise factor.
[0147] Specifically, for step S20121, texture sampling can be performed on the channel noise map based on the height parameter to obtain the noise texture value corresponding to that location. In this embodiment, the noise map is used to introduce random perturbations to simulate the irregular transparency and spread effect of the liquid edge, making the blending boundary more natural. For example, assuming the liquid height corresponds to the Y-axis coordinate of the noise map, when the height is 15 cm, the texture value (e.g., 0.3) at the coordinate (0.5, 0.5) in the noise map is sampled. This value reflects the degree of perturbation at the liquid edge at the current height.
[0148] Specifically, in step S20122, the first sampling result can be multiplied by the noise intensity parameter to obtain the first noise factor. The noise intensity parameter controls the amplitude of the disturbance; the higher the intensity, the greater the adjustment of the basic mixing ratio by the first noise factor, and the more pronounced the irregularity of the liquid edge. For example, if the noise sampling value is 0.3 and the noise intensity parameter is set to 0.2, then the first noise factor = 0.3 × 0.2 = 0.06. The first noise factor is used to subsequently adjust the basic mixing ratio, causing the mixing weight to fluctuate randomly within a range of ±0.06.
[0149] Specifically, in step S20123, the base mixing ratio and the first noise factor can be superimposed to obtain the second mixing weight. In this step, by superimposing the first noise factor, the second mixing weight can be made to randomly vary around the base mixing ratio, simulating the irregular boundary during the natural spread of liquid. For example, if the base mixing ratio is 0.5 and the first noise factor is 0.06, the superposition result is 0.56; if the first noise factor is -0.06, the superposition result is 0.44, and the second mixing weight is 0.44.
[0150] It should be noted that this embodiment may also be an improvement based on any one or more of the second to fourth embodiments.
[0151] It is not difficult to see that in this embodiment, by dynamically generating a second mixing weight based on the liquid height parameter and noise map, the non-uniform mixing region formed between liquid layers due to diffusion, penetration, etc., can be accurately simulated, realizing a natural gradient transition of the mixing edge; furthermore, by combining the second mixing weight with the RGB color value of the liquid to calculate the target pixel value, the generated mixed color visually presents rich details and soft layer changes, effectively avoiding harsh boundaries between colors, and significantly improving the realism and visual effect of liquid mixing simulation.
[0152] Sixth Embodiment
[0153] The sixth embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid within a container. The sixth embodiment is an improvement upon the fifth embodiment, specifically in that: in this embodiment, a transparency dimension processing is further introduced, providing a specific implementation method for determining the target pixel value based on the second mixing weight and the RGB color value.
[0154] The step S202, which determines the target pixel value based on the second mixing weight and the RGB color value, may include:
[0155] Step S2021: Determine the mixing transparency value based on the transparency parameters of each liquid to be mixed;
[0156] Step S2022: Determine the target pixel value based on the blended transparency value, the RGB color value, and the second blending weight.
[0157] Specifically, for step S2021, the transparency parameters (typically alpha values, ranging from 0 to 1, where 0 represents complete transparency and 1 represents complete opacity) can be integrated to calculate a mixed transparency value characterizing the overall transparency effect of the multi-layered liquids. This can be achieved through layer-by-layer processing: based on the transparency parameters of the current liquid to be mixed, combined with the current cumulative transparency state (i.e., the integrated transparency result of all previous liquid layers), the cumulative transparency state is updated according to a preset rule; after all liquid layers have been processed, the final cumulative transparency state is the mixed transparency value, used to reflect the overall transparency after the multi-layered liquids are stacked. For example, the preset rule can be: weighted stacking based on the height or volume percentage of each liquid layer.
[0158] For example, if a container contains three layers of liquid, with the first layer having a transparency parameter of 0.2 (30% of the height), the second layer 0.5 (50% of the height), and the third layer 0.8 (20% of the height), the processing would be as follows:
[0159] The initial cumulative transparency state is 0;
[0160] First layer processing: Updated cumulative transparency state = 0 + (0.2 × 30%) = 0.06;
[0161] Second layer processing: Updated cumulative transparency state = 0.06 + (0.5 × 50%) = 0.06 + 0.25 = 0.31;
[0162] Third layer processing: Updated cumulative transparency state = 0.31 + (0.8 × 20%) = 0.31 + 0.16 = 0.47;
[0163] The final mixed transparency value is 0.47, representing the overall transparency of the three liquid layers after mixing.
[0164] Specifically, for step S2022, the target pixel value, which simultaneously contains RGB color values and transparency information, can be calculated by combining the mixed transparency value, RGB color value, and second mixing weight, to simulate the visual effect of color and transparency working together when real liquids are mixed. In some examples, the RGB color values of the liquid to be mixed and the lower layer liquid can be weighted and fused according to the second mixing weight to obtain a basic mixed color; then, this mixed color can be associated with the mixed transparency value, and the target pixel value can be obtained by interpolating it with the background color (such as the ambient color outside the container) according to the transparency ratio.
[0165] Taking step S2021 as an example: Assume the liquid to be mixed is blue on the top layer (RGB(0,0,255)) and red on the bottom layer (RGB(255,0,0)). The second mixing weight of a certain pixel is 0.4 (meaning that blue accounts for 40% and red accounts for 60%), the mixing transparency value is 0.6 (meaning that the whole is 60% opaque and 40% transparent to the background), and the background color is white (RGB(255,255,255)).
[0166] Step 1: First, calculate the basic mixed color = blue × 0.4 + red × 0.6 = (255 × 0.6, 0, 255 × 0.4) = (153, 0, 102);
[0167] Step 2: You can combine the blending transparency value with the background color to calculate the RGB of the target pixel:
[0168] Red channel = 153 × 0.6 + 255 × 0.4 = 91.8 + 102 = 193.8 ≈ 194;
[0169] Green channel = 0 × 0.6 + 255 × 0.4 = 0 + 102 = 102;
[0170] Blue channel = 102 × 0.6 + 255 × 0.4 = 61.2 + 102 = 163.2 ≈ 163;
[0171] Step 3: Directly set the transparency channel to a blend transparency value of 0.6;
[0172] The resulting target pixel value is (194, 102, 163, 0.6). This approach not only reflects the color transition of red and blue mixing through the second mixing weight, but also reflects the background transparency effect through the mixing transparency value, making it closer to the visual representation of real liquids.
[0173] It should be noted that this embodiment may also be an improvement based on any one or more of the first to fourth embodiments.
[0174] It is not difficult to see that in the embodiments of this application, the mixed transparency value is calculated based on the transparency parameters of each liquid, thus accurately quantifying the overall light transmittance characteristics after different liquid layers are superimposed; then, by comprehensively calculating the mixed transparency value, the RGB color values of each liquid layer and the second mixing weight, the final generated target pixel value can not only realistically reflect the optical layer changes caused by the difference in transparency when the liquid is mixed, but also control the gradient effect of the mixed area through weight, which can significantly improve the visual realism and naturalness of the simulation, and effectively avoid the stiffness of color mixing and unrealistic light transmittance.
[0175] Seventh Embodiment
[0176] The seventh embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid within a container. The seventh embodiment is an improvement upon the first embodiment, specifically in that the method further includes a rendering step of multiple layers of transparent liquid.
[0177] Optionally, the rendering step may include:
[0178] Step S301: Determine the illumination result of each liquid layer based on the mixed RGB color values and the physical property parameters of each liquid layer;
[0179] Step S302: Determine the multi-layer liquid mixing lighting effect based on the preset light mixing weight of each liquid layer and the lighting result;
[0180] Step S303: Determine the rendering result based on the multi-layer liquid mixing lighting effect.
[0181] For step S301, for example, the illumination result of each liquid layer can be determined by decomposing the illumination model and based on the mixed RGB color values and the physical property parameters of each liquid layer. The physical property parameters are used to assign unique visual characteristics to different liquids.
[0182] Optionally, in some embodiments, the physical property parameters include at least one of the following: surface porosity, impurity, smoothness, metallicity, noise intensity, transparency, and bubble content.
[0183] The surface porosity characterizes the surface roughness. The impurity level describes the suspended particle content. The smoothness reflects the surface's reflectivity. The metallicity simulates the content of metal particles. The noise intensity controls the degree of random disturbance. The transparency represents the light transmittance. The bubble content describes the bubble density.
[0184] Combined with the multi-layer liquid mixing simulation method in the container of this application, Figure 5 The three liquids are shown in their basic states from left to right: Liquid A, which has a high surface porosity and contains impurities, has a rough and granular texture due to its physical parameters; Liquid B, which is opaque, has a smooth surface and no bubbles, has a flat and heavy visual effect due to its physical properties; and Liquid C, which is transparent, has a highly smooth surface and contains bubbles, has a transparent texture with reflective bubbles due to its physical properties.
[0185] For step S302, for example, the illumination results of each layer of liquid can be weighted and superimposed by a preset illumination mixing weight to obtain the overall illumination effect of the multi-layer liquid.
[0186] For step S303, for example, the multi-layered mixed lighting effect can be fused with the RGB color values output by the first embodiment to generate the final rendering result. Specifically, the brightness and saturation of the colors can be adjusted, or lighting and shadows can be superimposed to make the liquid color present a more realistic texture under lighting, such as brightening the color under strong light and deepening the color in shadows. At the same time, combined with dynamic liquid surface disturbance and other effects, the final pixel value is calculated.
[0187] Optionally, in some embodiments, the step of determining the multilayer liquid mixing lighting effect based on preset lighting mixing weights and lighting results, i.e., step S302, may include:
[0188] Step S3021: Determine the illumination mixing weight based on the height ratio of each liquid layer and the second noise factor; the second noise factor is determined based on the height parameter and the second sampling result of the illumination noise map.
[0189] Step S3022: Determine the multi-layer liquid mixing illumination effect based on the illumination mixing weight and the total illumination result of each liquid layer.
[0190] Specifically, the height percentage can refer to a base proportion; the higher the liquid layer, the greater its base weight. The second noise factor can be obtained by sampling from the illumination noise map using the height parameter, and is used to add random fluctuations to the weights, simulating the natural irregularity of illumination distribution during liquid flow. For example, in a container, the upper layer of juice accounts for 60% of the height, and the lower layer of water accounts for 40%. By sampling the height percentage of each liquid layer from the illumination noise map, the second noise factor is obtained as 0.08. Then, the upper layer illumination mixing weight = 60% + 0.08 = 0.68, and the lower layer illumination mixing weight = 40% - 0.08 = 0.32, which reflects the dominance of the upper layer while avoiding mechanical weight allocation through the noise factor.
[0191] Specifically, the total illumination results of each liquid layer can be weighted and superimposed according to the illumination mixing weight to obtain the overall mixed illumination effect of the multi-layer liquid. The illumination mixing weight directly determines the contribution ratio of each layer's illumination to the final effect. The higher the illumination mixing weight, the more prominent the illumination characteristics (such as color and brightness) of the corresponding liquid layer. For example, the total illumination result of the upper layer of juice is (130, 130, 80), with an illumination mixing weight of 0.68; the total illumination result of the lower layer of water is (30, 100, 180), with a weight of 0.32. The mixed lighting effect is calculated as follows: (130×0.68+30×0.32, 130×0.68+100×0.32, 80×0.68+180×0.32)≈(88.4+9.6, 88.4+32, 54.4+57.6)=(98,120.4,112), which presents a mixed effect where the upper layer of juice is dominated by light and the lower layer of water is assisted by light.
[0192] Optionally, in some embodiments, determining the rendering result based on the multi-layer liquid mixing lighting effect, i.e., step S303, may include:
[0193] The fused color lighting result is determined based on the mixed color value and the multi-layer liquid mixing lighting effect.
[0194] For example, the mixed color value output by the first embodiment and the multilayer liquid mixed lighting effect can be fused at the channel level, which is usually achieved through multiplication operations of each color channel. Specifically, each channel value of the mixed lighting effect (representing the intensity of the light's influence on that color channel) can be multiplied by the corresponding channel value of the mixed color value, so that the base color changes naturally with the intensity of the light, resulting in a fusion result that retains the characteristics of the base mixed color while reflecting the influence of the light.
[0195] For example, if the mixed color value is (180, 120, 50) (a base color with an orange tint), and the multi-layer liquid mixing lighting effect is (100, 120, 90) (lighting characteristics of slightly weak red light, medium green light, and relatively weak blue light), then the result of the blended color lighting is calculated by multiplying each channel separately and then normalizing (dividing by 255 to maintain the range of 0-255): Red channel = 180 × 100 ÷ 255 ≈ 70.6, Green channel = 120 × 120 ÷ 255 ≈ 56.5, Blue channel = 50 × 90 ÷ 255 ≈ 17.6, and the final result is approximately (71, 57, 18), presenting a darker orange tone under the lighting, which is consistent with the visual appearance of real liquids under this lighting condition.
[0196] It should be noted that this embodiment may also be an improvement based on any one or more embodiments from the second to the sixth embodiment.
[0197] It is easy to see that in the embodiments of this application, in the field of liquid lighting rendering, physically based rendering (PBR) parameters are used as the basic input, covering core elements such as intrinsic color, normal, metallicity, smoothness, and transparency. On this basis, texture control parameters such as turbidity, impurity level, and rough surface level are innovatively introduced, and combined with pre-baked four-channel texture maps, to achieve precise control over different liquid textures. Compared with existing solutions, it can present a richer and more diverse range of liquid textures.
[0198] In terms of light processing, by accurately calculating RGB color values and the physical property parameters of each liquid layer, the independent optical effects of light reflection, transmission, and absorption on the surface of each liquid layer are simulated. Then, the lighting results of each layer are fused according to preset weights to realistically present the complex light interaction and energy accumulation effects when multiple liquid layers are superimposed. At the same time, the solution deeply integrates subsurface scattering, refraction, and reflection functions to further enhance the visual differences between different liquids. This results in the final output image not only having rich color levels and realistic light transitions, but also significantly improving the physical accuracy and visual realism of transparent liquid mixing rendering.
[0199] Eighth embodiment
[0200] The eighth embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid in a container. The eighth embodiment is an improvement upon the seventh embodiment, specifically in that it provides a method for determining the illumination result of each liquid layer based on the mixed RGB color values and the physical property parameters of each liquid layer.
[0201] Specifically, in some embodiments, determining the illumination result of each liquid layer based on the mixed RGB color values and the physical property parameters of each liquid layer, i.e., step S301, may include:
[0202] Step S3011: Determine the diffuse reflection light component based on the normal direction, illumination direction, and color parameters of the liquid layer.
[0203] Step S3012: Determine the specular reflection illumination component based on the normal direction, line of sight, roughness parameter, and color parameter of the liquid layer.
[0204] Step S3013: Determine the subsurface scattered light component based on the subsurface scattering parameters and color parameters of the liquid layer;
[0205] Step S3014: Determine the illumination result for each liquid layer based on the diffuse reflection illumination component, specular reflection illumination component, and subsurface scattering illumination component.
[0206] For example, the diffuse reflection intensity can be calculated using the Lambert diffuse reflection model based on the liquid surface normal direction, the illumination direction, and the color parameters. The diffuse reflection intensity is positively correlated with the incident light intensity, the cosine of the angle between the normal and the illumination direction, and the roughness of the liquid surface. The color parameters directly determine the hue of the reflected light. Specifically, the normal direction determines the incident angle of the light, the illumination direction characterizes the position of the light source, and the color parameters determine the basic reflected color.
[0207] For example, a Phong or Blinn-Phong model can be used based on the normal direction, the viewing direction, the roughness parameter, and the color parameter. The viewing direction is the camera's observation angle, the roughness parameter reflects the surface smoothness, and the color parameter determines the base hue of the specular highlight (e.g., liquid metal will exhibit colored highlights). The smaller the angle between the viewing direction and the reflection direction of the normal, the stronger the specular highlight; the lower the roughness, the more concentrated the specular highlight area.
[0208] For example, the light transmission effect at the edge of a liquid or in a turbid area can be calculated using subsurface scattering parameters and color parameters. The subsurface scattering parameters control the penetration depth and scattering intensity of light within the liquid, while the color parameters determine the color of the scattered light. Higher subsurface scattering parameter values result in a more turbid liquid and stronger scattered light, such as the milky white effect of milk. The color parameters also determine the wavelength shift of the scattered light, such as orange juice scattering orange-red light.
[0209] For example, diffuse reflection, specular reflection, and subsurface scattering can be superimposed to obtain the total illumination result of a single-layer liquid. The components are fused according to their physical weights: diffuse reflection constitutes the basic illumination, specular reflection adds surface highlights, and subsurface scattering supplements the soft effect of the light-transmitting areas. The superposition of the three components forms an illumination performance that conforms to the real physical laws.
[0210] Optionally, in some embodiments, determining the illumination result for each liquid layer based on the diffuse reflection illumination component, specular reflection illumination component, and subsurface scattering illumination component, i.e., step S3014, may include:
[0211] Step S30141: Determine the simulated diffuse light component based on the custom light source direction, light source color, normal direction of the liquid layer, and color parameters.
[0212] Step S30142: Determine the illumination result for each liquid layer based on the diffuse reflection illumination component, specular reflection illumination component, subsurface scattering illumination component, and simulated diffuse reflection illumination component.
[0213] Specifically, this embodiment can introduce custom light sources (such as ambient lighting or side lighting) to supplement the basic illumination. By customizing the direction (e.g., 45° upwards), color (e.g., light blue), liquid surface normal direction, and color parameters of the light source, simulated diffuse reflection components are calculated to enhance the lighting hierarchy. The simulated diffuse reflection components are similar in principle to basic diffuse reflection, but based on the characteristics of the custom light source, they can compensate for areas insufficiently illuminated by the main light source (e.g., the backlit surface of the liquid). Furthermore, the basic diffuse reflection, specular reflection, subsurface scattering, and simulated diffuse reflection components can be superimposed according to the light source intensity ratio to obtain a single-layer liquid lighting result that more closely resembles a real multi-light source environment.
[0214] It should be noted that this embodiment may also be an improvement based on any one or more embodiments from the first to the sixth embodiment.
[0215] It is easy to see that in this embodiment, by calculating the diffuse reflection lighting component based on the normal direction of the liquid, the lighting direction, and color parameters, the uniform scattering effect of light on the liquid surface is accurately simulated, laying the foundation for realistic lighting. Furthermore, by determining the specular reflection lighting component based on the normal direction, the viewing direction, roughness, and color parameters, the highlights and reflection details produced by the change in smoothness of the liquid surface are shown, enhancing the visual expressiveness of the material. By calculating the subsurface scattering lighting component based on the subsurface scattering parameters and color parameters, the soft translucent effect unique to light penetrating the liquid surface and scattering internally can be restored. Best of all, the above three lighting components are fused, so the obtained lighting result comprehensively and meticulously presents the real optical characteristics of each layer of liquid under complex lighting conditions, significantly improving the physical accuracy and visual richness of multi-layer transparent liquid rendering.
[0216] Ninth Embodiment
[0217] The ninth embodiment of this application relates to a method for simulating multi-layer liquid mixing within a container. The ninth embodiment is an improvement upon the seventh embodiment, specifically in that it incorporates a technical solution for calculating the dynamic liquid level state, building upon the seventh embodiment.
[0218] Specifically, in this embodiment, the method may further include:
[0219] Step S401: Determine the dynamic liquid level state based on the liquid level height parameter and liquid flow characteristics;
[0220] Step S402: Determine the rendering result based on the dynamic liquid surface state, the fused color lighting result, and the transparency parameters of each liquid layer.
[0221] Specifically, based on liquid level parameters (such as the real-time change from 10cm to 12cm) and liquid flow characteristics (such as viscosity 0.8 and flow velocity 0.3m / s), a normal map of dynamic liquid surface undulations can be generated using a noise function (such as Perlin noise) to determine the real-time fluctuation state of each point on the liquid surface (such as ripples on the liquid surface when simulating shaking a cup). Then, this dynamic state is blended with the color lighting result output by weight 18 (such as the orange-red mixture under static lighting) and the transparency parameters of each layer of liquid (such as the upper layer) The juice transparency is 0.7 and the lower water transparency is 0.9. The direction of light reflection is adjusted by dynamic normal (so that the highlights move with the fluctuations). The blend color and the background (such as white desktop RGB(255,255,255)) are interpolated according to the transparency (such as 70% of the liquid color is displayed and 30% of the background is visible when the transparency is 0.7). Finally, the rendering result of the color, light and shadow and transparency change synchronously when the liquid surface fluctuates (such as the highlights of the shaking orange juice surface are flashing and the edges are translucent orange-red due to light transmission).
[0222] Optionally, in some embodiments, determining the dynamic liquid surface state based on the liquid level height parameter and liquid flow characteristics, i.e., step S401, may include: performing differentiated processing on the liquid rendering channels of the front and rear halves, wherein:
[0223] For the first half, dynamic simulation is achieved by clipping the liquid surface in the normal direction, transforming the coordinate space, and sampling noise; the first half is used to characterize the visible surface area in the whole liquid surface where the normal direction is towards the observer;
[0224] For the rear half, visual filling is achieved through pseudo-plane calculation and interlayer parameter analysis; the liquid in the rear half is used to characterize the non-directly visible areas and interlayer junction areas in the overall liquid surface facing away from the observer.
[0225] like Figure 6As shown, the front half of the liquid surface, based on the observer's perspective, refers to the visible surface area of the liquid surface whose normal direction faces the observer. In actual rendering, the portion of the liquid surface facing the observer can be selected first by clipping along the normal direction, constructing a virtual liquid surface calculation area. Then, through coordinate space transformation and noise sampling to simulate dynamics, this area presents a dynamic effect strongly correlated with the observer's perspective, restoring the realistic dynamics directly visible to the observer. It is important to emphasize that the entire liquid surface belongs to the front half and is not separately separated; all of its content is used to support the rendering calculations of the front half of the liquid.
[0226] The latter half of the liquid corresponds to the liquid surface and rendering area on the side facing away from the observer. Since this area does not directly face the observer, a virtual interlayer filling logic can be constructed through pseudo-plane calculations: combining parameters such as the position of the liquid interface plane and the height / density of each layer, the interlayer intervals are analyzed and divided, and then the interlayer colors and transparency are adjusted based on the interval information to fill the visual blanks, avoiding the sense of discontinuity and emptiness caused by the invisible back side, making the overall layering of the multi-layered liquid more realistic.
[0227] Optionally, in some embodiments, the dynamic simulation achieved by cutting the liquid surface in the normal direction, coordinate space transformation, and noise sampling may include:
[0228] Step S401A1: Cut out the liquid surface part according to the normal direction and determine the virtual liquid surface calculation area used for the front half liquid rendering channel;
[0229] Step S401B1: Map the virtual liquid surface calculation area to polar coordinate space to determine the texture sampling plane;
[0230] Step S401C1: Determine the dynamic simulation parameters based on the polar coordinate space: when simulating the stirring process, the rotational dynamic parameters are calculated using the noise offset in the polar coordinate X-axis direction; when simulating the liquid addition process, the diffusion wave dynamic parameters are calculated using the noise offset in the polar coordinate Y-axis direction.
[0231] Specifically, the liquid surface can be first clipped according to the normal direction to determine the virtual liquid surface calculation area for rendering the front half of the liquid. For example, in a 3D water cup model, the half of the liquid surface facing the observer can be clipped along the normal direction of the liquid surface. Then, the virtual liquid surface calculation area is mapped to polar coordinate space to generate a texture sampling plane, so that the two-dimensional plane of the liquid surface is transformed into a polar coordinate system with the center point as the pole, which is convenient for noise texture sampling. Then, the dynamic simulation parameters are determined according to the polar coordinate space. Among them, when simulating stirring, the rotation dynamic parameters can be calculated by the noise offset in the polar coordinate X-axis direction. For example, when the X-axis noise offset is 0.2, the liquid surface is driven to produce a clockwise rotating dynamic texture. When simulating the addition of liquid, the diffusion wave dynamic parameters can be calculated by the noise offset in the polar coordinate Y-axis direction. For example, when the Y-axis noise offset is 0.3, the liquid surface presents a ripple effect that spreads from the center outward, which is better than the dynamic performance of the existing technology.
[0232] The polar coordinate mapping and transformation logic described above can be visually presented through color space visualization. See also... Figure 7 As shown, the processing effect of color space coordinate system transformation in some embodiments of this application is presented: the "Cartesian" on the left is the color distribution in the Cartesian coordinate system, presenting a gradient color mapping based on rectangular coordinates (X, Y axes); the "CartesianToPolarColor" on the right is calculated by CartesianToPolar, with a set offset origin as the center, repeatedly mapped on the XZ plane and converted to polar coordinates (with the distance and angle from the origin as parameters), so that the color distribution changes from a linear gradient in rectangular coordinates to a polar coordinate form arranged around the center according to the rules of polar radius and polar angle, intuitively demonstrating the logic of coordinate system transformation on color space distribution.
[0233] Optionally, in some embodiments, the visual filling achieved through pseudo-plane calculation and interlayer parameter analysis may include:
[0234] Step S401A2: Determine the layer boundary region based on the calculation range of the pseudo-plane and the position information of the liquid interface plane;
[0235] Step S401B2: Based on the height parameters and density differences of each liquid layer, determine the interval region for different liquid layers within the layer boundary region;
[0236] Step S401C2: Fill the visual gaps between the liquid layers on the rear half according to the interval area.
[0237] Specifically, the layer boundary region can be determined based on the pseudo-plane calculation range and the position information of the liquid interface plane. The pseudo-plane calculation range limits the calculation area for rendering the latter half of the liquid, while the liquid interface plane is the boundary position between different liquid layers. Combining the two can accurately define the outer contour of each liquid layer. For example, when rendering a layered cocktail, this can be used to determine the boundary between the upper fruit wine and the lower base wine. Next, based on the height parameters and density differences of each liquid layer, the interval region is determined within the layer boundary region. The height parameter determines the vertical distribution of the liquid layers, and the density difference affects the visual clarity of the layering. By calculating these parameters, reasonable interlayer intervals can be divided within the boundary, such as reserving a suitable transition space between a high-density syrup layer and a low-density fruit juice layer. Finally, the visual gaps between the liquid layers in the latter half are filled according to the determined interval regions. By adjusting parameters such as interlayer color and transparency, the transition between different liquid layers is made more natural, eliminating the sense of layer discontinuity. For example, when filling the interval regions, the boundary between the syrup layer and the fruit juice layer is set to a gradient mixed color, thereby achieving a realistic multi-layered liquid visual effect.
[0238] Optionally, in some embodiments, determining the dynamic liquid surface state based on the liquid level height parameter and liquid flow characteristics may further include: determining a first virtual UV coordinate for dynamic simulation based on the coordinates of the intersection point of the camera ray and the liquid surface plane; determining a first noise disturbance value that changes over time based on the first virtual UV coordinate, time parameters, and noise map; and determining the dynamic liquid surface state based on the first noise disturbance value.
[0239] Specifically, the first virtual UV coordinates for dynamic simulation can be determined first based on the coordinates of the intersection of the camera ray and the liquid surface. The camera ray is the light emitted from the observation viewpoint, and its intersection with the liquid surface corresponds to the observed liquid surface position. This is converted into UV coordinates (range 0-1) to facilitate subsequent sampling of noise textures. Furthermore, the first virtual UV coordinates, time parameters (such as animation frame numbers to reflect the passage of time), and noise maps (providing random perturbation textures) can be combined to calculate the first noise perturbation value that changes over time. The time parameters make the perturbation exhibit dynamic changes, and the noise maps can give the perturbation a natural irregularity. Then, the dynamic liquid surface state is determined based on the first noise perturbation value. The magnitude of the perturbation value directly corresponds to the degree of undulation of the liquid surface; a positive value indicates a bulge, and a negative value indicates a depression.
[0240] Figure 8 This paper presents the differences in liquid disturbance effects achieved based on polar coordinate sampling noise in some embodiments of this application. The left side shows the result after the noise moves along the UVU direction, with the liquid surface exhibiting a disturbance pattern corresponding to the motion characteristics in this direction. The right side shows the effect produced by the noise moving along the UVV direction, with the liquid appearance exhibiting a different disturbance state than on the left due to the change in motion direction. This difference caused by movement in different directions is related to… Figure 7 The demonstrated polar coordinate transformation logically corresponds to the change in color space distribution. From the perspective of liquid dynamics, it intuitively shows the impact of changes in polar coordinate space parameters (directional movement) on the final visual effect, providing technical support for simulating the dynamic behavior of liquids during stirring, addition, and other processes. It is evident that in this embodiment, based on polar coordinate sampling noise, diverse disturbance behaviors are presented by allowing the noise to move in different directions.
[0241] Figure 9 The following are some embodiments of the present application, showing the basic visual state of different sides of the liquid in the container: the left side shows the rendering effect of the liquid only on the back: that is, only the liquid surface facing the back of the scene (the side away from the observer) is rendered, showing the shape and color of the liquid on the back side; the right side shows the rendering effect of the liquid only on the front: only the liquid surface facing the observer is rendered, showing the visual appearance of the liquid on the front side.
[0242] Figure 10 This is used to demonstrate the impact of virtual liquid surface dividers on realism. The left side shows the effect without virtual liquid surface dividers: because no interlayer occlusion treatment is performed, the inner surface of the liquid on the back side is directly displayed, causing confusion in the front and back contours of the liquid layers and reducing visual realism (if one can see through the front layer of liquid and directly see the inner surface of the back layer, it destroys the sense of layer thickness); the right side shows the effect with virtual liquid surface dividers: through the solution provided in this embodiment, a virtual occlusion surface is generated between the layers to block the direct display of the inner surface of the liquid on the back side, making the layer transition more natural.
[0243] It should be noted that this embodiment may also be an improvement based on any one or more of the first to sixth and eighth embodiments.
[0244] It is not difficult to see that in the embodiments of this application, by dynamically calculating the liquid surface morphology based on the liquid surface height parameter and the liquid flow characteristics, it is possible to accurately simulate the real-time deformation effects such as ripples and waves generated when the liquid is flowing, shaking, or mixing, which significantly enhances the dynamic realism of the liquid. Furthermore, by comprehensively processing the dynamic liquid surface state with the calculated fusion color lighting results and the transparency parameters of each layer, the final rendering result not only presents the light reflection and refraction effects that change dynamically with the liquid surface, but also maintains the color accuracy and light transmission level of the multi-layer liquid mixing, thus achieving a dynamic liquid rendering effect that combines physical accuracy and visual expressiveness.
[0245] Tenth Embodiment
[0246] The tenth embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid in a container. The tenth embodiment is an improvement on the ninth embodiment, specifically in that: after determining the rendering result in the ninth embodiment, a further technical solution regarding the refraction of light by transparent liquid is added to make the rendering effect closer to a real transparent object.
[0247] Specifically, after determining the rendering result based on the dynamic liquid surface state, the blended color lighting result, and the transparency parameters of each liquid layer, the method may further include:
[0248] Step S601: Based on the completion status of the transparent object rendering channel, determine to enter the refraction calculation stage;
[0249] Step S602: In the refraction calculation stage, the direction of light refraction is determined based on the line of sight, the surface normal of the transparent object, and the refractive index parameters.
[0250] Step S603: Determine the sampling offset of the scene texture based on the light refraction direction and the thickness parameters of the transparent object.
[0251] For example, the refraction calculation stage can be determined first based on the completion status of the transparent object rendering channel. For instance, when the basic rendering of the liquid's dynamic appearance, color, lighting, and transparency is completed, the refraction calculation is triggered. Then, in this stage, the direction of light refraction can be determined based on the viewing direction, the surface normal of the transparent object, and the refractive index parameter. The viewing direction is the angle at which the observer looks at the liquid, the surface normal is the tilt direction of the liquid surface, and the refractive index parameter, such as 1.33 for clear water, is used to calculate the angle of deflection of light when it enters the liquid from the air using the law of refraction. Then, the sampling offset of the scene texture is determined based on the refraction direction and the thickness parameter of the transparent object. The thickness parameter is the depth of the liquid in the container. The magnitude of the offset is positively correlated with the refraction angle and the thickness, causing the background texture (such as the pattern on the bottom of the cup) observed through the liquid to produce a corresponding displacement.
[0252] For example, when observing a glass of water, once the dynamic liquid surface, color lighting, and transparency of the glass are rendered, the line of sight is angled downwards at 45 degrees, and the surface normal direction formed by the water's ripples is angled upwards at 30 degrees. Combining this with the refractive index of water (1.33), we can calculate that the direction of light refraction is deflected by 15 degrees. Furthermore, based on the water thickness of 5 centimeters, we determine that the sampling offset of the pattern at the bottom of the glass is 0.5 centimeters. Ultimately, the pattern at the bottom of the glass observed through the water surface will be offset by 0.5 centimeters in the direction of refraction, simulating the real refraction effect in water.
[0253] Optionally, in some embodiments, determining the direction of light refraction based on the viewing direction, the surface normal of the transparent object, and the refractive index parameter, i.e., step S602, may include:
[0254] Step S6021: Determine the parameters input to the refraction function based on the opposite direction of the line of sight, the surface normal of the transparent object, and the relative refractive index;
[0255] Step S6022: Determine the direction of light refraction based on the parameters.
[0256] For example, the parameters input to the refraction function can be determined based on the opposite direction of the line of sight, the surface normal of the transparent object, and the relative refractive index. Here, the opposite direction of the line of sight is the direction in which light rays travel from the object to the observer, the surface normal is the direction perpendicular to the liquid surface, and the relative refractive index is the ratio of the refractive indices of the two media (e.g., 1 / 1.33 for air to water). These parameters together form the basis of refraction calculation. Then, these parameters are substituted into the refraction function (e.g., a calculation function based on Snell's law), and the direction of light refraction is determined through function operations, that is, the specific angle at which light rays are deflected when they enter another medium from one medium.
[0257] For example, when observing a pebble in water, the opposite direction of the line of sight is the direction from the pebble to the eye (opposite to the line of sight). The surface normal of the water is perpendicular to the surface and points upwards. The relative refractive index of air to water is 0.75 (1 / 1.33). These parameters are input into the refraction function. Through the function calculation, the light rays that originally travel in a straight line are refracted about 15 degrees towards the normal when they enter the air from the water. This results in the final direction of light refraction, which determines the visual effect that the pebble appears to be higher than its actual position to the observer.
[0258] Optionally, in some embodiments, determining the sampling offset of the scene texture based on the light refraction direction and the thickness parameter of the transparent object, i.e., step S603, may include:
[0259] Step S6031: Determine the direction scaling factor based on the ratio of the XY component to the Z component of the ray refraction direction.
[0260] Step S6032: Determine the sampling offset of the scene texture based on the orientation scaling factor and the thickness parameter of the transparent object.
[0261] For example, the direction scaling factor can be determined based on the ratio of the XY component to the Z component of the light refraction direction; wherein the XY component represents the deflection amplitude of the refracted light in the horizontal direction, and the Z component represents the propagation depth in the vertical direction. The ratio of the two reflects the proportion of horizontal offset relative to depth, that is, the degree of lateral deflection per unit depth. Then, the direction scaling factor can be multiplied by the thickness parameter of the transparent object to obtain the sampling offset of the scene texture. The thickness parameter is the depth of the transparent object, and the product result directly corresponds to the actual distance that the background texture needs to be offset.
[0262] For example, if the XY component of the light refraction direction is 0.3 (horizontal deflection amplitude) and the Z component is 1.5 (vertical propagation depth), the calculated direction scaling factor is 0.3 / 1.5 = 0.2 (that is, 0.2 cm of lateral deflection per centimeter of depth); if the thickness parameter of the transparent object is 4 cm (such as the water depth in a glass), then the sampling offset of the scene texture is 0.2 × 4 = 0.8 cm, which means that the background texture (such as the pattern on the bottom of the glass) observed through the transparent object will be offset by 0.8 cm in the XY direction, presenting a visual distortion caused by refraction.
[0263] like Figure 11 The diagram illustrates the difference in rendering effects of liquid within a container in some embodiments of this application, depending on whether a final refraction processing stage is performed. The left side shows the result when neither the cup nor the ice cube undergoes the final refraction calculation. Due to the lack of refraction simulation, the optical interaction between the liquid and the internal ice cube is simplified. The right side shows the effect after both the cup and the ice cube undergo the final refraction processing stage. Through refraction calculation, the deflection of light passing through the liquid can be accurately simulated. This not only allows the liquid to exhibit a physically transparent appearance but also enables the ice cube and cup to accurately refract the liquid, achieving a more natural optical fusion between the liquid and the internal objects.
[0264] It should be noted that this embodiment may also be an improvement based on any one or more of the first to eighth embodiments.
[0265] It is not difficult to see that in this embodiment, by triggering the refraction calculation stage after the transparent object rendering channel is completed, the refraction calculation is ensured to be based on complete lighting and color information. Then, the precise refraction direction of the light is dynamically calculated based on the viewing direction, surface normal and refractive index parameters, thereby realistically simulating the deflection behavior of light at the interface of the transparent medium. By combining the refraction direction and the object thickness parameter to determine the scene texture sampling offset, the final rendering result can reproduce the visual displacement and distortion effect produced when light penetrates the transparent object through offset sampling, which significantly improves the physical accuracy and visual realism of liquid and transparent container rendering.
[0266] Eleventh Embodiment
[0267] The eleventh embodiment of this application relates to a method for simulating the mixing of multiple layers of liquid in a container. The eleventh embodiment is an improvement on the first embodiment, specifically in that a pre-step of the first embodiment is provided.
[0268] Specifically, before rendering the multi-layered liquid and associated transparent objects, the method may further include:
[0269] Step S701: Determine the execution order of multi-channel rendering based on the asset type within the container;
[0270] Step S702: Based on the multi-channel sequence, pre-set the depth writing rules and mask constraints corresponding to each channel.
[0271] Specifically, the asset types may include, but are not limited to: ice blocks, scaleable liquid models, cup models, etc. The execution order of multi-channel rendering can be determined based on the sub-types defined by the shaders for the assets within the container. These sub-types may include the near half (and top) of the liquid, the far half of the liquid, the near half of the cup, the far half of the cup, ice block entities refracting the scene, and redrawn ice block refraction proxies. Sub-definitions of the liquid model (such as water, juice, etc.) all fall under the category of the liquid model and are treated as content within the same channel during rendering ordering.
[0272] In some cases, the spatial location and optical interaction logic of the asset sub-type can be sorted to avoid inter-layer occlusion errors. Then, based on this order, the depth writing rules and mask constraints corresponding to each channel are pre-set. The depth writing rules control whether to record pixel depth information (e.g., the liquid near half channel is enabled for depth writing to determine the front-to-back relationship with other assets, and the cup far half channel is disabled for depth writing to avoid covering the inner liquid). The mask constraints limit the rendering range of each channel according to the container shape (e.g., cylindrical cup) to prevent the liquid or container wall from being rendered outside the container.
[0273] For example, if a container contains a liquid model (including water and juice as sub-definitions), a cup model, and ice cubes, the rendering order can be determined as follows: liquid far half (water, juice, and other sub-definitions are rendered simultaneously in this channel) → liquid near half (and top surface, water, juice, and other sub-definitions are rendered simultaneously in this channel) → cup far half → cup near half → ice cube entity in the refraction scene → ice cube refraction proxy (ordered according to the spatial hierarchy and optical interaction logic of the asset sub-type). Rules can be set as follows: the liquid near half and far half channels enable depth writing (to ensure the correct internal hierarchy of the liquid and that water, juice, and other sub-definitions in the same channel are processed synchronously), the cup near half and far half channels selectively enable depth writing based on their positional relationship, the ice cube entity channel enables depth testing, and the ice cube refraction proxy channel disables depth writing but retains depth testing (to avoid occluding the already rendered content below). At the same time, all channels are constrained by cylindrical masks and only render within the cup, ensuring that the inter-layer relationship is correct and there is no "overflow" effect during rendering.
[0274] It should be noted that this embodiment may also be an improvement based on any one or more of the second to tenth embodiments.
[0275] It is not difficult to see that in this embodiment, by dynamically determining the execution order of multi-channel rendering based on the sub-types of assets (ice blocks, liquid models, cup models) within the container (where sub-definitions of liquid models such as water and juice are processed simultaneously in the same channel), the rendering order can be intelligently arranged according to the transparency characteristics, spatial position, rendering dependencies, and optical interaction logic of different sub-types, laying the foundation for correctly handling the occlusion, blending, and overlay relationships between objects. Furthermore, by pre-configuring the depth writing rules and mask constraints of each channel according to the rendering order, the update of depth information and the writing range of fragment colors during the rendering process can be precisely controlled. This can effectively avoid common problems in the rendering of transparent objects, such as depth conflicts, color misordering, and blending anomalies, ensuring the correctness, efficiency, and visual realism of rendering complex multi-layer liquid scenes.
[0276] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this application.
[0277] Furthermore, some embodiments of this application also provide an electronic device. The electronic device can be various forms of digital computer, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, etc. The electronic device can also be various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices.
[0278] The electronic device includes: one or more processors; and a memory storing computer program instructions that, when executed, cause the processor to perform the steps of the methods provided in any one or more of the above embodiments. Figure 12An exemplary structural diagram of the electronic device is disclosed. The electronic device includes one or more processors 1101, a memory 1102, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components are interconnected via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some other embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations. The components, their connections and relationships, and their functions shown herein are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0279] The electronic device may further include an input device 1103 and an output device 1104. The processor 1101, memory 1102, input device 1103 and output device 1104 may be connected by a bus or other means, as shown in the figure, which is connected by a bus.
[0280] Input device 1103 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 1104 may include a display device, auxiliary lighting device (e.g., LED), and haptic feedback device (e.g., vibration motor). The display device may include, but is not limited to, a liquid crystal display, a light-emitting diode display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0281] To provide interaction with the user, the electronic device can be a computer. The computer has: a display device (e.g., a cathode ray tube or LCD monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback); and input from the user can be received in any form (e.g., voice input or tactile input).
[0282] In this embodiment, a computer-readable medium stores a computer program / instructions that, when executed by a processor, implement the steps of the methods provided in any one or more of the above embodiments. This computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into that device. The aforementioned computer-readable medium carries one or more computer-readable instructions.
[0283] The memory 1102 can serve as a non-transitory computer-readable storage medium, used to store non-transitory software programs, non-transitory computer-executable programs, and modules. The processor 1101 executes various functional applications and data processing of the server by running the non-transitory software programs, instructions, and modules stored in the memory 1102, thereby implementing the program instructions / modules corresponding to the methods provided in any one or more of the embodiments described above in this application.
[0284] The memory 1102 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 1102 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 1102 may optionally include memory remotely located relative to the processor 1101, and these remote memories can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0285] It should be noted that the computer-readable medium described in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections having one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0286] Computer-readable media include permanent and non-permanent, removable and non-removable media, which can store information by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory, static random access memory, dynamic random access memory, other types of random access memory, read-only memory, electrically erasable programmable read-only memory, flash memory or other memory technologies, read-only optical discs, digital versatile optical discs or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0287] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including local area networks (LANs) or wide area networks (WANs), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0288] In the above embodiments, all or part of the implementation can be achieved through software, hardware, firmware, or any combination thereof. For example, it can be implemented using an application-specific integrated circuit (ASIC), a general-purpose computer, or any other similar hardware device. In some embodiments, the software program of this application can be executed by a processor to implement the above steps or functions. Similarly, the software program of this application (including related data structures) can be stored in a computer-readable recording medium, such as RAM memory, magnetic or optical drives, floppy disks, and similar devices. In addition, some steps or functions of this application can be implemented in hardware, for example, as circuitry that cooperates with a processor to perform the various steps or functions.
[0289] The computer program product provided in this application includes one or more computer programs / instructions. When executed by a processor, these computer programs / instructions generate, in whole or in part, the processes or functions described in this application. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0290] The flowcharts or block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-specific system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0291] The scope of this application is defined by the appended claims rather than the foregoing description, and is therefore intended to encompass all variations falling within the meaning and scope of equivalents of the claims. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a device claim may also be implemented by a single unit or device in software or hardware. Terms such as "first," "second," etc., are used only for distinguishing descriptions and do not indicate any particular order, nor should they be construed as indicating or implying relative importance.
[0292] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily made by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims, and the above embodiments should be regarded as exemplary and non-limiting.
Claims
1. A method for simulating the mixing of multiple liquids within a container, characterized in that, The method includes: Based on the initial reference color and the color parameters of at least one liquid to be mixed, a target mixed color state is determined; wherein, the target mixed color state is obtained in the CMYK color model and is used to simulate the color mixing effect of liquid layer fusion by accumulating color contributions layer by layer; The target mixed color state is converted from the CMYK color model to the RGB color model to obtain the mixed RGB color value.
2. The method according to claim 1, characterized in that, Determining the target mixed color state based on the initial reference color and the color parameters of at least one liquid to be mixed includes: Determine the current accumulated color state based on the initial base color; Based on the color parameters of each liquid to be mixed and the current cumulative color state, the updated cumulative color state is determined sequentially. The target mixed color state is determined based on the cumulative color state after all liquid layers have been processed.
3. The method according to claim 2, characterized in that, The step of determining the updated cumulative color state sequentially based on the color parameters of each liquid to be mixed and the current cumulative color state includes: Determine the corresponding CMYK color value of the liquid based on the RGB color value of the liquid to be mixed. A new cumulative color state is determined based on the liquid CMYK color value, the first mixing weight of the current liquid layer, and the current cumulative color state; the first mixing weight is used to quantify the contribution ratio of the current liquid layer color in the mixing process. The current cumulative color state is determined based on the new cumulative color state.
4. The method according to claim 3, characterized in that, The step of determining the corresponding CMYK color value of the liquid based on the RGB color value of the liquid to be mixed includes: Based on each component of the RGB color value, determine the complementary color component; The black component is determined based on the complementary color components. The CMYK color value of the liquid is determined based on the black component and the complementary color component.
5. The method according to claim 3, characterized in that, The step of determining a new cumulative color state based on the liquid CMYK color value, the first mixing weight of the current liquid layer, and the current cumulative color state includes: The first weighted component is determined based on each channel component of the liquid CMYK color value and the first mixing weight; A second weighted component is determined based on the channel components and compensation weights of the current accumulated color state; wherein the compensation weights are determined based on the first mixing weights. Based on the first weighted component and the second weighted component, determine the channel components of the new cumulative color value.
6. The method according to claim 3, characterized in that, The method for determining the first mixed weight includes: The first mixing weight is determined based on the current height parameter of the liquid to be mixed.
7. The method according to claim 1, characterized in that, The method further includes: The second mixing weight is determined based on the height parameters of the liquid to be mixed and the noise map; the second mixing weight is used to control the gradual transition of the interlayer mixing region of the liquid. The target pixel value is determined based on the second mixing weight and the RGB color value.
8. The method according to claim 7, characterized in that, The step of determining the second mixing weight based on the current height parameter of the liquid to be mixed and the noise map includes: The basic fusion ratio is determined based on the current height parameters of the liquid to be mixed, the preset starting value, and the preset ending value; The second mixing weight is determined based on the aforementioned basic fusion ratio.
9. The method according to claim 8, characterized in that, The step of determining the second mixing weight based on the basic fusion ratio includes: The first sampling result is determined based on the height parameter and the noise map; Based on the first sampling result and the noise intensity parameter, the first noise factor is determined; The second mixing weight is determined based on the basic fusion ratio and the first noise factor.
10. The method according to claim 7, characterized in that, The step of determining the target pixel value based on the second mixing weight and the RGB color value includes: Determine the mixing transparency value based on the transparency parameters of each liquid to be mixed; The target pixel value is determined based on the blended transparency value, the RGB color value, and the second blending weight.
11. The method according to claim 2, characterized in that, Before determining the target mixed color state, the method further includes: Based on the color parameters of the liquid to be mixed and the current cumulative color state, determine whether to perform darkening processing on the color parameters of the liquid to be mixed.
12. The method according to any one of claims 1 to 11, characterized in that, The method further includes a rendering step for multiple layers of transparent liquid, the rendering step comprising: Based on the mixed RGB color values and the physical property parameters of each liquid layer, the illumination result of each liquid layer is determined; The lighting effect of multi-layer liquid mixing is determined based on the preset light mixing weight of each liquid layer and the lighting results. The rendering result is determined based on the multi-layered liquid mixing lighting effect.
13. The method according to claim 12, characterized in that, The physical property parameters include at least one of the following: surface porosity, impurity, smoothness, metallicity, noise intensity, transparency, and bubble content.
14. The method according to claim 12, characterized in that, The process of determining the illumination result for each liquid layer based on the mixed RGB color values and the physical property parameters of each liquid layer includes: The diffuse reflection light component is determined based on the normal direction, illumination direction, and color parameters of the liquid layer. The specular reflection illumination components are determined based on the normal direction, line of sight, roughness parameters, and color parameters of the liquid layer. The subsurface scattered light component is determined based on the subsurface scattering parameters and color parameters of the liquid layer. The illumination results for each liquid layer are determined based on the diffuse reflection illumination component, specular reflection illumination component, and subsurface scattering illumination component.
15. The method according to claim 14, characterized in that, The determination of the illumination result for each liquid layer based on the diffuse reflection illumination component, specular reflection illumination component, and subsurface scattering illumination component includes: The simulated diffuse light component is determined based on the custom light source direction, light source color, normal direction of the liquid layer, and color parameters. The illumination results for each liquid layer are determined based on the diffuse reflection illumination component, specular reflection illumination component, subsurface scattering illumination component, and simulated diffuse reflection illumination component.
16. The method according to claim 12, characterized in that, The process of determining the multi-layer liquid mixing lighting effect based on preset lighting mixing weights and lighting results includes: The lighting mixing weight is determined based on the height ratio of each liquid layer and the second noise factor; the second noise factor is determined based on the height parameter and the second sampling result of the lighting noise map. The lighting effect of multi-layer liquid mixing is determined based on the light mixing weight and the total light result of each liquid layer.
17. The method according to claim 12, characterized in that, The determination of the rendering result based on the multi-layer liquid mixing lighting effect includes: The fused color lighting result is determined based on the mixed color value and the multi-layer liquid mixing lighting effect.
18. The method according to claim 17, characterized in that, The method further includes: The dynamic liquid level state is determined based on the liquid level height parameter and the liquid flow characteristics; The rendering result is determined based on the dynamic liquid surface state, the fused color lighting result, and the transparency parameters of each liquid layer.
19. The method according to claim 18, characterized in that, The process of determining the dynamic liquid surface state based on the liquid level height parameter and liquid flow characteristics includes: performing differentiated processing on the liquid rendering channels of the front and rear halves, wherein: For the first half, dynamic simulation is achieved by clipping the liquid surface in the normal direction, transforming the coordinate space, and sampling noise; the first half is used to characterize the visible surface area in the whole liquid surface where the normal direction is towards the observer; For the rear half, visual filling is achieved through pseudo-plane calculation and interlayer parameter analysis; the liquid in the rear half is used to characterize the non-directly visible areas and interlayer junction areas in the overall liquid surface facing away from the observer.
20. The method according to claim 19, characterized in that, The dynamic simulation achieved through normal direction liquid surface trimming, coordinate space transformation, and noise sampling includes: The liquid surface portion is clipped according to the normal direction, and the virtual liquid surface calculation area used for the front half liquid rendering channel is determined. The virtual liquid surface calculation area is mapped to polar coordinate space to determine the texture sampling plane; Based on polar coordinate space, the dynamic simulation parameters are determined: when simulating the stirring process, the rotational dynamic parameters are calculated using the noise offset in the polar coordinate X-axis direction; when simulating the liquid addition process, the diffusion wave dynamic parameters are calculated using the noise offset in the polar coordinate Y-axis direction.
21. The method according to claim 19, characterized in that, The method of achieving visual filling through pseudo-plane calculation and interlayer parameter analysis includes: Based on the calculation range of the pseudo-plane and the position information of the liquid interface plane, the layer boundary region is determined; Based on the height parameters and density differences of each liquid layer, the interval region for different liquid layers is determined within the layer boundary region. Based on the aforementioned interval region, fill in the visual gaps between the liquid layers on the rear half.
22. The method according to claim 18, characterized in that, After determining the rendering result based on the dynamic liquid surface state, the blended color lighting result, and the transparency parameters of each liquid layer, the method further includes: Based on the completion status of the transparent object rendering channel, determine whether to enter the refraction calculation stage; In the refraction calculation stage, the direction of light refraction is determined based on the line of sight, the surface normal of the transparent object, and the refractive index parameters. The sampling offset of the scene texture is determined based on the direction of light refraction and the thickness parameters of the transparent object.
23. The method according to claim 22, characterized in that, Determining the direction of light refraction based on the line of sight, the surface normal of the transparent object, and the refractive index parameters includes: The parameters input to the refraction function are determined based on the opposite direction of the line of sight, the surface normal of the transparent object, and the relative refractive index. The direction of light refraction is determined based on the parameters.
24. The method according to claim 22, characterized in that, The step of determining the sampling offset of the scene texture based on the direction of light refraction and the thickness parameters of the transparent object includes: The direction scaling factor is determined based on the ratio of the XY component to the Z component in the direction of light refraction. The sampling offset of the scene texture is determined based on the orientation scaling factor and the thickness parameter of the transparent object.
25. The method according to claim 1, characterized in that, Before rendering the multi-layered liquid and associated transparent objects, the method further includes: Determine the execution order of multi-channel rendering based on the asset type within the container; Based on the multi-channel sequence, the depth writing rules and mask constraints corresponding to each channel are pre-set.
26. An electronic device, characterized in that, The electronic device includes: One or more processors; and A memory storing computer program instructions, which, when executed, cause the processor to perform the steps of the method as described in any one of claims 1 to 25.
27. A computer-readable medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 25.
28. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1 to 25.