Color gradient processing method and device, equipment and storage medium
By mapping and mixing control of the current and target color sequences of scenes such as on-board terminals, the problem of poor display effect during color gradient switching is solved, and the effect of smooth gradient and resource saving is achieved.
Patent Information
- Application Number
- CN202510257108.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-06-20
AI Technical Summary
In the prior art, the display effect is poor during the color gradient switching process in scenes such as on-board terminals.
By performing map conversion processing on the current color sequence and the target color sequence of the scene, the first map and the second map are obtained, and the two are mixed and controlled according to the gradient control parameters, multiple sets of mixed color sequences are obtained and fused into the scene to achieve smooth gradient.
It realizes the smooth gradient of the color during the process of switching from the current color to the target color, improves the color gradient display effect, reduces the amount of data resources, and avoids the need for multiple groups of maps.
Smart Images

Figure CN120179137A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of display technology, and more particularly to a method, apparatus, device, and storage medium for color gradient processing. Background Art
[0002] The display screen switches different scenarios to display different information to users, enhancing the user interaction experience. When configuring a scenario, by configuring the color gradient effect, different times or seasons can be displayed, which can also enrich the scenario display effect.
[0003] However, in the color gradient scenario of the screen display of a vehicle-mounted terminal, for example, it is pre-set to change from color A to color B. When switching the color gradient, it directly switches from color A to color B, and the display effect of this switching method is poor. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention provide a method, apparatus, device, and storage medium for color gradient processing, which are used to solve the problem of poor display effect during the color gradient switching process in the existing technology.
[0005] According to one aspect of the embodiments of the present invention, a method for color gradient processing is provided, which is applied to the control end of the display screen system. The method includes:
[0006] Performing texture mapping conversion processing on the current color sequence of the scenario to obtain a first texture, and performing texture mapping conversion processing on the target color sequence of the scenario to obtain a second texture;
[0007] Controlling the mixing of the colors of the first texture and the second texture according to the gradient control parameter to obtain multiple groups of mixed color sequences, where the gradient control parameter is used to control different mixing ratios of the colors;
[0008] Sequentially fusing multiple groups of the mixed color sequences into the scenario.
[0009] In an optional manner, the controlling the mixing of the colors of the first texture and the second texture according to the gradient control parameter to obtain multiple groups of mixed color sequences includes:
[0010] Obtaining the color gradient speed of the scenario;
[0011] Obtaining the gradient control parameter according to the update of the color gradient speed and the display time of the scenario, where the gradient control parameter includes a control value sequence composed of multiple control values;
[0012] Based on a preset shader, call the control value, and perform mixing control on the colors of the first texture map and the second texture map according to the control value to obtain a mixed color sequence, wherein a control value sequence is obtained based on the update of the display time, and multiple groups of mixed color sequences are obtained based on the control value sequence.
[0013] In an alternative manner, the step of based on a preset shader, calling the control value, and performing mixing control on the colors of the first texture map and the second texture map according to the control value to obtain a mixed color sequence includes:
[0014] Based on the preset shader, decompress the first texture map and the second texture map respectively to obtain a first color sequence corresponding to the first texture map and a second color sequence corresponding to the second texture map;
[0015] In the shader, call the control value to determine a first mixing ratio of the first color sequence and a second mixing ratio of the second color sequence;
[0016] Mix the first color sequence and the second color sequence according to the first mixing ratio and the second mixing ratio to obtain the mixed color sequence.
[0017] In an alternative manner, the step of performing texture map conversion processing on the current color sequence of the scene to obtain a first texture map and performing texture map conversion processing on the target color sequence of the scene to obtain a second texture map includes:
[0018] Obtain the current color sequence according to the scene before the gradient, and compress the current color sequence onto a preset empty texture map to obtain the first texture map;
[0019] Obtain the target color sequence according to the scene after the gradient, and compress the target color sequence onto a preset empty texture map to obtain the second texture map.
[0020] In an alternative manner, the step of obtaining the current color sequence according to the scene before the gradient, and compressing the current color sequence onto a preset empty texture map to obtain the first texture map includes:
[0021] Obtain a corresponding target color gradient according to the color of the scene before the gradient, wherein the color gradient reflects the change value of the color during the process of light changing from bright to dark or from dark to bright;
[0022] Based on the current light and dark sequence of the scene, sample from the target color gradient to obtain the current color sequence of the scene before the gradient;
[0023] Compress the current color sequence onto a preset empty texture map to obtain the first texture map.
[0024] In an alternative manner, the current color sequence and the target color sequence are predefined in a gradient color component. By cyclically outputting the color data of the gradient color component on a preset empty texture map, the current color sequence is compressed onto the first texture map, and the target color sequence is compressed into the second texture map.
[0025] In an alternative manner, before performing texture mapping conversion processing on the current color sequence of the scene to obtain the first texture map, it further includes:
[0026] Obtaining the light and shade sequence of the scene according to the light direction in the scene and the feature points of the model in the scene;
[0027] Sampling from a target color gradient according to the light and shade sequence to obtain the color sequence of the scene;
[0028] Rendering the model on the preview interface of the display screen based on the color sequence.
[0029] According to another aspect of the embodiments of the present invention, there is provided a color gradient processing device, and the device includes:
[0030] A color processing module, configured to perform texture mapping conversion processing on the current color sequence of the scene to obtain a first texture map, and perform texture mapping conversion processing on the target color sequence of the scene to obtain a second texture map;
[0031] A color mixing module, configured to perform mixing control on the colors of the first texture map and the second texture map according to gradient control parameters to obtain multiple groups of mixed color sequences, where the gradient control parameters are used to control different mixing ratios of the colors;
[0032] A rendering module, configured to fuse multiple groups of the mixed color sequences into the scene.
[0033] According to another aspect of the embodiments of the present invention, there is provided an electronic device, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete mutual communication through the communication bus;
[0034] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the operations of the above-mentioned color gradient processing method.
[0035] According to yet another aspect of the embodiments of the present invention, there is provided a computer-readable storage medium, and at least one executable instruction is stored in the storage medium, and the executable instruction is configured to execute the above-mentioned scene switching steps.
[0036] According to another aspect of the embodiments of the present invention, a computer program product is provided. The computer program product includes at least one executable instruction configured to execute the above-mentioned scene switching step.
[0037] In the embodiments of the present invention, through texture mapping conversion processing on the current color sequence of the scene, a first texture map is obtained, and the first texture map reflects the current color; texture mapping conversion processing is performed on the target color sequence of the scene to obtain a second texture map, and the second texture map reflects the target color; then, according to the gradient control parameter, the colors of the first texture map and the second texture map are mixed and controlled to obtain multiple groups of mixed color sequences. Each time a group of mixed color sequences is obtained, it is fused into the scene, and each group of mixed color sequences is sequentially switched until the scene is switched to the target color sequence, realizing the switch from the current color to the target color. During the switching process, color gradient is realized based on the mixed color sequences. In this embodiment, the colors of the first texture map and the second texture map are mixed by the gradient control parameter to obtain multiple groups of mixed color sequences, without setting multiple texture maps to realize the gradient process, with less data resource volume, and combined with the method of rendering the scene with the mixed color sequences, achieving the effect of smooth transition during the switching process and improving the color gradient display effect.
[0038] The above description is only an overview of the technical solutions of the embodiments of the present invention. In order to be able to understand the technical means of the embodiments of the present invention more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features, and advantages of the embodiments of the present invention more obvious and understandable, the following specifically gives the specific implementation manners of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings are only used to illustrate the embodiments and are not considered as limitations to the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0040] Figure 1 Shows a schematic flowchart of the first embodiment of the color gradient processing method provided by the present invention;
[0041] Figure 2 Shows a schematic flowchart of the second embodiment of the color gradient processing method provided by the present invention;
[0042] Figure 3 Shows a schematic flowchart of the third embodiment of the color gradient processing method provided by the present invention;
[0043] Figure 4 Shows a schematic diagram of the setting interface of the model light and shadow effect in one embodiment;
[0044] Figure 5 Shows a schematic diagram of the setting interface of the model light and shadow effect in another embodiment;
[0045] Figure 6 The structural schematic diagram of the first embodiment of the color gradient processing device provided by the present invention is shown;
[0046] Figure 7 The structural schematic diagram of the embodiment of the electronic device provided by the present invention is shown. Specific embodiments
[0047] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein.
[0048] It should be noted that in the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a method or device including a series of elements not only includes the elements expressly recited, but also includes other elements not expressly listed, or also includes elements inherent to the implementation of the method or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of other related elements in the method or device including the element (for example, steps in a method or modules in a device, where a module can be a part of a circuit, a part of a processor, a part of a program or software, etc.).
[0049] For example, the color gradient processing method provided by the embodiments of the present invention includes a series of steps, but the color gradient processing method provided by the embodiments of the present invention is not limited to the steps described herein. Similarly, the color gradient processing device provided by the embodiments of the present invention includes a series of modules, but the color gradient processing device provided by the embodiments of the present invention is not limited to including the expressly recited modules, and may also include modules required for configuring relevant information or processing based on information.
[0050] The embodiments of the present invention first provide a color gradient processing method. For example, this method can be applied to an in-vehicle terminal. For example, a color gradient scene is displayed through the remote screen of the in-vehicle terminal. Or it can also be applied to the central control screen of the in-vehicle terminal, or it can also be applied to other terminal devices with a display screen. The embodiments of the present invention do not limit this. The following will be described by taking the application in an in-vehicle terminal as an example:
[0051] It should be noted that the above color gradient processing method can be implemented by a processor of a vehicle-mounted terminal. The above processor can be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. The embodiments of the present invention are not limited thereto.
[0052] Figure 1 FIG. is a schematic flowchart of the color gradient processing method provided by an embodiment of the present invention. As Figure 1 shown, the process may include steps 101 to 103:
[0053] S101, perform texture mapping conversion processing on the current color sequence of the scene to obtain a first texture, and perform texture mapping conversion processing on the target color sequence of the scene to obtain a second texture;
[0054] This embodiment is applied to a vehicle-mounted terminal, specifically at the control end of the display screen system of the vehicle-mounted terminal.
[0055] For a vehicle-mounted terminal, such as a display screen, it can provide a scene display to the user. The scene can be a reflection of a vehicle driving scene, such as a reflection of geographical location, weather environment, time, climate, etc. scenes, or a reflection of a landmark geographical scene, which is not limited herein. The display of the scene is controlled by the control end of the display screen system.
[0056] In the embodiments of the present application, a full 3D technology is used to display the models in the scene, and based on the multi-angle change control of the models in the scene, the display effect is increased, thereby meeting the scene requirements of more effects without adding more resources.
[0057] Exemplarily, by controlling the color gradient of the models in the scene, it is possible to reflect time changes, weather changes, climate changes, or location changes, etc., enriching the scene display effect. Therefore, in some scene displays, the color gradient effect of the models is increased.
[0058] In this embodiment, the process of the display screen system control end performing gradient processing on the scene color during the display process of the display screen is taken as an example for illustration. Exemplarily, the scene refers to the scene displayed on the display screen. For example, if the display screen displays a scene of a hill, then the hill scene is the scene displayed on the display screen. In some examples, during the display process of some scenes, a gradient effect of the model's color is added. For example, the scene currently displayed on the display screen is color A, and after a preset time interval, the scene switches to color B. That is, as time passes, the color of the scene changes from A to B, and during the process of changing from A to B, a gradient effect is presented. Therefore, the current color of the scene refers to the color of the currently displayed scene (such as color A), and the target color of the scene refers to the color to be switched of the currently displayed scene (such as color B).
[0059] It should be noted that in the embodiments of the present application, the color of the model is divided in units of pixels, and the overall color of the model is reflected by the color sequence. In this way, in each scene, the color of the model can be set to be the same (the model includes one color) or different according to requirements (the model includes multiple colors, such as the color of the model gradually changing from left to right). Therefore, in this step, the current color sequence of the scene refers to all the current colors from left to right or from right to left in the scene currently displayed on the display screen. The target color sequence of the scene refers to all the target colors from left to right or from right to left of the scene displayed on the display screen (that is, the color sequence after the scene gradient).
[0060] It can be understood that when directly switching between the current color sequence and the target color sequence, the two color sequences cannot be smoothly switched, resulting in a poor display effect. And since only two color sequences are set, other color sequences need to be derived from these two color sequences to achieve a gradient effect. Exemplarily, these two color sequences are passed to the shader, and the shader mixes the two colors in different proportions to obtain multiple sets of mixed colors. By changing the colors in the form of a sequence, a smooth gradient between the two colors can be achieved.
[0061] As an example, the color data of the scene is defined in the system control script, and this color data reflects the switching of the scene between two colors. Exemplarily, the color data includes color A and color B. Among them, during the display process of the scene, it switches from color A to... However, this method may cause the system control script
[0062] As an example, in system control, a gradient color component is used to pre-define the color data of a scene. Exemplarily, by defining a first gradient color component GradientColor A, the color A of the scene is defined, and by a second gradient color component GradientColor B, the color B of the scene is defined, where color A is the initial color of the scene (the current color / current color sequence before scene gradient), and color B is the target color of the scene gradient (the target color / target color sequence after scene gradient). Among them, color A and color B can be set according to the display requirements of the scene.
[0063] In this example, using a color gradient component to pre-define the color data of a scene can exist independently of the system control script, which can reduce the resource occupancy rate in the system. And based on the color gradient component, the color data can be set in advance. When the system control script executes scene control, the color data can be directly obtained through the color gradient component, which can reduce the computing power of the system control script.
[0064] Optionally, since the shader cannot directly process the color sequence in the gradient component, the color sequence needs to be processed by texture mapping conversion and imported into the shader by means of texture mapping. Exemplarily, the specific implementation method of performing texture mapping conversion processing on the current color sequence of the scene to obtain a first texture and performing texture mapping conversion processing on the target color sequence of the scene to obtain a second texture can be:
[0065] A1: Create an empty texture in advance;
[0066] Exemplarily, create an empty texture in the following way:
[0067] GradientTex = new Texture2D(128, 1);
[0068] In this example, it is defined that the horizontal direction of the empty texture includes 128 pixels and the vertical direction includes 1 pixel. It should be noted that the size of the empty texture can be set differently according to specific scenes or requirements, not limited to the size structure of 128 pixels in the horizontal direction and 1 pixel in the vertical direction.
[0069] A2: Obtain the current color sequence according to the scene before gradient, and compress the current color sequence onto this empty texture, then the first texture is obtained;
[0070] Exemplarily, through a per-pixel generation method, loop output the current color sequence on the empty texture and compress to obtain the first texture. For example, in the blank texture, fill the corresponding pixels according to the current color sequence.
[0071] A3: Obtain the target color sequence according to the scene after gradient, and compress the target color sequence onto the pre-set empty texture to obtain the second texture.
[0072] Exemplarily, through a pixel-by-pixel generation method, the target color sequence is cyclically output on an empty texture map, and the second texture map is obtained by compression. For example, in a blank texture map, the corresponding pixels are filled according to the target color sequence.
[0073] In this example, through the above method, the data of the gradient color component can be transmitted and stripped, compressed into a picture form, and transmitted to the shader for color mixing.
[0074] S102, control the color mixing of the first texture map and the second texture map according to the gradient control parameter to obtain multiple groups of mixed color sequences.
[0075] In this step, the gradient control parameter is used to control different mixing ratios of colors. Exemplarily, the gradient control parameter includes a control value sequence. For example, the control value sequence is a value sequence between 0 and 1.
[0076] In some embodiments, the control value sequence is preset in the storage area, and the corresponding control value sequence is sequentially retrieved from the storage area to generate the mixed color sequence. Or, in some embodiments, the control value sequence is determined according to the setting information of the scene gradient effect, such as the color gradient speed and time of the scene. For the specific process, refer to the following embodiments.
[0077] In this step, the gradient control parameter is used to control the color mixing ratio of the first texture map and the second texture map. Based on different color mixing ratios, the colors of the first texture map and the second texture map are mixed, and different mixed colors can be obtained. By setting the gradually changing manner (control value sequence) of the gradient control parameter, multiple groups of mixed color sequences are obtained, showing the effect of gradual change from the color of the first texture map to the color of the second texture map.
[0078] Exemplarily, controlling the color mixing of the first texture map and the second texture map according to the gradient control parameter to obtain multiple groups of mixed color sequences includes:
[0079] B1: Determine the first mixing ratio of the color of the first texture map and the second mixing ratio of the color of the second texture map according to the control value;
[0080] Wherein, the sum of the first mixing ratio and the second mixing ratio is 1.
[0081] B2: Mix the colors of the first texture map and the second texture map according to the first mixing ratio and the second mixing ratio to obtain the mixed color sequence.
[0082] Exemplarily, the control value sequence includes [0, 0.2, 0.4, 0.6, 0.8, 1]. Among them, when the control value is 0, it means that the blending ratio of the first texture map is 100% and the blending ratio of the second texture map is 0%; when the control value is 0.2, it means that the blending ratio of the first texture map is 80% and the blending ratio of the second texture map is 20%, corresponding to the obtained first mixed color sequence; when the control value is 0.4, it means that the blending ratio of the first texture map is 60% and the blending ratio of the second texture map is 40%, corresponding to the obtained second mixed color sequence; when the control value is 0.6, it means that the blending ratio of the first texture map is 40% and the blending ratio of the second texture map is 60%, corresponding to the obtained third mixed color sequence; when the control value is 0.8, it means that the blending ratio of the first texture map is 20% and the blending ratio of the second texture map is 80%, corresponding to the obtained fourth mixed color sequence; when the control value is 1, it means that the blending ratio of the first texture map is 0% and the blending ratio of the second texture map is 100%, corresponding to the obtained fifth mixed color sequence. The first mixed color sequence to the fifth mixed color sequence are five groups of mixed color sequences. During the process of gradually switching from the first mixed color sequence to the fifth mixed color sequence, the color of the first texture map gradually changes to the color of the second texture map.
[0083] In an alternative implementation, a shader is used to blend the colors of the first texture map and the second texture map, so as to obtain a mixed color sequence required for adapting to model rendering and improve the flexibility and realism of image rendering. Therefore, in this implementation, a shader is created according to requirements, such as the shader of a 3D model.
[0084] In the shader, the current texture map sampler_Current and the target texture map Sampler_Target are defined. The current texture map is used to import the first texture map, and the target texture map is used to import the second texture map. Exemplarily, the specific implementation method of blending and controlling the colors of the first texture map and the second texture map according to the gradient control parameter to obtain multiple groups of mixed color sequences can be:
[0085] C1: Import the first texture map into the current texture map of the shader, and import the second texture map into the target texture map of the shader, so as to call the shader to decompress the first texture map and the second texture map respectively, and obtain the first color sequence corresponding to the first texture map and the second color sequence corresponding to the second texture map;
[0086] Exemplarily, in this step, the first texture map can be decompressed by extracting pixels to obtain the first color sequence. Similarly, the second texture map can be decompressed by extracting pixels to obtain the second color sequence.
[0087] C2: In the shader, by mixing and controlling the first color sequence and the second color sequence according to the control parameters, multiple sets of mixed color sequences can be obtained.
[0088] In this step, the way of mixing and controlling the first color sequence and the second color sequence can refer to the ways listed in the above steps B1 and B2.
[0089] S103. Sequentially fuse multiple sets of mixed color sequences into the scene.
[0090] Exemplarily, sequentially fusing multiple sets of mixed color sequences into the scene means that when a set of mixed color sequences is obtained based on step S102, it is fused into the scene. When the next set of mixed color sequences is obtained in step S102, the next set of mixed color sequences is fused into the scene until the mixed color sequences are consistent with the target color sequence, and then the color gradient of the scene is completed.
[0091] In an alternative implementation, a 3D model is displayed in the scene, and the color gradient refers to the color gradient of the 3D model. Therefore, in this implementation, step S103 can be:
[0092] Obtain the original texture map of the model in the scene; copy each mixed color sequence to the original texture map in chronological order. On the one hand, it can fuse the original color of the model. On the other hand, each set of mixed colors is rendered on the original texture map of the model, which can avoid the superposition of the previously rendered mixed color sequence on the next rendered mixed color sequence and reduce the gradient effect.
[0093] In some examples, before fusion, the original texture map of the model is normalized to obtain an original texture map with a black-and-white effect, which can ensure that the model presents the target color corresponding to the rendering during rendering.
[0094] In some examples, the implementation method of switching the color of the model in the scene is as follows: The color A texture map and the color B texture map are preset. When the color of the scene is switched from color A to color B, the color B texture map is fused into the scene model, thus realizing the switching of the scene color. In order to achieve the gradient effect, multiple color texture maps need to be set, and the gradient effect is realized by sequentially replacing the texture maps. However, this method requires setting many sets of texture maps, with a large amount of data resources, large occupied space, and affects the performance of the display device. Moreover, when switching between two texture maps, there is always a sense of pause, resulting in an uneven gradient process and affecting the gradient display effect.
[0095] In the embodiments of the present application, if the scene needs to present the effect of gradually changing from color A to color B, two gradient texture maps, namely gradient texture map A and gradient texture map B, are correspondingly set, and then a series of gradient colors are obtained by mixing the colors of these two gradient texture maps until color B is obtained, achieving the effect of gradually changing the transition color. There is no need to set multiple groups of texture maps, reducing the amount of resources, occupying less space, and having a smooth transition with a better gradient display effect.
[0096] Figure 2 It is a schematic flowchart of a color gradient processing method provided by another embodiment of the present invention. Based on the foregoing embodiments, as Figure 2 shown, this process may include steps S201 to S205:
[0097] S201, perform texture map conversion processing on the current color sequence of the scene to obtain a first texture map, and perform texture map conversion processing on the target color sequence of the scene to obtain a second texture map;
[0098] Among them, the specific implementation manner of this step is similar to step S101 shown above Figure 1 The specific implementation process can refer to the above embodiments and will not be elaborated here.
[0099] S202, obtain the color gradient speed of the scene;
[0100] In this step, the color gradient speed of the scene is pre-set according to requirements. For different desired effects, different color gradient speeds can be set for different scenes or the same scene. Exemplarily, the color gradient speed corresponding to scene 1 is: gradually changing N1 frames within 20 minutes, and the color gradient speed corresponding to scene 2 is gradually changing N2 frames within 10 minutes, where N1 and N2 can be the same or different. Or, the color gradient speed of scene 1 in summer is gradually changing M frames in 20 minutes, and the color gradient speed of scene 1 in winter is gradually changing M frames in 10 minutes.
[0101] S203, obtain gradient control parameters according to the update of the color gradient speed and the display time of the scene, where the control gradient parameters include a control value sequence composed of multiple control values;
[0102] Exemplarily, if the color gradient speed is gradually changing N1 frames within 20 minutes, then within the 20 minutes of the scene display, N1 frames of gradient colors need to be switched. Correspondingly, N1 control values are required, and the control values are updated based on the update of the display time of the scene. Therefore, obtaining the control values according to the color gradient speed and the display time of the scene can, on the one hand, ensure that a corresponding mixed color sequence can be obtained during the gradient process to achieve the corresponding gradient effect, and on the other hand, ensure that during the color gradient process, the color gradually changes smoothly from the current color to the target color as the display time progresses.
[0103] S204. Based on a preset shader, call a control value, and control the blending of the colors of the first texture map and the second texture map according to the control value to obtain a sequence of blended colors;
[0104] In this embodiment, in the shader, a gradient control parameter _BlendTmp is defined, and the blending of the colors of the first texture map and the second texture map is implemented through the following function:
[0105] half3 final = lerp(currentColor.rgb, targetColor.rgb, _BlendTmp);
[0106] Among them, half3 final refers to the sequence of blended colors, currentColor.rgb refers to the color of the first texture map (the first color sequence), and targetColor.rgb refers to the color of the second texture map (the second color sequence).
[0107] In an optional implementation manner, the shader is provided with a call interface, and this call interface is used to call the control value of the gradient control parameter _BlendTmp. After obtaining the control value based on step S203, the shader can call this control value through the call interface, and then obtain the sequence of blended colors based on the lerp function.
[0108] Among them, for the principle and implementation manner of the lerp function, reference can be made to the specific implementation process of step S102 shown above Figure 1 and will not be elaborated here.
[0109] S205. Blend the sequence of blended colors into the scene.
[0110] After updating the display time, return to step S203 until the obtained sequence of blended colors is the same as the target color sequence, and the color gradient switching of this scene is completed.
[0111] Among them, the specific implementation manner of step S205 is similar to step S103 shown above Figure 1 and the specific implementation process can be referred to the above embodiment and will not be elaborated here.
[0112] In this embodiment, the control value of the gradient control parameter in the shader is calculated based on the color gradient speed and the display time of the scene. Moreover, the setting of the color gradient speed is independent of the shader. The shader controls the color mixing ratio of the first texture map and the second texture map by calling the control value. In this way, during the scene setting process, by modifying the color gradient speed, the color mixing ratio of the first texture map and the second texture map can be modified. That is, when it is necessary to modify the color gradient effect, there is no need to modify the settings of the shader, and the operation is simple. In addition, by setting the scene color gradient speed, different gradient effects can be presented on the display device, enriching the scene display effect.
[0113] Figure 3 FIG. 4 is a schematic flowchart of a color gradient processing method provided by another embodiment of the present invention. Based on the foregoing embodiment, as Figure 3 shown, this process may include steps S301 to S308:
[0114] S301, obtaining a corresponding first target color gradient according to the scene color before the gradient;
[0115] S302, sampling from the first target color gradient based on the current light and dark sequence of the scene to obtain the current color sequence of the scene before the gradient;
[0116] In this embodiment, if a light and shadow effect is set in the scene, based on the different light and dark of the model under the light and shadow, during the color gradient process, the influence of the light and shadow effect on the color gradient also needs to be considered, so that the presented effect during the color gradient process is more realistic.
[0117] Based on this, each color corresponding color gradient is set in advance based on the influence of light on the model color when the light irradiates the model. That is, this color gradient reflects the change value (color gradient) of the color during the process of light changing from bright to dark or from dark to bright. Exemplarily, assuming the color of light blue is [R, G, B], when the light irradiates the light blue from bright to dark, based on the influence of light and shadow, the displayed color changes to [R1, G1, B1], [R2, G2, B2]... [Rn, Gn, Bn]. Then, [R1, G1, B1], [R2, G2, B2]... [Rn, Gn, Bn] are the color gradients of light blue. Among them, each color value in the color gradient corresponds one-to-one with the light and dark degree.
[0118] Therefore, after determining the scene color before the gradient, the corresponding first target color gradient of this color can be obtained.
[0119] If the current display effect of the scene has set light and shadow, obtain the current light and dark sequence of the scene (i.e., the light and dark sequence on the model). The current light and dark sequence reflects the light and dark effect formed by the light from left to right or from right to left on the model. Based on the correspondence between the first target color gradient and the color before the scene gradient, sample on the first target color gradient based on the current light and dark sequence, and the current color sequence of the scene before the gradient can be obtained.
[0120] For example, in a scene without light and shadow effects, the current color sequence is the pixel value sequence corresponding to the colors in the scene before the gradient (for example, all are pixel p). In a scene with light and shadow effects, first determine the color corresponding color gradient in the scene before the gradient. If the brightness at position 1 is m1, then find the color value p1 (pixel value) corresponding to the position with the same brightness on this color gradient, that is, position 1 is the color value p1. If the brightness at position 2 is m2, then find the color value p2 (pixel value) corresponding to the position with the same brightness on this color gradient, that is, position 2 is the color value p2. In this way, the obtained current color sequence is consistent with the display effect of the model in the scene (the color and light and shadow are consistent).
[0121] In an optional implementation manner, the light and dark sequence is a set of numerical values (such as a sequence composed of multiple numerical values from 0 to 1), that is, the light and dark degrees of the model in the scene are normalized, and the light and dark relationships of each position on the model are reflected by a set of numerical values. Each color value in the color gradient corresponds to a numerical value. Therefore, after determining the current light and dark sequence of the scene, the corresponding color values can be sampled on the color gradient through the current light and dark sequence, and then the current color sequence can be obtained.
[0122] S303, Compress the current color sequence onto a preset empty texture map to obtain the first texture map.
[0123] Among them, the specific implementation manner of this step is the same as the specific implementation manner of step S101 above. Figure 1 For specific reference, please refer to the above embodiments and will not be elaborated here.
[0124] S304, Obtain the corresponding second target color gradient according to the color of the scene after the gradient;
[0125] S305, Based on the target light and dark sequence of the scene after the gradient, sample from the second target color gradient to obtain the target color sequence of the scene after the gradient;
[0126] S306, Compress the target color sequence onto a preset empty texture map to obtain the second texture map.
[0127] It should be noted that steps S304 to S306 are the processes of sampling and compressing the target color sequence, and the specific implementation method is the same as that of the above-mentioned current color sequence adoption and compression, so it will not be repeated here.
[0128] S307. Control the color mixing of the first texture map and the second texture map according to the gradient control parameter to obtain multiple groups of mixed color sequences.
[0129] S308. Sequentially fuse multiple groups of mixed color sequences into the scene.
[0130] Among them, the specific implementation methods of steps S307 and S308 are similar to steps S102 and S103 shown above. The specific implementation process can refer to the above embodiments and will not be elaborated here. Figure 1
[0131] Exemplarily, in the embodiment of the present application, the setting process and principle of the light and shadow effect on the model can be:
[0132] Before the above step S301, it further includes: obtaining the light and dark sequence of the model in the scene according to the light direction in the scene and the feature points of the model in the scene;
[0133] Among them, in a specific light direction, different light and dark degrees are presented based on the different feature point positions of the model. The feature point refers to the point that represents the most recognizable point of the model. For example, for a mountain scene, the feature points include several points such as the mountainside, mountain peak, hillside, mountain surface, and mountain back; for a car model, the feature points include the car roof, left and right doors, car lights, etc. In this example, in the scene, the light and dark degrees of the model from left to right, or from right to left, or from top to bottom, or from bottom to top form a group of light and dark sequences, and the light and dark degree is restricted to the range of (0, 1), so the light and dark sequence is composed of numerical values of (0, 1).
[0134] Sample from the target color gradient according to the light and dark sequence to obtain the color sequence of the scene. Among them, the target color gradient is the color gradient corresponding to the target color set in the scene, and the scene color sequence includes the color sequence before the gradient and the target color sequence after the gradient.
[0135] Exemplarily, the color gradient of the target color is the gradient color in the range of the target color (0, 1), so the corresponding color can be sequentially sampled from the color gradient through the light and dark sequence to obtain the color sequence corresponding to the target color.
[0136] Render the model according to the color sequence, then complete the coloring of the model under the light, and display the coloring effect of the model in the preview interface of the display interface.
[0137] In the above example, according to several feature points of the scene model and the lighting direction, the light and dark sequence of the model can be automatically generated, and the color with lighting effect can be rendered for the scene, so that the rendering of the scene can be completed quickly.
[0138] Alternatively, in some examples, the light and shadow effects of the scene model can also be rendered in the following way:
[0139] For example, according to the lighting direction in the scene, obtain the light and dark degrees of each position of the scene model; define the positions with the same light and dark degree as one area, obtain the target color selected on the color gradient of the target color, display the target color in the target area, and associate and save the target area with the target color. That is, in this embodiment, the color of each area can be set according to the artistic requirements to achieve the presentation of different scene effects.
[0140] Such as Figure 4 As shown, position 1 is taken as one area, position 2 is taken as one area, and position 3 is taken as one area. For position 1, determine color a on the rendering color gradient; for position 2, determine color b on the rendering color gradient; for position 3, determine color c on the rendering color gradient. Thus, when the scene is displayed, position 1 displays color a, position 2 displays color b, and position 3 displays color c.
[0141] Optionally, in this embodiment, as Figure 5 shown, a display interface is also provided. The display interface includes a preview interface 501 and a color gradient regulator (gradient bar) interface 502. The color change from light to dark or from dark to light is displayed in the color gradient regulator in the preview interface. The display effect of the model can be adjusted (adjust the color level) through the color gradient regulator.
[0142] Exemplarily, there are at least 1 adjustment node 503 on the color gradient regulator. The adjustment node 503 can move in the color gradient regulator and specify a color based on the moved position. Thus, when rendering the model in the preview interface of the display screen, receiving the movement operation of the adjustment node, determining the target position of the movement, adjusting the color of the position to be adjusted in the model according to the color corresponding to the target position, and rendering the adjusted color in the model. Thus, the color level adjustment of the position to be adjusted in the model is realized. The position to be adjusted is any selected position. In some examples, the position to be adjusted includes an area with the same light and dark degree.
[0143] In some alternative embodiments, the color gradient regulator includes eight adjustment nodes 503, which can adjust the color levels at eight positions on the model simultaneously. After setting the lighting effect of the model in the above manner, the set data is saved in the memory. When the scene is switched, the corresponding color sequence can be obtained through the light and dark sequence of the model, such as the process of steps S301 to S308 described above.
[0144] In this embodiment, when adding a light overlay effect to the scene, both the current color sequence and the target color sequence of the scene are generated based on the rendering effect after adding the light overlay effect. During the color gradual change process, not only can the smooth gradual change of the color be displayed, but also the gradual change of the light overlay effect can be displayed, increasing the realism of the scene change and further improving the display effect.
[0145] Figure 6 The structural schematic diagram of an embodiment of the color gradual change processing device provided by the present invention is shown. As Figure 6 shown, the device 600 includes: a color processing module 610, a color mixing module 620, and a rendering module 630.
[0146] The color processing module 610 is configured to perform texture mapping conversion processing on the current color sequence of the scene to obtain a first texture map, and perform texture mapping conversion processing on the target color sequence of the scene to obtain a second texture map;
[0147] The color mixing module 620 is configured to perform mixing control on the colors of the first texture map and the second texture map according to the gradient control parameter to obtain multiple groups of mixed color sequences, where the gradient control parameter is used to control different mixing ratios of the colors;
[0148] The rendering module 630 is configured to fuse multiple groups of mixed color sequences into the scene.
[0149] In an alternative manner, the color mixing module includes a first acquisition module, a determination module, and a shader call module. The first acquisition module is configured to acquire the color gradual change speed of the scene and the display time of the scene. The determination module is configured to obtain a control value according to the color gradual change speed and the display time of the scene. The shader call module is configured to call a shader, based on the shader, call the control value, and perform mixing control on the colors of the first texture map and the second texture map according to the control value to obtain a mixed color sequence.
[0150] In an alternative manner, the shader includes a decompression module, a call module, and a color mixing processing module. The decompression module is used to decompress the first texture map and the second texture map respectively to obtain a first color sequence corresponding to the first texture map and a second color sequence corresponding to the second texture map. The call module is used to call an external control value. The color mixing processing module is used to determine a first mixing ratio of the first color sequence and a second mixing ratio of the second color sequence according to the control value, and then mix the first color sequence and the second color sequence according to the first mixing ratio and the second mixing ratio.
[0151] In an alternative manner, the color processing module includes a first compression module and a second compression module. The first compression module is used to compress the current color sequence obtained according to the scene before the gradient onto a preset empty texture map to obtain a first texture map. The second compression module is used to compress the target color sequence obtained according to the scene after the gradient onto a preset empty texture map to obtain a second texture map.
[0152] In an alternative manner, the color processing module further includes a second acquisition module and a sampling module. The second acquisition module is used to obtain a corresponding first target color gradient according to the current color of the scene before the gradient, and obtain a corresponding second target color gradient according to the target color of the scene after the gradient. The sampling module is used to sample from the first target color gradient based on the current brightness sequence of the scene to obtain the current color sequence of the scene before the gradient, and is also used to sample from the second target color gradient based on the target brightness sequence of the scene to obtain the target color sequence of the scene after the gradient.
[0153] As can be seen from the above, the color gradient processing device provided by the embodiments of the present invention can increase the color gradient display effect of the scene on the basis of a small amount of data resources, and achieve a smooth transition effect during the color gradient process of the scene.
[0154] Figure 7 The structural schematic diagram of an embodiment of the electronic device provided by the present invention is shown. The specific implementation of the electronic device is not limited in the specific embodiments of the present invention.
[0155] As Figure 7 shown, the electronic device may include: a processor 702, a communications interface 704, a memory 706, and a communication bus 708.
[0156] Among them: The processor 702, the communication interface 704, and the memory 706 communicate with each other through the communication bus 708. The communication interface 704 is used to communicate with network elements of other devices such as clients or other servers. The processor 702 is used to execute the program 710, and specifically can execute the relevant steps in the above embodiments of the method for color gradient processing.
[0157] Specifically, the program 710 may include program code, and the program code includes computer-executable instructions.
[0158] The processor 702 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. One or more processors included in the electronic device may be of the same type of processor, such as one or more CPUs; or may be of different types of processors, such as one or more CPUs and one or more ASICs.
[0159] The memory 706 is used to store the program 710. The memory 706 may include a high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.
[0160] The embodiments of the present invention provide a computer-readable storage medium, and the storage medium stores at least one executable instruction. When the executable instruction runs on the electronic device / color gradient processing device, the electronic device / color gradient processing device is caused to execute the color gradient processing method in any of the above method embodiments.
[0161] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. In addition, the embodiments of the present invention are not directed to any specific programming language.
[0162] In the specification provided herein, a large number of specific details are set forth. However, it can be understood that the embodiments of the present invention may be practiced without these specific details. Similarly, in order to streamline the present invention and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. Among them, the claims following the specific implementation manners are hereby expressly incorporated into the specific implementation manners, and each claim itself serves as a separate embodiment of the present invention.
[0163] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from those of the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive.
[0164] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim listing several devices, several of these devices can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
Claims
1. A color gradient processing method, characterized in that: Applied to the display screen system control end, the method includes: Performing texture conversion processing on the current color sequence of the scene to obtain a first texture; Performing a texture conversion process on the target color sequence of the scene to obtain a second texture; Mixing and controlling the colors of the first map and the second map according to a gradient control parameter to obtain multiple sets of mixed color sequences, wherein the gradient control parameter is used to control different mixing ratios of the colors; A plurality of groups of the mixed color sequences are sequentially merged into the scene.
2. The method according to claim 1, characterized in that: The step of controlling the colors of the first map and the second map to be mixed according to the gradient control parameter to obtain multiple sets of mixed color sequences includes: Get the color gradient speed of the scene; According to the updating of the color gradient speed and the display time of the scene, the gradient control parameter is obtained, and the gradient control parameter includes a control value sequence composed of a plurality of control values; Based on a preset shader, the control value is called, and the colors of the first map and the second map are mixed and controlled according to the control value to obtain a mixed color sequence.
3. The method according to claim 2, characterized in that The method of calling the control value based on the preset shader and controlling the colors of the first map and the second map according to the control value to obtain a mixed color sequence includes: Based on a preset shader, the first map and the second map are decompressed respectively to obtain a first color sequence corresponding to the first map and a second color sequence corresponding to the second map; In the shader, calling the control value to determine a first mixing ratio of the first color sequence and a second mixing ratio of the second color sequence; The first color sequence and the second color sequence are mixed according to the first mixing ratio and the second mixing ratio to obtain the mixed color sequence.
4. The method according to claim 1, characterized in that The step of performing a texture conversion process on a current color sequence of a scene to obtain a first texture, and performing a texture conversion process on a target color sequence of the scene to obtain a second texture comprises: Obtaining a current color sequence according to the scene before the gradient, and compressing the current color sequence onto a preset empty map to obtain a first map; A target color sequence is obtained according to the scene after the gradient, and the target color sequence is compressed onto a preset empty map to obtain a second map.
5. The method according to claim 4, characterized in that The step of obtaining a current color sequence according to the scene before the gradient, and compressing the current color sequence onto a preset empty map to obtain a first map comprises: According to the scene color before the gradient, the corresponding target color gradient is obtained, wherein the color gradient reflects the color change value in the process of light changing from bright to dark or from dark to bright; Based on the current light and dark sequence of the scene, sampling is performed from the target color gradient to obtain the current color sequence of the scene before the gradient; The current color sequence is compressed onto a preset empty map to obtain a first map.
6. The method according to claim 4, characterized in that The current color sequence and the target color sequence are predefined in a gradient color component, and the current color sequence is compressed into a first map and the target color sequence is compressed into a second map by cyclically outputting the color data of the gradient color component on a preset empty map.
7. The method according to any one of claims 1 to 6, characterized in that: Before the texture conversion process is performed on the current color sequence of the scene to obtain the first texture, the method further includes: Obtaining a light and dark sequence of the scene according to the illumination direction in the scene and the feature points of the model in the scene; According to the light and dark sequence, sampling is performed from the target color gradient to obtain the color sequence of the scene; Based on the color sequence, the model is rendered on a preview interface of a display screen.
8. A color gradient processing device, characterized in that: The processing device comprises: A color processing module, used for performing a texture conversion process on a current color sequence of a scene to obtain a first texture, and performing a texture conversion process on a target color sequence of the scene to obtain a second texture; a color mixing module, used for controlling the mixing of the colors of the first map and the second map according to a gradient control parameter to obtain multiple sets of mixed color sequences, wherein the gradient control parameter is used to control different mixing ratios of the colors; A rendering module is used to merge multiple groups of the mixed color sequences into the scene.
9. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the color gradient processing method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one executable instruction. When the executable instruction is executed on the electronic device / color gradient processing device, the electronic device / color gradient processing device performs the operation of the color gradient processing method according to any one of claims 1 to 7.