Giter Club home page Giter Club logo

glsl-layout2's Introduction

GLSL-LAYOUT

This crates provides data types and traits to build structures ready to upload into UBO.

Usage

Deriving Uniform with proc-macro will produce associated type Std140 with same data layout as uniform blocks declared with layout(std140). All members of structure that derives Uniform must implement Uniform as well.

Implementing Uniform should be done via deriving. Implementing it manually is possible. It requires to provide associated type Std140 which must implement Std140 trait. But trait Std140 is marked unsafe so be careful.

Trait Uniform also requires Copy.

Typical usage scenario is:

#[derive(Copy, Clone, Uniform)]
struct FragmentArgs {
    pos: vec3,
    dir: vec3,
    count: uint,
}

write_to_buffer(&FragmentArgs {
    pos: [0.0, 1.0, 2.0].into(),
    dir: [3.0, 4.0, 5.0].into(),
    count: 42,
}.std140());

Data types

There are basic data types from glsl:

  • boolean (name bool is already occupied)
  • int
  • uint
  • float
  • double

Also more complex types:

  • vectors - (vec2, vec3, vec4, bvec2, ivec2, uvec2, dvec2 etc)
  • matrices - (mat2x3, dmat4 etc)
  • arrays -

License

glsl-layout is free and open source software distributed under the terms of both the MIT License and the Apache License 2.0.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Known issues

On MacOS

If uniform block contains array of structures and this array accessed with dynamic index (variable instead of literal) it may load wrong bytes for members not aligned to size of vec4 (16 bytes). In this case manual padding can be the fix.

glsl-layout2's People

Contributors

dasetwas avatar ishitatsuyuki avatar joe1994 avatar nazariglez avatar zakarumych avatar

Watchers

 avatar  avatar

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.