Skip to content

Conversation

@ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Jul 9, 2025

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.ShaderLanguage

returns the shader language type used by the active gfx driver

The ShaderLanguageType is defined as:

enum ShaderLanguageType {
    eShaderNotSupported = 0,
    eShaderGLSL = 1,
    eShaderHLSL = 2
};

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.

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.ShaderLanguage`

returns the shader language type used by the active gfx driver

NOTES:
The ShaderProgram created from string will keep the whole string 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.
@ivan-mogilko ivan-mogilko changed the base branch from master to ags4 July 9, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant