Created
April 23, 2014 17:05
-
-
Save CapsAdmin/11223744 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 SHADER = { | |
| shared = { | |
| uniform = { | |
| time = 0, | |
| }, | |
| }, | |
| vertex = { | |
| uniform = { | |
| camera_matrix = "mat4", | |
| model_matrix = "mat4", | |
| }, | |
| attributes = { | |
| {pos = "vec3"}, | |
| {normal = "vec3"}, | |
| {uv = "vec2"}, | |
| }, | |
| source = [[ | |
| void main() | |
| { | |
| // if this is commented out, the normal is just | |
| // passed onto the fragment shader as it is | |
| /* | |
| mat3 world_inverse = transpose(mat3(camera_matrix)); | |
| mat3 normal_matrix = transpose(inverse(mat3(model_matrix))); | |
| glw_out_normal = normalize(world_inverse * normal_matrix * normal); | |
| */ | |
| gl_Position = camera_matrix * model_matrix * vec4(pos, 1.0); | |
| } | |
| ]] | |
| }, | |
| fragment = { | |
| uniform = { | |
| diffuse = "sampler2D", | |
| bump = "sampler2D", | |
| specular = "sampler2D", | |
| }, | |
| attributes = { | |
| pos = "vec3", | |
| normal = "vec3", | |
| uv = "vec2", | |
| }, | |
| source = [[ | |
| out vec4 out_data[4]; | |
| void main() | |
| { | |
| out_data[0] = texture2D(diffuse, uv); | |
| out_data[1] = vec4(normalize(normal.xyz + texture2D(bump, uv).xyz), 1); | |
| out_data[2] = vec4(pos.xyz, 1); | |
| out_data[3] = texture2D(specular, uv); | |
| } | |
| ]] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment