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

Shader API #34

Open
5 tasks
Tracked by #42
STREGA opened this issue Jul 25, 2023 · 3 comments
Open
5 tasks
Tracked by #42

Shader API #34

STREGA opened this issue Jul 25, 2023 · 3 comments
Milestone

Comments

@STREGA
Copy link
Contributor

STREGA commented Jul 25, 2023

Rework Shader API for public consumption.

  • Use a result builder for shader construction
  • Attempt to prevent instance dependent build objects from being used on other shader instances at the compile stage.
    • These objects include custom uniforms, buffer attachments, and buffer destinations.
    • Type constraints?
  • Give shaders a unique identifier that will allow for static caching of generated/built shaders.
  • Give shaders the ability to be changed at runtime and auto recompile, even while being used.
    • Possibly with a MutableXXXXXShader type variant as these won't be cacheable.
  • Fully document and include examples as markdown sheets in SwiftDocC library.
@STREGA STREGA added this to the GateEngine v1.1.0 milestone Jul 25, 2023
@STREGA STREGA mentioned this issue Aug 18, 2023
8 tasks
@7ombie
Copy link

7ombie commented Mar 21, 2024

Hey, @STREGA. Awesome project!

Quick question... I'm very interested in GateEngine, but I'm only targeting Apple Silicon Macs. While GateEngine's shader API looks really useful for cross-platform projects, I'd naturally prefer to use platform-specific shaders (basically, Metal) for my usecase. Is that possible, and if so, how readily could I integrate my shaders into the rest of the engine?

Edit: I'm not looking to replace the renderer wholesale, but might, for example, want to apply a custom filter to the engine's output. In which case, I'd need some way to tell the engine to render to a buffer I can use with the Metal API (instead of sending it to the display). That kind of thing.

This is not a dealbreaker, but I'd be interested to know a bit more about it.

@STREGA
Copy link
Contributor Author

STREGA commented Mar 21, 2024

@7ombie Hi 🙂

No, it's not possible to use your existing shaders. All shaders must be built with the GateEngine shader API. On macOS, if Metal is available, Metal is used for rendering and the shader API will generate Metal shaders. So everything is native if that's your concern.

GateEngine does support render targets and you can use them as a texture and draw them with any shader you want. So you can create the effects you're talking about. Post processing will eventually get its own features in the renderer but it's just not a high priority at this phase of development.

@7ombie
Copy link

7ombie commented Mar 21, 2024

Hi, @STREGA. Thanks for taking the time. Much appreciated.

So everything is native if that's your concern.

I was mainly concerned that the GateEngine API will always be more limited than Metal, so there's questionable benefit (in my case) to wrapping Metal with it. On the other hand, if the API's adequate for making games, and it all gets compiled to the same thing in the end, not having Metal is not the end of the World. I might even prefer the pure-Swift approach.

To be honest, I've been learning Metal recently, so I just kinda wanted to use it. The technical concern was more of a rationalization after the fact. Being able to use Swift is much more important to me.

I think I just need to make a little game with GateEngine, and see how it goes.

Thanks again, @STREGA.

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

No branches or pull requests

2 participants