[Fix] (Shader): Implement a comprehensive compatibility patch for mod…#9
Open
DHJComical wants to merge 1 commit intoBZLZHH:mainfrom
Open
[Fix] (Shader): Implement a comprehensive compatibility patch for mod…#9DHJComical wants to merge 1 commit intoBZLZHH:mainfrom
DHJComical wants to merge 1 commit intoBZLZHH:mainfrom
Conversation
…ern desktop GLSL shaders on GLES 3.x This commit resolves a series of critical compilation and linking errors that occurred when trying to run modern desktop GLSL shaders (e.g., from Minecraft shader packs) on an OpenGL ES 3.x environment. The previous shader converter was insufficient, leading to multiple failures. A new, robust patching mechanism has been added to `gl4es_glShaderSource` to perform a full "modernization" pass on shaders before compilation. Key fixes include: - **GLSL Version:** Automatically replaces desktop GLSL versions (e.g., `#version 330 core`) with a compatible GLES version (e.g., `#version 320 es`). - **Input/Output Keywords:** - Replaces `attribute` with `in` in vertex shaders. - Replaces `varying` with `out` in vertex shaders. - Replaces `varying` with `in` in fragment shaders. - **Built-in Variables:** - Replaces legacy output variables `gl_FragColor` and `gl_FragData[0]` with a custom, correctly declared `out` variable (`fragColor`). - Intelligently inserts the `out` variable declaration only if it doesn't already exist. - **Built-in Functions:** Replaces legacy `texture2D()` calls with the modern `texture()` equivalent. - **GLES Specifics:** Automatically adds the mandatory `precision highp float;` qualifier to fragment shaders to prevent precision-related compile errors on mobile platforms. - **Insertion Logic:** Employs an intelligent insertion method to ensure declarations are placed after all preprocessor directives, fixing self-induced syntax errors. These changes collectively allow complex shaders, which previously failed, to be correctly converted, compiled, linked, and rendered successfully.
Owner
|
5d6479b 可能是一个相同的功能,请测试一下这一个commit能否解决你的问题 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ern desktop GLSL shaders on GLES 3.x
This commit resolves a series of critical compilation and linking errors that occurred when trying to run modern desktop GLSL shaders (e.g., from Minecraft shader packs) on an OpenGL ES 3.x environment.
The previous shader converter was insufficient, leading to multiple failures. A new, robust patching mechanism has been added to
gl4es_glShaderSourceto perform a full "modernization" pass on shaders before compilation.Key fixes include:
#version 330 core) with a compatible GLES version (e.g.,#version 320 es).attributewithinin vertex shaders.varyingwithoutin vertex shaders.varyingwithinin fragment shaders.gl_FragColorandgl_FragData[0]with a custom, correctly declaredoutvariable (fragColor).outvariable declaration only if it doesn't already exist.texture2D()calls with the moderntexture()equivalent.precision highp float;qualifier to fragment shaders to prevent precision-related compile errors on mobile platforms.These changes collectively allow complex shaders, which previously failed, to be correctly converted, compiled, linked, and rendered successfully.