Git Product home page Git Product logo

Comments (5)

f9x0 avatar f9x0 commented on May 10, 2024

Hello. Consider adding an API to use your shaders.
Without a doubt, this feature will be for experienced developers and will open the way to the world of shaders. Naga, wgsl and other community tools. I like Kage, but it's good to have an alternative..

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

I'm afraid this suggestion is not for enabling other languages than Kage

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

To minimize an impact of the existing APIs, I suggest this API:

// AddPrecompiledShader adds a pair of a shader source and a shader binary.
// When a new shader is created by NewShader,
// Ebitengine tries to seek the pair that has the same shader source.
// If there is such a pair, Ebitengine uses a registered shader binary for the same shader source instead of compiling it.
//
// AddPrecompiledShader is useful to shoten the shader compile time, or even necessary in an environment
// where you cannot compile a shader on the fly.
func AddPrecompiledShader(kageShaderSource []byte, nativeShaderBinary []byte, graphicsLibrary GraphicsLibrary) error

EDIT: Hmm, how can we treat vertex shader?

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

OpenGL: It is impossible to precompile shaders. AddPrecompiledShader should always return an error.

DirectX: A native shader binary is the result of D3DCompile. This function returns ID3DBlob, and this can be converted to a byte slice, and be created via D3DCreateBlob. A vertex shader and a pixel shader are separated.

Metal: A native shader binary is a .metallib format. This can be used at makeLibrary for NSData. See also https://developer.apple.com/documentation/metal/shader_libraries/building_a_shader_library_by_precompiling_source_files. A vertex shader and a fragment shader are NOT separated. So, Ebitengine would have to expose the binary for a vertex shader? Hmm.

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

Instead of exposing the the vertex shader, would this work?

func CompileShaderToNativeSource(kageShaderSource []byte, graphicsLibrary GraphicsLibrary) ([]byte, error)

// Compiling a native source to a native binary is a developer's responsibility.

func AddPrecompiledShader(kageShaderSource []byte, nativeShaderBinary []byte, graphicsLibrary GraphicsLibrary) error

from ebiten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.