Last active
August 25, 2017 21:25
-
-
Save ScatteredRay/dd60889a61d08a25d67e035b986e6c8c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@(at-point 'surface-struct | |
'( | |
(float3 albedo1 ;) | |
(float3 albedo2 ;) | |
(float blend ;))) | |
@(at-point 'surface-calc | |
'( | |
(surface . albedo1 = ... ;) | |
(surface . albedo2 = ... ;) | |
(surface . blend = ... ;))) | |
@(at-point 'surface-params """ | |
params.albedo = lerp(surface.albedo1, surface.albedo2, surface.blend); | |
""") | |
@(include "surface.frag") |
This file contains hidden or 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
@(log "Building %d layer blend" numLayers) | |
@(at-point 'surface-struct | |
(map | |
(lambda (i) '( | |
(float3 ,(concatenate "albedo" i) ;) | |
(float ,(concatenate "blend" i) ;)) | |
(range 0 numLayers))) | |
@(at-point 'surface-calc | |
'(...)) | |
@(at-point 'surface-params | |
(map | |
(lambda (i) | |
(list "params.albedo = lerp(params.albedo, surface." (concatenate "albedo" i) ", surface." (concatenate "blend" i) ");")) | |
(range 0 numLayers))) | |
@(include "surface.frag") |
This file contains hidden or 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
struct LightParams { | |
float3 albedo; | |
}; | |
struct Surface { | |
@(point 'surface-struct) | |
}; | |
void main() | |
{ | |
Surface surface; | |
@(point 'surface-calc) | |
... | |
LightParams params; | |
params.albedo = float3(0,0,0); | |
@(point 'surface-params) | |
float3 color = evalLights(params); | |
@(point 'modify-color) | |
out_color = color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment