Skip to content

Generic-able Shader Logic #2

@mcmonkey4eva

Description

@mcmonkey4eva

It should be more reasonably doable to inject custom shaders into the engine.
In particular, maintain a list of custom shaders for the primary stages and a mapping of their requirements?
Primary stages being: FORWARD/SOLID, FORWARD/TRANSPARENT, DEFERRED/SOLID, and DEFERRED/TRANSPARENT
The rest probably don't need custom injection so much? But also be open to having that option available maybe (separate/future issue?)

My idea is the shaders would be registered with a map of required data, be easily attached to standard Renderable properties, ...
Also they would be carefully crafted as to PARTIAL shader definitions, not writing the entire fragment or vertex main call, but rather a sub-function call or direct injection that allows defining values separately from the logic for EG wrapping data, inputs, or special required effects - such as light/shadow application in the FORWARD shaders. Would be disableable by booleans set in-shader
IE, might look like this in a FORWARD shader:

// Top of file
#define FGE_LIGHTS_ENABLE 1
// Main defs and logic
#inject forward_inclusions
// Start of injection area
#define FGE_LIGHTS_ENABLE myVariableHere
// End of injection area
// Additional logic
#if FGE_LIGHTS_ENABLE
// Lighting logic
#endif
// Rest of file

Basically: the define could either be a static 1 or 0, OR it could be a variable name which will parse fine by later code? not sure.

That code would also have easy access to whatever variables it requests and maps...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions