All Projects → jaredloomis → andromeda

jaredloomis / andromeda

Licence: WTFPL license
GLSL-targetting embedded compiler, and OpenGL rendering engine.

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to andromeda

FNode
Tool based in nodes to build GLSL shaders without any programming knowledge written in C using OpenGL and GLFW.
Stars: ✭ 81 (+8%)
Mutual labels:  shaders, glsl-shaders
30-days-of-shade
30 days of shaders in GLSL using GLSLCanvas
Stars: ✭ 134 (+78.67%)
Mutual labels:  shaders, glsl-shaders
ShaderView
ShaderView is an Android View that makes it easy to use GLSL shaders for your app. It's the modern way to use shaders for Android instead of RenderScript.
Stars: ✭ 53 (-29.33%)
Mutual labels:  shaders, glsl-shaders
ShaderToy-Chrome-Plugin
Web extension for shadertoy.com
Stars: ✭ 159 (+112%)
Mutual labels:  shaders, glsl-shaders
Thebookofshaders
Step-by-step guide through the abstract and complex universe of Fragment Shaders.
Stars: ✭ 4,070 (+5326.67%)
Mutual labels:  shaders, glsl-shaders
kotlin-glsl
Write your GLSL shaders in Kotlin.
Stars: ✭ 30 (-60%)
Mutual labels:  shaders, glsl-shaders
ModularMusicVisualizer
Project in Hiatus, unmaintained, being rewritten privately. Will Open Source when stuff is ready. Project will be Renamed.
Stars: ✭ 81 (+8%)
Mutual labels:  shaders, glsl-shaders
surface splatting
OpenGL demo of a point rendering and texture filtering technique called Surface Splatting.
Stars: ✭ 125 (+66.67%)
Mutual labels:  shaders, glsl-shaders
Shader Toy
Shadertoy-like live preview for GLSL shaders in Visual Studio Code
Stars: ✭ 349 (+365.33%)
Mutual labels:  shaders, glsl-shaders
Webgl Fundamentals
WebGL lessons that start with the basics
Stars: ✭ 3,315 (+4320%)
Mutual labels:  shaders, glsl-shaders
deffx
A collection of useful shader effects made ready to be used with the Defold game engine
Stars: ✭ 33 (-56%)
Mutual labels:  shaders, glsl-shaders
React Regl
React Fiber Reconciler Renderer for Regl WebGL
Stars: ✭ 171 (+128%)
Mutual labels:  shaders, glsl-shaders
YALCT
Yet Another Live Coding Tool - Powered by Veldrid and elbow grease
Stars: ✭ 25 (-66.67%)
Mutual labels:  shaders, glsl-shaders
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+15497.33%)
Mutual labels:  shaders, glsl-shaders
glNoise
A collection of GLSL noise functions for use with WebGL with an easy to use API.
Stars: ✭ 185 (+146.67%)
Mutual labels:  shaders, glsl-shaders
Anime4K
Makes it easy to encode a Anime using Anime4K with predefined encoding profiles!
Stars: ✭ 61 (-18.67%)
Mutual labels:  shaders
pipeVFX
A Visual Effects pipeline to manage jobs, shots and software assignment, with a simple asset manager. Its extensively integrated with CortexVFX and Gaffer. (and it builds booth, with support for Maya, Houdini and Nuke, if you have then installed!)
Stars: ✭ 47 (-37.33%)
Mutual labels:  shaders
drawingwithcode
Drawing with code 😘
Stars: ✭ 28 (-62.67%)
Mutual labels:  shaders
Unity3DShaders
Simple shaders for Unity3D that I created for games, for a challenge or following tutorials.
Stars: ✭ 17 (-77.33%)
Mutual labels:  shaders
GPU-Fog-Particles
Textureless fog particles using a highly customizable shader to attenuate noise values.
Stars: ✭ 303 (+304%)
Mutual labels:  shaders

Andromeda

This is a library that allows you to write and run GLSL shaders in Haskell.

Why would you want to write shaders in Haskell? Well with this eDSL instead of loading shaders, then creating and filling buffers with data, then binding each buffer, getting uniform locations and setting, etc., you just specify the data and how you want to transform and render the data.

More advantages of writing shaders in Haskell:

  • Everything is typechecked at compile time (by GHC).
  • Some of the distinction between GPU and CPU values / operations is removed.
  • You can use normal Haskell functions when writing shaders.
  • Optimizations can be performed on the shader.

Example

As an example of what the library can do, we will make a simple application that renders a red triangle to the screen.

First we have to import some stuff.

import Data.Vec ((:.)(..), Vec2, Vec3, Vec4)

import qualified Data.Vector.Storable as V

import Andromeda.Simple.Expr
import Andromeda.Simple.Type
import Andromeda.Simple.GLSL
import Andromeda.Simple.Var
import Andromeda.Simple.StdLib

import Andromeda.Simple.Render.Mesh
import Andromeda.Simple.Render.VertexBuffer
import Andromeda.Simple.Render.Compile

Then we define our triangle data.

triangle :: [Vec3 Float]
triangle = [(-1):.(-1):.0:.(),
              1 :.(-1):.0:.(),
              0 :.  1 :.0:.()]

myMesh :: Mesh
myMesh = Mesh [("vertex", MeshAttribute $ V.fromList triangle)] Triangles

Now we actually define the shaders. We'll start by defining what we want gl_Position to be.

glPosition :: Expr (Vec4 Float)
glPosition = fetch "vertex" (Vec3T SFloat) +-+ 1

gl_Position is a vec4 made from the vec3 "vertex" attribute we defined in the mesh and with a w value of 1. This is the same as vec4(vertex, 1) in GLSL.

Shaders are represented as a series of Statements. In this case, out vertex shader is just setting gl_Position.

vertShader :: Statement
vertShader = AssignS "gl_Position" glPosition

For the frag shader, we just want to define a constant out value for the color, which will always be red.

outColor :: Expr (Vec3 Float)
outColor = flt 1 +-+ flt 0 +-+ flt 0

fragShader :: Statement
fragShader = OutS "color" outColor

And that's it! All we have to do now is use our shaders.

main :: IO ()
main = do
    win <- openWindow
    initGL win

    prog <- addMesh myMesh =<< compile vertShader fragShader

    mainLoop win prog

Run this program (found in test/Main.hs), and you should see a red triangle!

Note

This repository contains 3 APIs:

  • A new lambda calculus-based eDSL ("Simple")
  • An old lambda calculus-based eDSL ("Lambda")
  • A Monad-based, imperative eDSL ("Monad")

The above example uses the "Simple" API. I'm not working any more on the other versions, but they may be interesting or of some use, especially the imperative one.

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].