]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix fog on particles (premultiplied alpha change was doing it wrong)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 19 Nov 2010 13:55:20 +0000 (13:55 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 19 Nov 2010 13:55:20 +0000 (13:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10615 d7cf8633-e32d-0410-b094-e92efae38249

cl_particles.c

index 955a579189c2633f0eabb1c287ad2d673771dba5..d0991e531e853afa28632924c3cd11a05e109b45 100644 (file)
@@ -2525,9 +2525,9 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh
                        c4f[3] = 0;
                        break;
                case PBLEND_ALPHA:
-                       c4f[0] = alpha * p->color[0] * colormultiplier[0];
-                       c4f[1] = alpha * p->color[1] * colormultiplier[1];
-                       c4f[2] = alpha * p->color[2] * colormultiplier[2];
+                       c4f[0] = p->color[0] * colormultiplier[0];
+                       c4f[1] = p->color[1] * colormultiplier[1];
+                       c4f[2] = p->color[2] * colormultiplier[2];
                        c4f[3] = alpha;
                        // note: lighting is not cheap!
                        if (particletype[p->typeindex].lighting)
@@ -2546,6 +2546,8 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh
                                c4f[1] = c4f[1] * fog + r_refdef.fogcolor[1] * ifog;
                                c4f[2] = c4f[2] * fog + r_refdef.fogcolor[2] * ifog;
                        }
+                       // for premultiplied alpha we have to apply the alpha to the color (after fog of course)
+                       VectorScale(c4f, alpha, c4f);
                        break;
                }
                // copy the color into the other three vertices