Add ability to include built-in include files#94193
Add ability to include built-in include files#94193Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
7121b3f to
ca79e2c
Compare
|
Added a really crude demonstration of the compositor effects use case of this functionality here: godotengine/godot-demo-projects#1086 This should both work if you build the shader manually like in the As we lack some of the build in defines, it all does come with a bit of a manual (yet to be written), but for instance to include the scene data we get: Then in code we get: To retrieve our RID, and then obviously our uniform set: Now in the shader we can access the build in scene data uniform buffer (view in this case coming from our push constant): |
ca79e2c to
9e58aae
Compare
9e58aae to
e43c14f
Compare
e43c14f to
d062946
Compare
d062946 to
c698698
Compare
c698698 to
0961347
Compare
|
Rebased and added some more code that is needed for custom shader templates. |
|
@clayjohn Would you mind reviewing this, I'd like to get this merged as the functionality added here is already useful even before we add custom shader templates. |
|
Forgot to put some extra info here after our rendering meeting a month ago. |
0961347 to
0df6723
Compare
0df6723 to
1fba27b
Compare
|
Rofl, edited the OP to include an example only to realise I had previously provided an example. A well, makes more sense in the OP. :) This is ready for review again, with changes applied as discussed in rendering meeting from some time ago. |
BlueCube3310
left a comment
There was a problem hiding this comment.
I've tested this locally and it works as expected. Looks good to me aside from some minor nitpicks
feafccd to
3d9698a
Compare
… shader templates)
3d9698a to
1bffefb
Compare
clayjohn
left a comment
There was a problem hiding this comment.
:) Reviewed in the rendering meeting
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <class name="ShaderIncludeDB" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> | ||
| <brief_description> | ||
| Internal database of built in shader include files. |
There was a problem hiding this comment.
| Internal database of built in shader include files. | |
| Internal database of built-in shader include files. |
| Internal database of built in shader include files. | ||
| </brief_description> | ||
| <description> | ||
| This object contains shader fragments from Godot's internal shaders. These can be used when access to internal uniform buffers and/or internal functions is required for instance when composing compositor effects or compute shaders. Only fragments for the current rendering device are loaded. |
There was a problem hiding this comment.
| This object contains shader fragments from Godot's internal shaders. These can be used when access to internal uniform buffers and/or internal functions is required for instance when composing compositor effects or compute shaders. Only fragments for the current rendering device are loaded. | |
| This object contains shader fragments from Godot's internal shaders. These can be used when it is necessary to access to internal uniform buffers and/or internal functions, for example when composing compositor effects or compute shaders. Only fragments for the current rendering device are loaded. |
| <return type="bool" /> | ||
| <param index="0" name="filename" type="String" /> | ||
| <description> | ||
| Returns [code]true[/code] if an include file with this name exists. |
There was a problem hiding this comment.
| Returns [code]true[/code] if an include file with this name exists. | |
| Returns [code]true[/code] if an include file with the given [param filename] exists. |
| <method name="list_built_in_include_files" qualifiers="static"> | ||
| <return type="PackedStringArray" /> | ||
| <description> | ||
| Returns a list of built-in include files that are currently registered. |
There was a problem hiding this comment.
| Returns a list of built-in include files that are currently registered. | |
| Returns the list of built-in include files that are currently registered. |
|
Thanks! |
|
Merged a bit too soon with the "built in" typo but ah well |
Shhhh, you can just fix it separately :P |
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial. If someone has a better example in mind I'm open to suggestions. I just wanted something short that isn't too much extra code around the include.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial. If someone has a better example in mind I'm open to suggestions. I just wanted something short that isn't too much extra code around the include.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial. If someone has a better example in mind I'm open to suggestions. I just wanted something short that isn't too much extra code around the include.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial. If someone has a better example in mind I'm open to suggestions. I just wanted something short that isn't too much extra code around the include.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
) Documents merged feature godotengine/godot#94193 to the end of the compute shader tutorial.
This PR is a prelude to functionality we need for custom shader templates, but also has broader use in compositor effects.
This adds extra code so our include files are compiled along side the full template shader files. We can then include those in source and register them which enables us to use them in user shaders.
As part of this PR only 3 include files are actually exposed as a larger reorganisation will be needed before custom shader templates can be a thing.
For compositor effects however these can be useful includes. Right now we only have access to the scene data uniform but we'll be exposing more in the near future.
Note, this PR in godot demo projects has an example of how to use this in compositor effects:
godotengine/godot-demo-projects#1086
Here you can see that we're including our scene data UBO by including the scene data include file:
(the SceneDataBlock is not part of the include file so you can use your own set and binding as this will be likely different from the built in values).
Then in the compositor effect code you simply assign the existing UBO:
Now you have access to all the global scene data information such as projection matrices, view matrices, etc. in your compositor effect.