Skip to content
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

Generic-able Shader Logic #2

Open
mcmonkey4eva opened this issue Sep 3, 2017 · 2 comments
Open

Generic-able Shader Logic #2

mcmonkey4eva opened this issue Sep 3, 2017 · 2 comments

Comments

@mcmonkey4eva
Copy link
Member

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

@FutureMaximus
Copy link
Contributor

I think the graphics pipeline should adapt to what the shader requires if someone wants to mix 6 textures they could maybe pass a custom shader properties class to the custom shader telling the pipeline what to do with that shader. The pipeline would be like ok we got 6 textures so let's put those in.

@FutureMaximus
Copy link
Contributor

Custom uniforms would be a really powerful thing to have. We can have actions that get invoked when the shader gets used allowing people to use their variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants