Giter Site home page Giter Site logo

nuance's Introduction

Nuance

Crates.io Crates.io

A tool to run your shaders on the gpu.

screenshot Loaded with example shader : shaders/demo/foamy_water.frag Made by k-mouse ( 2016-11-23) https://www.shadertoy.com/view/llcXW7

Installation

Install with cargo:

$ cargo install --locked nuance

See Development when building from source.

Or download a prebuilt binary from the Release page. Prebuilt binaries are currently available for Windows (x86_64-pc-windows-msvc) and Linux (x86_64-unknown-linux-gnu).

Usage

Run it as is or nuance -H to force using the best gpu on your machine. By default, nuance selects the less power-hungry gpu.

Shaders

Nuance allows you tu run a custom fragment shader. You can also use a shader already compiled to SpirV directly given it was compiled with the Nuance header.

See the complete list of changes from GLSL in the manual.

Custom parameters

You can specify additional parameters to your shader using a special interface block. When compiling your shader, parameters will be parsed from the source code to generate sliders and other appropriate UI elements. The shader source will then be transpiled to correct GLSL to be compiled. Example :

// layout(params) indicates that this block is the special one to be parsed.
layout(params) uniform Params {
// layout(min, max, init) to modify each parameters settings
    layout(min = 0, max = 100, init = 1) float fSlider0;
    layout(min = 0, max = 20) float fSlider1;
};

void main() {
    // You can use special values like <param>.min and <param>.max, they will be replaced by the settings defined
    // in the params block
    fragColor = vec4(fSlider0 / fSlider0.max, fSlider1 / fSlider1.max, 0.0, 1.0);
}

Why this implementation for specifying parameters ?

"Hijacking" the layout qualifier allows me to use an existing GLSL parser. It parses those qualifiers as arbitrary identifiers which permits great flexibility.

Examples

This repository includes some examples under shaders/. Some of these are not from me and are just included here for demonstration purposes. They are the property of their respective owners.

Development

We use shaderc-rs to compile GLSL shaders to spirv. It is therefore highly recommended to install the vulkan sdk and set the VULKAN_SDK env var in order to find the prebuilt shaderc libraries. If not, shaderc will download and build the vulkan libraries from source, which takes about 90% of this entire application build time.

TODO

Ideas and tasks I should work on in no particular order.

  • Merge params uniform block with push_constant block
  • Preprocessor error handling & reporting
  • Complete error handling (currently crashes if something goes wrong)
  • GPU hot switch (for when you need some extra gpu juice on the fly)
  • Bind textures as input
  • Bind buffers as output
  • Sound processing (in and out)
  • Save to gif or video
  • Load shaders directly from shadertoy.com (need to convert globals)
  • Shader editor (code editor, GLSL highlighting)
  • Small standard library for GLSL shaders with common functions
  • Custom additions to GLSL language built into the preprocessor for a more fluent language
  • Custom parser for glsl
  • Support rust-gpu shaders

nuance's People

Contributors

gui-yom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pudnax

nuance's Issues

Devices do not support Rgba8UnormSrgb

Hey there! I saw your post on reddit and came here to see this beauty in action. However, it seems none of my devices (laptop with igpu and dgpu) support Rgba8UnormSrgb:
intel.log
nvidia.log

I used the 3.1 release's nuance linux executable as I can't build the project due to nightly ICEs. All my drivers are up-to-date.

After a quick search, it seems that BGR is widely used in many graphics APIs which explains why on my linux machine, Vulkan only supports BGR and not RGB like Window's DX12 .

I'm just getting started in the world of graphics APIs and I don't know how this can be solved/implemented. What do you think?

Edit: grammar.

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.