CapsAdmin

Untitled

Nov 25th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local SHADER = {      
  2.     shared = {
  3.         uniform = {
  4.             time = 0,
  5.         },
  6.     },
  7.      
  8.     vertex = {
  9.         uniform = {
  10.             camera_matrix = "mat4",
  11.             model_matrix = "mat4",
  12.         },         
  13.         attributes = {
  14.             {pos = "vec3"},
  15.             {normal = "vec3"},
  16.             {uv = "vec2"},
  17.         }, 
  18.         source = [[
  19.             void main()
  20.             {              
  21.                 // if this is commented out, the normal is just
  22.                 // passed onto the fragment shader as it is
  23.                    
  24.                 /*
  25.                     mat3 world_inverse = transpose(mat3(camera_matrix));
  26.                     mat3 normal_matrix = transpose(inverse(mat3(model_matrix)));
  27.                     glw_out_normal = normalize(world_inverse * normal_matrix * normal);
  28.                 */
  29.                
  30.                 gl_Position = camera_matrix * model_matrix * vec4(pos, 1.0);
  31.             }
  32.         ]]
  33.     },
  34.    
  35.     fragment = {
  36.         uniform = {
  37.             diffuse = "sampler2D",
  38.             bump = "sampler2D",
  39.             specular = "sampler2D",
  40.         },     
  41.         attributes = {
  42.             pos = "vec3",
  43.             normal = "vec3",
  44.             uv = "vec2",
  45.         },         
  46.         source = [[
  47.             out vec4 out_data[4];
  48.            
  49.             void main()
  50.             {
  51.                 out_data[0] = texture2D(diffuse, uv);
  52.                 out_data[1] = vec4(normalize(normal.xyz + texture2D(bump, uv).xyz), 1);
  53.                 out_data[2] = vec4(pos.xyz, 1);
  54.                 out_data[3] = texture2D(specular, uv);
  55.             }
  56.         ]]
  57.     }  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment