]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
r_shadows 2: cast shadows always DOWN, ignore level lighting
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 10 Nov 2008 14:02:19 +0000 (14:02 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 10 Nov 2008 14:02:19 +0000 (14:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8555 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
r_shadow.c

index 14a1c3f47104c1e0b8f534ebc0c8623bee698b05..e5937b7ed7cebda3faeb1bfd59081178441c4d82 100644 (file)
@@ -58,7 +58,7 @@ cvar_t r_fullbright = {0, "r_fullbright","0", "makes map very bright and renders
 cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1", "opacity of water polygons"};
 cvar_t r_dynamic = {CVAR_SAVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"};
 cvar_t r_fullbrights = {CVAR_SAVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"};
-cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this)"};
+cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows DOWN, otherwise use the model lighting"};
 cvar_t r_shadows_throwdistance = {CVAR_SAVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"};
 cvar_t r_q1bsp_skymasking = {0, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"};
 cvar_t r_polygonoffset_submodel_factor = {0, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"};
index 17dc96b30b7aecdbe5182512014f3b61df9fc182..feed37e41844fddf7e08ae306a152ec38c184c40 100644 (file)
@@ -3173,6 +3173,7 @@ void R_ShadowVolumeLighting(qboolean visible)
 }
 
 extern void R_SetupView(qboolean allowwaterclippingplane);
+extern cvar_t r_shadows;
 extern cvar_t r_shadows_throwdistance;
 void R_DrawModelShadows(void)
 {
@@ -3212,31 +3213,40 @@ void R_DrawModelShadows(void)
                        VectorSet(relativeshadowmins, -relativethrowdistance, -relativethrowdistance, -relativethrowdistance);
                        VectorSet(relativeshadowmaxs, relativethrowdistance, relativethrowdistance, relativethrowdistance);
 
-                       if(ent->entitynumber != 0)
+                       if(r_shadows.integer == 2)
                        {
-                               // networked entity - might be attached in some way (then we should use the parent's light direction, to not tear apart attached entities)
-                               int entnum, entnum2, recursion;
-                               entnum = entnum2 = ent->entitynumber;
-                               for(recursion = 32; recursion > 0; --recursion)
+                               // 2: simpler mode, throw shadows always DOWN
+                               VectorSet(tmp, 0, 0, -1);
+                               Matrix4x4_Transform3x3(&ent->inversematrix, tmp, relativelightdirection);
+                       }
+                       else
+                       {
+                               if(ent->entitynumber != 0)
                                {
-                                       entnum2 = cl.entities[entnum].state_current.tagentity;
-                                       if(entnum2 >= 1 && entnum2 < cl.num_entities && cl.entities_active[entnum2])
-                                               entnum = entnum2;
+                                       // networked entity - might be attached in some way (then we should use the parent's light direction, to not tear apart attached entities)
+                                       int entnum, entnum2, recursion;
+                                       entnum = entnum2 = ent->entitynumber;
+                                       for(recursion = 32; recursion > 0; --recursion)
+                                       {
+                                               entnum2 = cl.entities[entnum].state_current.tagentity;
+                                               if(entnum2 >= 1 && entnum2 < cl.num_entities && cl.entities_active[entnum2])
+                                                       entnum = entnum2;
+                                               else
+                                                       break;
+                                       }
+                                       if(recursion && recursion != 32) // if we followed a valid non-empty attachment chain
+                                       {
+                                               VectorNegate(cl.entities[entnum].render.modellight_lightdir, relativelightdirection);
+                                               // transform into modelspace of OUR entity
+                                               Matrix4x4_Transform3x3(&cl.entities[entnum].render.matrix, relativelightdirection, tmp);
+                                               Matrix4x4_Transform3x3(&ent->inversematrix, tmp, relativelightdirection);
+                                       }
                                        else
-                                               break;
-                               }
-                               if(recursion && recursion != 32) // if we followed a valid non-empty attachment chain
-                               {
-                                       VectorNegate(cl.entities[entnum].render.modellight_lightdir, relativelightdirection);
-                                       // transform into modelspace of OUR entity
-                                       Matrix4x4_Transform3x3(&cl.entities[entnum].render.matrix, relativelightdirection, tmp);
-                                       Matrix4x4_Transform3x3(&ent->inversematrix, tmp, relativelightdirection);
+                                               VectorNegate(ent->modellight_lightdir, relativelightdirection);
                                }
                                else
                                        VectorNegate(ent->modellight_lightdir, relativelightdirection);
                        }
-                       else
-                               VectorNegate(ent->modellight_lightdir, relativelightdirection);
 
                        VectorScale(relativelightdirection, -relativethrowdistance, relativelightorigin);
                        RSurf_ActiveModelEntity(ent, false, false);