]> git.tdb.fi Git - libs/gl.git/blobdiff - shaderlib/singlepass.glsl
Add functions for setting arrays of 2x2 and 3x3 matrix uniforms
[libs/gl.git] / shaderlib / singlepass.glsl
index a1062fed7125bd2f69886e33c3d9a61bec25b7a3..f782f3dad543ead82db5c583d3ebfbcfe955132e 100644 (file)
@@ -1,35 +1,4 @@
-struct LightSourceParameters
-{
-       vec4 position;
-       vec4 diffuse;
-       vec4 specular;
-};
-
-struct MaterialParameters
-{
-       vec4 ambient;
-       vec4 diffuse;
-       vec4 specular;
-       float shininess;
-};
-
-struct ClipPlane
-{
-       vec4 equation;
-};
-
-uniform mat4 eye_obj_matrix;
-uniform mat3 eye_obj_normal_matrix;
-uniform Transform
-{
-       mat4 projection_matrix;
-};
-
-uniform Material
-{
-       MaterialParameters material;
-       float reflectivity;
-};
+import msp_interface;
 
 const bool use_vertex_color = false;
 
@@ -37,53 +6,15 @@ const bool use_lighting = false;
 const bool use_specular = false;
 const bool use_sky = false;
 const bool use_fog = false;
-uniform Lighting
-{
-       // Declared as an array for compatibility reasons
-       LightSourceParameters light_sources[1];
-       vec4 ambient_color;
-       vec4 sky_color;
-       vec3 eye_sky_dir;
-       float horizon_limit;
-       vec4 fog_color;
-       float fog_density;
-};
 
 const bool use_diffuse_map = false;
-uniform sampler2D diffuse_map;
-
 const bool use_normal_map = false;
-uniform sampler2D normal_map;
 
 const bool use_shadow_map = false;
-uniform sampler2DShadow shadow;
-uniform ShadowMap
-{
-       float shadow_darkness;
-       mat4 shd_eye_matrix;
-};
 
 const bool use_environment_map = false;
-uniform samplerCube environment;
-uniform EnvMap
-{
-       mat3 env_eye_matrix;
-};
-
-const int max_clip_planes = 0;
-uniform Clipping
-{
-       ClipPlane clip_planes[max_clip_planes];
-};
-
-////// vertex
-layout(location=0) in vec4 vertex;
-layout(location=8) in vec4 texcoord;
-layout(location=3) in vec4 color;
-layout(location=2) in vec3 normal;
-layout(location=4) in vec3 tangent;
-layout(location=5) in vec3 binormal;
 
+#pragma MSP stage(vertex)
 vec4 get_vertex_position()
 {
        return vertex;
@@ -113,7 +44,7 @@ void singlepass_transform_and_lighting()
                ldir = ldir*eye_tbn_matrix;
        out vec3 light_dir = ldir;
 
-       out vec3 tbn_sky_dir = eye_sky_dir*eye_tbn_matrix;
+       out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
        out vec3 shadow_coord = (shd_eye_matrix*eye_vertex).xyz;
        out float fog_coord = eye_vertex.z;
 
@@ -127,9 +58,7 @@ void main()
        passthrough;
 }
 
-////// fragment
-layout(location=0) out vec4 frag_color;
-
+#pragma MSP stage(fragment)
 vec4 get_diffuse_sample()
 {
        return texture(diffuse_map, texcoord.xy);
@@ -156,12 +85,12 @@ vec3 singlepass_lighting()
        vec3 ambient_light = ambient_color.rgb;
        if(use_sky)
        {
-               vec3 sky_dir;
+               vec3 zenith_dir;
                if(use_normal_map)
-                       sky_dir = tbn_sky_dir;
+                       zenith_dir = tbn_zenith_dir;
                else
-                       sky_dir = eye_sky_dir;
-               float skylight_intensity = dot(normal, sky_dir)*0.5+0.5;
+                       zenith_dir = eye_zenith_dir;
+               float skylight_intensity = dot(normal, zenith_dir)*0.5+0.5;
                ambient_light += skylight_intensity*sky_color.rgb;
        }