Created
July 10, 2014 04:58
-
-
Save MatthewBlanchard/46c0ccd2b612b0db52d4 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
local s = [[ | |
extern Image normaltex; | |
extern Image materialtex; | |
extern Image ramp; | |
extern Image sramp; | |
extern vec2 lightvec; | |
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ) | |
{ | |
vec4 material = Texel(materialtex, texture_coords); | |
float emission = material.g; | |
float specintensity = material.r; | |
float specpower = material.b; | |
vec4 Lcol = vec4(1, 1, 1, 1); | |
vec4 tcol = Texel(texture, texture_coords); | |
vec3 E = vec3(0, 0, -1); | |
vec3 N = 2 * Texel(normaltex, texture_coords).xyz - 1; | |
vec3 L = normalize(vec3(lightvec, 100)); | |
vec3 R = reflect(L, N); | |
float NdotL = dot(N, L); | |
float EdotR = pow(dot(E, R), specpower*255); | |
vec4 diffuse = Lcol * Texel(ramp, vec2(NdotL, 0)); | |
vec4 specular = Lcol * Texel(sramp, vec2(EdotR, 0)) * specintensity; | |
return (diffuse+specular) * tcol + emission * tcol; //Texel(ramp, vec2(dot(normal, l), 0)); | |
} | |
]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment