AI-driven Shader effect editing method, system and equipment and medium
The AI-driven shader effect editing method uses visual feature extraction and generative adversarial networks to generate initial code, combined with genetic algorithms to optimize performance. This solves the problem of shader writing complexity, enabling efficient and intuitive shader development and optimization, and improving development efficiency and visual effects.
Patent Information
- Application Number
- CN202510858522.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2025-11-07
AI Technical Summary
The existing technology for writing and debugging shaders is complex, requires professional knowledge and skills, is time-consuming and labor-intensive, and makes it difficult to achieve creative diversity, which affects development efficiency and design experience.
This AI-driven shader effect editing method extracts visual features using image recognition and text description components, combines reinforcement learning and generative adversarial networks to generate initial shader code, optimizes performance through genetic algorithms, integrates high-resolution preview and 3D scene analysis technologies, and supports real-time editing by multiple users.
It lowers the barrier to entry for shader development, improves development efficiency and design experience, enhances team collaboration convenience, provides intuitive effect display, reduces debugging work, and improves rendering performance and visual fidelity.
Smart Images

Figure CN120909592A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to an AI-driven Shader effect editing method, system, device and medium. BACKGROUND
[0002] In the field of computer graphics and game development, Shader (shader) as a key program for graphics processing, undertakes the important responsibility of realizing various visual effects. At present, the writing and debugging of Shader mainly rely on professional graphic programmers, who need to manually write GLSL (OpenGL Shading Language), HLSL (High Level Shading Language) and other language codes. Although this manual writing method can realize highly customized visual effects, it also exposes many significant problems.
[0003] Firstly, manual writing of Shader code requires developers to have professional knowledge of graphics and programming skills. The knowledge of graphics covers multiple complex fields such as lighting model, texture mapping, geometric transformation, and the programming skills require a good command of specific shading language syntax and programming paradigm. This makes it difficult for non-professionals to participate in the development of Shader, limiting the diversification of creativity and the improvement of development efficiency.
[0004] Secondly, manual writing and debugging of Shader code is a very time-consuming and laborious process. For complex visual effects, developers need to repeatedly write, compile, run and debug the code to adjust parameters, optimize algorithms and ensure that the final effect meets the expectations. This tedious process not only increases the development cycle, but also may lead to the rise of development cost.
[0005] Finally, the design process of Shader is complex and challenging. Developers need to build complex visual effect models in their minds and translate them into code implementation. During this process, developers may encounter various unpredictable problems such as rendering errors, performance bottlenecks, etc., which require a lot of time and effort to troubleshoot and solve. This not only affects the developers' creative enthusiasm, but also reduces the overall design experience. SUMMARY
[0006] The purpose of the present application is to provide an AI-driven Shader effect editing method, system, device and medium, which realizes the automatic generation and optimization of Shader effects through AI driving, reduces the development threshold of Shader, improves the development efficiency and enhances the design experience, to solve at least one of the above-mentioned problems of the prior art.
[0007] In a first aspect, the present application provides an AI-driven Shader effect editing method, which specifically comprises: receive a reference image, a GIF animation and a text description uploaded by a user, extract visual features through an image recognition component, and generate a structured Shader effect description through a text description component; based on the visual features, search for Shader templates with similar styles in a Shader template library, and generate an initial parameter combination in combination with a reinforcement learning model; input the structured Shader effect description and the initial parameter combination into a Shader generation component, and generate an initial Shader code using a conditional GAN architecture; support multiple users in real-time editing of the same initial Shader code through a CRDT conflict resolution algorithm, and perform performance optimization on the edited initial Shader code based on a genetic algorithm to generate an optimized Shader code; based on the optimized Shader code, generate a high-resolution preview image using Stable Diffusion, and integrate NeRF technology to analyze 3D scene data to automatically generate ambient light shading effects.
[0008] In a second aspect, the present application provides an AI-driven Shader effect editing system, which specifically comprises: a feature extraction module for receiving a reference image, a GIF animation and a text description uploaded by a user, extracting visual features through an image recognition component, and generating a structured Shader effect description through a text description component; a parameter recommendation module for searching for Shader templates with similar styles in a Shader template library based on the visual features, and generating an initial parameter combination in combination with a reinforcement learning model; a code generation module for inputting the structured Shader effect description and the initial parameter combination into a Shader generation component, and generating an initial Shader code using a conditional GAN architecture; a code optimization module for supporting multiple users in real-time editing of the same initial Shader code through a CRDT conflict resolution algorithm, and performing performance optimization on the edited initial Shader code based on a genetic algorithm to generate an optimized Shader code; an effect preview module for generating a high-resolution preview image using Stable Diffusion based on the optimized Shader code, and integrating NeRF technology to analyze 3D scene data to automatically generate ambient light shading effects.
[0009] In a third aspect, the present application provides a computer device comprising a memory and a processor, and a computer program stored in the memory, when the computer program is executed on the processor, the AI-driven Shader effect editing method is realized.
[0010] In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the AI-driven Shader effect editing method of any one of the above methods.
[0011] Compared with the prior art, the present application has at least one of the following technical effects: 1. The present application realizes the automatic generation and optimization of Shader effects through AI driving, reduces the development threshold of Shader, improves the development efficiency, and enhances the design experience.
[0012] 2. The present application does not require the user to have professional knowledge of graphics and programming skills, but only needs to provide intuitive visual materials and text descriptions, greatly reducing the development threshold of Shader, so that non-professionals can also participate in the creation of Shader.
[0013] 3. The present application optimizes the edited Shader code based on a genetic algorithm, generates optimized Shader code, and improves the rendering performance and visual effect fidelity.
[0014] 4. The present application generates high-resolution preview images based on the optimized Shader code by integrating Stable Diffusion and NeRF technologies, and automatically generates ambient light shading effects, which enables developers to intuitively see the final effect of Shader without repeatedly compiling and running code for debugging.
[0015] 5. The multi-user real-time editing function of the present application also enhances the convenience of team collaboration and improves the overall design experience, allowing developers to focus more on creative expression and less on technical implementation details.
[0016] 6. The present application uses image recognition and text description components to automatically extract visual features and generate structured Shader effect descriptions, reducing manual input and improving the accuracy and completeness of the descriptions.
[0017] 7. The present application retrieves similar Shader templates based on visual features and generates initial parameter combinations using a reinforcement learning model, improving the quality and adaptability of the initial Shader code and reducing subsequent debugging work.
[0018] 8. The present application uses a conditional GAN architecture to generate initial Shader code, dynamically allocates parameter weights through an attention mechanism, and ensures that the generated code meets user requirements and has good rendering effects.
[0019] 9、The application supports multi-user real-time editing of the same Shader code through the CRDT conflict resolution algorithm, ensuring data consistency and integrity during the editing process, and improving team collaboration efficiency.
[0020] 10、The application generates high-resolution preview images using Stable Diffusion and integrates NeRF technology to analyze 3D scene data, automatically generating ambient light shading effects, providing intuitive Shader effect display, and enhancing user experience. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0022] Figure 1 is a flowchart of an AI-driven Shader effect editing method provided by an embodiment of the present application; Figure 2 is a structural schematic diagram of an AI-driven Shader effect editing system provided by an embodiment of the present application; Figure 3 is a structural schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0023] In the following description, specific details such as specific system structures, techniques, etc. are presented in order to thoroughly understand the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits and methods are omitted to avoid unnecessary details that hinder the description of the present application.
[0024] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, whole, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, whole, steps, operations, elements, components and / or sets thereof.
[0025] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0026] As used in the specification and appended claims herein, the term “if’ can be interpreted as meaning “when” or “upon” or “in response to a determination” or “in response to a detection” depending on the context. Similarly, the phrase “if it is determined” or “if [the described condition or event] is detected” can be interpreted as meaning “upon a determination” or “in response to a determination” or “upon a detection of [the described condition or event]” or “in response to a detection of [the described condition or event]” depending on the context.
[0027] In addition, in the description of the present application and the appended claims, the terms “first”, “second”, “third” and the like are used only to distinguish descriptions, and cannot be understood as indicating or implying relative importance.
[0028] In the present application, the reference “one embodiment” or “some embodiments” and the like means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements “in one embodiment”, “in some embodiments”, “in other some embodiments”, “in further some embodiments” and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean “one or more but not all embodiments”, unless otherwise specifically emphasized. The terms “include”, “contain”, “have” and their variants mean “include but not limited to”, unless otherwise specifically emphasized.
[0029] In the embodiments of the present application, the execution subject of the flow includes a terminal device. The terminal device includes but is not limited to a server, a computer, a smart phone, a tablet computer and other devices capable of executing the method disclosed in the present application. Figure 1 The flowchart of the AI-driven Shader effect editing method disclosed in an embodiment of the present application is shown, and the details are as follows: S101, receiving a reference image, a GIF animation and a text description uploaded by a user, extracting visual features through an image recognition component, and generating a structured Shader effect description through a text description component.
[0030] In this embodiment, a dedicated upload area is set on the user interface, where the user can select a locally stored reference image file (such as JPEG, PNG, etc.) and GIF animation file by clicking the upload button. After receiving the file, the system first performs format verification to ensure that the file format meets the requirements. For example, check if the image file is a valid image format, and if the GIF animation file is a standard GIF format. If the file format does not meet the requirements, the system prompts the user with error information and asks the user to upload a file that meets the format. For GIF animations, the system will disassemble them into a series of frame images for subsequent frame-by-frame visual feature extraction. The text description is subjected to basic legality checks, such as checking if the text length is within a reasonable range and if it contains illegal characters. If the text description does not meet the requirements, the system prompts the user with corresponding error information.
[0031] For reference images and frame images of GIF animations, first perform size normalization to adjust the image size to a uniform size suitable for subsequent feature extraction, such as adjusting the image size to 256x256 pixels. Perform color space conversion to convert the image from the common RGB color space to a color space more suitable for feature extraction, such as the HSV color space. The HSV color space decomposes color into hue (H), saturation (S), and value (V) components, which helps more accurately extract color-related visual features.
[0032] Calculate the histogram of each color channel in the image. For the HSV color space, calculate the histograms of the hue, saturation, and value channels respectively. The histogram can reflect the distribution of different color values in the image, such as the frequency of each hue value. By analyzing the color histogram, the color value with the highest frequency is found as the dominant color. At the same time, the average value, standard deviation, and other statistical quantities of the color can be calculated to more comprehensively describe the color features of the image.
[0033] Use the gray level co-occurrence matrix (GLCM) method to extract the texture features of the image. GLCM describes texture information by calculating the spatial dependence between gray levels in the image. Some commonly used statistical quantities of GLCM can be calculated, such as contrast, correlation, energy, and entropy, which can reflect the texture roughness, directionality, and other characteristics of the image. Use the local binary pattern (LBP) method to extract the local texture features of the image. LBP compares the gray values of each pixel point and its neighborhood pixel points in the image to generate a binary code, thereby describing the local texture structure of the image. The LBP histogram can be calculated to reflect the texture distribution of the image.
[0034] For cases where there are obvious shapes in the reference image, an edge detection algorithm (such as the Canny edge detection algorithm) can be used to extract the edge information of the image. Then, morphological processing is performed on the edges, such as dilation, erosion, etc., to enhance the continuity and integrity of the edges. The geometric features of the edges are calculated, such as the length, area, perimeter, shape factor, etc. of the edges. The shape factor can reflect the complexity of the shape, such as circularity, rectangularity, etc.
[0035] The extracted color features, texture features, and shape features are integrated to form a comprehensive visual feature vector. This feature vector contains information about the image in terms of color, texture, and shape, and can comprehensively describe the visual features of the image.
[0036] The natural language processing technique is used to perform word segmentation on the user input text description, dividing the text into individual words. The segmented words are tagged with their parts of speech, such as nouns, verbs, adjectives, etc. Based on the part-of-speech tagging results, the keywords in the text description are extracted. Generally, nouns and adjectives are the key information for describing Shader effects. The extracted keywords are further filtered and classified. For example, keywords describing colors (such as "blue") are classified into one category, keywords describing materials (such as "metallic texture") are classified into another category, and keywords describing special effects (such as "glitter" and "starlight") are classified into a third category. Based on the classification results of the keywords, a structured Shader effect description is generated.
[0037] S102, based on the visual features, retrieve Shader templates with similar styles from the Shader template library, and generate an initial parameter combination in combination with the reinforcement learning model.
[0038] In this embodiment, various Shader codes are collected, which cover different styles, different application scenarios, such as cartoon style, realistic style, science fiction style, etc., and Shaders for implementing different visual effects, such as lighting effects, texture effects, special effect effects, etc.
[0039] The collected Shader codes are classified and arranged, and a multi-level classification system is established according to dimensions such as style and function. For example, in the style dimension, it can be divided into cartoon, realistic, retro, etc. subcategories; in the function dimension, it can be divided into lighting, texture, particle special effect, etc. subcategories. At the same time, detailed label information is added to each Shader template, including style label, function label, applicable scene label, etc., to facilitate subsequent retrieval.
[0040] For each Shader template, use the same image recognition method (such as color feature extraction, texture feature extraction, etc.) as the user input image to extract its corresponding visual features. These visual features reflect the visual style characteristics presented by the Shader template. Store the extracted visual features together with the Shader template's code, label, and other information in a dedicated database, forming a Shader template library. The database uses an efficient indexing structure to facilitate fast retrieval.
[0041] When the visual features extracted from the user input image are received, perform similarity calculation with the visual features of each template in the Shader template library. Similarity calculation can use various methods, such as distance-based methods, such as Euclidean distance, cosine similarity, etc. Take color features as an example, compare the color histogram of the user input image with the color histogram of the template, and calculate the Euclidean distance between them. The smaller the distance, the more similar the color features. For texture features and shape features, etc., similar methods are used for similarity calculation. Combine the similarity calculation results of each feature to get the comprehensive similarity of each Shader template and the user input image. Weighted average method can be used, different weights are assigned according to the importance of different features in visual effects, such as color feature weight 0.4, texture feature weight 0.3, shape feature weight 0.3, etc.
[0042] According to the comprehensive similarity, sort the templates in the Shader template library in order of similarity from high to low. Set a similarity threshold to filter out Shader templates with a similarity higher than the threshold as candidate templates. The similarity threshold can be adjusted according to actual needs to ensure the accuracy and diversity of the retrieval results. If the retrieval results are too many, further filtering can be performed according to other conditions (such as the popularity of the template, usage frequency, etc.) to obtain the final similar Shader template set.
[0043] Build a reinforcement learning environment based on the filtered similar Shader templates. Define the parameter space of each Shader template as the action space in reinforcement learning, and the value range of the parameters as the possible values of the action. For example, for a parameter that controls the intensity of the light, its value range may be between 0 and 1.
[0044] Define the state space of reinforcement learning, which can include the visual effect features of the current Shader (such as color, texture, etc.), the text description information input by the user, and some performance indicators (such as rendering frame rate, etc.).
[0045] A reward function is set, and the purpose of the reward function is to guide the reinforcement learning model to generate an initial parameter combination that meets the user's needs and has good performance. The reward function can be designed according to the matching degree of the visual effect of the Shader with the user's expectations, rendering performance, and other aspects. For example, the closer the generated Shader effect is to the visual features input by the user, the higher the reward given; if the rendering frame rate is higher, a certain reward is also given.
[0046] A suitable reinforcement learning algorithm is selected, such as Deep Q Network (DQN), Policy Gradient Algorithm (PG), etc., to train the reinforcement learning model. During the training process, the model continuously tries different parameter combinations through interaction with the environment, adjusts the strategy according to the feedback of the reward function, and maximizes the cumulative reward.
[0047] After training, the structured Shader effect description input by the user and the current state information are input into the trained reinforcement learning model, and the model generates an initial parameter combination according to the learned strategy.
[0048] S103, input the structured Shader effect description and the initial parameter combination to the Shader generation component, and generate the initial Shader code using the conditional GAN architecture.
[0049] In this embodiment, the generator is the core part of the conditional GAN, responsible for generating Shader code according to the input conditions. When designing the generator, a multi-layer neural network structure is used, such as a combination of convolutional neural network (CNN) and fully connected neural network (FCN). First, the structured Shader effect description and the initial parameter combination are preprocessed. For the structured description, it is converted into a vector form suitable for neural network processing. For example, arrange the attributes in the description (such as color attributes, material attributes, special effect attributes, etc.) in a certain order, and assign a specific numerical representation to each attribute to form a high-dimensional vector. For the initial parameter combination, it is also converted into a vector form and concatenated with the structured description vector to form a comprehensive input vector. After the input vector enters the generator, it goes through a series of convolutional layers and fully connected layers. The convolutional layers are used to extract local features and patterns in the input vector, and the fully connected layers are used to further combine and transform the features. In the middle layer of the generator, some regularization techniques such as Dropout can be introduced to prevent overfitting. The output layer of the generator is designed to generate Shader code. The Shader code can be regarded as a sequence data, so the output layer can use recurrent neural network (RNN) or its variants (such as LSTM, GRU) to generate code characters or code fragments one by one. For example, the output layer outputs a probability distribution of a character each time, and then selects the next character to be generated according to the probability distribution until the complete Shader code is generated.
[0050] The role of the discriminator is to determine whether the generated Shader code is real and valid, and whether it meets the input conditions. The discriminator also uses a multi-layer neural network structure, usually a combination of CNN and FCN. The input of the discriminator includes two parts: one is the generated Shader code (or real Shader code samples), and the other is the corresponding structured Shader effect description and initial parameter combination. The two inputs are spliced to form a comprehensive input vector. After the input vector enters the discriminator, it is processed by convolutional layers and fully connected layers. The convolutional layers are used to extract features in the code, and the fully connected layers are used to make a comprehensive judgment of the features. The output layer of the discriminator is a binary classifier, which outputs a probability value representing the probability that the input Shader code is real. If the probability value is close to 1, the code is considered real; if the probability value is close to 0, the code is considered generated.
[0051] A large number of real Shader code samples are collected, which should cover different styles, functions and visual effects. At the same time, the corresponding structured Shader effect description and initial parameter combination are prepared for each Shader code sample. The structured Shader effect description can be generated by manual annotation. The annotators fill in the attribute information of color, material, special effect, etc. according to the actual effect of the Shader code. The initial parameter combination can be obtained by analyzing the parameter settings in the Shader code, or determined by professional graphic programmers based on experience.
[0052] The collected real Shader code is preprocessed, including removing comments, uniforming code format, etc. to facilitate the processing of neural networks. The structured Shader effect description and initial parameter combination are converted into vector form suitable for neural network input, and paired with the corresponding Shader code to form a training data set. The training data set is divided into training set, validation set and test set, usually according to a certain proportion (such as 70% training set, 15% validation set, 15% test set).
[0053] In the training process, the generator and the discriminator are in an adversarial training. The goal of the generator is to generate as realistic Shader code as possible to deceive the discriminator; the goal of the discriminator is to accurately determine whether the input Shader code is real or generated. First, a batch of real Shader code samples and their corresponding structured Shader effect descriptions and initial parameter combinations are randomly extracted from the training set. The structured description and the initial parameter combination are input into the generator to generate a batch of fake Shader code. Then, the real Shader code samples and the generated fake code samples are respectively spliced with the corresponding structured description and initial parameter combination, and input into the discriminator. The discriminator judges the two batches of data and outputs the corresponding probability value. According to the output result of the discriminator, the loss function of the generator and the discriminator is calculated. The loss function of the generator encourages the generator to generate more realistic code, and the loss function of the discriminator encourages the discriminator to more accurately determine the authenticity of the code. Through the back propagation algorithm, the parameters of the generator and the discriminator are updated according to the loss function. In the training process, the performance of the generator and the discriminator is monitored using the validation set. The generation effect indicators of the generator on the validation set, such as the accuracy of the generated code and the matching degree with the input conditions, and the discrimination accuracy of the discriminator are calculated regularly. According to the performance of the validation set, the training parameters are adjusted, such as the learning rate, the number of training rounds, etc. If the performance of the generator improves slowly or oscillates, the learning rate can be appropriately reduced; if the discrimination accuracy of the discriminator is too high, it means that the code generated by the generator is not realistic enough, and the training intensity of the generator or the network structure of the generator can be adjusted.
[0054] When it is necessary to input the structured Shader effect description and the initial parameter combination provided by the user into the trained conditional GAN to generate the initial Shader code, the input conditions are first preprocessed in the same way as the training data. The structured description and the initial parameter combination are converted into vector form and spliced. The processed input vector is input into the generator, and the generator starts to generate Shader code characters or fragments one by one. During the generation process, some sampling strategies can be used, such as greedy sampling or beam search sampling, to improve the quality of the generated code. After generating the complete initial Shader code, the code is post-processed. The syntax correctness of the code is checked, and possible syntax errors are repaired; the code is formatted to conform to common Shader code writing specifications.
[0055] S104, through the CRDT conflict resolution algorithm, multiple users can edit the same initial Shader code in real time, and based on the genetic algorithm, the edited initial Shader code is optimized in performance to generate an optimized Shader code.
[0056] In this embodiment, an operation transformation (OT) or state-based CRDT data structure is chosen to store the initial Shader code. Taking the operation transformation as an example, the Shader code is regarded as a character sequence, and each user's editing operation (such as inserting a character, deleting a character, or modifying a character) is recorded as an operation object. The operation object contains information such as operation type (insert, delete, modify), operation position, and operation content. A shared CRDT document is created on the server side, and the initial Shader code is loaded into the document. At the same time, a unique user identifier is assigned to each user participating in the editing, and the operation history and current document state of each user are recorded.
[0057] When a user edits the Shader code on their own client, the client first records the editing operation locally. The client broadcasts the local operation to the server and other clients through the network. After receiving the operation, the server adds it to the operation history of the shared document and updates the document state according to the CRDT algorithm. After receiving the operation, other clients also apply the operation to the local document copy according to the CRDT algorithm.
[0058] During the operation application process, conflicts may occur. For example, two users simultaneously modify characters at the same position. The server monitors the dependency relationship and execution order between operations and marks these conflicting operations when conflicts are detected.
[0059] A conflict resolution strategy based on timestamps and user priority is adopted. Each operation has a timestamp recording the time of operation. When a conflict occurs, the timestamps of the operations are compared, and the operation with a later timestamp has a higher priority. If the timestamps are the same, the user's preset priority is used for judgment. The operation with high priority is applied to the document, and for the operation with low priority, appropriate adjustments or mergers are made according to the difference between the two operations. For example, if the operation with low priority is to modify a character, and the operation with high priority is to delete the character at that position, the modification operation with low priority is discarded.
[0060] The rendering frame rate is taken as one of the important performance evaluation indicators. By running the Shader code in a specific hardware environment and rendering scene, the number of frames rendered per unit time is counted. The higher the frame rate, the better the performance of the Shader code. The memory size occupied by the Shader code during running is monitored. The lower the memory usage, the better the performance of the code. The calculation logic in the Shader code is analyzed to estimate its computational complexity. For example, the number of loops and conditional judgments in the code is counted, and the lower the complexity, the better the performance.
[0061] Determine the parameters of the genetic algorithm, including population size, crossover probability, mutation probability, etc. Population size represents the number of Shader code individuals included in each iteration, crossover probability determines the probability of two individuals performing crossover operation, and mutation probability determines the probability of individual mutation. These parameters can be adjusted according to actual situation to achieve better optimization effect. Based on the initial Shader code edited by multiple users, an initial population is generated. A number of different Shader code individuals can be generated by making some random minor modifications to the initial code (such as changing parameter values, adjusting code structure, etc.), forming an initial population.
[0062] Evaluate the individuals in the initial population according to the performance evaluation index, and calculate the fitness value of each individual. The higher the fitness value, the better the performance of the individual. Use roulette selection, tournament selection and other methods to select excellent individuals into the next generation population according to the fitness value. Randomly select two individuals from the selected population and perform crossover operation according to the crossover probability. Crossover operation can be exchanging part of the code fragments at a specific position in the code. For example, exchange the code of two Shader code individuals at a function definition part to generate two new individuals. Perform mutation operation on the individuals after crossover according to the mutation probability. Mutation operation can be randomly changing parameter values in the code, inserting or deleting some statements that do not affect the basic function of the code, etc. Repeat the selection, crossover and mutation operations to generate a new population, and evaluate the performance of the individuals in the new population. Through multiple iterations, the performance of the Shader code is continuously optimized. Set termination conditions, such as reaching the maximum number of iterations, the fitness value of the individuals in the population reaching the preset threshold, etc. When the termination condition is met, stop iteration and select the individual with the highest fitness value from the current population as the optimized Shader code.
[0063] S105, based on the optimized Shader code, generate high-resolution preview images using Stable Diffusion, and integrate NeRF technology to analyze 3D scene data and automatically generate ambient light shading effects.
[0064] In this embodiment, scene information related to the optimized Shader code is extracted from the game or graphics application scene, including object models in the scene, material properties, lighting settings, etc. For example, determine which objects in the scene use the optimized Shader, the geometry, color, texture, and other material information of these objects, and the type of light source (such as point light, parallel light, spotlight), light source position and intensity, and other lighting information in the scene.
[0065] Map the parameters in the optimized Shader code to the scene information. Parameters in the Shader code can affect the visual effects of objects, such as color, glossiness, transparency, etc. Associate these parameters with the material properties and lighting in the scene. For example, there is a parameter in the Shader code that controls the reflectivity of objects. Correspond it to the material reflectance property of objects in the scene so that the effect of the Shader code can be accurately reflected when generating a preview image.
[0066] Select a Stable Diffusion model suitable for generating a graphical preview image. Based on the adapted scene information and Shader code parameters, construct the input data for the Stable Diffusion model. Input the constructed input data into the Stable Diffusion model to start the image generation process. The model will gradually generate high-resolution preview images based on the input guide image, text description, and lighting information. During the generation process, the model will continuously iterate and optimize the details and visual effects of the image to accurately reflect the performance of the optimized Shader code in the scene as much as possible.
[0067] Integrate the NeRF (Neural Radiance Field) technology into the graphics processing system. The NeRF model can learn the 3D representation of a scene by inputting a series of 2D images and corresponding camera pose information. When integrating the NeRF model, ensure that it can interact with existing graphics rendering processes and data processing modules.
[0068] Use multiple cameras to capture the scene from different angles to obtain a series of 2D images. At the same time, record the pose information (such as position, rotation angle) of each camera. These 2D images and camera pose information will be used as input data for the NeRF model to learn the 3D structure of the scene. For example, in an indoor scene, use multiple cameras to capture images from different angles around the room.
[0069] Input the collected 2D images and camera pose information into the NeRF model for 3D scene reconstruction. The NeRF model will learn the color and density information of each point in the scene to construct a 3D representation of the scene. During the reconstruction process, some optimization algorithms can be used to improve the accuracy and efficiency of the reconstruction, such as gradient descent-based optimization methods.
[0070] Based on the reconstructed 3D scene, construct an ambient occlusion calculation model. Ambient occlusion reflects the degree of occlusion of the surface of objects in the scene by surrounding ambient light. The ambient occlusion effect can be calculated using a ray tracing-based method, which involves emitting a ray from each point on the object's surface to the surrounding environment, counting the proportion of occluded rays, and obtaining the ambient occlusion value of that point. To improve computational efficiency, some approximation algorithms or acceleration structures such as voxelization, octree, etc. can be used.
[0071] According to the constructed ambient light shading calculation model, the reconstructed 3D scene is calculated to generate the ambient light shading value of each point. These ambient light shading values are stored in a three-dimensional texture or voxel grid for subsequent rendering.
[0072] The generated ambient light shading effect is fused with the optimized Shader code. During the rendering process, the corresponding ambient light shading value is obtained from the ambient light shading texture or voxel grid according to the position and surface normal of the object, and is applied to the Shader code. For example, in the Shader code, the ambient light shading value is multiplied with the diffuse reflection color of the object, thereby simulating the dark part effect of the object surface under the ambient light shading. In this way, the rendering image with ambient light shading effect is automatically generated, enhancing the realism and stereoscopic sense of the scene.
[0073] Ensure that the process of generating high-resolution preview images by Stable Diffusion and generating ambient light shading effects by NeRF technology can be coordinated and synchronized. When generating preview images, the influence of ambient light shading effects needs to be considered as part of the input or added as post-processing effects to the preview images. For example, in the input of the Stable Diffusion model, a text description or a low-resolution ambient light shading image of the ambient light shading can be included to guide the model to generate a preview image with correct ambient light shading effects.
[0074] Establish a data interaction mechanism between the two processes to timely transmit scene information, Shader code parameters, and ambient light shading effects, etc. to ensure that the final generated image quality is consistent and meets expectations.
[0075] In some embodiments, in step S101, the reference image, GIF animation and text description uploaded by the user are received, the visual features are extracted by an image recognition component, and the structured Shader effect description is generated by a text description component, specifically including: Obtain the reference image, GIF animation and text description input by the user; For the reference image or GIF animation, extract its texture features, color distribution features and dynamic motion features through a convolutional neural network; For the text description, convert it into key-value pair structured data containing lighting type, texture attribute and physical parameter through a pre-trained language model; Based on the key-value pair structured data, map the texture features to the normal map parameters, map the color distribution features to the gradient function, and map the dynamic motion features to the particle motion equation to generate a unified Shader effect description matrix; For undefined parameters in the Shader effect description matrix, automatically fill in the default parameter values by querying the historical effect database for similar cases.
[0076] In this embodiment, for each frame of the reference image or GIF animation, it is input into the CNN model. Feature maps are extracted at the middle layers or specific convolutional layers of the CNN model, which contain the texture information of the image. By performing statistical analysis on the feature maps, such as calculating the mean, variance, energy, and other statistics of the feature maps, a texture feature vector is obtained. For example, for each frame of the GIF animation, a texture feature vector is extracted respectively, and then the texture feature vectors of all frames are averaged or weighted averaged to obtain the texture feature of the entire GIF animation.
[0077] Similarly, the image or GIF frame is input into the CNN model, and color-related features are extracted at specific layers of the model (such as pooling layers). The image can be converted from the RGB color space to the HSV color space, and the distribution information of hue, saturation, and brightness is extracted respectively. By quantifying these distribution information, such as counting the number of pixels in different color intervals, a color distribution feature vector is obtained.
[0078] For GIF animations, since it is a sequence composed of multiple frames of images, dynamic motion features can be extracted by analyzing the differences between frames. For example, calculate the pixel displacement and color change between adjacent frames. Optical flow method can be used to estimate the motion direction and speed of pixels, and these motion information is integrated into a dynamic motion feature vector. For reference images, since they are static, dynamic motion features can be set to default values or reasonably inferred according to the context.
[0079] Select a pre-trained language model suitable for processing natural language text, such as BERT, GPT, etc. These models have been trained on large-scale text corpora and have good language understanding and representation capabilities. According to the requirements of the Shader effect description, adapt the pre-trained language model. For example, some specific task layers can be added to convert text into key-value pair structured data containing lighting types, texture attributes, and physical parameters. Fine-tune the model using some text data related to Shader effect description to improve its performance on this task. Input the preprocessed text description into the adapted pre-trained language model. The model will perform semantic analysis on the text and identify information related to lighting types (such as parallel light, point light source, ambient light, etc.), texture attributes (such as material type, roughness, reflectivity, etc.), and physical parameters (such as light intensity, color shift, etc.). According to the identified information, generate key-value pair structured data.
[0080] Formulate mapping rules of texture features, color distribution features, and dynamic motion features to Shader parameters. For example, map certain statistics in the texture feature vector to normal map parameters. The strength and direction of the normal map can be determined according to the roughness, directionality, and other features of the texture. For color distribution features, map them to a gradient function. According to the distribution of colors, determine the starting color, ending color, and gradient method (such as linear gradient, radial gradient, etc.) of the gradient. For dynamic motion features, map them to a particle motion equation. According to the direction and speed of the motion, determine the initial position, motion trajectory, and speed variation law of the particles.
[0081] According to the formulated mapping rules, convert the extracted features and structured data into Shader parameters. Organize normal map parameters, gradient functions, and particle motion equations into a unified Shader effect description matrix. Each row or column of the matrix can represent a specific Shader parameter or parameter combination, and the values of the matrix represent the specific values of the parameters. In the process of generating the matrix, perform necessary unit conversion and formatting processing on the parameters to ensure that the value range and format of the parameters meet the requirements of the Shader code.
[0082] Collect and organize previously generated Shader effect cases to build a historical effect database. The database should include the Shader effect description matrix, reference images, GIF animations, and text descriptions of each case. Classify and label the data in the database, such as by lighting type, texture style, etc., to facilitate subsequent queries and matching.
[0083] For undefined parameters in the Shader effect description matrix, query the historical effect database. According to some information in the reference images, GIF animations, and text descriptions of the current case, match similar cases in the database. Similarity calculation methods such as cosine similarity, Euclidean distance, etc. can be used to calculate the similarity between the current case and the cases in the database.
[0084] Select the top several cases with the highest similarity, and extract their default parameter values. According to certain rules, such as weighted average or selecting the parameter values of the most similar cases, automatically fill in the undefined parameters of the current case. After filling, perform a completeness check on the Shader effect description matrix to ensure that all parameters have reasonable values.
[0085] In some embodiments, in step S102, based on the visual features, retrieve Shader templates with similar styles from the Shader template library, and generate an initial parameter combination in combination with a reinforcement learning model, specifically including: Based on the visual features, compress the feature dimension through principal component analysis algorithm to generate a low-dimensional feature vector; The low-dimensional feature vector is subjected to cosine similarity calculation with the template features in the Shader template library, and candidate templates with similarity greater than a preset threshold are screened out; When the number of candidate templates is greater than 1, the historical use data of the candidate templates is input into the reinforcement learning strategy network, and the optimal template and initial parameter combination are output; For the initial parameter combination, the Monte Carlo tree search algorithm is used to sample the neighborhood values in the parameter space, and a set of robust parameters against interference is generated.
[0086] In this embodiment, the visual features are input into the PCA model, and the high-dimensional feature data is projected into a low-dimensional space through linear transformation. The PCA model will find a set of new orthogonal bases, so that the projection variance of the data on these bases is maximized, thereby realizing the dimensionality reduction of the features. After projection, a low-dimensional feature vector is obtained, which retains the main information of the original visual features and reduces the dimension of the data, improving the efficiency of subsequent calculations. The generated low-dimensional feature vector is stored in the database for subsequent retrieval and matching operations. With the input of new reference images and GIF animations, the low-dimensional feature vector dataset is constantly updated, and PCA analysis is performed again to adapt to the new data distribution and feature changes.
[0087] Various styles of Shader templates are collected, and the features of each template are extracted. Template features can include visual effect features (such as texture style, color matching, dynamic effect, etc.) and parameter features (such as lighting parameters, texture mapping parameters, etc.) of the template. The visual features of the template are extracted using the same method as before and are standardized. The extracted template features are stored in a special database, and an index is established for each template for fast retrieval. Hash tables, tree structures, and other data structures can be used to organize template data and improve retrieval efficiency.
[0088] The generated low-dimensional feature vector is subjected to cosine similarity calculation with each template feature in the Shader template library. Cosine similarity is used to measure the cosine value of the included angle between two vectors, with a value range of [-1, 1], and the larger the value, the more similar the two vectors. For each template, the cosine similarity between its feature vector and the low-dimensional feature vector is calculated. According to actual requirements and experience, a similarity preset threshold is set. The calculated cosine similarity is compared with the preset threshold, and candidate templates with similarity greater than the threshold are screened out.
[0089] Define the state, action, and reward function for reinforcement learning. The state can include historical usage data of candidate templates, such as the frequency of use, user reviews, performance in different scenarios, etc. The action is to select different candidate templates and their initial parameter combinations. The reward function is defined according to the effect of the selected template and parameter combination in actual application, for example, if the generated Shader effect meets the user's needs and has good performance, a higher reward is given; otherwise, a lower reward is given.
[0090] Select a suitable reinforcement learning algorithm, such as Deep Q Network (DQN), policy gradient algorithm, etc., to construct the reinforcement learning policy network. Use historical data to train the policy network, so that the network can learn the policy of selecting the optimal action in different states. In the training process, the parameters of the network are constantly adjusted to improve the performance of the policy network.
[0091] When the number of candidate templates is greater than 1, input the historical usage data of the candidate templates into the trained reinforcement learning policy network. The policy network makes decisions based on the input data and outputs the optimal template and its initial parameter combination. For example, the policy network will select a template that is most likely to meet the user's needs based on factors such as historical usage frequency, user reviews, etc., and give the corresponding initial parameter settings.
[0092] Verify the output of the optimal template and initial parameter combination. Testing can be done in a simulated environment to observe whether the generated Shader effect meets the expectations. If the effect is not ideal, the reinforcement learning policy network can be adjusted, such as modifying the reward function, increasing the training data, etc., to make a new decision.
[0093] Define the search space of parameters based on the initial parameter combination. The search space includes the value range and possible value interval of each parameter. For example, for a light intensity parameter, its value range can be [0, 1] and the value interval can be 0.01.
[0094] A suitable MCTS algorithm implementation is selected to initialize the MCTS model. The MCTS model generally includes four stages: selection, expansion, simulation, and backtracking. In the initialization stage, the parameters of the model are set, such as the exploration-exploitation balance factor, the number of simulations, etc. The MCTS algorithm is used to sample in the parameter space. In the selection stage, the next node to be expanded is selected according to the statistical information of the current node (such as the number of visits, the average reward, etc.). In the expansion stage, a random neighbor value is selected from the search space as a new node. In the simulation stage, the sampled parameter combination is used to generate a Shader effect, and its performance is evaluated to obtain the corresponding reward value. In the backtracking stage, the reward value obtained by simulation is backtracked to the parent node, and the statistical information of the node is updated. After multiple sampling and simulation, a set of parameters with good performance is selected as the robustness parameter set according to the statistical information of the nodes. For example, the parameter combination with more visits and higher average reward is selected as the robustness parameter set, and the generated robustness parameter set is stored together with the optimal template.
[0095] In some embodiments, in step S103 described above, the structured Shader effect description and the initial parameter combination are input into the Shader generation component to generate an initial Shader code using a conditional GAN architecture, specifically including: Based on the structured Shader effect description and the initial parameter combination, the lighting model, texture attributes, and physical parameters are encoded into a fixed-dimensional conditional vector; The conditional vector is input into the generator network, and an attention mechanism is used to dynamically allocate the weights of each technical parameter in the code segment. The intermediate code representation is generated by gradually upsampling through the deconvolution layer; For the intermediate code representation output by the generator, the discriminator network performs parallel verifications of the code's compilability and the rendering effect matching degree, and generates a comprehensive confidence score; When the comprehensive confidence score is lower than the preset score threshold, the weights of the generator network and the discriminator network are adjusted simultaneously through the gradient backpropagation mechanism; For the intermediate code representation that meets the confidence requirement, syntax normalization processing is performed and target platform adaptation instructions are added, and an executable initial Shader code is output.
[0096] In this embodiment, the structured Shader effect description and initial parameter combination covers the lighting model (such as Phong lighting model, Blinn-Phong lighting model, etc.), texture attribute (such as texture type, texture coordinate mapping method, texture blending mode, etc.), and physical parameter (such as light intensity, material reflectivity, refractive index, etc.). The fixed dimension of the condition vector is determined, which should be able to fully represent all key information of the lighting model, texture attribute, and physical parameter. According to the importance and number of different parameters, the dimension proportion of each parameter in the condition vector is reasonably allocated. A specific encoding rule is used to map the lighting model, texture attribute, and physical parameter into the fixed-dimension condition vector. For the lighting model, One-Hot Encoding can be used to represent different lighting models as different positions in the vector being 1 and the remaining positions being 0. For texture attributes and physical parameters, normalized encoding is used according to their value range and characteristics. The value range of the parameter is mapped to the [0, 1] interval, and then the normalized value is used as the value of the corresponding position in the vector. The vectors of all encoded parameters are concatenated to form a complete fixed-dimension condition vector.
[0097] The structure of the generator network is designed, which mainly consists of attention mechanism modules and deconvolution layers. The attention mechanism module is used to dynamically allocate the weight of each technical parameter in the code snippet, which can automatically adjust the attention degree to different parameters according to the input condition vector. The deconvolution layer is used for step-by-step upsampling to generate intermediate code representation, which converts low-dimensional feature information into high-dimensional code representation. The number and parameters of the attention mechanism module and the deconvolution layer are determined. The number of attention mechanism modules can be adjusted according to the complexity of the condition vector and the difficulty of code generation, and the number and kernel size of the deconvolution layer determine the degree of upsampling and the resolution of the intermediate code representation.
[0098] The encoded condition vector is input into the generator network. First, the condition vector is processed by the attention mechanism module, which calculates a weight for each technical parameter based on the information in the condition vector. For example, if the parameter of the lighting model in the current condition vector is important, the attention mechanism will allocate a higher weight to the code snippet related to the lighting model.
[0099] The feature information after attention mechanism processing enters the deconvolution layer. The deconvolution layer converts low-dimensional feature information into high-dimensional intermediate code representation through step-by-step upsampling. In each deconvolution operation, the size of the feature map gradually increases, and the feature information is further enriched and refined. Finally, the generator network outputs an intermediate code representation, which contains the basic structure and part of the key information of the Shader code.
[0100] The structure of the discriminator network is designed, which needs to perform the compilability verification and the rendering effect matching degree evaluation in parallel. The discriminator network can be composed of multiple convolutional layers and fully connected layers, the convolutional layers are used to extract features of the intermediate code representation, and the fully connected layers are used for classification and scoring. The input and output of the discriminator network are determined. The input is the intermediate code representation output by the generator network, and the output is the comprehensive confidence score. The comprehensive confidence score considers both the compilability and the rendering effect matching degree.
[0101] The discriminator network first performs the compilability verification on the intermediate code representation. It checks whether the syntax structure of the code is correct and whether it meets the specifications of the Shader language. For example, it checks whether the parentheses in the code match, whether the use of keywords is correct, etc. If the code has syntax errors, the discriminator network will reduce its compilability score.
[0102] At the same time, the discriminator network will evaluate the matching degree of the rendering effect generated by the intermediate code representation according to the structured Shader effect description and the initial parameter combination. It compares the differences in lighting, texture, color, etc. between the generated rendering effect and the expected effect. For example, if the expected effect is a rendering with a metallic texture, but the generated rendering effect is more like a plastic texture, then the discriminator network will reduce its rendering effect matching degree score.
[0103] According to the results of the compilability verification and the rendering effect matching degree evaluation, the discriminator network generates a comprehensive confidence score. This score reflects the overall quality of the intermediate code representation, and the higher the score, the closer the code is to the expected Shader effect.
[0104] When the comprehensive confidence score is lower than the preset score threshold, the gradient backpropagation mechanism is used to adjust the weights of the generator network and the discriminator network simultaneously. Gradient backpropagation is an optimization algorithm used to train neural networks, which calculates the gradient of the loss function with respect to the network weights, and then updates the weights in the opposite direction of the gradient to minimize the loss function.
[0105] The definition of the loss function is determined. The loss function can consider the errors of the compilability verification and the rendering effect matching degree evaluation. For example, the errors of the compilability verification and the rendering effect matching degree evaluation are weighted and summed to obtain the total loss function value.
[0106] According to the gradient backpropagation mechanism, the gradient of the loss function with respect to the weights of the generator network and the discriminator network is calculated. Then, using an optimization algorithm such as the stochastic gradient descent algorithm, the network weights are updated according to the calculated gradient. In the process of updating the weights, a suitable learning rate can be set to control the step size of the weight update. Repeat the process of generating code by the generator network, evaluating by the discriminator network, and adjusting the weights until the comprehensive confidence score reaches or exceeds the preset score threshold.
[0107] The intermediate code representation that meets the confidence requirement is subjected to syntax normalization processing. Check if the indentation, spaces, comments, etc. in the code conform to the specifications of the Shader language. For example, unify the indentation format of the code, add necessary comments to improve the readability of the code.
[0108] Normalize the naming of variables, function names, etc. in the code to avoid using non-standard or easily confusing names. For example, use meaningful English word combinations as variable names and function names.
[0109] According to the characteristics of the target platform, add adaptation instructions to the code after syntax normalization processing. Different target platforms (such as different graphics card models, operating systems, etc.) may have different requirements and restrictions on Shader code. For example, some platforms may require specific instructions to enable certain functions, or have different specifications for the value range of certain parameters. After adding adaptation instructions, the initial Shader code that can be executed is generated.
[0110] In some embodiments, in step S104, the CRDT conflict resolution algorithm is used to support multiple users editing the same initial Shader code in real time, which specifically includes: Real-time monitoring of editing operations on the same Shader code by multiple users, and encoding the editing operations into operation instruction units containing position identifiers, operation types and content increments; Based on the syntax structure of the initial Shader code, add semantic block boundary markers to function declarations, variable definitions and flow control statements; According to the semantic block boundary markers, convert the operation instruction units into causally ordered operation sequences based on logical timestamps; When multiple causally ordered operation sequences act on the same semantic block, detect parameter modification conflicts, control flow conflicts and resource dependency conflicts, and obtain detection results; Based on the detection results, process parameter modification conflicts through operation conversion algorithms, process control flow conflicts through control flow graph analysis, and process resource dependency conflicts through dependency relationship topological sorting, to obtain operation sequences after conflict resolution; Merge the operation sequences after conflict resolution to generate version-consistent code and broadcast it to all user terminals.
[0111] In this embodiment, a real-time communication framework is built in a system that supports multi-user real-time editing of Shader code. Protocols such as WebSocket can be used to establish a long connection between the server and each user terminal. The server continuously monitors the connection status and data transmission from different user terminals. When a user performs editing operations on the Shader code, such as inserting, deleting, or modifying code content, the terminal device captures these operation events. By adding event listeners in the editor component, the user's keyboard input, mouse clicks, and other operation behaviors can be sensed in real time.
[0112] For each captured editing operation, it is encoded into an operation instruction unit containing a position identifier, an operation type, and a content delta.
[0113] The position identifier is used to determine the specific location of the operation in the Shader code. It can be achieved by recording the line number and column number where the operation is located. For example, if a user inserts a piece of content at the 10th character of the 5th line of the code, the position identifier is recorded as (5, 10).
[0114] The operation type is used to determine the type of operation, such as INSERT, DELETE, MODIFY, etc. Different types of operations will have different processing methods in the subsequent processing process.
[0115] The content delta is used to record the specific content changes involved in the operation. For the INSERT operation, the content delta is the inserted code fragment; for the DELETE operation, the content delta is the deleted code fragment; for the MODIFY operation, the content delta includes the code fragment before modification and the modified code fragment.
[0116] Based on the syntax structure of the initial Shader code, use syntax analysis tools or custom syntax analysis rules to parse the code. Understand the structure and characteristics of common syntax elements in Shader code, such as function declarations, variable definitions, and flow control statements (such as if statements, for loops, while loops, etc.). According to the results of syntax analysis, add semantic block boundary markers at the start and end positions of function declarations, variable definitions, and flow control statements. Boundary markers can use specific symbols or comment forms.
[0117] Assign a logical timestamp to each operation instruction unit. Logical timestamps can be generated using Vector Clock or Lamport Timestamp. Vector Clock can record the operation progress of each user terminal, and the order of operations can be determined by comparing the size of the vector clock.
[0118] According to the semantic block boundary markers and logical timestamps, the operation instruction units are converted into causally ordered operation sequences based on logical timestamps. First, the operation instruction units are classified according to semantic blocks, and operations acting on the same semantic block are grouped together. Then, within each semantic block, the operation instruction units are sorted according to their logical timestamps. Operations with smaller logical timestamps are placed in front, and operations with larger logical timestamps are placed in back. In this way, a causally ordered operation sequence is obtained, ensuring that the execution order of operations conforms to their causal relationship.
[0119] When multiple causally ordered operation sequences act on the same semantic block, detect possible conflict types, including parameter modification conflicts, control flow conflicts, and resource dependency conflicts.
[0120] Parameter modification conflicts occur when multiple users simultaneously modify the same variable or parameter, resulting in inconsistent values. For example, user A modifies the value of variable x to 10, while user B simultaneously modifies the value of variable x to 20.
[0121] Control flow conflicts occur when multiple users modify flow control statements, causing changes in the execution flow of the code. For example, user A adds a condition to the condition expression of an if statement, while user B simultaneously modifies the code block content of the if statement, which may affect the execution logic of the code.
[0122] Resource dependency conflicts occur when multiple users modify dependent resources (such as textures, shader functions, etc.) in the code, causing conflicts in the use of resources. For example, user A modifies the reference path of a texture, while user B simultaneously deletes the texture, which may cause the code to fail to load the texture correctly at runtime.
[0123] By traversing the causally ordered operation sequences, each operation in the semantic block is compared and analyzed one by one to determine whether there are conflicts of the above types. If there is a conflict, record the type of conflict, the involved parameters or code location, etc. to obtain the detection result.
[0124] Based on the detection result, handle parameter modification conflicts through operation conversion algorithms. Operation conversion algorithms can adjust and convert conflicting operations according to their causal relationship and logical timestamps. Handle control flow conflicts through control flow graph analysis. Control flow graphs can represent the execution flow of the code, and by analyzing the control flow graph, the influence of different operations on the execution flow of the code can be determined.
[0125] Resource dependency conflicts are handled through dependency relationship topological sorting. First, a dependency relationship graph of resources in the code is constructed to determine the dependency relationship between each resource. Then, the dependency relationship graph is topologically sorted to determine the loading and usage order of resources. When a resource dependency conflict occurs, the execution order of operations is adjusted according to the results of topological sorting to ensure that resources can be loaded and used in the correct order.
[0126] The operation sequence after conflict resolution is merged to generate version-consistent code. According to the order of the causal and ordered operation sequence, each operation is applied to the initial Shader code in turn. During the merging process, pay attention to the boundaries and mutual influence of operations to ensure that the merged code is grammatically correct and logically clear. For example, when inserting an operation, make sure that the insertion position is correct and will not damage the structure of the code; when deleting an operation, make sure that the deleted content will not affect the normal execution of other code.
[0127] The generated version-consistent code is broadcast to all user terminals. Through the real-time communication framework, the merged code is sent to each connected user terminal. After receiving the code, the user terminal updates the local Shader code to ensure that all users see the same version of the code. At the same time, continue to listen to the user's editing operation and repeat the above process to continuously support multiple users editing the same initial Shader code in real time.
[0128] In this embodiment, the CRDT conflict resolution algorithm can be used to support multiple users editing the same initial Shader code in real time, effectively solving the conflict problem that may occur during concurrent editing by multiple users, and ensuring the version consistency and real-time editing of the code.
[0129] In some embodiments, in step S104, the performance of the edited initial Shader code is optimized based on a genetic algorithm to generate an optimized Shader code, which specifically includes: Based on the initial Shader code after collaborative editing, it is compiled into a platform-independent intermediate representation instruction sequence; For the intermediate representation instruction sequence, encode every three related instructions as a gene segment, and add a performance tuning flag bit to form a chromosome to generate a chromosome population; For each individual in the chromosome population, calculate its rendering performance score and visual effect fidelity score through a multi-objective evaluation function to generate a comprehensive fitness; According to the ranking of the comprehensive fitness, perform selection, crossover and mutation operations on the chromosomes to generate a child population. When the highest fitness change rate of the population is less than a preset change rate threshold for three consecutive generations, decode the optimal chromosome to generate an optimized intermediate representation instruction sequence; The optimized intermediate representation instruction sequence is decompiled into optimized Shader code for the target platform, while retaining the semantic annotations of the original code.
[0130] In this embodiment, the initial Shader code after collaborative editing is input into the compilation environment. The compiler performs lexical analysis, syntax analysis, and semantic analysis on the code, checking for syntax errors and semantic errors. If the code has errors, the compiler outputs error information, prompting the user to make modifications. After the code passes the compilation check, the compiler converts it into a platform-independent intermediate representation instruction sequence. The intermediate representation instruction sequence typically consists of a series of instructions, each with a specific opcode and operand, representing the logic and computation process of the code. For example, an instruction may represent an addition operation on the values in two registers and store the result in another register.
[0131] The structure and characteristics of the intermediate representation instruction sequence are analyzed to determine that every three related instructions form a gene fragment. Related instructions are instructions that have logical connections in the code execution process, such as an instruction for loading data, followed by two instructions for processing that data.
[0132] Each gene fragment is encoded. The encoding method can use binary encoding or other suitable encoding methods. For example, the opcode and operand of each instruction are converted to binary form, and then the binary encodings of the three instructions are spliced together to form the encoding of a gene fragment.
[0133] A performance tuning flag is added to each gene fragment. The performance tuning flag indicates whether the gene fragment can be optimized for performance and the direction of optimization. For example, the flag can be set to "optimizable - reduce computational complexity" or "optimizable - improve parallelism."
[0134] Multiple gene fragments are combined in a certain order and necessary connection information is added to form a chromosome. A chromosome represents a possible Shader code optimization scheme. Repeat the above process to generate a certain number of chromosomes to form a chromosome population. The size of the population can be set according to the complexity of the problem and the computing resources, for example, set to 100 chromosomes.
[0135] A multi-objective evaluation function is designed to calculate the rendering performance score and visual effect fidelity score of each chromosome.
[0136] The rendering time, frame rate, and other performance indicators of the Shader code on the target platform are measured through simulation or actual running. Compare the performance indicators with the preset performance targets to calculate the rendering performance score. For example, the shorter the rendering time and the higher the frame rate, the higher the rendering performance score.
[0137] The rendering results generated by the optimized Shader code are compared with the rendering results generated by the original Shader code. The similarity in color, texture, lighting, etc. of the two can be evaluated manually or automatically. The visual effect fidelity score is calculated according to the similarity. For example, the higher the visual effect fidelity score is, the closer the rendering results are to the original results.
[0138] According to the rendering performance score and the visual effect fidelity score, the comprehensive fitness of each chromosome is generated by weighted summation or other comprehensive methods. The weights can be adjusted according to actual needs, for example, if more attention is paid to rendering performance, a higher weight can be assigned to the rendering performance score.
[0139] According to the ranking of the comprehensive fitness, excellent individuals are selected from the chromosome population as parents by roulette selection, tournament selection, etc. The higher the fitness of an individual is, the greater the probability of being selected is. The selected parent individuals are subjected to crossover operation to generate offspring individuals. The crossover operation can be single-point crossover, multi-point crossover, etc. The offspring individuals are subjected to mutation operation to increase the diversity of the population. The mutation operation can be gene segment replacement, gene segment insertion, etc. The highest fitness of each generation population is recorded, and the change rate of the highest fitness of the population of three consecutive generations is calculated. When the change rate of the highest fitness of the population of three consecutive generations is less than a preset change rate threshold, it is considered that the optimization process has converged, and the genetic operation is stopped.
[0140] The chromosome with the highest fitness is selected from the population after stopping the genetic operation as the optimal chromosome. The optimal chromosome is decoded to restore the gene segments coded by it to the intermediate representation instruction sequence. During decoding, the instruction sequence is optimized and adjusted according to the performance tuning flag bit, for example, the computational complexity of some instructions is reduced or the parallelism is improved. The optimized intermediate representation instruction sequence is decompiled into the optimized Shader code of the target platform. The decompilation process can use operations opposite to the compilation process to convert the intermediate representation instruction sequence into Shader code executable on the target platform. During the decompilation process, the semantic annotations of the original code are preserved. Semantic annotations can help developers understand the functions and logic of the code, facilitating subsequent maintenance and modification.
[0141] In this embodiment, the edited initial Shader code can be optimized based on the genetic algorithm to generate optimized Shader code, which improves the rendering performance while trying to maintain the fidelity of the visual effect, meeting the needs of different application scenarios.
[0142] In some embodiments, in step S105, based on the optimized Shader code, a high-resolution preview image is generated using Stable Diffusion, and NeRF technology is used to analyze 3D scene data to automatically generate ambient light shading effects, specifically including: Based on the optimized Shader code, a high-resolution static preview image is generated through the latent diffusion process of the Stable Diffusion model. The static preview image is input into a time series prediction module to generate multiple frames of continuous animation and extract key motion trajectories to form an initial Shader dynamic effect animation. Obtain user input 3D scene data, reconstruct three-dimensional geometric structure through neural radiation field, and automatically label light sensitive area; Based on the reconstructed three-dimensional geometric structure, perform ray tracing sampling to calculate the ambient light shading intensity map in the light sensitive area. Pixel-level fusion of ambient light shading intensity map and initial Shader dynamic effect animation to generate target Shader dynamic effect animation.
[0143] In this embodiment, the Stable Diffusion model running environment is built, and the required deep learning framework (such as PyTorch) and related dependent libraries are installed. Load the pre-trained Stable Diffusion model weights, which contain the features and patterns learned by the model from a large amount of image data.
[0144] The optimized Shader code is used as input condition, which is converted into semantic information that the Stable Diffusion model can understand through a specific interface or coding method. For example, the key parameters (such as color, texture, lighting settings, etc.) in the Shader code can be extracted as prompt information for the model.
[0145] Start the latent diffusion process of the Stable Diffusion model. This process starts with random noise and gradually generates a high-resolution static preview image that matches the input condition through a series of iterative steps. During the iteration process, the model adjusts the direction of image generation according to the semantic information of the input optimized Shader code, so that the generated preview image can reflect the visual effect expected by the Shader code.
[0146] Design and implement a time series prediction module that can adopt model structures suitable for processing time series data, such as Recurrent Neural Networks (RNN), Long Short-Term Memory Networks (LSTM), or Gated Recurrent Units (GRU). Collect a large amount of static image sequence data related to optimizing Shader code for training the time series prediction module. These data can be manually created or obtained from existing resources, and the image sequence should have certain continuity and variability in visual effects. Use the collected data to train the time series prediction module, adjust the model's parameters, and make it learn the temporal dependence and variation rules between image sequences. During training, use appropriate loss functions (such as mean square error loss) to measure the prediction accuracy of the model, and update the model parameters through the backpropagation algorithm. Input the generated static preview image into the trained time series prediction module. The module will predict and generate multiple frames of continuous animation based on the input static image and previously learned knowledge. Each frame of animation is predicted based on the information of the previous frames and the current input static image. Analyze the generated multiple frames of continuous animation and extract key motion trajectories. Motion estimation algorithms such as optical flow can be used to calculate the motion vector of pixels between adjacent frames. By analyzing the distribution and changes of motion vectors, determine the key motion trajectories in the animation, such as the moving path of objects and the rotation angle. These key motion trajectories will be used to form the basic framework of the initial Shader dynamic effect animation.
[0147] Design a user interaction interface to facilitate user input of 3D scene data. Users can import 3D scene data into the system by uploading 3D model files (such as.obj,.fbx, etc.) or using 3D scanning devices to obtain scene data in real time. Preprocess the user input 3D scene data, including data format conversion, coordinate system unification, noise removal, and redundant data removal operations. Ensure the quality and consistency of the 3D scene data to facilitate the subsequent NeRF reconstruction process.
[0148] Set up the environment for the NeRF model, load the pre-trained NeRF model or use the open-source NeRF implementation library. NeRF model learns the color and density information in the 3D scene, and can reconstruct high-quality three-dimensional geometric structure. The preprocessed 3D scene data is input into the NeRF model, and the training process of the model is started. During the training process, the model will adjust its parameters according to the input scene data to minimize the difference between the rendered image and the real scene image. After a certain number of iterations of training, the NeRF model can reconstruct the accurate three-dimensional geometric structure. At the same time of reconstructing the three-dimensional geometric structure, the light-sensitive area is automatically labeled using the NeRF model. The light-sensitive area refers to the area in the scene where the change of light has a greater impact on the visual effect, such as the edge of the object, the highlight area, etc. The location and range of the light-sensitive area can be determined by analyzing the color and density information output by the NeRF model, combined with the light model, and labeled.
[0149] Based on the reconstructed three-dimensional geometric structure, construct the scene data structure required for ray tracing sampling. This data structure should be able to efficiently store and query geometric information in the scene, such as the position, shape, and material of objects. Determine the parameters of ray tracing, such as the starting point, direction, and sampling density of the ray. The starting point of the ray can be set to the camera position or a specific point in the scene as needed, and the direction of the ray is determined according to the location of the light-sensitive area and the direction of the light. The higher the sampling density, the more accurate the ambient occlusion intensity map calculated, but the larger the amount of calculation.
[0150] Perform ray tracing sampling calculation in the light-sensitive area. For each point in the light-sensitive area, emit multiple rays and trace along different directions. During the ray tracing process, record the intersection information of the ray with the objects in the scene, including the position, distance, etc. According to the results of ray tracing, calculate the ambient occlusion intensity. Ambient occlusion intensity reflects the degree of occlusion of the object surface by surrounding objects, and the more serious the occlusion, the higher the ambient occlusion intensity. By statistically analyzing the results of all ray tracing, an ambient occlusion intensity map is generated. Each pixel value in the ambient occlusion intensity map represents the ambient occlusion intensity at the corresponding position.
[0151] Preprocess the ambient occlusion intensity map and the initial Shader dynamic effect animation to ensure that their size, resolution, and format are consistent. Determine the strategy and parameters of pixel-level fusion. The fusion strategy can use weighted fusion, multiplication fusion, etc., and the appropriate strategy can be selected according to actual needs. The fusion parameters are used to control the contribution proportion of the ambient occlusion intensity map and the initial Shader dynamic effect animation in the fusion process.
[0152] According to the determined fusion strategy and parameters, the ambient light shielding intensity map and the initial Shader dynamic effect animation are fused at the pixel level. For each frame of animation image, it is fused with the ambient light shielding intensity map at the corresponding position to obtain the fused pixel value. All the fused frame images are combined to generate the target Shader dynamic effect animation. The target Shader dynamic effect animation not only contains the motion information in the initial Shader dynamic effect animation, but also integrates the ambient light shielding effect, so that the visual effect of the animation is more realistic and lifelike.
[0153] With reference to Figure 2 An embodiment of the present application provides an AI-driven Shader effect editing system 2, which specifically comprises: A feature extraction module 201 is configured to receive a reference image, a GIF animation and a text description uploaded by a user, extract visual features through an image recognition component, and generate a structured Shader effect description through a text description component; A parameter recommendation module 202 is configured to search for a Shader template similar in style in a Shader template library based on the visual features, and generate an initial parameter combination in combination with a reinforcement learning model; A code generation module 203 is configured to input the structured Shader effect description and the initial parameter combination into a Shader generation component, and generate initial Shader code by using a conditional GAN architecture; A code optimization module 204 is configured to support real-time editing of the same initial Shader code by multiple users through a CRDT conflict resolution algorithm, and perform performance optimization on the edited initial Shader code based on a genetic algorithm to generate optimized Shader code; An effect preview module 205 is configured to generate a high-resolution preview image by using Stable Diffusion based on the optimized Shader code, and automatically generate an ambient light shielding effect by integrating NeRF technology to analyze 3D scene data.
[0154] It can be understood that the contents in the AI-driven Shader effect editing method embodiment as Figure 1 shown are all applicable to the AI-driven Shader effect editing system embodiment, the AI-driven Shader effect editing system embodiment specifically realizes the same functions as the AI-driven Shader effect editing method embodiment as Figure 1 shown, and achieves the same beneficial effects as the AI-driven Shader effect editing method embodiment as Figure 1 shown.
[0155] It should be noted that the information interaction between the above systems, the execution process and the like, since based on the same concept as the method embodiments of the present application, the specific functions and the technical effects brought about, can be specifically referred to the method embodiments part, and will not be repeated here.
[0156] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the system is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the system can refer to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0157] With reference to Figure 3 The embodiment of the present application also provides a computer device 3, comprising a memory 302 and a processor 301 and a computer program 303 stored in the memory 302, when the computer program 303 is executed on the processor 301, the AI-driven Shader effect editing method as described in any one of the above methods is realized.
[0158] The computer device 3 can be a desktop computer, a notebook computer, a palm computer, a cloud server and the like. The computer device 3 can include, but is not limited to, a processor 301, a memory 302. Those skilled in the art can understand that, Figure 3 The computer device 3 is only an example and does not constitute a limitation on the computer device 3, and can include more or fewer components than shown, or combine certain components, or different components, for example, it can also include input / output devices, network access devices, etc.
[0159] The processor 301 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0160] The memory 302 can be an internal storage unit of the computer device 3 in some embodiments, for example, a hard disk or a memory of the computer device 3. The memory 302 can also be an external storage device of the computer device 3 in other embodiments, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 302 can include both an internal storage unit and an external storage device of the computer device 3. The memory 302 is used to store an operating system, an application program, a boot loader, data, and other programs, for example, program codes of the computer program, etc. The memory 302 can also be used to temporarily store data that has been output or is to be output.
[0161] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the AI-driven Shader effect editing method is implemented.
[0162] In this embodiment, the integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the computer program for instructing the relevant hardware to complete all or part of the processes in the above-described embodiment methods can be stored in a computer readable storage medium. The computer program can be executed by a processor to implement the steps of the above-mentioned various method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the photographing device / terminal equipment, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium can not be an electrical carrier signal and a telecommunication signal.
[0163] In the above embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0164] Those of ordinary skill in the art can understand that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0165] In the embodiments disclosed in the present application, it should be understood that the disclosed apparatus / terminal equipment and methods can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0166] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may also be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
Claims
1. An AI-driven Shader effect editing method, characterized in that, The method specifically comprises: Receiving user-uploaded reference images, GIF animations, and text descriptions, extracting visual features through an image recognition component, and generating a structured Shader effect description through a text description component; Based on the visual features, retrieving Shader templates with similar styles from the Shader template library, and generating an initial parameter combination in combination with a reinforcement learning model; Inputting the structured Shader effect description and the initial parameter combination into a Shader generation component, and generating an initial Shader code using a conditional GAN architecture; Supporting multiple users to edit the same initial Shader code in real time through a CRDT conflict resolution algorithm, and performing performance optimization on the edited initial Shader code based on a genetic algorithm to generate an optimized Shader code; Based on the optimized Shader code, generating a high-resolution preview image using Stable Diffusion, and integrating NeRF technology to analyze 3D scene data and automatically generate ambient light shading effects.
2. The method of claim 1, wherein, The receiving user-uploaded reference images, GIF animations, and text descriptions, extracting visual features through an image recognition component, and generating a structured Shader effect description specifically comprises: Obtaining user-inputted reference images, GIF animations, and text descriptions; For reference images or GIF animations, extracting their texture features, color distribution features, and dynamic motion features through a convolutional neural network; For text descriptions, converting them into key-value pair structured data containing lighting types, texture attributes, and physical parameters through a pre-trained language model; Based on the key-value pair structured data, mapping texture features to normal map parameters, color distribution features to gradient functions, and dynamic motion features to particle motion equations to generate a unified Shader effect description matrix; For undefined parameters in the Shader effect description matrix, automatically filling in default parameter values by querying a historical effect database to match similar cases.
3. The method of claim 1, wherein, The based on visual features, retrieving Shader templates with similar styles from the Shader template library, and generating an initial parameter combination in combination with a reinforcement learning model specifically comprises: Based on the visual features, compressing feature dimensions through principal component analysis to generate low-dimensional feature vectors; Performing cosine similarity calculation on the low-dimensional feature vectors and template features in the Shader template library to filter candidate templates with similarity greater than a preset threshold; When the number of candidate templates is greater than 1, inputting historical usage data of the candidate templates into a reinforcement learning strategy network to output an optimal template and an initial parameter combination; For the initial parameter combination, sampling neighborhood values in the parameter space through a Monte Carlo tree search algorithm to generate a robust parameter set resistant to interference.
4. The method of claim 1, wherein, The inputting the structured Shader effect description and the initial parameter combination into a Shader generation component, and generating an initial Shader code using a conditional GAN architecture specifically comprises: Based on the structured Shader effect description and the initial parameter combination, encoding lighting models, texture attributes, and physical parameters into fixed-dimensional conditional vectors; The condition vector is input into the generator network, which dynamically allocates the weights of each technical parameter in the code segment using an attention mechanism, and generates an intermediate code representation through a deconvolution layer step by step. The discriminator network performs compile-time verification and rendering effect matching degree evaluation in parallel for the intermediate code representation generated by the generator, and generates a comprehensive confidence score. When the comprehensive confidence score is lower than the preset score threshold, the weights of the generator network and the discriminator network are adjusted simultaneously through the gradient backpropagation mechanism. For the intermediate code representation that meets the confidence requirement, perform syntax normalization processing and add target platform adaptation instructions to output executable initial Shader code.
5. The method of claim 1, wherein, The CRDT conflict resolution algorithm supports multiple users to edit the same initial Shader code in real time, specifically including: Real-time monitoring of editing operations on the same Shader code by multiple users, and encoding the editing operations into operation instruction units containing position identifiers, operation types, and content increments; Based on the syntax structure of the initial Shader code, add semantic block boundary markers to function declarations, variable definitions, and flow control statements; According to the semantic block boundary markers, convert the operation instruction units into causally ordered operation sequences based on logical timestamps; When multiple causally ordered operation sequences act on the same semantic block, detect parameter modification conflicts, control flow conflicts, and resource dependency conflicts to obtain detection results; Based on the detection results, handle parameter modification conflicts through operation conversion algorithms, control flow conflicts through control flow graph analysis, and resource dependency conflicts through dependency relationship topological sorting to obtain conflict-resolved operation sequences; Merge the conflict-resolved operation sequences to generate version-consistent code and broadcast it to all user terminals.
6. The method of claim 5, wherein, The genetic algorithm is used to optimize the edited initial Shader code to generate optimized Shader code, specifically including: Based on the collaborative edited initial Shader code, compile it into a platform-independent intermediate representation instruction sequence; For the intermediate representation instruction sequence, encode every three related instructions as a gene fragment, add performance tuning marker bits to form a chromosome, and generate a chromosome population; For each individual in the chromosome population, calculate its rendering performance score and visual effect fidelity score through a multi-objective evaluation function to generate a comprehensive fitness; According to the ranking of the comprehensive fitness, perform selection, crossover, and mutation operations on the chromosomes to generate a child population. When the highest fitness change rate of the population is less than the preset change rate threshold for three consecutive generations, decode the optimal chromosome to generate the optimized intermediate representation instruction sequence. The optimized intermediate representation instruction sequence is decompiled into the target platform's optimized Shader code, while preserving the semantic annotations of the original code.
7. The method according to any one of claims 1 to 6, characterized in that, Based on the optimized Shader code, use Stable Diffusion to generate high-resolution preview images, and integrate NeRF technology to analyze 3D scene data and automatically generate ambient light shading effects, specifically including: Based on the optimized Shader code, generate high-resolution static preview images through the latent diffusion process of the Stable Diffusion model. The static preview image is input into a time series prediction module to generate a multi-frame continuous animation and extract a key motion trajectory, forming an initial Shader dynamic effect animation; 3D scene data input by a user is acquired, a three-dimensional geometric structure is reconstructed through a neural radiance field, and a light-sensitive area is automatically labeled; Based on the reconstructed three-dimensional geometric structure, ray tracing sampling is performed on the light-sensitive area to calculate an ambient light shading intensity map; The ambient light shading intensity map and the initial Shader dynamic effect animation are fused at a pixel level to generate a target Shader dynamic effect animation.
8. An AI-driven Shader effect editing system, characterized in that, The system specifically includes: A feature extraction module configured to receive a reference image, a GIF animation, and a text description uploaded by a user, extract visual features through an image recognition component, and generate a structured Shader effect description through a text description component; A parameter recommendation module configured to search for a Shader template with a similar style in a Shader template library based on the visual features, and generate an initial parameter combination in combination with a reinforcement learning model; A code generation module configured to input the structured Shader effect description and the initial parameter combination into a Shader generation component, and generate initial Shader code using a conditional GAN architecture; A code optimization module configured to support real-time editing of the same initial Shader code by multiple users through a CRDT conflict resolution algorithm, and perform performance optimization on the edited initial Shader code based on a genetic algorithm to generate optimized Shader code; An effect preview module configured to generate a high-resolution preview image using Stable Diffusion based on the optimized Shader code, and automatically generate an ambient light shading effect by integrating NeRF technology to analyze 3D scene data.
9. A computer device, comprising: A memory and a processor, and a computer program stored in the memory, when the computer program is executed on the processor, the AI-driven Shader effect editing method as claimed in any one of claims 1 to 7 is implemented. A computer program is stored thereon, when the computer program is run by a processor, the AI-driven Shader effect editing method as claimed in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that,