1
0
Fork 0
forked from fte/fteqw

Proper support for lit sprites.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6167 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-01-17 09:13:05 +00:00
parent 2ed3378a75
commit 2ed9c6a968
4 changed files with 20 additions and 14 deletions

View file

@ -2733,6 +2733,12 @@ static void R_Sprite_GenerateTrisoup(entity_t *e, int bemode)
} }
VectorScale(e->shaderRGBAf, lightmap, rgba[0]); VectorScale(e->shaderRGBAf, lightmap, rgba[0]);
if (frame && frame->lit && !(r_refdef.flags & RDF_NOWORLDMODEL) && cl.worldmodel && cl.worldmodel->funcs.LightPointValues)
{
R_CalcModelLighting(e, e->model);
VectorMul(rgba[0], e->light_avg, rgba[0]);
VectorMA(rgba[0], 0.5, e->light_range, rgba[0]);
}
rgba[0][3] = e->shaderRGBAf[3]; rgba[0][3] = e->shaderRGBAf[3];
Vector4Copy(rgba[0], rgba[1]); Vector4Copy(rgba[0], rgba[1]);
Vector4Copy(rgba[0], rgba[2]); Vector4Copy(rgba[0], rgba[2]);

View file

@ -5655,7 +5655,7 @@ void Mod_LoadDoomSprite (model_t *mod)
//we need to override the rtlight shader for sprites so they get lit properly ignoring n+s+t dirs //we need to override the rtlight shader for sprites so they get lit properly ignoring n+s+t dirs
//so lets split the shader into parts to avoid too many dupes //so lets split the shader into parts to avoid too many dupes
#define SPRITE_SHADER_MAIN \ #define SPRITE_SHADER_MAIN(extra) \
"{\n" \ "{\n" \
"if gl_blendsprites\n" \ "if gl_blendsprites\n" \
"program defaultsprite\n" \ "program defaultsprite\n" \
@ -5675,9 +5675,12 @@ void Mod_LoadDoomSprite (model_t *mod)
"rgbgen vertex\n" \ "rgbgen vertex\n" \
"alphagen vertex\n" \ "alphagen vertex\n" \
"}\n" \ "}\n" \
"surfaceparm noshadows\n" "surfaceparm noshadows\n" \
#define SPRITE_SHADER_UNLIT "surfaceparm nodlight\n" extra \
#define SPRITE_SHADER_LIT \ "}\n"
#define SPRITE_SHADER_UNLIT SPRITE_SHADER_MAIN( \
"surfaceparm nodlight\n")
#define SPRITE_SHADER_LIT SPRITE_SHADER_MAIN( \
"sort seethrough\n" \ "sort seethrough\n" \
"bemode rtlight\n" \ "bemode rtlight\n" \
"{\n" \ "{\n" \
@ -5686,8 +5689,7 @@ void Mod_LoadDoomSprite (model_t *mod)
"map $diffuse\n" \ "map $diffuse\n" \
"blendfunc add\n" \ "blendfunc add\n" \
"}\n" \ "}\n" \
"}\n" "}\n")
#define SPRITE_SHADER_FOOTER "}\n"
void Mod_LoadSpriteFrameShader(model_t *spr, int frame, int subframe, mspriteframe_t *frameinfo) void Mod_LoadSpriteFrameShader(model_t *spr, int frame, int subframe, mspriteframe_t *frameinfo)
{ {
@ -5733,9 +5735,10 @@ void Mod_LoadSpriteFrameShader(model_t *spr, int frame, int subframe, mspritefra
#endif #endif
if (litsprite) // a ! in the filename makes it non-fullbright (and can also be lit by rtlights too). if (litsprite) // a ! in the filename makes it non-fullbright (and can also be lit by rtlights too).
shadertext = SPRITE_SHADER_MAIN SPRITE_SHADER_LIT SPRITE_SHADER_FOOTER; shadertext = SPRITE_SHADER_LIT;
else else
shadertext = SPRITE_SHADER_MAIN SPRITE_SHADER_UNLIT SPRITE_SHADER_FOOTER; shadertext = SPRITE_SHADER_UNLIT;
frameinfo->lit = litsprite;
frameinfo->shader = R_RegisterShader(name, SUF_NONE, shadertext); frameinfo->shader = R_RegisterShader(name, SUF_NONE, shadertext);
frameinfo->shader->defaulttextures->base = frameinfo->image; frameinfo->shader->defaulttextures->base = frameinfo->image;
frameinfo->shader->width = frameinfo->right-frameinfo->left; frameinfo->shader->width = frameinfo->right-frameinfo->left;

View file

@ -627,6 +627,7 @@ typedef struct mspriteframe_s
{ {
float up, down, left, right; float up, down, left, right;
qboolean xmirror; qboolean xmirror;
qboolean lit;
shader_t *shader; shader_t *shader;
image_t *image; image_t *image;
} mspriteframe_t; } mspriteframe_t;

View file

@ -3,12 +3,11 @@
//used by both particles and sprites. //used by both particles and sprites.
//note the fog blending mode is all that differs from defaultadditivesprite //note the fog blending mode is all that differs from defaultadditivesprite
#include "sys/defs.h"
#include "sys/fog.h" #include "sys/fog.h"
#ifdef VERTEX_SHADER
attribute vec2 v_texcoord;
attribute vec4 v_colour;
varying vec2 tc; varying vec2 tc;
varying vec4 vc; varying vec4 vc;
#ifdef VERTEX_SHADER
void main () void main ()
{ {
tc = v_texcoord; tc = v_texcoord;
@ -17,9 +16,6 @@ void main ()
} }
#endif #endif
#ifdef FRAGMENT_SHADER #ifdef FRAGMENT_SHADER
varying vec2 tc;
varying vec4 vc;
uniform vec4 e_colourident;
uniform vec4 e_vlscale; uniform vec4 e_vlscale;
void main () void main ()
{ {