Shader code multiplexing method and terminal

A code reuse and shader technology, which is applied in the shader code reuse method and the terminal field, can solve the problems of increasing system overhead, reducing shader execution efficiency, and failing to achieve rendering effects, etc., to achieve the effect of increasing consumption

Pending Publication Date: 2020-10-13
FUJIAN TQ DIGITAL
View PDF4 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0002] When rendering images, you need to use shaders. Shaders have the advantage of being editable, and can achieve various image effects in 3D image rendering without being limited by the fixed rendering pipeline of the graphics card, which greatly improves the image quality. Image quality; using a shader source code to achieve different rendering effects, mainly by adjusting or introducing shader parameters, by modifying or introducing variables, it may introduce GPU (Graphics Processing Unit, graphics processing unit) calculation branches or increase instructions number, reducing the overall execution efficiency of the shader; and modifying or introducing variables cannot achieve all rendering effects. Sometimes it is necessary to change the source code of the shader or the parsing method of the source code to achieve some rendering effects, but directly modify the source code of the shader Doubling the development and maintenance cost of the shader, changing the parsing method of the shader source code increases additional system overhead

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Shader code multiplexing method and terminal
  • Shader code multiplexing method and terminal
  • Shader code multiplexing method and terminal

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0071] Please refer to figure 1 , Embodiment 1 of the present invention is:

[0072] A shader code reuse method, specifically comprising:

[0073] S1. Obtain a shader macro in the shader source code;

[0074] S2. Classify the shader macros according to their functions, and generate a shader macro combination;

[0075] Please refer to Figure 5 , classifying the shader macros into global macros, local macros, light macros and real-time macros;

[0076] Global macros: apply to all shaders, control the basic rendering framework logic of shaders, such as lighting model-related calculation processes, shadow calculation processes, fog calculation processes, platform-related calculation processes, rendering quality, etc.;

[0077] Local macros: act on a single shader to control the calculation logic of shader special effects, such as vertex animation special effects, ripple special effects, dissolution special effects, etc.;

[0078] Lighting macro: applies to all shaders, contr...

Embodiment 2

[0102] A shader code reuse method, which differs from Embodiment 1 in that:

[0103] In S3, according to the actual rendering task, the corresponding shader macro combination is selected, and the shader macro combination set is generated specifically as follows:

[0104] According to the actual rendering task, select a shader macro combination in each shader macro category;

[0105] generating a shader macro combination set according to a shader combination selected in each shader macro category;

[0106] According to the actual rendering task, select the corresponding shader macro combination, and generate the shader macro combination set including:

[0107] Analyzing the completed rendering task, selecting a corresponding shader macro combination according to the analysis result of the completed rendering task, and generating a preconfigured shader macro combination set according to the selected shader macro combination;

[0108] According to the actual rendering task, sel...

Embodiment 3

[0115] Apply the above shader code reuse method to the actual scene:

[0116] Need to render a scene with configurable quality level, obtain the shader macro in the shader source code, such as: PBR lighting model calculation macro, Phong lighting model calculation macro, fog calculation macro, quality level macro, skin calculation Macros, Outer Glow Mapping Macros, Lighting Calculation Macros, Point Light Number Macros, and Bloom Macros;

[0117] Classify the above shader macros

[0118] Global macro: PBR lighting model calculation macro, Phong lighting model calculation macro, fog calculation macro, image quality level macro;

[0119] Local macros: skinning calculation macros, outer light texture macros, lighting calculation macros;

[0120] Light macro: point light source number macro;

[0121] Live macro: flood macro;

[0122] Generate shader macro combinations:

[0123] Global macro combination 1: PBR lighting model calculation macro, Phong lighting model calculation ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention provides a shader source code multiplexing method and a terminal. The shader source code multiplexing method comprises the following steps: acquiring a shader macro in a shader source code; classifying the shader macros according to functions to generate shader macro combinations; selecting a corresponding shader macro combination according to an actual rendering task, generating a shader macro combination set, and defining the shader macro combination set in the shader source code; compiling the shader source code defining the shader macro combination set to obtain a shader, andrendering an image through the shader; and obtaining the shader macro in the shader source code, and achieving different computing logics by changing the shader macro combination set, namely different shader is generated to achieve different rendering effects, and the different rendering effects can be achieved without modifying the shader source code or changing the analysis mode of the shader source code.

Description

technical field [0001] The invention relates to the field of shaders, in particular to a shader code multiplexing method and a terminal. Background technique [0002] When rendering images, you need to use shaders. Shaders have the advantage of being editable, and can achieve various image effects in 3D image rendering without being limited by the fixed rendering pipeline of the graphics card, which greatly improves the image quality. Image quality; using a shader source code to achieve different rendering effects, mainly by adjusting or introducing shader parameters, by modifying or introducing variables, it may introduce GPU (Graphics Processing Unit, graphics processing unit) calculation branches or increase instructions number, reducing the overall execution efficiency of the shader; and modifying or introducing variables cannot achieve all rendering effects. Sometimes it is necessary to change the source code of the shader or the parsing method of the source code to ach...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
IPC IPC(8): G06F8/36G06F8/41G06T11/00
CPCG06F8/36G06F8/41G06T11/001Y02D10/00
Inventor 刘德建涂智业范堂舢陈宏展
Owner FUJIAN TQ DIGITAL
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products