All Projects → jwollen → nim2spirv

jwollen / nim2spirv

Licence: other
A SPIR-V backend for the Nim compiler

Programming Languages

nim
578 projects

Projects that are alternatives of or similar to nim2spirv

Spirv Vm
Virtual machine for executing SPIR-V
Stars: ✭ 173 (+408.82%)
Mutual labels:  shaders, spir-v
Reshade
A generic post-processing injector for games and video software.
Stars: ✭ 2,285 (+6620.59%)
Mutual labels:  shaders, spir-v
cs paint
Vulkan rendering library for graphics and text
Stars: ✭ 79 (+132.35%)
Mutual labels:  shaders
deffx
A collection of useful shader effects made ready to be used with the Defold game engine
Stars: ✭ 33 (-2.94%)
Mutual labels:  shaders
Camera2GLPreview
Android camera preview application using Camera2 API and OpenGL ES/Vulkan
Stars: ✭ 140 (+311.76%)
Mutual labels:  shaders
sph vulkan
SPH simulation in Vulkan compute shader.
Stars: ✭ 29 (-14.71%)
Mutual labels:  spir-v
kotlin-glsl
Write your GLSL shaders in Kotlin.
Stars: ✭ 30 (-11.76%)
Mutual labels:  shaders
BezierCurves2D
An implementation of 2D Bezier Curves in C++ using OpenGL, gl3w, glfw3 and imgui.
Stars: ✭ 41 (+20.59%)
Mutual labels:  shaders
Fake-Interior-Shader-for-GodotEngine
Interior Mapping shader for the Godot Game Engine 3.x that works with both GLES3 and GLES2.
Stars: ✭ 40 (+17.65%)
Mutual labels:  shaders
Godot-3.0-Noise-Shaders
Godot 3.0 Noise Shaders
Stars: ✭ 38 (+11.76%)
Mutual labels:  shaders
ios-spritekit-shader-sandbox
👾 Collection of custom effects for SpriteKit implemented using GLSL/Metal shaders.
Stars: ✭ 63 (+85.29%)
Mutual labels:  shaders
NovaShader
Multi-functional shader for the Particle System that supports Universal Render Pipeline (URP) of Unity.
Stars: ✭ 448 (+1217.65%)
Mutual labels:  shaders
unity-shadergraph-sketches
🎨 Sketches made with ShaderGraph in Unity.
Stars: ✭ 47 (+38.24%)
Mutual labels:  shaders
Nabla
OpenGL/OpenGL ES/Vulkan/CUDA/OptiX Modular Rendering Framework for PC/Linux/Android
Stars: ✭ 235 (+591.18%)
Mutual labels:  spir-v
manyworlds
A scifi-inspired study of signed distanced functions and noise fields in WebGL
Stars: ✭ 24 (-29.41%)
Mutual labels:  shaders
grid-shader-unity
A grid shader for Unity 🌐
Stars: ✭ 81 (+138.24%)
Mutual labels:  shaders
Tokenmagic
A Foundry VTT module that allows you to add animations and graphic effects to tokens, tiles, templates and drawings.
Stars: ✭ 28 (-17.65%)
Mutual labels:  shaders
mathematical-sculptures
Generate custom parametric surfaces ✒️💠
Stars: ✭ 26 (-23.53%)
Mutual labels:  shaders
rendeer
A simple 3D rasterizer made from scratch in Python.
Stars: ✭ 105 (+208.82%)
Mutual labels:  shaders
nvjob-boids
#NVJOB Simple Boids (Flocks of Birds, Fish and Insects). Flocking Simulation. Free Unity Asset.
Stars: ✭ 55 (+61.76%)
Mutual labels:  shaders

nim2spirv

A backend for the Nim compiler and standalone executable to compile Nim into SPIR-V.

Note: This is an early proof-of-concept and work-in-progress!

Goals

  • Make Nim an awesome shader language, closely mapping to SPIR-V concepts.
  • Share code between host program and shader modules by compiling .nim-files with both nim and nim2spirv.
  • Define a high-level shader DSL through the power meta-programming that
    • trivializes shader permutation management
    • abstracts API differences
    • exposes shader meta-data to the host program and authoring tools, by directly importing shader modules

Usage

This needs to built against a patched branch of the nim compiler: https://github.com/fragcolor-xyz/Nim/tree/nim2spirv

Use similarly to nim:

nim2spirv spirv test.nim
spirv-dis test.spv
spirv-opt -o test-opt.spv test.spv

Consume direcly with Vulkan or cross-compile with SPIRV-Cross.

Progress

Currently the following compiles and produces a valid SPIR-V module with a Vulkan vertex and fragment entry-point:

import shaders

type
  Data = object
    worldViewProjection {.rowMajor.}: Matrix4x4

var
  data {.uniform, descriptorSet: 0, binding: 0.}: Data

  position {.input, location: 0.}: Vector4
  normal {.input, location: 1.}: Vector3
  texCoordVIn {.input, location: 2.}: Vector2
  texCoordVOut {.output, location: 0.}: Vector2
  clipSpacePosition {.output, builtIn: Position.}: Vector4

  texCoord {.input, location: 0.}: Vector2
  color {.output, location: 0.}: Vector4

proc vsMain() {.stage: Vertex.} =
  clipSpacePosition = construct[Vector4](position.xyz, 1.0'f32) * data.worldViewProjection
  clipSpacePosition.y = -clipSpacePosition.y
  texCoordVOut = texCoordVIn

proc fsMain() {.stage: Fragment.} =
  color = construct[Vector4](texCoord.xy, 0.0'f32, 1.0'f32)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].