AGS 4: support creating ShaderProgram from a string in script #2782
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.
Implements following api:
static ShaderProgram.CreateFromString(name, shaderScript, shaderDef)creates a ShaderProgram compiled from the given shaderScript string, optionally using a "shader definition" config in INI format (currently only used by Direct3D).
static ShaderProgram.CreateShaderStub(name)creates a ShaderProgram that does nothing (no-op).
static readonly ShaderLanguageType System.ShaderLanguagereturns the shader language type used by the active gfx driver
The ShaderLanguageType is defined as:
NOTES:
The ShaderProgram created from string will keep the whole shader script in memory and serialize one into game saves in order to recreate itself after save's restoration.
However, since it has only a string in language used at a time when it was created, so unlike the shaders created from file, it won't be able to automatically re-initialize if the gfx driver changes.
That is something that the user has to resolve in script. I suppose, they might save the ShaderLanguageType in a variable and check that variable's value after the save is restored.
In summary, on upside this api lets to create custom shaders programmatically in script, but on a downside user has to also script switching shaders if a gfx driver have changed in between the game sessions.