nametag rendering
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / model_character_view.h
index bae5d38721bcd9c285308f4a3c88059d61ae9348..060e5b2419c3fd715fcf9c1c5e7447ba12749c20 100644 (file)
@@ -75,11 +75,7 @@ static struct vg_shader _shader_model_character_view = {
 .orig_file = "shaders/model_character_view.fs",
 .static_src = 
 "uniform sampler2D uTexMain;\n"
-"uniform sampler2D uTexSceneDepth;\n"
 "uniform vec3 uCamera;\n"
-"uniform vec3 uInverseRatioDepth;\n"
-"uniform vec3 uInverseRatioMain;\n"
-"uniform bool uDepthCompare;\n"
 "\n"
 "in vec4 aColour;\n"
 "in vec2 aUv;\n"
@@ -389,7 +385,7 @@ static struct vg_shader _shader_model_character_view = {
 "   return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n"
 "}\n"
 "\n"
-"#line     15        0 \n"
+"#line     11        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -409,25 +405,19 @@ static struct vg_shader _shader_model_character_view = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     16        0 \n"
+"#line     12        0 \n"
+"#line       1        3 \n"
+"uniform sampler2D uTexSceneDepth;\n"
+"uniform vec3 uInverseRatioDepth;\n"
+"uniform vec3 uInverseRatioMain;\n"
+"uniform bool uDepthCompare;\n"
 "\n"
-"float linear_depth( float depth, float near, float far ) \n"
-"{\n"
+"float linear_depth( float depth, float near, float far ) {\n"
 "   float z = depth * 2.0 - 1.0;\n"
 "   return (2.0 * near * far) / (far + near - z * (far - near));       \n"
 "}\n"
 "\n"
-"void main()\n"
-"{\n"
-"   compute_motion_vectors();\n"
-"\n"
-"   vec3 qnorm     = aNorm;\n"
-"   vec3 diffuse   = texture( uTexMain, aUv ).rgb;\n"
-"   vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n"
-"\n"
-"   float dist    = distance( aWorldCo, uCamera ) - 0.08;\n"
-"   float opacity = clamp( dist*dist, 0.0, 1.0 );\n"
-"\n"
+"void depth_compare_dither(){\n"
 "   if( uDepthCompare ){\n"
 "      vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n"
 "                                        * uInverseRatioDepth.xy;\n"
@@ -444,6 +434,20 @@ static struct vg_shader _shader_model_character_view = {
 "      if( step(0.0,diff)+dither<0.3 )\n"
 "         discard;\n"
 "   }\n"
+"}\n"
+"\n"
+"#line     13        0 \n"
+"\n"
+"void main(){\n"
+"   depth_compare_dither();\n"
+"   compute_motion_vectors();\n"
+"\n"
+"   vec3 qnorm     = aNorm;\n"
+"   vec3 diffuse   = texture( uTexMain, aUv ).rgb;\n"
+"   vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n"
+"\n"
+"   float dist    = distance( aWorldCo, uCamera ) - 0.08;\n"
+"   float opacity = clamp( dist*dist, 0.0, 1.0 );\n"
 "\n"
 "   oColour = vec4( composite, opacity );\n"
 "}\n"
@@ -453,26 +457,29 @@ static struct vg_shader _shader_model_character_view = {
 static GLuint _uniform_model_character_view_uPv;
 static GLuint _uniform_model_character_view_uTransforms;
 static GLuint _uniform_model_character_view_uTexMain;
-static GLuint _uniform_model_character_view_uTexSceneDepth;
 static GLuint _uniform_model_character_view_uCamera;
-static GLuint _uniform_model_character_view_uInverseRatioDepth;
-static GLuint _uniform_model_character_view_uInverseRatioMain;
-static GLuint _uniform_model_character_view_uDepthCompare;
 static GLuint _uniform_model_character_view_g_world_depth;
 static GLuint _uniform_model_character_view_uLightsArray;
 static GLuint _uniform_model_character_view_uLightsIndex;
+static GLuint _uniform_model_character_view_uTexSceneDepth;
+static GLuint _uniform_model_character_view_uInverseRatioDepth;
+static GLuint _uniform_model_character_view_uInverseRatioMain;
+static GLuint _uniform_model_character_view_uDepthCompare;
 static void shader_model_character_view_uPv(m4x4f m){
    glUniformMatrix4fv(_uniform_model_character_view_uPv,1,GL_FALSE,(float*)m);
 }
 static void shader_model_character_view_uTexMain(int i){
    glUniform1i(_uniform_model_character_view_uTexMain,i);
 }
-static void shader_model_character_view_uTexSceneDepth(int i){
-   glUniform1i(_uniform_model_character_view_uTexSceneDepth,i);
-}
 static void shader_model_character_view_uCamera(v3f v){
    glUniform3fv(_uniform_model_character_view_uCamera,1,v);
 }
+static void shader_model_character_view_g_world_depth(int i){
+   glUniform1i(_uniform_model_character_view_g_world_depth,i);
+}
+static void shader_model_character_view_uTexSceneDepth(int i){
+   glUniform1i(_uniform_model_character_view_uTexSceneDepth,i);
+}
 static void shader_model_character_view_uInverseRatioDepth(v3f v){
    glUniform3fv(_uniform_model_character_view_uInverseRatioDepth,1,v);
 }
@@ -482,9 +489,6 @@ static void shader_model_character_view_uInverseRatioMain(v3f v){
 static void shader_model_character_view_uDepthCompare(int b){
    glUniform1i(_uniform_model_character_view_uDepthCompare,b);
 }
-static void shader_model_character_view_g_world_depth(int i){
-   glUniform1i(_uniform_model_character_view_g_world_depth,i);
-}
 static void shader_model_character_view_register(void){
    vg_shader_register( &_shader_model_character_view );
 }
@@ -493,13 +497,13 @@ static void shader_model_character_view_link(void){
    _uniform_model_character_view_uPv = glGetUniformLocation( _shader_model_character_view.id, "uPv" );
    _uniform_model_character_view_uTransforms = glGetUniformLocation( _shader_model_character_view.id, "uTransforms" );
    _uniform_model_character_view_uTexMain = glGetUniformLocation( _shader_model_character_view.id, "uTexMain" );
-   _uniform_model_character_view_uTexSceneDepth = glGetUniformLocation( _shader_model_character_view.id, "uTexSceneDepth" );
    _uniform_model_character_view_uCamera = glGetUniformLocation( _shader_model_character_view.id, "uCamera" );
-   _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" );
-   _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" );
-   _uniform_model_character_view_uDepthCompare = glGetUniformLocation( _shader_model_character_view.id, "uDepthCompare" );
    _uniform_model_character_view_g_world_depth = glGetUniformLocation( _shader_model_character_view.id, "g_world_depth" );
    _uniform_model_character_view_uLightsArray = glGetUniformLocation( _shader_model_character_view.id, "uLightsArray" );
    _uniform_model_character_view_uLightsIndex = glGetUniformLocation( _shader_model_character_view.id, "uLightsIndex" );
+   _uniform_model_character_view_uTexSceneDepth = glGetUniformLocation( _shader_model_character_view.id, "uTexSceneDepth" );
+   _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" );
+   _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" );
+   _uniform_model_character_view_uDepthCompare = glGetUniformLocation( _shader_model_character_view.id, "uDepthCompare" );
 }
 #endif /* SHADER_model_character_view_H */