GLSL: Chrome is now identical to the non-GLSL renderer, emulating TCGEN_ENVIRONMENT properly. It's still not GoldSrc accurate, as the models themselves contain chrome information for every bone (wth)

Flashlight: You can now see other players' light being cast.
This commit is contained in:
Marco Cawthorne 2019-03-13 20:46:07 +01:00
parent d18d7bf561
commit 2af78be51a
10 changed files with 81 additions and 23 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*~
*.lno
csqccore.txt
ssqccore.txt
menucore.txt
conhistory.txt
condump.txt
config.cfg
fte.cfg
qkey

View File

@ -32,7 +32,7 @@ void Player_ReadEntity(float flIsNew)
pl.origin[0] = readcoord();
pl.origin[1] = readcoord();
pl.origin[2] = readcoord();
pl.pitch = readcoord() / 90;
pl.pitch = readcoord();
pl.angles[1] = readcoord();
pl.angles[2] = readcoord();
pl.velocity[0] = readcoord();

View File

@ -165,12 +165,6 @@ void CSQC_UpdateView(float w, float h, float focus)
View_DrawViewModel();
}
// TODO: Move this someplace less... entry-ish. like into a pre-draw.
if (pl.flags & FL_FLASHLIGHT) {
traceline(getproperty(VF_ORIGIN), getproperty(VF_ORIGIN) + (v_forward * 9000), FALSE, self);
dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]);
}
addentities(MASK_ENGINE);
setproperty(VF_MIN, video_mins);
setproperty(VF_SIZE, video_res);

View File

@ -51,15 +51,25 @@ string sPModels[CS_WEAPON_COUNT - 1] = {
void player::gun_offset(void)
{
vector v1, v2;
this.p_model.angles = this.angles; // Set it to something consistent
gettaginfo(this, this.p_hand_bone); // Updates the v_ globals for the player hand bone angle
v1 = vectoangles(v_right, v_up); // Create angles from the v_ matrix
gettaginfo(this.p_model, this.p_model_bone); // Updates the v_ globals for the weapon hand bone angle
v2 = vectoangles(v_right, v_up);
this.p_model.angles = this.angles + (v1 - v2); // The difference is applied
// Fix the origin
setorigin(this.p_model, this.origin); // Set it to something consistent
/* Set it to something consistent */
this.p_model.angles = this.angles;
/* Updates the v_ globals for the player hand bone angle */
gettaginfo(this, this.p_hand_bone);
/* Create angles from the v_ matrix */
v1 = vectoangles(v_right, v_up);
/* Updates the v_ globals for the weapon hand bone angle */
gettaginfo(this.p_model, this.p_model_bone);
v2 = vectoangles(v_right, v_up);
/* The difference is applied */
this.p_model.angles = this.angles + (v1 - v2);
/* Fix the origin */
setorigin(this.p_model, this.origin);
vector ofs = gettaginfo(this.p_model, this.p_model_bone) - gettaginfo(this, this.p_hand_bone);
setorigin(this.p_model, this.origin - ofs);
}
@ -72,9 +82,9 @@ void player::draw(void)
this.p_model.owner = this;
}
this.subblend2frac = this.pitch;
this.subblend2frac = this.pitch / 90;
// Only bother updating the model if the weapon has changed
/* Only bother updating the model if the weapon has changed */
if (this.lastweapon != this.activeweapon) {
if (this.activeweapon) {
#ifdef CSTRIKE
@ -85,8 +95,8 @@ void player::draw(void)
}
this.lastweapon = this.activeweapon;
// Update the bone index of the current p_ model so we can calculate the offset
// Get the weapon bone ID for the current player model
/* Update the bone index of the current p_ model so we can calculate the offset
* and get the weapon bone ID for the current player model */
this.p_hand_bone = gettagindex(this, "Bip01 R Hand");
this.p_model_bone = gettagindex(this.p_model, "Bip01 R Hand");
}
@ -150,6 +160,30 @@ void player::draw(void)
float player::predraw(void)
{
/* Handle the flashlights... */
if (flags & FL_FLASHLIGHT) {
vector src;
vector ang;
if (this.entnum != player_localentnum) {
src = origin + view_ofs;
ang = [pitch, angles[1], angles[2]];
} else {
src = getproperty(VF_ORIGIN);
ang = getproperty(VF_CL_VIEWANGLES);
}
makevectors(ang);
traceline(src, src + (v_forward * 8096), FALSE, self);
if (serverkeyfloat("*bspversion") == 30) {
dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]);
} else {
float p = dynamiclight_add(src, 512, [1,1,1], 0, "textures/flashlight");
dynamiclight_set(p, LFIELD_ANGLES, ang);
}
}
/* Run animations regardless of rendering the player */
draw();
gun_offset();

View File

@ -23,7 +23,7 @@ void Player_ReadEntity(float flIsNew)
pl.origin[0] = readcoord();
pl.origin[1] = readcoord();
pl.origin[2] = readcoord();
pl.pitch = readcoord() / 90;
pl.pitch = readcoord();
pl.angles[1] = readcoord();
pl.angles[2] = readcoord();
pl.velocity[0] = readcoord();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -26,6 +26,22 @@ varying vec3 light;
return ( dot( normal, dir ) * 0.5 ) + 0.5;
}*/
#ifdef CHROME
/* Rotate Light Vector */
vec3 rlv(vec3 axis, vec3 origin, vec3 lightpoint)
{
vec3 offs;
vec3 result;
offs[0] = lightpoint[0] - origin[0];
offs[1] = lightpoint[1] - origin[1];
offs[2] = lightpoint[2] - origin[2];
result[0] = dot(offs[0], axis[0]);
result[1] = dot(offs[1], axis[1]);
result[2] = dot(offs[2], axis[2]);
return result;
}
#endif
void main ()
{
vec3 n, s, t, w;
@ -34,9 +50,13 @@ varying vec3 light;
light = e_light_ambient + (e_light_mul * dot(n, e_light_dir));
#ifdef CHROME
vec3 viewc = normalize(e_eyepos - v_position.xyz);
vec3 rorg = rlv(vec3(0,0,0), w, e_light_dir);
vec3 viewc = normalize(rorg - w);
float d = dot(n, viewc);
vec3 reflected = n * 2 * d - viewc;
vec3 reflected;
reflected.x = n.x * 2 * d - viewc.x;
reflected.y = n.y * 2 * d - viewc.y;
reflected.z = n.z * 2 * d - viewc.z;
tex_c.x = 0.5 + reflected.y * 0.5;
tex_c.y = 0.5 - reflected.z * 0.5;
#endif