]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_particles.c
add dpsoftrast to some missing targets
[xonotic/darkplaces.git] / cl_particles.c
index 955a579189c2633f0eabb1c287ad2d673771dba5..a1af7730169c4b9833b0ade7d74a6df65e624730 100644 (file)
@@ -1983,6 +1983,7 @@ static void R_InitParticleTexture (void)
        char *buf;
        fs_offset_t filesize;
        char texturename[MAX_QPATH];
+       skinframe_t *sf;
 
        // a note: decals need to modulate (multiply) the background color to
        // properly darken it (stain), and they need to be able to alpha fade,
@@ -2241,7 +2242,13 @@ static void R_InitParticleTexture (void)
                                Con_Printf("particles/particlefont.txt: texnum %i outside valid range (0 to %i)\n", i, MAX_PARTICLETEXTURES);
                                continue;
                        }
-                       particletexture[i].texture = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, false)->base;
+                       sf = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, true);
+                       if(!sf)
+                       {
+                               // R_SkinFrame_LoadExternal already complained
+                               continue;
+                       }
+                       particletexture[i].texture = sf->base;
                        particletexture[i].s1 = s1;
                        particletexture[i].t1 = t1;
                        particletexture[i].s2 = s2;
@@ -2525,14 +2532,14 @@ 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)
                        {
-                               R_CompleteLightPoint(ambient, diffuse, diffusenormal, p->org, true, false);
+                               R_CompleteLightPoint(ambient, diffuse, diffusenormal, p->org, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT);
                                c4f[0] *= (ambient[0] + 0.5 * diffuse[0]);
                                c4f[1] *= (ambient[1] + 0.5 * diffuse[1]);
                                c4f[2] *= (ambient[2] + 0.5 * diffuse[2]);
@@ -2546,6 +2553,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