An image processing method, device, chip and storage medium
Patent Information
- Application Number
- CN202410904042.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2044-07-05
AI Technical Summary
[0003]然而,光照质量效果的提升,导致手机GPU、DDR等硬件资源负载压力较大,造成手机温度升高,耗电加快,游戏帧率不稳定等问题,使得用户游戏体验感较差
[0006]通过上述方式,对以光源为中心以临界距离为半径的显示区域进行光照渲染,可以减少光照渲染中在临界距离以外对图像最终呈现没有明显着色贡献的光照区域像素计算,可以减小GPU渲染的负载,有效降计算功耗,提升性能表现。
Smart Images

Figure CN121330158B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more particularly to an image processing method, apparatus, chip, and storage medium. Background Technology
[0002] Currently, while mobile games are constantly improving frame rates and rendering resolutions, they are also making significant improvements to lighting quality in pursuit of a more immersive visual experience. Lighting quality is determined by factors such as the number of light sources, the range of illumination, the lighting shader, and the sampling texture.
[0003] However, the improved lighting quality puts a greater strain on the phone's GPU, DDR and other hardware resources, leading to problems such as increased phone temperature, faster power consumption, and unstable game frame rates, resulting in a poor gaming experience for users. Summary of the Invention
[0004] This application provides an image processing method and related equipment that can reduce the rendering load of the GPU, save the computational power consumption of lighting effects, and improve performance without affecting the final rendering effect.
[0005] In a first aspect, some embodiments of this application provide an image processing method. This image processing method may include: determining the type of an illumination attenuation model, wherein the illumination attenuation model is used for illumination rendering centered on a light source, such that the illumination intensity centered on the light source varies with the distance from the light source; determining a critical distance corresponding to the illumination attenuation model based on the type of the illumination attenuation model, wherein the illumination intensity corresponding to the critical distance is greater than zero; and performing illumination rendering on a display area centered on the light source with a radius equal to the critical distance, based on the illumination attenuation model.
[0006] By performing lighting rendering on the display area centered on the light source and with a critical distance as the radius, the pixel calculation in the lighting rendering of the lighting area outside the critical distance that does not make a significant contribution to the final image rendering can be reduced. This can reduce the load on GPU rendering, effectively reduce computing power consumption, and improve performance.
[0007] In one possible implementation, determining the type of illumination attenuation model includes: obtaining the source code of the first shader; and determining the type of illumination attenuation model based on the source code of the first shader.
[0008] By analyzing the source code, the type of light attenuation model can be determined, which is beneficial for optimizing lighting rendering at the source code level without modifying the hardware.
[0009] In one possible implementation, determining the type of the illumination attenuation model based on the source code of the first shader includes: performing feature matching on the source code of the first shader to determine that the first shader is used for illumination rendering, wherein the feature matching includes variable feature matching and computational feature matching; performing regularity matching on the source code of the first shader with multiple reference illumination attenuation models of different types to determine the first reference illumination attenuation model that is regularly matched with the illumination attenuation model used in the source code of the first shader; and determining the type of the first reference illumination attenuation model as the type of illumination attenuation model.
[0010] The above method can be used to quickly determine the type of light attenuation model.
[0011] In one possible implementation, obtaining the source code of the first shader includes: intercepting the loaded source code of the first shader and obtaining the source code of the first shader when loading the source code of the first shader; after determining the type of the illumination attenuation model based on the source code of the first shader, the method further includes: updating the source code of the first shader to update the rendering rules to the target rendering rules, the target rendering rules being based on the illumination attenuation model, and performing illumination rendering on the display area centered on the light source with a critical distance as the radius.
[0012] The above method allows for lighting and rendering optimization at the source code level without requiring hardware modifications.
[0013] In one possible implementation, the source code of the first shader is updated by adding a source code segment to the source code of the first shader so that the first shader calculates the lighting effect in a region centered on the light source and with a critical distance as the radius, based on the light attenuation model.
[0014] By using the above method, lighting rendering optimization can be achieved simply by updating the shaders by adding source code segments.
[0015] In one possible implementation, updating the source code of the first shader includes: obtaining the source code of the second shader; updating the source code of the first shader to the source code of the second shader, wherein the second shader is based on a light attenuation model and performs lighting effect calculations in a region centered on the light source and with a critical distance as the radius.
[0016] By using the above method, the shader can be replaced as a whole, which can maintain the integrity of the shader source code calculation logic and help avoid logical problems that may be introduced by adding new source code segments.
[0017] In one possible implementation, after updating the source code of the first shader, the method further includes: compiling the source code of the first shader into binary code; and saving the binary code.
[0018] By using the above method, the binary code can be directly loaded during subsequent rendering, which can reduce unnecessary source code compilation events and thus improve loading speed.
[0019] Secondly, this application provides an image processing apparatus, which may be an electronic device, a device within an electronic device, or a device compatible with an electronic device. The image processing apparatus may also be a chip system, capable of executing the methods performed by the electronic device in the first aspect. The functions of the image processing apparatus can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more units corresponding to the aforementioned functions. These units may be software and / or hardware. The operations performed by the image processing apparatus and its beneficial effects are described in the first aspect above, and will not be repeated here.
[0020] Thirdly, this application provides an electronic device including one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program source code, which includes computer instructions. When the one or more processors execute the computer instructions, the electronic device performs the image processing method in any possible implementation of the first aspect described above.
[0021] Fourthly, this application provides a chip system including a processor and an interface, the processor and the interface being coupled; the interface is used to receive or output signals, and the processor is used to execute source code instructions to perform the image processing method in any possible implementation of the first aspect above.
[0022] Fifthly, this application provides a computer-readable storage medium storing a computer program / instructions that, when the computer program product is run on a computer, cause the computer to perform the image processing method in any possible implementation of the first aspect described above.
[0023] Sixthly, this application provides a computer program product that, when run on a computer, causes the computer to execute the image processing method in any possible implementation of the first aspect described above. Attached Figure Description
[0024] Figure 1 A schematic diagram of an image coloring process provided in an embodiment of this application;
[0025] Figure 2 A logical diagram of a rendering instruction stream provided in an embodiment of this application;
[0026] Figure 3This application provides a schematic diagram illustrating the distribution of color-related functions during the loading process.
[0027] Figure 4 This application provides a schematic diagram illustrating the distribution of shading-related functions during the loading process, as shown in an embodiment.
[0028] Figure 5 Example diagram of a planar projection of spherical illumination provided in an embodiment of this application;
[0029] Figure 6 Example diagrams of different light attenuation models provided in the embodiments of this application;
[0030] Figure 7 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0031] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0032] Figure 9 A schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;
[0033] Figure 10 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0034] Figure 11 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0035] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0036] Figure 13 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application;
[0037] Figure 14 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0039] It should be understood that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0040] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0041] Currently, applications installed in electronic devices can instruct the electronic device to perform corresponding image rendering operations by sending out instruction streams that include multiple image rendering commands, thereby obtaining relevant data for the displayed image (such as the color, shape, and other data of various parts of the model included in the image), and then displaying different images to the user through the electronic device's display screen based on the obtained relevant data.
[0042] For example, the rendering instruction stream may include shader-related instructions to instruct the electronic device to use the corresponding shader to perform shading operations on the vertices and / or fragments of the model included in the image. The shader may refer to a small program, function, or process running on a graphics processing unit (GPU), by which the GPU can perform shading of the vertices or fragments.
[0043] A fragment can be a unit composed of one or more points in an image. For example, a shape (such as a triangle) in an image can correspond to a fragment. The data corresponding to a fragment can include corresponding color, depth, and texture data. A shader can be an editable program used to implement image rendering. Shaders can include vertex shaders and fragment shaders. Fragment shaders can also be called pixel shaders. The shader information sent by the application can include pairs of vertex shaders and fragment shaders so that the electronic device can achieve complete rendering of the model. In the embodiments of this application, vertex shaders and fragment shaders for the same model can be referred to as shader pairs.
[0044] It's important to note that the vertex shader is used to draw the vertex coordinates of the object to be rendered, and it's also used to perform model transformations, view transformations, and projection transformations. The fragment shader is used to calculate color, lighting, etc., to obtain textures, and to fill each pixel with color. The following section combines... Figure 1 The processing mechanisms of vertex shaders and fragment shaders are explained.
[0045] See Figure 1 , Figure 1 This is a schematic diagram of an image coloring process provided in an embodiment of this application. Figure 1 As shown, the output of the vertex shader can be used as input data for the fragment shader. For example, vertex data from the rendering command stream issued by the application can be input into the vertex shader for processing. Rendering processing in the vertex shader can include operations such as primitive assembly and rasterization. As a possible example, the primitive assembly process can include performing operations such as clipping, perspective splitting, and viewport transformation. Figure 1 In the example, the primitive assembly process can be implemented using a Tessellation Control Shader (TCS) and a Tessellation Evaluation Shader (TES). The output data after rasterization (such as drawable pixel coordinates) can be passed to the fragment shader to perform the corresponding shading operations.
[0046] In other words, in a pair of vertex shaders and fragment shaders, the output data of the vertex shader can be used as the input data of the fragment shader for rendering the corresponding model.
[0047] Taking the application as an example of a game application installed on an electronic device, combined with Figure 1The shader usage mechanism is illustrated with an example of the process from issuing instructions to completing rendering in a game application.
[0048] See Figure 2 , Figure 2 This is a logical diagram illustrating a rendering instruction stream provided in an embodiment of this application. For example... Figure 2 As shown, a game application can issue a series of rendering instruction streams, including shading instructions. These rendering instruction streams can include one or more functions issued sequentially. This rendering instruction stream can be passed to the graphics library in the electronic device, allowing the library to invoke the corresponding Application Programming Interface (API) and instruct the rendering component (such as a Graphics Processing Unit (GPU)) in the electronic device to perform the corresponding shading operations. In the following description, the instruction stream used to instruct shading operations within the rendering instruction stream will be referred to as the shading instruction stream.
[0049] See Figure 3 , Figure 3 This is a logical diagram illustrating the distribution of color-related functions during the loading process, provided as an embodiment of this application. In some embodiments, combined with... Figure 3 The shading instruction stream issued by a game application can include functions that sequentially create shader objects, create shader programs, compile shaders, load shader objects, link programs, and use programs. Thus, electronic devices can perform shading operations on models in an image based on this shading instruction stream.
[0050] The following uses the Open Graphics Library (OpenGL) rendering platform as an example to illustrate the command functions included in the above-mentioned shading instruction stream. These commands can achieve their functionality through different functions. For example, the shading instruction stream may include the functions glCreateShader, glCreateProgram, glCompileShader, glAttachShader, and glLinkProgram. These functions are briefly described below.
[0051] 1. `glCreateShader(shadertype)`. This function creates a shader object. A shader object corresponds to a piece of shader source code. In this example, `glCreateShader` can take a parameter, such as `shadertype`, to indicate the shader type. `shadertype` can be passed as a numeric value in `glCreateShader`. Different values for `shadertype` can indicate either `gl_vertex_shader` or `gl_fragment_shader`.
[0052] The `glCreateShader` function, which instructs `gl_vertex_shader`, is used to create a vertex shader. By calling this vertex shader object, the source code of the corresponding vertex shader can be used to perform vertex shading operations.
[0053] Correspondingly, the glCreateShader function of gl_fragment_shader is used to create a fragment shader. By calling this fragment shader object, the source code of the corresponding fragment shader can be used to perform fragment shading operations.
[0054] 2. `glShaderSource(shader)`. This function loads the shader's source code into a shader object. The shader's source code can be stored in a file corresponding to the shader resource (Shader Source). For example, this file can be a text file with the `.shader` extension. One shader object can correspond to one shader resource, and the `glShaderSource` function can be used to load the shader's source code into the shader object. In other words, the shader resource can be used to define the shader object.
[0055] 3. glCompileShader(shader). The glCompileShader function can be used to compile the source code of the shader.
[0056] It should be understood that the source code (such as C++, Java, etc.) of the corresponding shader can be stored in the shader resource file. Since source code cannot be directly recognized by electronic devices, it usually needs to be compiled (i.e., inputting the source code into a compiler to convert it into binary code) before it can be executed. To facilitate fast access, game applications can compile most (or all) of the shader source code into binary code and store it before using the shaders, such as during the loading process. In this way, during subsequent runtime, the electronic device can call and run the pre-compiled binary code when a shader is needed, avoiding the delay caused by the compilation process and thus improving efficiency.
[0057] In some embodiments, after the compilation and storage of the binary code are completed, the electronic device can add a pointer to the corresponding shader ID to indicate the ID and storage address of the binary code, thereby enabling the corresponding binary code to be obtained according to the shader ID in subsequent calls.
[0058] In some embodiments, game applications can compile shaders using glCompileShader(shader). The shader parameter passed to this function can be identified by the ID of an already created shader object.
[0059] 4. `glCreatProgram(void)`. This `glCreatProgram` function can be used to create an empty shader program object and return a non-zero value (program ID) that can be referenced. By calling a program that loads a shader pair consisting of at least one vertex shader and one fragment shader, a one-time call to the vertex shader and fragment shader can be achieved.
[0060] In some embodiments, the program object created by the glCreateProgram function can be used to load shader objects. That is, by loading shader objects onto the program, the electronic device can smoothly call the corresponding vertex shader and fragment shader according to the instructions of the game application, and achieve the purpose of using the shader to perform shading operations by running the source code stored in the shader resource corresponding to the shader.
[0061] It should be noted that the glCompileShader function mentioned above can be issued before the game application issues the instruction to create the corresponding program object. However, in different implementations, there is no restriction on the order of the shader compilation operation and the program creation operation.
[0062] For example, the `glCompileShader(shader)` instruction can be issued before the `glCreateProgram(void)` instruction. Similarly, the `glCompileShader(shader)` instruction can be issued after the `glCreateProgram(void)` instruction. Furthermore, the `glCompileShader(shader)` instruction can be issued simultaneously with the `glCreateProgram(void)` instruction.
[0063] 5. `glAttachShader(program, shader)`. This function loads (or attaches) an existing shader to an existing program for use in subsequent game applications. In some embodiments, the parameter `program` can be identified by its ID. The parameter `shader` can be identified by its ID.
[0064] Based on the foregoing explanation, since both vertex shaders and fragment shaders are used during the rendering of a model, an electronic device can load at least one vertex shader and one fragment shader onto the same program by issuing the glAttachShader function. For example, a vertex shader can be loaded onto the program using glAttachShader(program ID, VertexShader ID). Similarly, a fragment shader can be loaded onto the program using glAttachShader(programID, FragmentShader ID).
[0065] 6. glLinkProgram(program). This glLinkProgram function can be used to link the corresponding program to the current game application.
[0066] Thus, as Figure 3 The flowchart illustrates that during game loading, the game application can issue an instruction stream including the above 6 functions. During the subsequent running of the game application, the program object can be called through functions such as glUseProgram to directly use the binary code including the corresponding vertex shader and fragment shader for shading operations.
[0067] It should be noted that, in this embodiment, the game loading process refers to the process by which the game application prepares data for normal operation after it has started. For example, during this loading process, the game application can read the necessary data from external storage into memory for quick access during runtime. The game application can also perform a pre-compilation process, such as compiling the source code of frequently used shader resources into binary code. During this game loading process, the electronic device can display a "Loading" message or a loading progress bar on the interface. Dynamic or static images can also be displayed during this process. After loading is complete, the electronic device can enter the main interface that allows user interaction.
[0068] In addition, in some scenarios, game applications can also link the shader-loaded program to the application by issuing some instructions from functions 1 to 6.
[0069] For example, after the game application links the program to itself by issuing functions 1 through 6, it typically uses the `glGetProgramBinary` function to retrieve the compiled binary code and saves it to a file. In this case, upon entering the game a second time, after the `glCreateProgram` function creates the program object, it reads the binary code file and uses the `glProgramBinary` function to load the binary code into the program object. Alternatively, before compiling (as in issuing the `glCompileShader(shader)` function), the game application can check if a file containing the binary code is stored on the electronic device to determine if the shader's source code has been compiled. If the shader's binary code is stored, the compilation instructions for that shader, i.e., the `glCompileShader(shader)` function, do not need to be issued. This allows the application to link the program containing the shader to itself by issuing only some of the instructions in functions 1 through 6, and also reduces loading time.
[0070] The following examples and Figure 4 This paper explains the process from creating a shader to using it for shading operations. The example used is one that requires compiling the shader's source code. It should be noted that the following examples involve multiple correspondences. In different implementations, these correspondences can be indicated through the source code, through table entries, or through pointer settings. This application does not limit the specific method of indicating these correspondences.
[0071] See Figure 4 , Figure 4 This is a schematic diagram illustrating the distribution of shading-related functions during the loading process, as provided in an embodiment of this application. Figure 4 As shown, game applications can send functions to the graphics library during the loading process.
[0072] First, the game application can issue `glCreateShader(A)` to create a vertex shader object `shader(V1)`, and the electronic device can also map this shader (V1) to the source code segment `V1`. The game application can also issue `glCreateShader(B)` to create a fragment shader object `shader(F1)`, and the electronic device can also map this shader (F1) to the source code segment `F1`. Here, `V1` can be the ID of `shader(V1)`, and `F1` can be the ID of `shader(F1)`.
[0073] In some embodiments, the electronic device may store shader IDs and pointers to the storage addresses of their corresponding source code. Alternatively, the electronic device may store the mapping between shader IDs and the storage addresses of their corresponding source code.
[0074] like Figure 4 As shown, the game application can also issue glShaderSource(V1) to load the vertex shader source code segment V1 into the vertex shader shader(V1). The game application can also issue glShaderSource(F1) to load the fragment shader source code segment F1 into the fragment shader shader(V1).
[0075] The game application can also distribute glCompileShader(V1), and the electronic device can compile the source code corresponding to shader(V1) to obtain the corresponding binary code.
[0076] In some embodiments, the electronic device may determine that the storage address of the source code of the shader with shader ID V1 is address 1, read the source code segment V1 of the shader(V1) from address 1, and input the source code into the compiler to compile and obtain the corresponding binary code (such as binary code V1').
[0077] Similarly, a game application can issue glCompileShader(F1) to compile shader(F1). The electronic device can determine that the storage address of the source code of the shader with shader ID F1 is address 2, read the source code segment F1 of shader(F1) from address 2, and input the source code into the compiler for compilation, thereby obtaining the corresponding binary code (such as binary code F1').
[0078] It should be noted that in some embodiments, after compiling and obtaining the binary code, the binary code can be stored in the original file that stores the source code, and its address can remain unchanged. For example, binary code V1' can be stored in the storage space corresponding to address 1. Similarly, binary code F1' can be stored in the storage space corresponding to address 2.
[0079] Based on the foregoing description of shader resources, in some embodiments, the compiled binary code V1' can be stored in the file corresponding to the shader resources storing the source code segment V1. Similarly, the compiled binary code F1' can be stored in the file corresponding to the shader resources storing the source code segment F1.
[0080] In other embodiments, after compiling and obtaining the binary code, the binary code may be stored in a new file different from the original file storing the source code, and its address may be different from the address of the file storing the source code. For example, binary code V1' may be stored in the storage space corresponding to address 1'. Similarly, binary code F1' may be stored in the storage space corresponding to address 2'.
[0081] The game application can also issue a glCreateProgram(void) command to create a new program. The electronic device can respond to this command, create a new program, assign a new ID to the program, and send the ID back to the game application. For example, let's say the ID of the new program is 1, and the new program is program(1).
[0082] Next, the game application can send glAttachShader(1, V1) to load the vertex shader (V1) onto program(1). The game application can also send glAttachShader(1, F1) to load the fragment shader (F1) onto program(1). In this way, a vertex shader and a fragment shader are loaded onto program(1).
[0083] After issuing the instruction to load the shader into the program, the game application can issue the glLinkProgram instruction 1 (such as glLinkProgram(1)) to link the program that has loaded shader(V1) and shader(F1) to the current application (i.e., the game application). Thus, during subsequent operation, the game application can call the program(1) to use shader(V1) and shader(F1) for shading.
[0084] For example, a game application can invoke program(1) by sending glUseProgram(1). Thus, when invoking program(1), the electronic device can determine the corresponding shaders, including shader(V1) and shader(F1), and simultaneously determine the storage address of the binary code for each shader. By reading and running the code at that storage address, the purpose of invoking program(1) to perform the shading operation can be achieved.
[0085] Therefore, game applications can achieve the purpose of performing shading operations through shaders.
[0086] It should be noted that the correspondence between a shader and / or program and its source code storage address (or source code storage address and binary code storage address) can be achieved by adding pointers to the source code segments corresponding to the shader ID and / or program ID.
[0087] Understandably, shading operations, as an indispensable part of rendering, have a significant impact on the rendering time and power consumption. Furthermore, as the resolution of images displayed on electronic devices increases, the required shading operations become increasingly complex.
[0088] For example, while mobile games are constantly improving frame rates and rendering resolutions, they are also significantly enhancing lighting quality to pursue a more immersive visual experience. Lighting effects are typically determined by factors such as the number of light sources, the range of illumination, the lighting shader, and the sampled texture.
[0089] Generally speaking, a lighting shader is a shader used for lighting rendering. The shader uses typical spherical lighting and calculates lighting effects based on a light attenuation model for lighting rendering.
[0090] See Figure 5 , Figure 5 An example diagram of a planar projection of spherical illumination provided in an embodiment of this application.
[0091] In spherical lighting, the light source is located at the geometric center of the sphere, i.e., the center of the sphere. Assuming the light is projected orthographically onto the illuminated plane of the view, the illuminated area to be calculated is approximately circular. The normalized light intensity generally starts from the maximum light intensity of 1 at the light source location and follows a light attenuation model to decrease towards the surrounding boundaries to the minimum light intensity of 0.
[0092] See Figure 6 , Figure 6 Example diagrams of different light attenuation models provided in the embodiments of this application.
[0093] Illumination attenuation models simulate the change in illuminance of light emitted from naturally diffused light sources with distance from the light source (i.e., optical center distance). Illumination attenuation models can be categorized into linear attenuation models, inverse square attenuation models, generalized attenuation models, etc. Different applications or light source types may use different attenuation curve models. The commonality is that the illuminance decreases continuously as the optical center distance increases; the difference lies in the variation of the attenuation slope at different distances from the light source center. In this model, both illuminance and optical center distance are normalized. When the optical center distance is 0, the current position is considered to be at the light source, with a maximum illuminance of 1. When the optical center distance is 1, the current position is considered to be at the boundary of spherical illumination, with a minimum illuminance of 0.
[0094] To improve lighting effects, more light sources are typically introduced, and their illumination range is expanded, increasing the computational complexity of lighting calculations. This results in increased rendering time and power consumption for the image.
[0095] To reduce the lighting rendering overhead in shading operations, the solution provided in this application optimizes the calculation radius of lighting rendering, achieving the same or similar lighting rendering effect without affecting the final lighting rendering effect.
[0096] The following detailed description, in conjunction with the accompanying drawings, illustrates the solutions provided in the embodiments of this application. It should be noted that, in the following description, an application (such as a game application) can instruct an electronic device to perform rendering operations, including shading operations, by issuing a rendering command stream. In the rendering command stream, the original shader to be loaded can be a first shader. The electronic device can store multiple different types of reference illumination attenuation models, and corresponding critical distances for optimizing the computational radius.
[0097] See Figure 7 , Figure 7 This is a flowchart illustrating an image processing method provided in an embodiment of this application. Figure 7 The method shown can be executed by an electronic device. Or Figure 7 The subject of the method shown can be a chip or chip system in an electronic device, but this application does not limit it. Figure 7 The method will be explained using an electronic device as the executing entity. Specifically:
[0098] S701. Determine the type of illumination attenuation model. The illumination attenuation model is used for lighting rendering centered on the light source, so that the illumination intensity centered on the light source varies with the distance from the light source.
[0099] The light attenuation model simulates the change in light intensity emitted by naturally diffused light sources with distance from the light source. Rendering based on this model can make the rendered lighting effects more realistic. Combined with... Figure 5 and Figure 6 Generally speaking, both the light intensity and the optical center distance are normalized. When the optical center distance is 0, the current position is considered to be at the light source, and its light intensity is the maximum value of 1. When the optical center distance is 1, the current position is considered to be at the boundary of the spherical light, and its light intensity is the minimum value of 0.
[0100] Electronic devices can determine the type of illumination attenuation model used for lighting rendering in any suitable manner.
[0101] In some embodiments, a game application running on an electronic device can instruct the electronic device to determine the type of lighting attenuation model used for lighting rendering.
[0102] Alternatively, the instruction may be sent by the game application to the electronic device according to its default settings or configuration to instruct the electronic device on the lighting attenuation model to be used for lighting rendering, so that the electronic device can determine the type of lighting attenuation model.
[0103] Optionally, the instruction may be sent by the game application to the electronic device in response to a user's input regarding the display effect of the game application, instructing the electronic device to use the light attenuation model required for lighting rendering, so that the electronic device can determine the type of light attenuation model.
[0104] In some embodiments, the electronic device can obtain information about the type of illumination attenuation model used for lighting rendering when installing a game application or an updated version of the game application, thereby determining the type of illumination attenuation model. For example, the application's installation package or version update package may include an indication of the illumination attenuation model used by the game application. Therefore, information about the type of illumination attenuation model used for lighting rendering can be obtained when installing the game application or an iteration of the game application, thereby determining the type of illumination attenuation model used for lighting rendering.
[0105] In some embodiments, determining the type of illumination attenuation model may include: obtaining the source code of a first shader; and determining the type of illumination attenuation model based on the source code of the first shader.
[0106] In this application, the first shader can be a shader stored in the memory of an electronic device (i.e., the shader to be updated). The memory can store the source code of the shader. That is to say, the electronic device can determine the type of illumination attenuation model by obtaining the source code of the first shader and comparing and analyzing the obtained source code of the first shader.
[0107] In some embodiments, if the source code of the first shader has been compiled into binary code, the binary code can also be analyzed and compared to determine the type of illumination attenuation model.
[0108] In some embodiments, determining the type of illumination attenuation model based on the source code of the first shader includes: performing feature matching on the source code of the first shader to determine that the first shader is used for illumination rendering, wherein feature matching includes variable feature matching and computational feature matching; performing regularity matching on the source code of the first shader with multiple reference illumination attenuation models of different types to determine a first reference illumination attenuation model that is regularly matched with the illumination attenuation model used in the source code of the first shader; and determining the type of the first reference illumination attenuation model as the type of illumination attenuation model.
[0109] The source code of the first shader may include the shader ID (or index) name, the shader type, the number of compiled source codes, the source code string content, and its length information. The shader type may include a vertex shader and a fragment shader. In this application, a fragment shader is used for lighting rendering.
[0110] Generally speaking, feature matching can be performed on the source code strings in the source code of the first shader. By matching the shader, the type of illumination attenuation model used by the shader can be determined.
[0111] The source code of the first shader has two main characteristics: one is the use of uniform variables, and the other is computation.
[0112] The use of Uniform variables can vary across different shader source codes. However, lighting shaders used for lighting rendering typically include Uniform variables that can include parameters such as light color and light position.
[0113] The computational characteristics at specific locations can differ across different shader source codes. However, the computations typically involved in lighting shaders used for lighting rendering can include texture sampling, coordinate normalization based on a light attenuation model, and view matrix transformation operations. These computations all have specific computational characteristics and corresponding computational logic.
[0114] Therefore, by matching the uniform variable features and computational features of the first shader with the uniform variable features and computational features typically present in the lighting shader source code, the electronic device can determine that the first shader is used for light rendering.
[0115] Optionally, if the lighting shading calculation is performed in a fragment shader, you can first use its ID name to query the type via the glGetShaderiv interface for filtering. If it is a vertex shader or other types of shaders, you can exit directly. If it is a fragment shader, you can perform feature matching on the shader's source code.
[0116] Furthermore, since different illumination attenuation models employ different mathematical expressions to fit the change in illumination intensity with the distance from the optical center, the illumination intensity calculations of different attenuation models have specific computational logic or expressions. For example, the mathematical expression of a specific illumination attenuation model may involve one or more lines of source code for calculation, and these lines of source code have specific addition, subtraction, multiplication, and division calculation processes specific to the mathematical expression. Therefore, the electronic device can perform regular expression matching between the source code of the first shader and multiple different types of reference illumination attenuation models. Based on the characteristics of the specific computational logic or expressions, it can determine the first reference illumination attenuation model that regularly matches the illumination attenuation model used in the source code of the first shader, and thus determine the type of the first reference illumination attenuation model as the type of illumination attenuation model. In this way, the type of illumination attenuation model can be determined.
[0117] Optionally, the electronic device can also perform matching based on the length information included in the source code of the first shader, and if the length match is successful, perform source code feature matching. Here, length matching can refer to the two matched source code segments having the same source code length.
[0118] In some embodiments, the memory of an electronic device may store a plurality of reference shaders, each of which has a different type of illumination attenuation model. The electronic device can determine the type of illumination attenuation model used by the first shader based on the illumination attenuation model used by the matched reference shaders by matching the first shader with the plurality of reference shaders respectively.
[0119] S702. Based on the type of illumination attenuation model, determine the critical distance corresponding to the illumination attenuation model.
[0120] Among them, the light intensity corresponding to the critical distance is greater than zero.
[0121] Combination Figure 5 and Figure 6As shown, in a typical normalized illumination attenuation model, the light intensity attenuates to a minimum of 0 at the projection boundary. Therefore, lighting rendering in areas below the critical light intensity (i.e., areas outside the critical distance in the illumination attenuation model, i.e., areas between the critical distance and the maximum distance of 1) does not significantly contribute to the actual lighting effect. Therefore, electronic devices can determine the critical distance corresponding to the illumination attenuation model based on its type, thus optimizing lighting rendering by omitting lighting rendering in areas outside the critical distance.
[0122] In some embodiments, the critical distance for optimizing illumination calculations corresponding to different types of illumination attenuation models can be determined offline.
[0123] For example, the critical distance corresponding to the reference illumination attenuation model in the aforementioned steps can be determined through offline analysis. The source code features of the reference illumination attenuation model and the corresponding critical distance can be stored in the memory of the electronic device. In this way, before the game application starts running, the source code related to the reference illumination model and the corresponding critical distance can be stored in the electronic device, allowing the electronic device to directly determine the critical distance corresponding to the illumination attenuation model used by the first shader after determining the type of illumination attenuation model used by the first shader through a matching mechanism.
[0124] In some embodiments, electronic devices can determine the critical distance of the light attenuation model by adapting to the light intensity.
[0125] Combination Figure 5 and Figure 6 As shown, it can be seen that in the light attenuation model, the critical light intensity corresponds to the critical distance. In other words, electronic devices can also optimize light rendering by not rendering light in areas below the critical light intensity.
[0126] In this scenario, electronic devices can determine the critical distance of the light attenuation model by adjusting the set light intensity value and detecting whether display anomalies occur when rendering the lighting based on that set light intensity value.
[0127] For example, if the set light intensity value is too large, the area outside the distance corresponding to the set light intensity will not be lit and rendered. As a result, the difference in light intensity between adjacent pixels will be greater than a certain threshold. In this case, due to the loss of lighting rendering that contributes significantly to the lighting effect, a clear truncation effect will occur on the displayed screen, that is, there will be a clear light-dark boundary line, which can be considered as a display abnormality.
[0128] If a display anomaly occurs, the set light intensity value can be reduced, and the judgment can continue based on the light attenuation model. If the display is normal (the difference between the light intensity of adjacent pixels is less than a certain threshold and there is no truncation effect), the set light intensity value can be determined as the critical light intensity value, and the corresponding critical distance in the light attenuation model can be determined using the critical light intensity.
[0129] In some embodiments, obtaining the source code of the first shader may include: intercepting the loaded source code of the first shader during loading and obtaining the source code of the first shader. After determining the type of the illumination attenuation model based on the source code of the first shader, the method may further include: updating the source code of the first shader to update the rendering rules to a target rendering rule, the target rendering rule being based on the illumination attenuation model, performing illumination rendering on a display area centered on the light source with a critical distance as its radius. Based on the target rendering rule, the electronic device may not render areas outside the critical distance, which can reduce the computational load of illumination rendering.
[0130] Electronic devices can intercept the source code of the first shader when it is loaded by functions such as glShaderSource, thereby obtaining the source code of the first shader.
[0131] Alternatively, the electronic device can use hook technology to intercept the source code of the first shader.
[0132] After determining the type of illumination attenuation model used by the first shader based on the obtained source code of the first shader, the electronic device can update the source code of the first shader so that the updated first shader performs illumination rendering based on the target rendering rule, which is to perform illumination rendering on the display area centered on the light source and with a critical distance as the radius based on the illumination attenuation model used.
[0133] Optionally, updating the source code of the first shader may include: adding a source code segment to the source code of the first shader so that the first shader calculates lighting effects in a region centered on the light source and with a critical distance as the radius, based on the light attenuation model.
[0134] Electronic devices can update the first shader by adding source code segments, so that the rendering rules of the updated first shader meet the target rendering rules, that is, not rendering areas outside the critical distance.
[0135] For example, after an electronic device obtains the source code of the first shader, since the lighting shading source code itself involves calculations for lighting rendering, and lighting rendering requires calculating the lower position coordinates of the currently rendered pixel in the three-dimensional world space and calculating them with the spatial coordinates of the light source position, the final lighting performance (e.g., light intensity, light color, etc.) of the pixel on the screen plane is calculated based on the spatial distance between the two. The source code of the first shader based on different lighting attenuation models has different specific logic implementations. In the source code implementation of the specific logic corresponding to the lighting attenuation model, for example, involving calculations of the spatial position coordinates of planar pixels, light intensity, etc., specific calculation logic or calculation expressions corresponding to the lighting attenuation model will be used (e.g., the matching expression can be a series of consecutive lines of source code, multiple calculation processes). Although the variable names of the expressions in different shader source codes may be different, the calculation characteristics and logic correspond to the type of lighting attenuation model used (e.g., a series of consecutive addition, subtraction, multiplication, and division calculation characteristics).
[0136] Therefore, the electronic device can add source code segments at appropriate locations based on regular expression matching according to the source code of the first shader to update the first shader, so that the updated first shader calculates the lighting effect only in the region centered on the light source and with a critical distance as the radius, based on the light attenuation model.
[0137] Optionally, updating the source code of the first shader may include: obtaining the source code of the second shader; updating the source code of the first shader to the source code of the second shader, wherein the second shader is based on a light attenuation model and performs lighting effect calculations in a region centered on the light source and with a critical distance as the radius.
[0138] The memory of the electronic device can store the source code of a second shader that corresponds to the first shader and uses the same light attenuation model for lighting rendering. The only difference is that the source code of the second shader has been written to satisfy the target rendering rules, that is, to calculate the lighting effect only in the region centered on the light source with a critical distance as the radius.
[0139] Therefore, electronic devices can directly replace the source code of the shader with the source code of the second shader, which helps to avoid logical errors that may be introduced by adding source code segments due to inappropriate insertion position matching.
[0140] In some embodiments, after updating the source code of the first shader, the method further includes: compiling the source code of the first shader into binary code; and saving the binary code.
[0141] Electronic devices can compile the updated source code of the first shader into binary code and store it in memory, so that the shader's binary code can be directly loaded when the application is launched later, thereby reducing unnecessary source code compilation events and improving the loading speed of the game application.
[0142] S703: Based on the light attenuation model, perform light rendering on the display area centered on the light source and with a critical distance as the radius.
[0143] Electronic devices can perform lighting rendering on a display area centered on the light source and with a critical distance as the radius, based on this light attenuation model.
[0144] In some embodiments, if an electronic device determines an illumination attenuation model according to an instruction, it can perform illumination rendering based on the illumination attenuation model indicated by the instruction and using the critical distance corresponding to the indicated illumination attenuation model.
[0145] In some embodiments, the electronic device determines the lighting attenuation model based on information about the type of lighting attenuation model used for lighting rendering obtained when installing a game application or an updated version of the game application. Lighting rendering can be performed based on the lighting attenuation model indicated by the obtained information, using the critical distance corresponding to the lighting attenuation model.
[0146] In some embodiments, the electronic device determines the light attenuation model by analyzing the source code of the first shader, and can perform lighting rendering on the display area centered on the light source with a critical distance as the radius based on the updated first shader.
[0147] In this way, through the operations of S701-S703 described above, the electronic device can perform lighting rendering on the display area centered on the light source and with a critical distance as the radius. This can reduce the pixel calculations in the lighting rendering of the lighting area that does not make a significant contribution to the final image rendering outside the critical distance, reduce the load on the GPU rendering, effectively reduce computing power consumption, and improve performance.
[0148] Furthermore, in some embodiments, a flag can be set for the binary code stored in the memory, indicating whether the binary code stored in the memory is the updated first shader binary code. If the electronic device reads that the flag indicates that the binary code stored in the memory is not the updated first shader binary code, then the operations described in S701-S703 can be performed.
[0149] It is easy to understand that this implementation method is suitable for scenarios where binary code is already stored in memory. For example, before executing the image processing method of this application, the game application has already created and compiled shaders and stored the compiled binary code in memory. By setting a flag to indicate whether the binary code is the binary code of the updated shader, and executing the above steps of the image processing method of this application when the flag indicates that the binary code is not the binary code of the updated shader, the performance of the game application can be further improved while increasing the loading speed of the game application.
[0150] The image processing method provided in this application can be applied to a user's electronic device. For example, the electronic device can be a portable mobile device with image processing capabilities, such as a mobile phone, tablet computer, personal digital assistant (PDA), augmented reality (AR) / virtual reality (VR) device, or media player. It can also be a wearable electronic device such as a smartwatch. This application does not impose any special limitations on the specific form of the device.
[0151] See Figure 8 , Figure 8 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application.
[0152] Electronic device 800 may include processor 810, external memory interface 820, internal memory 821, universal serial bus (USB) interface 830, charging management module 840, power management module 841, battery 842, antenna 1, antenna 2, mobile communication module 850, wireless communication module 860, audio module 870, speaker 870A, receiver 870B, microphone 870C, headphone jack 870D, sensor module 880, button 890, motor 891, indicator 892, camera 893, display screen 894, and subscriber identification module (SIM) card interface 895, etc. The sensor module 880 may include a pressure sensor 880A, a gyroscope sensor 880B, a barometric pressure sensor 880C, a magnetic sensor 880D, an accelerometer sensor 880E, a distance sensor 880F, a proximity light sensor 880G, a fingerprint sensor 880H, a temperature sensor 880J, a touch sensor 880K, an ambient light sensor 880L, a bone conduction sensor 880M, etc.
[0153] The processor 810 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.
[0154] The controller can be the nerve center and command center of the electronic device 800. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0155] The processor 810 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 810 is a cache memory. This memory can store instructions or data that the processor 810 has just used or that are used repeatedly. If the processor 810 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 810, and thus improves the efficiency of the system. The processor 810 retrieves the instructions or data stored in the memory, causing the electronic device 800 to execute the imaging method performed by the electronic device in the following method embodiments.
[0156] In some embodiments, the processor 810 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0157] The charging management module 840 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger.
[0158] The power management module 841 is used to connect the battery 842, the charging management module 840, and the processor 810. The power management module 841 receives input from the battery 842 and / or the charging management module 840 to power the processor 810, internal memory 821, external memory, display 894, camera 893, and wireless communication module 860, etc. In some other embodiments, the power management module 841 may also be located in the processor 810.
[0159] The wireless communication function of electronic device 800 can be implemented through antenna 1, antenna 2, mobile communication module 850, wireless communication module 860, modem processor and baseband processor, etc.
[0160] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 800 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0161] The mobile communication module 850 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 800. The mobile communication module 850 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 850 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 850 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 850 may be housed in the processor 810. In some embodiments, at least some functional modules of the mobile communication module 850 and at least some modules of the processor 810 may be housed in the same device.
[0162] A modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor.
[0163] The wireless communication module 860 can provide solutions for wireless communication applications on the electronic device 800, including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), BLE broadcasting, global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 860 can be one or more devices integrating at least one communication processing module. The wireless communication module 860 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 810. The wireless communication module 860 can also receive signals to be transmitted from processor 810, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0164] The electronic device can connect to a Bluetooth headset via the wireless communication module 860.
[0165] The display screen 894 is used to display images, videos, etc. The display screen 894 includes a display panel. In some embodiments, the electronic device 800 may include one or N display screens 894, where N is a positive integer greater than 1. The display screen 894 may be an outward-folding screen, i.e., a display screen that folds outwards.
[0166] Electronic device 800 can achieve shooting functions through an ISP, camera 893, video codec, GPU, display 894, and application processor. The ISP processes data fed back by the camera 893. The camera 893 captures still images or videos. The camera 893 may include a front-facing camera and a rear-facing camera; the front-facing camera is located on the display area of the screen, and the rear-facing camera is located on the back area of the screen. The digital signal processor processes digital signals, including digital image signals and other digital signals. The video codec is used to compress or decompress digital video. Electronic device 800 may support one or more video codecs.
[0167] NPU stands for Neural-Network (NN) Computing Processor. By drawing inspiration from the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can quickly process input information and continuously learn on its own.
[0168] The external memory interface 820 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 800. The external memory card communicates with the processor 810 through the external memory interface 820 to perform data storage functions.
[0169] Internal memory 821 can be used to store executable program code, including instructions. Processor 810 executes various functional applications and data processing of electronic device 800 by running the instructions stored in internal memory 821. Internal memory 821 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback), etc. The data storage area may store data created during the use of electronic device 800 (such as audio data), etc. Furthermore, internal memory 821 may include high-speed random access memory and may also include non-volatile memory, such as flash memory devices.
[0170] Electronic device 800 can implement audio functions such as music playback and recording through audio module 870, speaker 870A, receiver 870B, microphone 870C, headphone jack 870D, and application processor.
[0171] The audio module 870 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. The audio module 870 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 870 may be located in the processor 810, or some functional modules of the audio module 870 may be located in the processor 810.
[0172] A speaker 870A, also called a "loudspeaker," is used to convert audio electrical signals into sound signals. A receiver 870B, also called a "handpiece," is used to convert audio electrical signals into sound signals. A microphone 870C, also called a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. A headphone jack 870D is used to connect wired headphones. A pressure sensor 880A is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor 880A may be located on a display screen 894. A gyroscope sensor 880B can be used to determine the motion posture of the electronic device 800. A barometric pressure sensor 880C is used to measure barometric pressure. A magnetic sensor 880D includes a Hall effect sensor. An accelerometer sensor 880E can detect the magnitude of acceleration of the electronic device 800 in various directions (typically three axes). A distance sensor 880F is used to measure distance. A proximity sensor 880G may include, for example, a light-emitting diode (LED) and a photosensor. An ambient light sensor 880L is used to sense ambient light intensity. A fingerprint sensor 880H is used to collect fingerprints. Temperature sensor 880J is used to detect temperature. Touch sensor 880K, also known as a "touch panel," can be located on display screen 894. The touch sensor 880K and display screen 894 together form a touchscreen, also known as a "touch screen." Touch sensor 880K is used to detect touch operations applied to or near it. Bone conduction sensor 880M can acquire vibration signals. Buttons 890 include power button, volume buttons, etc. Motor 891 can generate vibration prompts. Indicator 892 can be an indicator light, used to indicate charging status, battery level changes, messages, missed calls, notifications, etc. SIM card interface 895 is used to connect a SIM card.
[0173] In addition, an operating system runs on top of the aforementioned components. Examples include iOS and Android. The operating system of the electronic device 800 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of the electronic device 800. It should be noted that although this application embodiment uses the Android system as an example for illustration, its basic principles are equally applicable to electronic devices with other operating systems.
[0174] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 800. In other embodiments of this application, the electronic device 800 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0175] In some embodiments, the electronic device may have a layered software architecture, with different layers having their own corresponding modules or components to implement corresponding functions.
[0176] See Figure 9 , Figure 9 This is a schematic diagram of the software architecture of an electronic device provided in an embodiment of this application. In this example, the electronic device may include several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. Taking an electronic device running an (Android) operating system as an example, the system can be divided into multiple layers, from top to bottom: the application layer (referred to as the application layer), the application framework layer (referred to as the framework layer), the system library, and the hardware layer.
[0177] The application layer may include a series of application packages. These application packages may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS. In some embodiments of this application, the application layer may include applications that provide multimedia streaming functionality to the user. For example, the application layer may include various game applications. It may also include various video applications. During the running of these applications that require image rendering (or shading processing in image rendering), the solutions provided in the embodiments of this application can be used to obtain corresponding beneficial effects. The following examples all use running game applications as an example for illustration.
[0178] The framework layer provides application programming interfaces and a programming framework for applications in the application layer. The framework layer includes predefined functions. It can include a window manager, content providers, a view system, a resource manager, a notification manager, an activity manager, an input manager, etc. The window manager provides the WindowManager Service (WMS), which can be used for window management, window animation management, surface management, and as an intermediary for the input system. The content provider stores and retrieves data, making this data accessible to applications. This data can include video, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc. The view system includes visual controls and can be used to build applications. The display interface can consist of one or more views. The resource manager provides various resources to the application. The notification manager allows applications to display notifications in the status bar, which can be used to convey informative messages and can disappear automatically after a short pause without user interaction. The notification manager can also display notifications as icons or scrollbar text in the system's top status bar. The Activity Manager provides the Activity Manager Service (AMS), which manages and schedules system components (such as activities, services, content providers, and broadcast receivers) and application processes. The Input Manager provides the Input Manager Service (IMS), which manages system input, such as touchscreen input, keypad input, and sensor input. IMS retrieves events from input device nodes and, through interaction with the Workflow Management System (WMS), distributes these events to appropriate windows.
[0179] In this embodiment, to implement the image processing method provided in this embodiment, the framework layer may include an interception module, an acquisition module, a matching module, a compilation module, and an update module. In other embodiments, the framework layer may include more or fewer modules to implement the solution provided in this embodiment. For example, if the binary code of the shader is already stored in the electronic device, the framework layer may not need to include a compilation module, and the shader can be run directly by calling the stored binary code.
[0180] The system library can include multiple functional modules. Examples include: a surface manager, a media framework (MediaFramework), a standard C library (libc), OpenGL, an open graphics library for embedded systems (OpenGL for Embedded Systems, OpenGL ES), Vulkan, SQLite, Webkit, etc. In this embodiment, a rendering mechanism based on an OpenGL-based rendering platform is used as an example. In this embodiment, the system library can also include a runtime. For example, a runtime based on the Android system can be the Android runtime. This runtime can provide virtual machine functionality. When the electronic device needs to run various types of code, it can execute these codes in the virtual environment provided by the runtime. For example, during compilation (or pre-compilation), the electronic device can input the source code into the compiler in the runtime, and through the compiler's processing, obtain the corresponding binary code in the current virtual environment. Taking rendering using the OpenGL platform as an example, the electronic device can use the Microsoft-provided FXC HLSL compiler in the Android runtime to compile the source code, and then use a shader bytecode cross-compiler (HLSLcc) to convert the compiled result into GLSL language format for subsequent calls by the graphics library and GPU.
[0181] In this example, the electronic device may also include a hardware layer. For example, the hardware layer may include various hardware components for implementing the functions of the electronic device. For instance, the hardware layer may include a GPU for rendering, a CPU for data processing, and a memory for data storage. The memory may include internal storage media embedded in the CPU or GPU, flash memory with fast read / write capabilities provided in the electronic device, or non-volatile storage media for storing large files.
[0182] Combination Figure 4 For example, in the embodiments of this application, there are such Figure 9 In the software architecture shown, the game application at the application layer can send rendering command streams to the electronic device after the game starts running. Correspondingly, the rendering command streams call the graphics library's interface through the framework layer to execute the corresponding rendering operations. This achieves... Figure 4 The process shown is from creating a shader to linking the program with the shader loaded to the game application.
[0183] It should be noted that, in this embodiment, the electronic device's memory may store a portion of shaders that need to be updated (referred to as shaders to be updated), as well as multiple different types of reference illumination attenuation models. The shaders can perform illumination rendering based on these attenuation models. The electronic device's memory may also store critical distances corresponding to the reference illumination attenuation models for computational radius optimization. The shaders to be updated may be some or all of the shaders that need to be called during application execution. For these shaders to be updated, the electronic device can use the scheme provided in this embodiment to update the original shaders to be loaded on the program based on the critical distances for computational radius optimization. The specific matching and updating process will be described in detail later. This allows the updated shader's source code to be run for illumination rendering during subsequent game application execution, thereby saving power consumption and time overhead in illumination rendering.
[0184] See Figure 10 , Figure 10 This is a schematic flowchart of an image processing method provided in an embodiment of this application. The following will describe the method in conjunction with the foregoing description, which includes the following features: Figure 9 Taking the electronic device with the software architecture shown as an example, the image processing method provided in the embodiments of this application will be described in detail.
[0185] like Figure 10 As shown, a game application can issue a rendering instruction stream during the loading process. This rendering instruction stream can include instructions for creating shaders, instructions for loading the shader source code, instructions for compiling shaders, instructions for creating a program, instructions for loading the shaders onto the program, and instructions for linking the program to the game application. In conjunction with the foregoing description, in some embodiments, the rendering instruction stream may not include instructions for compiling shaders.
[0186] In the solution provided in this application, after the game application begins loading, each instruction in the rendering instruction stream can be intercepted by an interception module. This interception module can be used to intercept the source code of the shaders indicated in the rendering instruction stream issued by the game application. The interception module can also pass the intercepted shader source code to the acquisition module.
[0187] For functions such as glCreateShader, glShaderSource, glCompileShader, glCreateProgram, and glAttachShader involved in the rendering instruction stream, the interception module can call back these instructions to the graphics library to ensure the implementation of the native logic.
[0188] In some embodiments, the interception module can use hook technology to intercept shader source code. For example, when the glShaderSource function loads shader source code into a shader object, the interception module can use the hook function to intercept the glShaderSource instruction, and then the acquisition module can obtain the source code of the shader to be loaded.
[0189] The acquisition module can be used to obtain the source code of the shaders intercepted by the interception module.
[0190] In some embodiments, the acquisition module can acquire the source code to be loaded, thereby facilitating the determination of the number, type, and length of shaders. This number, type, and length of shaders can be used for subsequent shader matching. In some implementations, the acquisition module can first determine the number of shaders, and then further determine the type and length of each shader.
[0191] The acquisition module can transfer the source code of the original shader to the matching module.
[0192] The matching module can be used to match the source code of the original shader from the acquisition module with information such as the original shader's ID, length, type, and string content in order to determine the shader used for lighting rendering and thus determine the lighting attenuation model used by the shader.
[0193] In this example, the matching mechanism can be source code matching based on the source code itself.
[0194] For example, in conjunction with the aforementioned method for updating shaders, the electronic device can store the source code of multiple shaders to be updated, which can be uncompiled source code. The electronic device can also store the source code of multiple different types of illumination attenuation models and their corresponding critical distances.
[0195] In other words, electronic devices can update the shader by using the critical distance corresponding to the lighting attenuation model after determining the type of lighting attenuation model used by the shader through a matching operation.
[0196] In some embodiments, before performing the matching operation, the matching module can read the source code segments of different types of illumination attenuation models analyzed offline and their corresponding critical distances from the memory.
[0197] The matching module can perform matching operations on the source code of the shaders from the acquisition module. For example, the matching module can perform feature matching analysis using source code segments of the original shaders and perform regularization matching with different types of illumination attenuation models.
[0198] In some embodiments of this application, the matching mechanism may further include: the matching module performs length matching based on the length of the source code segment, and performs source code matching only if the length matching is successful.
[0199] In this context, a successful length match means that the two source code segments being matched have exactly the same length. A successful source code match means that all the source code in the two compared source code segments is completely identical or that the regular expressions match. Conversely, a failed match means that the source code in the two compared source code segments differs from at least some of them.
[0200] If a match is successful, the matching module can transmit the determined type of illumination attenuation model and the corresponding critical distance information to the update module for subsequent operations. For example, the matching module can transmit the illumination attenuation model corresponding to the original shader and the corresponding critical distance to the update module.
[0201] Correspondingly, if a match fails, the obtained shader will not be updated.
[0202] The update module can be used to update the current shader information based on the type of illumination attenuation model sent by the matching module and the corresponding critical distance.
[0203] Understandably, when the matching module transmits the type of the illumination attenuation model and the corresponding critical distance to the update module, the update module can determine the computational characteristics of the illumination attenuation model and the corresponding critical distance. Then, the update module can use the illumination attenuation model type and corresponding critical distance information sent by the matching module to update the original shader.
[0204] As one possible implementation, the update module can update the original shader by adding source code segments.
[0205] As one possible implementation, the update module can update the shaders by replacing the operation process of the shader source code.
[0206] After updating the original shader, the update module can transfer the updated shader to the compilation module so that the compilation module can compile the updated shader for subsequent shading operations.
[0207] In the examples above, it is a combination Figure 10 The solution provided in the embodiments of this application will be described from the perspective of module functionality. The following will be combined with... Figure 11 The interaction between the modules shown will be further explained in the embodiments of this application.
[0208] See Figure 11 , Figure 11This is a flowchart illustrating an image processing method provided in an embodiment of this application. The game application can issue rendering command streams. The various modules in the framework layer can cooperate with each other, following the interaction flow below, to implement the solution provided in this embodiment of the application.
[0209] S1101. After the game application sends out the rendering command stream, the interception module can respond to the rendering command stream and intercept the source code of the shader indicated in the rendering command stream.
[0210] In the solution provided in this application, after the game application starts loading, in response to each instruction in the rendering instruction stream, the interception module can intercept the source code of the shader indicated in the rendering instruction stream issued by the game application.
[0211] In some embodiments, the source code of a shader can be loaded into the shader object indicated in the instruction stream through the glShaderSource function. The interception module can intercept the glShaderSource function, thereby intercepting the source code of the shader indicated in the instruction stream.
[0212] S1102. The interception module sends the source code of the intercepted shader to the acquisition module.
[0213] The interception module can send the source code of the intercepted shader to the acquisition module. The source code of this shader is the original source code of the shader.
[0214] S1103, Obtain the source code of the original shader using the module.
[0215] S1104. The acquisition module transmits the source code of the original shader to the matching module.
[0216] S1105, The matching module performs type matching on the shaders.
[0217] In some embodiments, the type of the shader can be queried and matched using the glGetShaderiv function.
[0218] If the type match is successful, for example, when the shader is a fragment shader, execute S1106 below. If the match fails, for example, when the shader is a shader other than a fragment shader, execute S1115-S1116 below.
[0219] S1106, The matching module shader performs feature variable matching.
[0220] For example, the matching module can perform feature variable matching on the Uniform variables of the shader.
[0221] If the feature variable matches successfully, execute S1107. If the match fails, execute S1115-S1116.
[0222] S1107. The matching module performs feature matching on the shader.
[0223] For example, the matching module can perform computational feature matching on the computational features of the shader.
[0224] If the feature match is successful, execute S1108. If the match fails, execute S1115-S1116.
[0225] S1108, The matching module performs regular matching on the shader's features related to the illumination attenuation model.
[0226] The matching module further performs regular matching on the shader with respect to the illumination attenuation model to determine the illumination attenuation model used by the shader.
[0227] If the illumination attenuation model regularization match is successful and the illumination attenuation model used by the shader can be determined, execute S1109 below. If the match fails, execute S1115-S1116 below.
[0228] S1109. The matching module transmits the determined type of illumination attenuation model to the update module, and the update module reads the critical distance information corresponding to the determined type of illumination attenuation model from the memory.
[0229] S1110, The update module updates the shader based on the determined type of illumination attenuation model and the relevant information of the corresponding critical distance.
[0230] S1111, The update module sends the updated shader source code to the compilation module.
[0231] S1112. The compilation module compiles the source code of the updated shader.
[0232] S1113, The compilation module stores the binary code of the updated shader.
[0233] S1114. The compilation module sends the compiled binary code to the graphics library.
[0234] The binary code compiles an updated shader that is based on a light attenuation model and performs lighting rendering on a display area centered on the light source with a critical distance as its radius.
[0235] S1115. The matching module sends a matching failure message to the interception module.
[0236] S1116. The interception module transmits the rendering instruction stream to the graphics library.
[0237] The solutions in S1115 and S1116 enable the original shader to be used for coloring operations in the event of a matching failure, thus maintaining the original logic for subsequent calls.
[0238] This completes the shader update process during the loading phase. The updated shader can then be invoked to perform shading operations during subsequent game execution.
[0239] Through the above Figure 10 as well as Figure 11 The description of the solution should provide a comprehensive understanding for those skilled in the art. The example used is source code matching.
[0240] In some other embodiments of this application, matching can also be based on binary code.
[0241] For example, the length information can be the binary length of the shader to be updated, and the corresponding updated shader code can also be stored as binary code. In this way, after determining the updated shader through length matching and binary matching, the corresponding updated shader's binary code can be directly called without needing to compile it through the compilation module. This can further reduce rendering time overhead.
[0242] Understandably, in different scenarios, either a binary-based replacement scheme or a source code-based replacement scheme can be chosen depending on the needs. Specifically, in scenarios where improving rendering efficiency is a priority, a binary replacement scheme can be adopted. In scenarios where storage space is a concern, since the amount of source code is generally less than the corresponding binary code, a source code-based replacement scheme can be used.
[0243] The foregoing mainly describes the solutions provided by the embodiments of this application from the perspective of each module. To achieve the above functions, it includes the corresponding hardware structure and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware 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 this application.
[0244] Figure 12This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 1200 can be used to implement the methods described in the above method embodiments, and for details, please refer to the description in the above method embodiments.
[0245] Electronic device 1200 may include one or more processors 1201. Processor 1201 may be a general-purpose processor or a special-purpose processor. For example, it may be a central processing unit (CPU) used to control image processing, execute software programs, and process data from the software programs.
[0246] Optionally, the electronic device 1200 may include one or more memories 1202, which may store instructions that can be executed on the processor 1201, causing the electronic device 1200 to perform the methods described in the above method embodiments. Optionally, the memories 1202 may also store data. The processor 1201 and the memories 1202 may be provided separately or integrated together.
[0247] Figure 13 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application. Figure 13 The image processing device 1300 shown may be an electronic device, a device within an electronic device, or a device that can be used in conjunction with an electronic device. Figure 13 The image processing apparatus 1300 shown may include a determining unit 1301 and a processing unit 1302. Wherein:
[0248] The determination unit 1301 is used to determine the type of the light attenuation model. The light attenuation model is used for lighting rendering centered on the light source, so that the light intensity centered on the light source changes with the distance from the light source.
[0249] The determining unit 1301 is also used to determine the critical distance corresponding to the light attenuation model based on the type of light attenuation model, wherein the light intensity corresponding to the critical distance is greater than zero.
[0250] The processing unit 1302 is used to perform lighting rendering on a display area centered on the light source and with a critical distance as the radius, based on a light attenuation model.
[0251] In one possible implementation, the image processing apparatus 1300 may further include an acquisition unit for acquiring the source code of the first shader; and a determination unit 1301 for determining the type of illumination attenuation model based on the source code of the first shader.
[0252] In one possible implementation, the image processing apparatus 1300 may further include a matching unit for performing feature matching on the source code of the first shader, and a determining unit 1301 for determining that the first shader is used for lighting rendering, wherein the feature matching includes variable feature matching and computational feature matching; performing regular matching on the source code of the first shader with multiple reference lighting attenuation models of different types respectively, determining a first reference lighting attenuation model that is regularly matched with the lighting attenuation model used in the source code of the first shader; and determining the type of the first reference lighting attenuation model as the type of lighting attenuation model.
[0253] In one possible implementation, the image processing apparatus 1300 may further include an interception unit and an update unit. The interception unit is used to intercept the source code of the first shader when it is being loaded, and the acquisition unit is used to acquire the source code of the first shader. After determining the type of the illumination attenuation model based on the source code of the first shader, the update unit is used to update the source code of the first shader to update the rendering rules to the target rendering rules. The target rendering rules are based on the illumination attenuation model and perform illumination rendering on the display area centered on the light source and with a critical distance as the radius.
[0254] In one possible implementation, the update unit is used to add a source code segment to the source code of the first shader so that the first shader calculates the lighting effect in a region centered on the light source and with a critical distance as the radius, based on the light attenuation model.
[0255] In one possible implementation, the acquisition unit is used to acquire the source code of the second shader; the update unit is used to update the source code of the first shader to the source code of the second shader. The second shader is based on the light attenuation model and performs lighting effect calculations in a region centered on the light source and with a critical distance as the radius.
[0256] In one possible implementation, the image processing apparatus 1300 may further include a compilation unit. After the update unit updates the source code of the first shader, the compilation unit is used to compile the source code of the first shader into binary code and save the binary code.
[0257] For cases where the image processing device can be a chip or a chip system, see [link to relevant documentation]. Figure 14 The diagram shows the structure of the chip. Figure 14 The chip 1400 shown includes a processor 1401 and an interface 1402. Optionally, it may also include a memory 1403. The number of processors 1401 can be one or more, and the number of interfaces 1402 can be multiple.
[0258] For cases where the chip is used to implement the electronic device in the embodiments of this application:
[0259] Interface 1402 is used to receive or output signals;
[0260] Processor 1401 is used to perform data processing operations of electronic devices.
[0261] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0262] It is understood that some optional features in the embodiments of this application can be implemented independently in certain scenarios without relying on other features, such as the current solution on which they are based, to solve the corresponding technical problems and achieve the corresponding effects. Alternatively, they can be combined with other features as needed in certain scenarios. Accordingly, the image processing apparatus given in the embodiments of this application can also implement these features or functions, which will not be elaborated here.
[0263] It should be understood that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method embodiments can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0264] It is understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0265] This application also provides a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed on an electronic device, implement the functions of any of the above method embodiments.
[0266] This application also provides a computer program product that, when run on a computer, enables the computer to perform the functions of any of the above method embodiments.
[0267] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs (DVDs)), or semiconductor media (e.g., solid-state disks (SSDs)).
[0268] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image processing method, characterized in that, The method includes: The type of illumination attenuation model is determined, which is used for illumination rendering centered on the light source, such that the illumination intensity centered on the light source varies with the distance from the light source; Based on the type of the light attenuation model, determine the critical distance corresponding to the light attenuation model, where the light intensity at the critical distance is greater than zero. Based on the aforementioned light attenuation model, lighting rendering is performed on the display area centered on the light source and with the critical distance as its radius. The determination of the type of illumination attenuation model includes: Obtain the source code of the first shader; Based on the source code of the first shader, determine the type of illumination attenuation model. And wherein, determining the type of illumination attenuation model based on the source code of the first shader includes: The source code of the first shader is subjected to feature matching to determine that the first shader is used for lighting rendering, wherein the feature matching includes variable feature matching and computational feature matching; The source code of the first shader is matched with multiple different types of reference illumination attenuation models using regular expressions to determine the first reference illumination attenuation model that is regularly matched with the illumination attenuation model used in the source code of the first shader. The type of the first reference illumination attenuation model is determined as the type of the illumination attenuation model.
2. The method according to claim 1, characterized in that, The step of obtaining the source code of the first shader includes: When loading the source code of the first shader, the loaded source code of the first shader is intercepted and the source code of the first shader is obtained. After determining the type of illumination attenuation model based on the source code of the first shader, the method further includes: The source code of the first shader is updated to update the rendering rules to the target rendering rules, which are based on the light attenuation model and perform lighting rendering on the display area centered on the light source and with the critical distance as the radius.
3. The method according to claim 2, characterized in that, The update of the source code of the first shader includes: Add a source code segment to the source code of the first shader so that the first shader calculates the lighting effect in a region centered on the light source and with a critical distance as the radius, based on the lighting attenuation model.
4. The method according to claim 2, characterized in that, The update of the source code of the first shader includes: Obtain the source code for the second shader; The source code of the first shader is updated to the source code of the second shader. The second shader calculates the lighting effect in a region centered on the light source and with a critical distance as the radius, based on the light attenuation model.
5. The method according to any one of claims 2-4, characterized in that, After updating the source code of the first shader, the method further includes: Compile the source code of the first shader into binary code; Save the binary code.
6. An image processing apparatus, characterized in that, include: A determining unit is used to determine the type of the illumination attenuation model, which is used for illumination rendering centered on a light source, such that the illumination intensity centered on the light source varies with the distance from the light source. The determining unit is further configured to determine the critical distance corresponding to the illumination attenuation model based on the type of the illumination attenuation model, wherein the illumination intensity corresponding to the critical distance is greater than zero; The processing unit is configured to perform lighting rendering on a display area centered on the light source and with the critical distance as its radius, based on the lighting attenuation model. The determination of the type of illumination attenuation model includes: Obtain the source code of the first shader; Based on the source code of the first shader, determine the type of illumination attenuation model. And wherein, determining the type of illumination attenuation model based on the source code of the first shader includes: The source code of the first shader is subjected to feature matching to determine that the first shader is used for lighting rendering, wherein the feature matching includes variable feature matching and computational feature matching; The source code of the first shader is matched with multiple different types of reference illumination attenuation models using regular expressions to determine the first reference illumination attenuation model that is regularly matched with the illumination attenuation model used in the source code of the first shader. The type of the first reference illumination attenuation model is determined as the type of the illumination attenuation model.
7. An electronic device comprising one or more memories and one or more processors, characterized in that, The memory is used to store a computer program; the processor is used to invoke the computer program to cause the electronic device to perform the method of any one of claims 1-5.
8. A chip system for use in electronic devices, characterized in that, The chip system includes at least one processor and an interface for receiving instructions and transmitting them to the at least one processor; the at least one processor executes the instructions to cause the electronic device to perform the method as described in any one of claims 1-5.
9. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-5.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Image processing method and electronic device
WO2023093212A1