The invention discloses a cross-platform modularized
shader language general integration method which comprises the following steps: defining the format and grammar of a
macro definition analysis file, and creating the
macro definition analysis file; creating a grammar parser
Shader-X, and pre-compiling a
shader file by using the
Shader-X parser; analyzing the
macro definition analysis file, generating a macro definition
result set, and generating a macro definition result ordered
list according to the macro definition
result set; respectively calculating hash values of the ordered
list of the macro definition results, generating
shader files of the platforms corresponding to the macro definition results respectively according to the macro definition results, pre-compiling the shader files into binary files through a
Shader-X analyzer, and marking the binary files through the Hash values of the macro definition results and the platforms; and locating and executing the binary file by the rendering program according to the hash value of the macro definition result ordered
list and the platform. The same shader code can be used on different platforms, online compiling is not needed, a
modular programming scheme is supported, and the shader
programming efficiency is improved.