Last active
January 2, 2016 08:49
-
-
Save barcharcraz/8278622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TVert = tuple | |
pos: vec3 | |
norm: vec3 | |
uv: vec2 | |
type TMVP = tuple | |
model: mat4x4 | |
view: mat4x4 | |
proj:mat4x4 | |
type TVSOut = tuple | |
uv: vec2 | |
#this would come from some other library | |
#would need to be able to do image related things | |
#with it | |
type TImage | |
shader standard: | |
using pervert input: TVert | |
using uniform mvp: TMVP | |
using texture tex: TImage | |
vc to ps vsout: vec2 | |
vsproc(): vec4 = | |
vsout = input.uv | |
result = mvp.proj * mvp.view * mvp.model * input.pos | |
psproc(): vec4 = | |
result = sample(tex, vsout.uv) | |
#the generated code would have something like: | |
proc drawStandard(input: seq[TVert], mvp: TMVP, tex: TImage) = ... | |
#we could have seperate stages as well maybe something liek | |
vertex shader standardvs: | |
using pervert input: TVert | |
using uniform mvp: TMVP | |
using vertex output: TVert.pos | |
vsproc(): TVert = | |
result.pos = mvp.proj * mvp.view * mvp.model * input.pos | |
result.norm = input.norm | |
result.uv = input.uv | |
pixel shader standardps: | |
using texture tex: TImage | |
psproc(input: TVert): vec4 = | |
result = sample(tex, input.uv) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment