-
Notifications
You must be signed in to change notification settings - Fork 433
WGSL/WebGPU GLSL ShaderGenerator #2407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jstone-lucasfilm
merged 30 commits into
AcademySoftwareFoundation:main
from
scotbrew:brews/feature/wgsl
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
58208f2
WGSL: Derive WgslShaderGenerator and similar classes from VkShaderGen…
scotbrew fabd07f
Updating .gitignore -- ignore .DSStore
scotbrew 38867fd
For GLSL (WGSL flavor), use texture2D+sampler types instead of sample…
scotbrew 770fcaa
Cleanup debug output.
scotbrew 03eacd4
Fixing MSLShaderGenerator after refactoring mx_environment_prefilter.…
scotbrew 2fae1f6
Testing: Add "genglsl_wgsl" to the list of code generators to use.
scotbrew 17666a4
Merge branch 'AcademySoftwareFoundation:main' into brews/feature/wgsl
scotbrew 131d322
WGSL: Refactor shader code and CompountNode shader gen
scotbrew 8249985
Reverting changes to mx_microfacet
scotbrew c1a6c29
Code cleanup for WGSL. Removing unused items.
scotbrew e16dc86
Cleaning up unused variables.
scotbrew 75cddf1
Add wgsl to github tests (main.yml)
scotbrew 3216a40
Revising WGSL validator test to use vulkan1.3 glsl
scotbrew 84c011b
WGSL: Tweaking Github tests
scotbrew c50abbb
Removing unused wgsl.glsl file.
scotbrew 7592972
Streamlining out unneeded WGSL overrides.
scotbrew 2885f70
Align introduced virtual function to align with naming conventions.
scotbrew a99de01
Removing unnecessary override.
scotbrew 1eaa79d
Replace constructed string with static for virtual func.
scotbrew c32a2e4
Creating T_ENV_RADIANCE_TEXTURE and T_ENV_RADIANCE_SAMPLER
scotbrew 06ee2ed
Adding docs and missing externs for added strings
scotbrew 5622026
Merge branch 'main' into brews/feature/wgsl
scotbrew 44e5a48
Add full list of WGSL Keywords and Reserved Words
scotbrew 9a7c5c8
Merge branch 'main' into brews/feature/wgsl
jstone-lucasfilm a4a26c4
Merge branch 'main' into brews/feature/wgsl
jstone-lucasfilm d94732f
Remove extra newline
jstone-lucasfilm 9971db0
Remove extra newline
jstone-lucasfilm e7bbffb
Minor coding style update
jstone-lucasfilm aac3bfc
Fix issue introduced with emitFunctionDefinitionParameter refactor
scotbrew cc5f77d
Merge branch 'main' into brews/feature/wgsl
scotbrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| build | ||
| dist | ||
| .DS_Store |
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_color3(texture2D tex_texture, sampler tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv).rgb; | ||
|
jstone-lucasfilm marked this conversation as resolved.
|
||
| } | ||
| #else | ||
| void mx_image_color3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv).rgb; | ||
| } | ||
| #endif | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_color4(texture2D tex_texture, sampler tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv); | ||
| } | ||
| #else | ||
| void mx_image_color4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv); | ||
| } | ||
| #endif |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_float(texture2D tex_texture, sampler tex_sampler, int layer, float defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out float result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv).r; | ||
| } | ||
| #else | ||
| void mx_image_float(sampler2D tex_sampler, int layer, float defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out float result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv).r; | ||
| } | ||
| #endif |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_vector2(texture2D tex_texture, sampler tex_sampler, int layer, vec2 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec2 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv).rg; | ||
| } | ||
| #else | ||
| void mx_image_vector2(sampler2D tex_sampler, int layer, vec2 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec2 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv).rg; | ||
| } | ||
| #endif |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_vector3(texture2D tex_texture, sampler tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv).rgb; | ||
| } | ||
| #else | ||
| void mx_image_vector3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv).rgb; | ||
| } | ||
| #endif |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| #include "lib/$fileTransformUv" | ||
|
|
||
| #ifdef HW_SEPARATE_SAMPLERS | ||
| void mx_image_vector4(texture2D tex_texture, sampler tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(sampler2D(tex_texture, tex_sampler), uv); | ||
| } | ||
| #else | ||
| void mx_image_vector4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) | ||
| { | ||
| vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); | ||
| result = texture(tex_sampler, uv); | ||
| } | ||
| #endif |
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
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
27 changes: 27 additions & 0 deletions
27
source/JsMaterialX/JsMaterialXGenWgsl/JsWgslShaderGenerator.cpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // | ||
| // Copyright Contributors to the MaterialX Project | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #include <MaterialXGenGlsl/WgslShaderGenerator.h> | ||
| #include <MaterialXGenShader/Util.h> | ||
|
|
||
| #include <emscripten/bind.h> | ||
|
|
||
| namespace ems = emscripten; | ||
| namespace mx = MaterialX; | ||
|
|
||
| namespace | ||
| { | ||
| // Creator wrapper to avoid having to expose the TypeSystem class in JavaScript | ||
| mx::ShaderGeneratorPtr WgslShaderGenerator_create() | ||
| { | ||
| return mx::WgslShaderGenerator::create(); | ||
| } | ||
| } | ||
|
|
||
| EMSCRIPTEN_BINDINGS(WgslShaderGenerator) | ||
| { | ||
| ems::class_<mx::WgslShaderGenerator, ems::base<mx::GlslShaderGenerator>>("WgslShaderGenerator") | ||
| .class_function("create", &WgslShaderGenerator_create); | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.