All Projects → hagmas → Shaderview

hagmas / Shaderview

Licence: mit
A library for simple shader programming

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Shaderview

Toypathtracer
Toy path tracer for my own learning purposes (CPU/GPU, C++/C#, Win/Mac/Wasm, DX11/Metal, also Unity)
Stars: ✭ 753 (+765.52%)
Mutual labels:  metal, gpu
Metalpetal
A GPU accelerated image and video processing framework built on Metal.
Stars: ✭ 907 (+942.53%)
Mutual labels:  metal, gpu
Flexibleimage
A simple way to play with the image!
Stars: ✭ 798 (+817.24%)
Mutual labels:  metal, playground
Stablefluids
A straightforward GPU implementation of Jos Stam's "Stable Fluids" on Unity.
Stars: ✭ 430 (+394.25%)
Mutual labels:  shader, gpu
Phenomenon Px
⚡️ The fastest way to create pixel shaders.
Stars: ✭ 77 (-11.49%)
Mutual labels:  shader, gpu
Gfx
[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Stars: ✭ 5,045 (+5698.85%)
Mutual labels:  metal, gpu
Unity3d Cg Programming
Various shaders.
Stars: ✭ 800 (+819.54%)
Mutual labels:  shader, gpu
LuisaRender
High-Performance Multiple-Backend Renderer Based on LuisaCompute
Stars: ✭ 47 (-45.98%)
Mutual labels:  metal, gpu
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+1217.24%)
Mutual labels:  shader, metal
Gpu Spline Deformation
Baking spline deformation to a texture then applying it to a mesh via a shader.
Stars: ✭ 52 (-40.23%)
Mutual labels:  shader, gpu
Unity Miscellaneous Shaders
Miscellaneous Shaders in Unity, WIP(maybe?)
Stars: ✭ 403 (+363.22%)
Mutual labels:  shader, gpu
Aardvark.rendering
The dependency-aware, high-performance aardvark rendering engine. This repo is part of aardvark - an open-source platform for visual computing, real-time graphics and visualization.
Stars: ✭ 79 (-9.2%)
Mutual labels:  shader, gpu
Colormap Shaders
A collection of shaders to draw color maps.
Stars: ✭ 315 (+262.07%)
Mutual labels:  shader, metal
Gpu Gems Book Source Code
💿 CD Content ( Source Code ) Collection of Book <GPU Gems > 1~ 3 | 《GPU精粹》 1~ 3 随书CD(源代码)珍藏
Stars: ✭ 567 (+551.72%)
Mutual labels:  shader, gpu
Ultralight
Next-generation HTML renderer for apps and games
Stars: ✭ 3,585 (+4020.69%)
Mutual labels:  metal, gpu
Tvm
Open deep learning compiler stack for cpu, gpu and specialized accelerators
Stars: ✭ 7,494 (+8513.79%)
Mutual labels:  metal, gpu
Shadermania
A metal shader editor for macOS and iOS
Stars: ✭ 155 (+78.16%)
Mutual labels:  shader, metal
Pixel
📷 A composable image editor using Core Image and Metal.
Stars: ✭ 2,495 (+2767.82%)
Mutual labels:  shader, gpu
Computesharp
A .NET 5 library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
Stars: ✭ 982 (+1028.74%)
Mutual labels:  shader, gpu
Metalbrot Playground
An interactive playground showing how to use Metal compute kernels.
Stars: ✭ 78 (-10.34%)
Mutual labels:  metal, playground

ShaderView

A library for simple shader programming.

A ShaderView example with Playground

About ShaderView

ShaderView wraps the MTKView setup.

ShaderView is designed to extend MTKView which enables to do shader view programming simpler and easier, like GLSL Sandbox or Shadertoy. This library wraps the configuration process of MTLLibrary, MTLFunction, MTLComputePipelineState, MTLCommandQueue, MTLCommandBuffer and MTLCommandEncoder, and takes a simple kernel function with the arguments of output texture, current time, touch events and the position in the grid. Create ShderViewRenderer, set it on MTLView and add the MTLView to other UIKit view.

Test with Playground.

The screen recorded above is a playground attacked to this workspace MSLPlayground on which you can write/test simple MSLs. The shader function in the screenshot is converted from the GLSL on Shadertoy.

Usage

ShaderView is consisted mainly from ShaderViewRenderer and MTKView's extension.

import MetalKit
import ShaderView

// Create MTLDevice. MTLDevice is encouranged to create right after the app launch and retain throughout the life time of the app.
guard let device = MTLCreateSystemDefaultDevice else {
    return
}

// Optional: Create MTLLibrary. This is optional and if you don't set your own MTLLibrary, ShaderViewRenderer will generate a default library from the device.
var library: MTLLibrary?
do {
    let path = Bundle.main.path(forResource: "MSLPlayground", ofType: "metal")
    let source = try String(contentsOfFile: path!, encoding: .utf8)
    library = try device.makeLibrary(source: source, options: nil)
} catch let error as NSError {
    print("library error: " + error.description)
}

// Create MTLView
let shaderView = MTKView(frame: NSRect(x: 0, y: 0, width: 400, height: 400), device: device)

// Create ShaderViewRenderer with the device you created.
let renderer = ShaderViewRenderer(device: device)

// Optional: Set MTLLibrary to ShaderViewRenderer
renderer.library = library

// Set the kernel function name to ShaderViewRenderer. The function you specified must have the same arguments as "MSLPlayground.metal" in the example Playground.
renderer.functionName = "playgroundSample"

// Set the renderer to the metal view.
shaderView.sv.set(renderer: renderer)

Requirements

  • Xcode 9.1
  • Swift 4.0.2
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].