Rendering method and apparatus, and electronic device and storage medium

By establishing a mapping relationship between target shader and non-target shader attribute names, the problem of mismatch between user-defined materials and official Shaders is solved, rendering adaptation and effect consistency of material objects are achieved, and rendering errors are avoided.

WO2024188255A1PCT designated stage expired Publication Date: 2024-09-19BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/081327
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-13
Filing Date
2024-03-13
Publication Date
2024-09-19

AI Technical Summary

Technical Problem

After uploading, the user-defined materials may not meet the official Shader requirements of the application, resulting in rendering errors or failure to obtain the expected rendering effect. There is no effective solution in the existing technology.

Method used

By pre-establishing the attribute name mapping relationship between the target shader and the non-target shader, in response to the conversion operation, it is determined that the attribute name in the shader to be converted matches the target attribute name, and its value is assigned to the target attribute name, and regenerated Material objects for rendering.

Benefits of technology

It avoids rendering errors caused by the incompatibility of the shader to be converted, ensures that the rendering effect of the converted material object is basically the same as the original material object, and improves the adaptability and reliability of user-defined materials.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024081327_19092024_PF_FP_ABST
    Figure CN2024081327_19092024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present disclosure are a rendering method and apparatus, and an electronic device and a storage medium. The method comprises: in response to a conversion operation, obtaining a shader to be converted of a first material object and a target shader, wherein the first material object is generated on the basis of the shader to be converted; and according to a pre-established mapping relationship between a target attribute name in the target shader and a non-target attribute name in a non-target shader, determining a target attribute name, which matches an attribute name to be converted in the shader to be converted, and assigning, to the matching target attribute name, the value of the attribute name to be converted; and according to the target shader after the value is assigned, for the first material object, regenerating and rendering a second material object. In this way, conversion between different types of material objects can be implemented, thereby ensuring a rendering effect.
Need to check novelty before this filing date? Find Prior Art

Description

Rendering method, device, electronic device and storage medium

[0001] This application claims priority to Chinese Patent Application No. 202310260517.3 filed on March 13, 2023, and the contents of the above-mentioned Chinese patent application disclosure are hereby incorporated by reference in their entirety as a part of this application. Technical Field

[0002] The present disclosure relates to a rendering method, device, electronic device and storage medium. Background Art

[0003] Unity is a real-time 3D interactive content creation and development platform that supports users to create materials and user-generated content (UGC). Users can then upload the created materials to the desired application (APP) software or platform for use. However, the shaders (Shaders) of user-defined materials are diverse and may not meet the APP's requirements for official Shaders, resulting in rendering errors or failure to achieve the expected rendering effect after uploading. In some embodiments, there is no relevant solution for this.

[0004] Summary of the Invention

[0005] The embodiments of the present disclosure at least provide a rendering method, device, electronic device, and storage medium.

[0006] The present disclosure provides a rendering method, including:

[0007] In response to a conversion operation, obtaining a to-be-converted shader and a target shader of a first material object, wherein the first material object is generated based on the to-be-converted shader;

[0008] Determining a target attribute name that matches the attribute name to be converted in the shader to be converted based on a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name;

[0009] According to the assigned target shader, the first material object is regenerated and rendered to obtain a second material object.

[0010] In an optional embodiment, the method further includes:

[0011] Obtaining the names of the target attributes included in the target shader;

[0012] Obtaining the name of each non-target attribute included in each non-target shader;

[0013] According to the functions represented by the target attribute names and the non-target attribute names, a mapping relationship between the target attribute names and the non-target attribute names is established.

[0014] In an optional embodiment, determining the target attribute name that matches the attribute name to be converted in the shader to be converted based on a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name, includes:

[0015] Deserialize and parse the first material object to obtain the name of the attribute to be converted included in the shader to be converted;

[0016] Determining a target attribute name that matches the attribute name to be converted based on a pre-established mapping relationship between a target attribute name in the target shader and a non-target attribute name in a non-target shader;

[0017] The shader to be converted is converted into the target shader, and the value of the attribute name to be converted is assigned to the matched target attribute name.

[0018] In an optional embodiment, the method further includes: in a case where the mapping relationship between the attribute name to be converted and the target attribute name is not recorded, determining the target attribute name that matches the attribute name to be converted based on the writing order of the target attribute names in the program file of the target shader and the writing order of the attribute names to be converted in the program file of the shader to be converted.

[0019] In an optional embodiment, determining the target attribute name that matches the attribute name to be converted based on the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted includes:

[0020] Determine the writing order of the target attribute names in the program file of the target shader, and the writing order of the to-be-converted attribute names in the program file of the to-be-converted shader;

[0021] Match the attribute names to be converted to the target attribute names in the same writing order.

[0022] In an optional embodiment, the method further includes:

[0023] For the shader to be converted of the currently displayed first material object, in response to a shader configuration operation, displaying a shader configuration interface, wherein the shader to be converted and a shader conversion function are displayed in the shader configuration interface, and the shader conversion function is used to receive the conversion operation;

[0024] The target shader is received by selecting and inputting from each candidate shader provided in the shader configuration interface.

[0025] In an optional embodiment, the method further includes: displaying a message indicating that the material object conversion is successful, and displaying the rendered second material object.

[0026] The present disclosure also provides a rendering device, including:

[0027] an obtaining module, configured to obtain, in response to a conversion operation, a shader to be converted and a target shader of a first material object, wherein the first material object is generated based on the shader to be converted;

[0028] a conversion module, configured to determine a target attribute name that matches the attribute name to be converted in the shader to be converted based on a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assign the value of the attribute name to be converted to the matched target attribute name;

[0029] A rendering module is used to regenerate and render the first material object according to the assigned target shader to obtain a second material object.

[0030] An optional implementation of the present disclosure further provides an electronic device, including a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the steps of the above embodiment or any possible implementation of the above embodiment.

[0031] An optional implementation of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the above embodiment or any possible implementation of the above embodiment are implemented.

[0032] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure.

[0033] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.

[0035] FIG1 shows a flowchart of a rendering method provided by an embodiment of the present disclosure;

[0036] FIG2 shows a schematic diagram of the rendering effect of the first material object in an embodiment of the present disclosure;

[0037] FIG3 shows a schematic diagram of a shader configuration interface in an embodiment of the present disclosure;

[0038] FIG4 shows a schematic diagram of the rendering effect of the second material object in an embodiment of the present disclosure;

[0039] FIG5 shows a schematic diagram of a rendering device provided by an embodiment of the present disclosure;

[0040] FIG6 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0041] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0042] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present disclosure.

[0043] To facilitate understanding of the technical solution of the present disclosure, the technical terms used in the embodiments of the present disclosure are first explained:

[0044] Shader: A relatively short program fragment running on a graphics processing unit (GPU) that processes image information and tells the graphics software how to calculate and output images. Shaders can be divided into vertex shaders and fragment shaders.

[0045] Texture: Texture can be understood as an attribute parameter in Shader. Shader is responsible for combining the input vertex data with the input texture or color in a specified way, and then outputting it. The drawing unit can then draw the image to the screen based on this output.

[0046] Material: The input texture or color, plus the corresponding shader and the shader's specific parameter settings, are packaged and stored together to form a material. Of course, the packaged package will also include other parameters. The material can then be assigned to the 3D model for rendering and output. For ease of understanding, you can think of the material as the final product used by the engine, the shader as the processing method to produce this product, and the texture as the raw material of this product.

[0047] Research has found that the types of shaders commonly used by users when creating custom materials are diverse, and may not meet the official shader requirements of the desired application (APP) software or platform. Therefore, when the user-created materials are uploaded to the APP server and then loaded into the APP terminal, rendering errors may occur or the expected rendering effect may not be achieved. There is no relevant solution to this problem in the relevant technology.

[0048] Based on the above research, the present disclosure provides a rendering method, which pre-establishes a mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and thus can realize a one-click conversion function of different types of material objects based on this. Specifically, in response to the conversion operation, the shader to be converted and the target shader of the first material object are obtained, and according to the mapping relationship, the target attribute name that matches the attribute name to be converted in the shader to be converted is determined, and the value of the attribute name to be converted is assigned to the matched target attribute name, and then according to the assigned target shader, the first material object is regenerated and rendered to obtain the second material object. In this way, by pre-establishing a mapping relationship between other non-target attribute names and target attribute names, the shader to be converted can be associated with the target shader, so that the target shader can be used, and based on the value of the attribute name to be converted, the material object is regenerated and rendered, avoiding the problem of rendering errors of the first material object caused by the incompatibility of the shader to be converted, and the conversion assignment can ensure that the rendering effect of the converted second material object is basically similar to the original rendering effect of the first material object.

[0049] The defects in the above solutions are the results obtained by the inventors after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by this disclosure for the above problems below should be the contributions made by the inventors to this disclosure during the disclosure process.

[0050] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.

[0051] To facilitate understanding of this embodiment, a rendering method disclosed in an embodiment of the present disclosure is first described in detail. The rendering method provided in the embodiment of the present disclosure is generally executed by an electronic device with certain computing capabilities, such as a terminal device, a server, or other processing device. The terminal device may be a user equipment (UE), a mobile device, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, an in-vehicle device, a wearable device, etc. A personal digital assistant is a handheld electronic device that has some of the functions of an electronic computer and can be used to manage personal information, browse the Internet, send and receive emails, etc. It is generally not equipped with a keyboard and can also be called a handheld computer. In some possible implementations, the rendering method can be implemented by a processor calling computer-readable instructions stored in a memory.

[0052] The rendering method provided by the embodiment of the present disclosure is described below by taking the execution subject as a terminal device as an example.

[0053] 1 is a flowchart of a rendering method according to an embodiment of the present disclosure, the method comprising:

[0054] S101: In response to a conversion operation, obtaining a to-be-converted shader and a target shader of a first material object, wherein the first material object is generated based on the to-be-converted shader.

[0055] The rendering method in the disclosed embodiment can be applied to scenes such as 3D applications or 3D games. Users can create 3D resources on the Unity platform or other UGC platforms. The created 3D resources can be uploaded to the software server or platform of the required application for sale or use. The process of creating 3D resources can be simply understood as using shaders (Shaders) and some textures, parameter settings, etc. to process and generate material objects, and assigning the material objects to the three-dimensional model for rendering output. In the application process, such as game scenes, when running the game, the interface will be called, and the material objects will be rendered and displayed on the screen through the GPU. During the GPU processing operation, Shaders will be used for calculations, and finally pixel information that can be displayed on the screen will be output, thereby realizing the display of 3D resources such as 3D virtual images, virtual scenes, etc.

[0056] In the embodiments of the present disclosure, the main purpose is to solve the problem that the shader used by the user when making 3D resources is inconsistent with the requirements of the applied software or platform for the official shader, which may result in the shader used by the user not being recognized or being recognized incorrectly when the application software or platform is rendering, resulting in errors in the final rendering. Therefore, a function is provided that can realize one-click conversion of any other shader to the official shader.

[0057] Specifically, in the embodiment of the present disclosure, the user can input a conversion operation for the customized first material object, for example, by clicking a conversion button to input the conversion operation, thereby implementing Shader conversion.

[0058] The first material object is generated based on the shader to be converted. The shader to be converted can be any other unofficial shader used by the user. Regarding the method of determining the shader to be converted and the target shader of the first material object, this disclosure provides a possible implementation method:

[0059] 1) For the shader to be converted of the currently displayed first material object, in response to the shader configuration operation, a shader configuration interface is displayed, wherein the shader to be converted and a shader conversion function are displayed in the shader configuration interface, and the shader conversion function is used to receive the conversion operation.

[0060] For example, the rendering method disclosed in the present invention, that is, the conversion function, is integrated into a certain UGC platform. The user imports the first material object produced into the UGC platform. Through the UGC platform, the shader to be converted used by the first material object can be parsed and obtained. Then, the user can select the shader configuration on the UGC platform, and the shader configuration interface can be displayed, and the conversion-related configuration can be performed in the shader configuration interface.

[0061] 2) Receive a target shader input from the provided candidate shaders in the shader configuration interface.

[0062] In the embodiment of the present disclosure, the user can also be provided with various candidate shaders for selection. The provided candidate shaders can be understood as various official shaders that can be correctly identified and rendered. For example, multiple official shaders under the cartoon type are provided, and the user can select any candidate shader as the target shader according to needs. After selecting the target shader, the user can click the shader conversion function to convert the shader to be converted to the target shader.

[0063] S102: According to the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, the target attribute name that matches the attribute name to be converted in the shader to be converted is determined, and the value of the attribute name to be converted is assigned to the matched target attribute name.

[0064] For step S102, the present disclosure provides possible implementations:

[0065] 1) Deserialize and parse the first material object to obtain the name of the attribute to be converted included in the shader to be converted.

[0066] In the embodiment of the present disclosure, after obtaining the first material object, deserialization parsing can be performed to obtain information such as the shader to be converted used by the first material object and the names of the various attributes to be converted included in the shader to be converted, the values ​​of the various attribute names to be converted, etc.

[0067] 2) According to the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, the target attribute name that matches the attribute name to be converted is determined.

[0068] In the disclosed embodiment, a mapping relationship between other non-target attribute names and target attribute names is pre-established, that is, the non-target attribute names that may be used by any other unofficial Shader, and the target attribute names are the attribute names used by the official target Shader. The definitions of attribute names in any other unofficial Shader are also diverse, and the functions or types implemented may be similar, but the names are not the same. The mapping relationship can be used to establish a match between other non-target attribute names and target attribute names.

[0069] In addition, Shader includes multiple different types of attributes, such as vectors, maps, etc. The required attributes can be defined in Shader. The attribute names to be converted in the embodiment of the present disclosure are mainly for map attributes. Of course, other attributes can also be converted, and this is not limited in the embodiment of the present disclosure.

[0070] 3) Convert the shader to be converted into a target shader, and assign the value of the attribute name to be converted to the matching target attribute name.

[0071] For example, the shader to be converted is the general Lit, the attribute name to be converted is _MainTex, and the target shader is AN_HD under the cartoon type. According to the pre-established mapping relationship, a match is performed to find out that the target attribute name matched by the attribute name to be converted _MainTex is _BaseTex. Then the value of _MainTex, that is, the used map, can be assigned to _BaseTex. In this way, the _BaseTex in the target shader AN_HD can also use the map for rendering.

[0072] Furthermore, the mapping relationship between target attribute names and non-target attribute names pre-established in the embodiment of the present disclosure can basically cover the attribute names that may be used by other mainstream unofficial shaders, and meet the shader conversion requirements. However, due to the diversity of non-target shaders, there may be cases where the mapping relationship is not recorded. In this case, the matching target attribute name cannot be found according to the pre-established mapping relationship. In order to ensure the conversion and rendering effects, the present disclosure also provides a possible implementation method for this: in the case where the mapping relationship between the attribute name to be converted and the target attribute name is not recorded, the target attribute name that matches the attribute name to be converted is determined according to the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted.

[0073] Shader itself is a piece of program code. There is a sequence when writing each attribute or variable in the program code. If the mapping relationship is not recorded, it can be matched by default in sequence. Specifically, determine the writing order of the target attribute names in the program file of the target shader, and the writing order of the attribute names to be converted in the program file of the shader to be converted; match the attribute names to be converted to the target attribute names with the same writing order.

[0074] For example, the name of the attribute to be converted is a map attribute, and four maps are used in the shader to be converted, such as abcd in sequence, and six maps are used in the target shader, such as 123456 in sequence, and none of them are matched from the mapping relationship, then according to the writing order in the program file, that is, the program code, abcd can be matched to 1234 in sequence, that is, a matches 1, b matches 2, c matches 3, and d matches 4.

[0075] For the case where the mapping relationship is not recorded, a possible implementation method is also provided in the embodiment of the present disclosure. Usually, there may be multiple attribute names to be converted in the shader to be converted. During matching, each attribute name to be converted is traversed and matched according to the mapping relationship. Some of the attribute names to be converted may be matched to the target attribute name, while some of the attribute names to be converted are not matched. For the case where some of the attribute names to be converted have recorded mapping relationships, the embodiment of the present disclosure can be based on the write order of the attribute names to be converted that have been matched to the target attribute name, and the write order relationship between the attribute names to be converted that have not recorded the mapping relationship and the matched attribute names to be converted, and the write order of the corresponding matched target attribute names, and then the attribute names to be converted that have not recorded the mapping relationship can be matched to the next target attribute name in the write order according to the write order of the corresponding matched target attribute names.

[0076] For example, the names of the attributes to be converted are abcd in the writing order, and the names of the target attributes are 1234 in the writing order. According to the pre-established mapping relationship, abc are matched to 123 respectively, and there is no mapping relationship recorded for d. In this case, d can be matched to 4 in the writing order.

[0077] In this way, in the disclosed embodiment, the attribute names of various other unofficial Shaders can be automatically matched to the attribute names of the official Shader based on the pre-established mapping relationship between the target attribute names and the non-target attribute names, thereby realizing the conversion of the Shader. Moreover, for the attribute names to be converted whose mapping relationships are not recorded, they can also be matched according to the rules of writing order, which can ensure that the target shader can be converted and improve reliability.

[0078] S103: According to the assigned target shader, regenerate and render the first material object to obtain a second material object.

[0079] In the embodiment of the present disclosure, after the shader to be converted is converted into the target shader, and the value of the attribute name to be converted has been assigned to the target shader, the material can be re-generated and rendered based on the target shader and combined with the value of the target attribute name. It can be understood that the official target shader is used to generate the second material object, but the second material object also uses the attribute parameters such as the texture of the first material object, thereby ensuring that the rendered second material object and the rendering effect of the first material object expected by the user are basically the same.

[0080] Furthermore, in order to improve user experience and interaction efficiency, the embodiment of the present disclosure may also display a message indicating successful material object conversion and display the rendered second material object.

[0081] For example, when the user clicks the conversion function button, the shader conversion logic is executed in the background. After completion, a message indicating that the material object has been successfully converted is displayed, and the rendered second material object is displayed. In this way, the user can clearly understand the rendering effect after the conversion.

[0082] In the embodiment of the present disclosure, in response to a conversion operation, a shader to be converted and a target shader of a first material object are obtained, and according to a pre-established mapping relationship between a target attribute name in a target shader and a non-target attribute name in a non-target shader, a target attribute name that matches the attribute name to be converted in the shader to be converted is determined, and the value of the attribute name to be converted is assigned to the matched target attribute name, and then according to the assigned target shader, a second material object is regenerated and rendered for the first material object. In this way, a mapping relationship between non-target attribute names and target attribute names can be established in advance, and the attribute name to be converted of the non-target shader to be converted can be automatically matched to the target attribute name of the target shader, thereby realizing the conversion from the shader to be converted to the target shader, so that the material object can be regenerated and rendered based on the target shader, avoiding the problem of rendering errors of the first material object due to the incompatibility of the shader to be converted, and the user can freely use any shader to create material objects, and only needs to convert them before uploading, which can also reduce the difficulty of user resource creation.

[0083] Furthermore, in the embodiment of the present disclosure, a mapping relationship between target attribute names and non-target attribute names needs to be established in advance. A possible implementation method is provided for establishing the mapping relationship. Specifically, the mapping relationship can be established in the following manner:

[0084] 1) Get the names of each target attribute included in the target shader.

[0085] In the embodiment of the present disclosure, the target shader is a Shader provided and supported by the official platform, which is usually limited. All target shaders and the names of target attributes included in all target shaders can be enumerated.

[0086] 2) Get the name of each non-target attribute included in each non-target shader.

[0087] For example, through data mining, the names of various non-target attributes used by any other non-target shaders are collected. There may be many non-target shaders, and the names of various non-target attributes used in non-target shaders are also diverse. The mainstream non-target attribute names can be collected as much as possible to basically meet the conversion requirements.

[0088] 3) According to the functions represented by each target attribute name and each non-target attribute name, a mapping relationship between each target attribute name and each non-target attribute name is established.

[0089] When different users write Shaders, the names used for the attribute definitions in Shaders are also diverse. In the disclosed embodiment, the function or meaning expressed by the attribute name can be used for judgment. The attribute names with the same function have corresponding mapping relationships. Of course, the non-target attribute name used by the non-target shader and the target attribute name used by the target shader may be the same. It can be considered that the same attribute names have a mapping relationship, or it can be judged whether there is a mapping relationship based on the function represented. A mapping relationship table can be established to record the mapping relationship between each non-target attribute name and each target attribute name. In addition, it can also support continuous updating of the mapping relationship table to meet the needs of more different non-target attribute names.

[0090] For example, the target attribute name is _BaseTex, and there may be multiple corresponding non-target attribute names, such as _MainTex, BaseMap, etc.

[0091] In this way, in the embodiment of the present disclosure, the non-target attribute names that may be used by any non-target shader can be collected, and then a mapping relationship between the non-target attribute names of the non-target shader and the target attribute names of the official target shader can be established, so that various types of non-target shaders can be matched and converted to the target shader.

[0092] In addition, it should be noted that the rendering method in the embodiment of the present disclosure can develop a corresponding software development kit (SDK) for release. The SDK package can be integrated into an existing UGC platform, such as the Unity platform, as a functional plug-in of the Unity platform, and provide the official target Shaders that can be converted. In this way, before uploading the material object they have made, the user can first convert it based on this function and convert it into the official target Shader, and then upload the converted material object. The converted material object can be guaranteed to be rendered correctly.

[0093] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0094] The following uses a specific application scenario for illustration. In an embodiment of the present disclosure, the rendering method in the embodiment of the present disclosure can be integrated into the UGC platform as a functional plug-in to facilitate user conversion operations. The interface operation in the UGC platform is used as an example for illustration.

[0095] For example, a user imports a first material object into the UGC platform. Since the first material object is generated based on a non-official non-target shader, an error occurs during rendering. For example, the non-target shader actually uses a texture, but the texture is not recognized during rendering. Refer to Figure 2, which is a schematic diagram of the rendering effect of the first material object in an embodiment of the present disclosure. As can be seen from Figure 2, the texture used is not rendered.

[0096] Then the user can select the shader configuration operation to display the shader configuration interface. Refer to Figure 3, which is a schematic diagram of the shader configuration interface in the embodiment of the present disclosure. As shown in Figure 3, the target shader to be converted is displayed as "*** / A", and the user can select the target shader to be converted. For example, if the selected target shader is "*** / B", click the conversion button of the shader conversion function to convert the target shader to the target shader, and according to the pre-established mapping relationship between the target attribute name and the non-target attribute name, assign the value of the attribute name to be converted in the shader to the matching target attribute name.

[0097] In this way, after the conversion is completed, the second material object can be regenerated and rendered according to the target shader. For example, as shown in Figure 4, it is a schematic diagram of the rendering effect of the second material object in the embodiment of the present disclosure. Through conversion, the map used by the shader to be converted can be assigned to the corresponding matching target attribute name of the target shader. Compared with Figure 2, the map can be rendered in Figure 4 to ensure the correctness of the rendering. It can be understood that Figure 4 and Figure 2 are only possible example figures and no color image is displayed. In practice, the second material object in Figure 4 will display the actual style of the colored map after rendering. However, from the comparison between Figure 4 and Figure 2, it can be seen that the rendering effects of Figure 4 and Figure 2 are different. The main difference is that Figure 4 can identify and correctly render the map used.

[0098] It should be noted that the interface operation diagram in the embodiment of the present disclosure is only an example and should not limit the embodiment of the present disclosure.

[0099] In the disclosed embodiment, the non-target attribute name of any unofficial non-target shader can be matched and associated with the target attribute name of the target shader to achieve one-click conversion between different types of material objects, ensure rendering correctness, and improve reliability and efficiency.

[0100] In the embodiment of the present disclosure, a mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader is pre-established, and then in response to the conversion operation, the shader to be converted and the target shader of the first material object can be obtained, and according to the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, the target attribute name matched by the attribute name to be converted in the shader to be converted is determined, and the value of the attribute name to be converted is assigned to the matched target attribute name, and according to the assigned target shader, the second material object is regenerated and rendered for the first material object. In this way, the mapping relationship between the non-target attribute name and the target attribute name is pre-established, and the attribute name to be converted of the non-target shader to be converted can be automatically matched to the target attribute name of the target shader, and the shader to be converted can be converted into the target shader, thereby avoiding the problem of rendering errors caused by the incompatibility of the shader to be converted and ensuring the correctness of rendering.

[0101] Based on the same inventive concept, the embodiments of the present disclosure also provide a rendering device corresponding to the rendering method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to that of the above-mentioned rendering method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0102] 5 is a schematic diagram of a rendering device provided by an embodiment of the present disclosure, the device comprising:

[0103] An obtaining module 51 is configured to obtain, in response to a conversion operation, a shader to be converted and a target shader of a first material object, wherein the first material object is generated based on the shader to be converted;

[0104] a conversion module 52 for determining a target attribute name that matches the attribute name to be converted in the shader to be converted based on a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name;

[0105] The rendering module 53 is used to regenerate and render the first material object according to the assigned target shader to obtain a second material object.

[0106] In an optional embodiment, the method further includes establishing a module 54 for:

[0107] Obtaining the names of the target attributes included in the target shader;

[0108] Obtaining the name of each non-target attribute included in each non-target shader;

[0109] According to the functions represented by the target attribute names and the non-target attribute names, a mapping relationship between the target attribute names and the non-target attribute names is established.

[0110] In an optional embodiment, when determining the target attribute name that matches the attribute name to be converted in the shader to be converted based on the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name, the conversion module 52 is configured to:

[0111] Deserialize and parse the first material object to obtain the name of the attribute to be converted included in the shader to be converted;

[0112] Determining a target attribute name that matches the attribute name to be converted based on a pre-established mapping relationship between a target attribute name in the target shader and a non-target attribute name in a non-target shader;

[0113] The shader to be converted is converted into the target shader, and the value of the attribute name to be converted is assigned to the matched target attribute name.

[0114] In an optional embodiment, the conversion module 52 is also used to: in the absence of a record of the mapping relationship between the attribute name to be converted and the target attribute name, determine the target attribute name that matches the attribute name to be converted according to the writing order of the target attribute names in the program file of the target shader and the writing order of the attribute names to be converted in the program file of the shader to be converted.

[0115] In an optional embodiment, when determining the target attribute name that matches the attribute name to be converted based on the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted, the conversion module 52 is configured to:

[0116] Determine the writing order of the target attribute names in the program file of the target shader, and the writing order of the to-be-converted attribute names in the program file of the to-be-converted shader;

[0117] Match the attribute names to be converted to the target attribute names in the same writing order.

[0118] In an optional embodiment, a configuration module 55 is further included, which is used to:

[0119] For the shader to be converted of the currently displayed first material object, in response to a shader configuration operation, displaying a shader configuration interface, wherein the shader to be converted and a shader conversion function are displayed in the shader configuration interface, and the shader conversion function is used to receive the conversion operation;

[0120] The target shader is received by selecting and inputting from each candidate shader provided in the shader configuration interface.

[0121] An optional embodiment further includes a display module 56 for displaying a message indicating that the material object conversion is successful and displaying the rendered second material object.

[0122] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0123] The present disclosure also provides an electronic device, as shown in FIG6 , which is a schematic diagram of the structure of the electronic device provided by the present disclosure, including:

[0124] Processor 61 and memory 62; the memory 62 stores machine-readable instructions executable by the processor 61, and the processor 61 is configured to execute the machine-readable instructions stored in the memory 62. When the machine-readable instructions are executed by the processor 61, the processor 61 performs the following steps:

[0125] In response to a conversion operation, obtaining a to-be-converted shader and a target shader of a first material object, wherein the first material object is generated based on the to-be-converted shader;

[0126] Determining a target attribute name that matches the attribute name to be converted in the shader to be converted based on a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name;

[0127] According to the assigned target shader, the first material object is regenerated and rendered to obtain a second material object.

[0128] In an optional embodiment, the processor 61 is further configured to:

[0129] Obtaining the names of the target attributes included in the target shader;

[0130] Obtaining the name of each non-target attribute included in each non-target shader;

[0131] According to the functions represented by the target attribute names and the non-target attribute names, a mapping relationship between the target attribute names and the non-target attribute names is established.

[0132] In an optional embodiment, when determining the target attribute name that matches the attribute name to be converted in the shader to be converted based on the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name, the processor 61 is configured to:

[0133] Deserialize and parse the first material object to obtain the name of the attribute to be converted included in the shader to be converted;

[0134] Determining a target attribute name that matches the attribute name to be converted based on a pre-established mapping relationship between a target attribute name in the target shader and a non-target attribute name in a non-target shader;

[0135] The shader to be converted is converted into the target shader, and the value of the attribute name to be converted is assigned to the matched target attribute name.

[0136] In an optional embodiment, the processor 61 is also used to: in the absence of a record of the mapping relationship between the attribute name to be converted and the target attribute name, determine the target attribute name that matches the attribute name to be converted based on the writing order of the target attribute names in the program file of the target shader and the writing order of the attribute names to be converted in the program file of the shader to be converted.

[0137] In an optional embodiment, when determining the target attribute name that matches the attribute name to be converted based on the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted, the processor 61 is configured to:

[0138] Determine the writing order of the target attribute names in the program file of the target shader, and the writing order of the to-be-converted attribute names in the program file of the to-be-converted shader;

[0139] Match the attribute names to be converted to the target attribute names in the same writing order.

[0140] In an optional embodiment, the processor 61 is further configured to:

[0141] For the shader to be converted of the currently displayed first material object, in response to a shader configuration operation, displaying a shader configuration interface, wherein the shader to be converted and a shader conversion function are displayed in the shader configuration interface, and the shader conversion function is used to receive the conversion operation;

[0142] The target shader is received by selecting and inputting from each candidate shader provided in the shader configuration interface.

[0143] In an optional embodiment, the processor 61 is further configured to display a message indicating that the material object conversion is successful, and to display the rendered second material object.

[0144] The above-mentioned memory 62 includes internal memory 621 and external memory 622; the memory 621 here is also called internal memory, which is used to temporarily store the calculation data in the processor 61 and the data exchanged with the external memory 622 such as the hard disk. The processor 61 exchanges data with the external memory 622 through the internal memory 621.

[0145] The specific execution process of the above instructions can refer to the steps of the rendering method described in the embodiment of the present disclosure, which will not be repeated here.

[0146] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program executes the steps of the rendering method described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0147] For a description of the effects of the above-mentioned rendering device, electronic device, and computer-readable storage medium, please refer to the description of the above-mentioned rendering method, which will not be repeated here.

[0148] The embodiments of the present disclosure further provide a computer program product, which carries program code. The instructions included in the program code can be used to execute the steps of the rendering method described in the above method embodiment. For details, please refer to the above method embodiment and will not be repeated here.

[0149] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0150] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0151] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0152] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0153] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0154] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.

Claims

1. A rendering method, include: In response to a conversion operation, obtaining a to-be-converted shader and a target shader of a first material object, wherein the first material object is generated based on the to-be-converted shader; Determine the target attribute name that matches the attribute name to be converted in the shader to be converted according to the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assign the value of the attribute name to be converted to the matched target attribute name; According to the assigned target shader, the first material object is regenerated and rendered to obtain a second material object.

2. The method according to claim 1, further comprising: include: Obtain the name of each target attribute included in the target shader; Obtaining the name of each of the non-target attributes included in each of the non-target shaders; According to the functions represented by each of the target attribute names and each of the non-target attribute names, a mapping relationship between each of the target attribute names and each of the non-target attribute names is established.

3. The method according to claim 1 or 2, in, The step of determining the target attribute name that matches the attribute name to be converted in the shader to be converted according to the pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assigning the value of the attribute name to be converted to the matched target attribute name, comprises: Deserialize and parse the first material object to obtain the name of the attribute to be converted included in the shader to be converted; Determine the target attribute name that matches the attribute name to be converted according to a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader; The shader to be converted is converted into the target shader, and the value of the attribute name to be converted is assigned to the matched target attribute name.

4. The method according to claim 3, further comprising: include: In the case where the mapping relationship between the attribute name to be converted and the target attribute name is not recorded, the mapping relationship between the attribute name to be converted and the target attribute name is determined according to the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted. The target attribute name that the attribute name to be converted matches.

5. The method according to claim 4, in, Determining the target attribute name that matches the attribute name to be converted according to the writing order of the target attribute name in the program file of the target shader and the writing order of the attribute name to be converted in the program file of the shader to be converted, comprising: Determine the writing order of the target attribute names in the program file of the target shader, and the writing order of the to-be-converted attribute names in the program file of the to-be-converted shader; The attribute names to be converted are matched to the target attribute names in the same writing order.

6. The method according to any one of claims 1 to 5, further comprising: include: For the shader to be converted of the first material object currently displayed, in response to a shader configuration operation, a shader configuration interface is displayed, wherein the shader to be converted and a shader conversion function are displayed in the shader configuration interface, and the shader conversion function is used to receive the conversion operation; The target shader is received by selecting and inputting from each candidate shader provided in the shader configuration interface.

7. The method according to any one of claims 1 to 6, further comprising: include: A message indicating successful material object conversion is displayed, and the rendered second material object is displayed.

8. A rendering device, include: An obtaining module is configured to obtain a to-be-converted shader and a target shader of a first material object in response to a conversion operation, wherein the first material object is generated based on the to-be-converted shader; A conversion module is configured to determine a target attribute name that matches the attribute name to be converted in the shader to be converted according to a pre-established mapping relationship between the target attribute name in the target shader and the non-target attribute name in the non-target shader, and assign the value of the attribute name to be converted to the matched target attribute name; The rendering module is configured to regenerate and render the first material object to obtain a second material object according to the assigned target shader.

9. An electronic device, include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, the processor is configured to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the processor performs the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, in: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Shader using method based on multiple platforms and related equipment

    CN114356289A

  • Method and device for rendering target image, electronic equipment and storage medium

    CN114677469A

  • Method and device for rendering material effect

    CN115018964A

  • Rendering method and device, electronic equipment and storage medium

    CN116206038A

  • Graphics Pipeline State Object And Model

    US20150348224A1