Giter Club home page Giter Club logo

shaderc.net's Introduction

shaderc.net

Net bindings for google shaderc.

spirv compilation

This sample use vk.net to create the shader module. On success, Result object will hold a native pointer on the generated spirv code suitable for the ShaderModuleCreateInfo pCode field. This pointer will stay valid until the Result disposal.

using (Compiler comp = new Compiler ()) {
  using (Result res = comp.Compile ("test.vert", ShaderKind.VertexShader)) {
    if (res.Status == Status.Success) {
      VkShaderModuleCreateInfo ci = VkShaderModuleCreateInfo.New ();
      ci.codeSize = res.codeSize;
      ci.pCode = res.code;
      vkCreateShaderModule (VkDev, ref moduleCreateInfo, IntPtr.Zero, out VkShaderModule shaderModule));

Resolving includes

shaderc library provide the ability to add #include statements as in c/c++. This functionality is enabled or not in the Options class constructor, the default is enabled.

Options opt = new Options(false);

A default Options instance is created by the Compiler constructor which enable the include resolution. You may provide a custom Options instance to the compiler constructor.

Compiler comp = new Compiler (opt);
comp.Options.InvertY = true;

As in c/c++, you may have local or global include (enclosed in "" or <>). Local includes enclosed in "" will be searched from the current parsed source file. Global includes enclosed in '<>' will be searched in directories listed in Options.IncludeDirectories. The pathes may be relative to the executable directory, or absolute.

comp.Options.IncludeDirectories.AddRange ("shaders", @"c:\test");

If you want to override the default include resolution, to search for embedded ressources for example, derive the Options class and override the TryFindInclude method.

class OptionsWithCustomIncResolve : Options {
  protected override bool TryFindInclude (string sourcePath, string includePath, IncludeType incType, out string incFile, out string incContent) {
...

shaderc.net's People

Contributors

jpbruyere avatar khhs167 avatar tacodiva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tacodiva

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.