CN112612459A - Cross-platform shader language configuration method - Google Patents
Cross-platform shader language configuration method Download PDFInfo
- Publication number
- CN112612459A CN112612459A CN202011581152.7A CN202011581152A CN112612459A CN 112612459 A CN112612459 A CN 112612459A CN 202011581152 A CN202011581152 A CN 202011581152A CN 112612459 A CN112612459 A CN 112612459A
- Authority
- CN
- China
- Prior art keywords
- engine
- unity
- model
- realbox
- illumination model
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 17
- 238000005286 illumination Methods 0.000 claims abstract description 63
- 238000009877 rendering Methods 0.000 claims abstract description 31
- 238000013507 mapping Methods 0.000 claims description 12
- 239000000463 material Substances 0.000 claims description 9
- 239000002966 varnish Substances 0.000 claims description 9
- 238000004364 calculation method Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 claims description 3
- 230000000694 effects Effects 0.000 abstract description 9
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/34—Graphical or visual programming
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/35—Creation or generation of source code model driven
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/20—Processor architectures; Processor configuration, e.g. pipelining
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Image Generation (AREA)
Abstract
The invention discloses a cross-platform shader language configuration method, which relates to the technical field of computers, and is characterized in that a GLSL (generic markup language) language of a rendering algorithm of a Unity engine is converted into an HLSL (high level markup language) language at a Unity engine end according to the rendering algorithm of the realbox engine, a precompilation head is additionally arranged in the Unity engine according to a macro branch of a shader language controlled in the realbox engine, and an illumination model of the realbox engine is improved at the Unity engine end according to GPU (graphics processing unit) architectures of different platforms, so that the illumination model of the realbox engine is matched with the illumination model of the Unity engine, the problem of inconsistent rendering effect between the Unity engine and the realbox engine is solved, and the consistency of the rendering effect under the GPU architectures of different platforms can be ensured.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a cross-platform shader language configuration method.
Background
Different architectures among different engines lead each engine to have a set of shader compiling system, wherein the real engine uses macros to dynamically generate and compile shader languages, and the Unity engine uses an entire shader code to compile, so that the problem that rendering effects are inconsistent between the Unity engine and the real engine and the problem that rendering effects are inconsistent under GPU architectures of different platforms exist.
Disclosure of Invention
To solve the deficiencies of the prior art, an embodiment of the present invention provides a cross-platform shader language configuration method, including the following steps:
at the Unity engine end, converting the rendering algorithm of the Unity engine from GLSL language to HLSL language according to the rendering algorithm of the Realibox engine;
adding a precompiled header in the Unity engine according to the macro branch of the shader language controlled in the Realibox engine;
and at the Unity engine end, improving an illumination model of the Realibox engine according to GPU architectures of different platforms, so that the illumination model of the Realibox engine is matched with the illumination model of the Unity engine.
Preferably, the converting the rendering algorithm of the Unity engine from the GLSL language to the HLSL language according to the rendering algorithm of the realbox engine includes:
and at the Unity engine end, respectively writing corresponding HLSL languages according to GLSL languages corresponding to the PBR material, the automotive varnish algorithm model, the IBL algorithm model, the MatCap algorithm model, the point light source model and the spotlight model of the Realibox engine.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine includes:
identifying a current platform according to the pre-compiling header;
simulating the calculation of the real plane mapping to the sphere by using the numerical value of the plane mapping to the sphere;
for the MatCap algorithm, the mapping from a plane to a spherical surface is used at the mobile terminal, and the mapping from Cartesian coordinates to spherical coordinates is used at the PC terminal.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine so that the illumination model of the realbox engine matches with the illumination model of the Unity engine further includes:
for a component whose rendering consumption performance is greater than a set threshold, dynamically controlling a rendering switch of the component according to a camera in a scene, specifically comprising:
the number of main light sources and additional light sources of a scene are set in a Unity engine, which dynamically renders lighting according to the distance between the lighting position and the camera position.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine so that the illumination model of the realbox engine matches with the illumination model of the Unity engine further includes:
and removing the dynamic branch in the original Realibox engine, judging which part of numerical values are selected by using a step function built in the HLSL language, and reducing the performance consumption of the dynamic branch in a GPU architecture.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine so that the illumination model of the realbox engine matches with the illumination model of the Unity engine further includes:
and modifying the secondarily converged light attenuation model built in the Unity into the primary convergence of the Realibox engine, and modifying the light brightness of the Unity engine into the primary convergence.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine so that the illumination model of the realbox engine matches with the illumination model of the Unity engine further includes:
and adding the automobile varnish algorithm in the Realibox engine into the Unity material system, and switching varnish on and off the material appearance through the precompiled head.
Preferably, at the Unity engine end, according to GPU architectures of different platforms, improving an illumination model of the realbox engine so that the illumination model of the realbox engine matches with the illumination model at the Unity engine end further includes:
determining the thickness degree of the sky box seam according to the Mipmap detail degree of the sky box;
according to the size of three components of Cartesian coordinates, a seam repair datum plane is determined, and the other two components are subjected to certain offset according to MipMap reciprocal values.
The cross-platform shader language configuration method provided by the embodiment of the invention has the following beneficial effects:
(1) the problem that rendering effects between the Unity engine and the Realibox engine are inconsistent is solved;
(2) the consistency of rendering effects under GPU architectures of different platforms can be ensured.
Detailed Description
The present invention will be described in detail with reference to the following embodiments.
The cross-platform shader language configuration method provided by the embodiment of the invention comprises the following steps:
s101, converting a rendering algorithm of the Unity engine from a GLSL language to an HLSL language at the Unity engine end according to the rendering algorithm of the Realibox engine;
s102, adding a precompilation head in the Unity engine according to the macro branch of the shader language controlled in the Realibox engine;
and S103, at the Unity engine end, improving the illumination model of the Realibox engine according to the GPU architectures of different platforms, so that the illumination model of the Realibox engine is matched with the illumination model of the Unity engine.
Wherein, different platforms include PC end and removal end.
Optionally, converting the rendering algorithm of the Unity engine from the GLSL language to the HLSL language according to the rendering algorithm of the realbox engine includes:
and at the Unity engine end, respectively writing corresponding HLSL languages according to GLSL languages corresponding to the PBR material, the automotive varnish algorithm model, the IBL algorithm model, the MatCap algorithm model, the point light source model and the spotlight model of the Realibox engine.
Optionally, at the Unity engine end, improving an illumination model of the realbox engine according to GPU architectures of different platforms, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine includes:
identifying a current platform according to the pre-compiling header;
simulating the calculation of the real plane mapping to the sphere by using the numerical value of the plane mapping to the sphere;
for the MatCap algorithm, the mapping from a plane to a spherical surface is used at the mobile terminal, and the mapping from Cartesian coordinates to spherical coordinates is used at the PC terminal.
Optionally, at the Unity engine end, improving an illumination model of the realbox engine according to GPU architectures of different platforms, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine further includes:
for a component whose rendering consumption performance is greater than a set threshold, dynamically controlling a rendering switch of the component according to a camera in a scene, specifically comprising:
the number of main light sources and additional light sources of a scene are set in a Unity engine, which dynamically renders lighting according to the distance between the lighting position and the camera position.
Optionally, at the Unity engine end, improving an illumination model of the realbox engine according to GPU architectures of different platforms, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine further includes:
and removing the dynamic branch in the original Realibox engine, judging which part of numerical values are selected by using a step function built in the HLSL language, and reducing the performance consumption of the dynamic branch in a GPU architecture.
Under the condition that the rendering effect is not changed, the same set of algorithms of different versions are dynamically used according to different platforms, for example, a pre-calculated approximate value or a texture is searched at a mobile terminal, so that the performance is saved.
Optionally, at the Unity engine end, improving an illumination model of the realbox engine according to GPU architectures of different platforms, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine further includes:
and modifying the secondarily converged light attenuation model built in the Unity into the primary convergence of the Realibox engine, and modifying the light brightness of the Unity engine into the primary convergence.
Optionally, at the Unity engine end, improving an illumination model of the realbox engine according to GPU architectures of different platforms, so that matching the illumination model of the realbox engine with the illumination model of the Unity engine further includes:
and adding the automobile varnish algorithm in the Realibox engine into the Unity material system, and switching varnish on and off the material appearance through the precompiled head.
Optionally, at the Unity engine end, improving the illumination model of the realbox engine according to GPU architectures of different platforms, so that the matching between the illumination model of the realbox engine and the illumination model of the Unity engine end further includes:
determining the thickness degree of the sky box seam according to the Mipmap detail degree of the sky box;
according to the size of three components of Cartesian coordinates, a seam repair datum plane is determined, and the other two components are subjected to certain offset according to MipMap reciprocal values.
According to the cross-platform shader language configuration method provided by the embodiment of the invention, the rendering algorithm of the Unity engine is converted into the HLSL language from the GLSL language according to the rendering algorithm of the Realibox engine at the Unity engine end, the precompiling head is additionally arranged in the Unity engine according to the macro branch of the shader language controlled in the Realibox engine, and the illumination model of the Realibox engine is improved at the Unity engine end according to the GPU architectures of different platforms, so that the illumination model of the Realibox engine is matched with the illumination model of the Unity engine, the problem of inconsistent rendering effect between the Unity engine and the Realibox engine is solved, and the consistency of the rendering effect under the GPU architectures of different platforms can be ensured.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims (8)
1. A cross-platform shader language configuration method, comprising:
at the Unity engine end, converting the rendering algorithm of the Unity engine from GLSL language to HLSL language according to the rendering algorithm of the Realibox engine;
adding a precompiled header in the Unity engine according to the macro branch of the shader language controlled in the Realibox engine;
and at the Unity engine end, improving an illumination model of the Realibox engine according to GPU architectures of different platforms, so that the illumination model of the Realibox engine is matched with the illumination model of the Unity engine.
2. The method of claim 1, wherein converting the rendering algorithm of the Unity engine from the GLSL language to the HLSL language according to the rendering algorithm of the realbox engine comprises:
and at the Unity engine end, respectively writing corresponding HLSL languages according to GLSL languages corresponding to the PBR material, the automotive varnish algorithm model, the IBL algorithm model, the MatCap algorithm model, the point light source model and the spotlight model of the Realibox engine.
3. The method of claim 2, wherein the improving the lighting model of the realbox engine at the Unity engine according to the GPU architectures of different platforms so that the lighting model of the realbox engine matches the lighting model of the Unity engine comprises:
identifying a current platform according to the pre-compiling header;
simulating the calculation of the real plane mapping to the sphere by using the numerical value of the plane mapping to the sphere;
for the MatCap algorithm, the mapping from a plane to a spherical surface is used at the mobile terminal, and the mapping from Cartesian coordinates to spherical coordinates is used at the PC terminal.
4. The method of claim 2, wherein at the Unity engine end, the modifying the illumination model of the realbox engine according to the GPU architecture of different platforms, such that the illumination model of the realbox engine matches the illumination model of the Unity engine, further comprises:
for a component whose rendering consumption performance is greater than a set threshold, dynamically controlling a rendering switch of the component according to a camera in a scene, specifically comprising:
the number of main light sources and additional light sources of a scene are set in a Unity engine, which dynamically renders lighting according to the distance between the lighting position and the camera position.
5. The method of claim 2, wherein at the Unity engine end, the modifying the illumination model of the realbox engine according to the GPU architecture of different platforms, such that the illumination model of the realbox engine matches the illumination model of the Unity engine, further comprises:
and removing the dynamic branch in the original Realibox engine, judging which part of numerical values are selected by using a step function built in the HLSL language, and reducing the performance consumption of the dynamic branch in a GPU architecture.
6. The method of claim 2, wherein at the Unity engine end, the modifying the illumination model of the realbox engine according to the GPU architecture of different platforms, such that the illumination model of the realbox engine matches the illumination model of the Unity engine, further comprises:
and modifying the secondarily converged light attenuation model built in the Unity into the primary convergence of the Realibox engine, and modifying the light brightness of the Unity engine into the primary convergence.
7. The method of claim 2, wherein at the Unity engine end, the modifying the illumination model of the realbox engine according to the GPU architecture of different platforms, such that the illumination model of the realbox engine matches the illumination model of the Unity engine, further comprises:
and adding the automobile varnish algorithm in the Realibox engine into the Unity material system, and switching varnish on and off the material appearance through the precompiled head.
8. The method of claim 2, wherein at the Unity engine end, the modifying the lighting model of the realbox engine according to the GPU architecture of the different platforms, such that the lighting model of the realbox engine matches the lighting model of the Unity engine end, further comprises:
determining the thickness degree of the sky box seam according to the Mipmap detail degree of the sky box;
according to the size of three components of Cartesian coordinates, a seam repair datum plane is determined, and the other two components are subjected to certain offset according to MipMap reciprocal values.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011581152.7A CN112612459B (en) | 2020-12-28 | 2020-12-28 | Cross-platform shader language configuration method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011581152.7A CN112612459B (en) | 2020-12-28 | 2020-12-28 | Cross-platform shader language configuration method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112612459A true CN112612459A (en) | 2021-04-06 |
CN112612459B CN112612459B (en) | 2024-03-22 |
Family
ID=75248342
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011581152.7A Active CN112612459B (en) | 2020-12-28 | 2020-12-28 | Cross-platform shader language configuration method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112612459B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114077433A (en) * | 2021-11-18 | 2022-02-22 | 大连东软信息学院 | Cross-platform modular shader language general integration method |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111796867A (en) * | 2019-07-11 | 2020-10-20 | 厦门雅基软件有限公司 | Shader conversion method and device and electronic equipment |
CN111813380A (en) * | 2019-04-29 | 2020-10-23 | 厦门雅基软件有限公司 | Coloring data processing method and device based on game engine and electronic equipment |
-
2020
- 2020-12-28 CN CN202011581152.7A patent/CN112612459B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111813380A (en) * | 2019-04-29 | 2020-10-23 | 厦门雅基软件有限公司 | Coloring data processing method and device based on game engine and electronic equipment |
CN111796867A (en) * | 2019-07-11 | 2020-10-20 | 厦门雅基软件有限公司 | Shader conversion method and device and electronic equipment |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114077433A (en) * | 2021-11-18 | 2022-02-22 | 大连东软信息学院 | Cross-platform modular shader language general integration method |
CN114077433B (en) * | 2021-11-18 | 2024-05-03 | 大连东软信息学院 | Cross-platform modularized shader language universal integration method |
Also Published As
Publication number | Publication date |
---|---|
CN112612459B (en) | 2024-03-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100742419B1 (en) | Systems and methods for implementing shader-driven compilation of rendering assets | |
US7773087B2 (en) | Dynamically configuring and selecting multiple ray tracing intersection methods | |
US8004518B2 (en) | Combined spatial index for static and dynamic objects within a three-dimensional scene | |
US7940265B2 (en) | Multiple spacial indexes for dynamic scene management in graphics rendering | |
KR101386180B1 (en) | System and method for using a secondary processor in a graphics system | |
US8284195B2 (en) | Cooperative utilization of spatial indices between application and rendering hardware | |
US6400842B2 (en) | Image processing apparatus and image processing method | |
CN112612459B (en) | Cross-platform shader language configuration method | |
US11610364B2 (en) | Method, device, and storage medium for applying lighting to a rendered object in a scene | |
CN111915712B (en) | Illumination rendering method and device, computer readable medium and electronic equipment | |
US11995759B2 (en) | Adaptive ray tracing suitable for shadow rendering | |
CN103310488A (en) | mental ray rendering-based virtual reality rendering method | |
CN112215938B (en) | Method and device for generating reflected illumination data in game and computer equipment | |
JP2023547224A (en) | Image-based lighting effect processing method, apparatus, device and storage medium | |
CN113344766A (en) | Ray tracing processor, processor chip, equipment terminal and ray tracing method | |
CN112750189A (en) | Illumination coloring method and device, electronic equipment and computer readable storage medium | |
CN114332203A (en) | Method and device for determining light source information of virtual light source | |
US20110032258A1 (en) | Source code generator for a graphics card | |
CN111767046A (en) | Shader code multiplexing method and terminal | |
GB2432499A (en) | Image generation of objects distant from and near to a virtual camera | |
CN114077433B (en) | Cross-platform modularized shader language universal integration method | |
Öztürk et al. | Semi-dynamic light maps | |
CN114937119A (en) | BRDF rendering method based on directional scattering micro-surface material | |
CN112927342B (en) | Illumination calculation method and fixed pipeline rendering and programmable pipeline rendering methods | |
CA2185915A1 (en) | Bump mapping in 3-d computer graphics |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |