Platform: Add gl_stipplealpha support to models.

This commit is contained in:
Marco Cawthorne 2020-10-25 11:50:15 +01:00
parent 4962f82f89
commit 8cbbeaae24
8 changed files with 85 additions and 30 deletions

View file

@ -8,6 +8,7 @@
!!cvardf gl_halflambert=1
!!cvardf gl_mono=0
!!cvardf gl_kdither=0
!!cvardf gl_stipplealpha=0
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -151,6 +152,33 @@ varying vec3 light;
diffuse_f *= e_colourident;
// awful stipple alpha code
if (gl_stipplealpha == 1.0) {
float alpha = e_colourident.a;
int x = int(mod(gl_FragCoord.x, 2.0));
int y = int(mod(gl_FragCoord.y, 2.0));
if (alpha <= 0.0) {
discard;
} else if (alpha <= 0.25) {
diffuse_f.a = 1.0f;
if (x + y == 2)
discard;
if (x + y == 1)
discard;
} else if (alpha <= 0.5) {
diffuse_f.a = 1.0f;
if (x + y == 2)
discard;
if (x + y == 0)
discard;
} else if (alpha < 1.0) {
diffuse_f.a = 1.0f;
if (x + y == 2)
discard;
}
}
if (gl_mono == 1.0) {
float bw = (diffuse_f.r + diffuse_f.g + diffuse_f.b) / 3.0;
diffuse_f.rgb = vec3(bw, bw, bw);

View file

@ -6,6 +6,7 @@
#define VALVE
#define CSTRIKE
#define BULLETPENETRATION
#define BULLETPATTERNS
#define GS_RENDERFX
#includelist

View file

@ -24,6 +24,7 @@
#include "weapons.h"
#include "plugins.h"
#include "vehicles.h"
#include "traceattack.h"
#define CLASSEXPORT(classname,classa) void classname(void) { spawnfunc_##classa(); }
@ -59,7 +60,6 @@ entity g_eAttacker;
.entity eUser;
.float material;
.float deaths;
.float fStepTime;
.float identity;
/* in idTech the .owner field causes collisions to fail against set entity,

View file

@ -14,10 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* TODO: Move this into the player class. Monsters will call steps via
* modelevents. */
.int iStep;
/* HLBSP materials.txt character id's */
#define MATID_ALIEN 'H'
#define MATID_BLOODYFLESH 'B'
@ -37,7 +33,7 @@
/* Valve Half-Life BSP */
void
Footsteps_HLBSP(entity target)
Footsteps_HLBSP(base_player target)
{
string mat_name = "";
string tex_name = "";
@ -100,7 +96,7 @@ Footsteps_HLBSP(entity target)
mat_name = "step_ladder";
}
if (target.iStep) {
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
@ -109,7 +105,7 @@ Footsteps_HLBSP(entity target)
/* Vera Visions BSP / Modified RFBSP */
void
Footsteps_VVBSP(entity target)
Footsteps_VVBSP(base_player target)
{
string mat_name = "";
@ -173,7 +169,7 @@ Footsteps_VVBSP(entity target)
mat_name = "step_ladder";
}
if (target.iStep) {
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
@ -182,7 +178,7 @@ Footsteps_VVBSP(entity target)
/* anything unsupported */
void
Footsteps_Default(entity target)
Footsteps_Default(base_player target)
{
string mat_name = "";
@ -193,7 +189,7 @@ Footsteps_Default(entity target)
mat_name = "step_ladder";
}
if (target.iStep) {
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
@ -210,34 +206,41 @@ Run every frame for each player, plays material based footsteps
void
Footsteps_Update(void)
{
if (self.movetype == MOVETYPE_WALK) {
if ((self.velocity[0] == 0 && self.velocity[1] == 0) || self.fStepTime > time) {
base_player pl;
if (self.classname != "player")
return;
pl = (base_player)self;
if (pl.movetype == MOVETYPE_WALK) {
if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time) {
return;
}
/* make it so we step once we land */
if (!(self.flags & FL_ONGROUND) && !(self.flags & FL_ONLADDER)) {
self.fStepTime = 0.0f;
if (!(pl.flags & FL_ONGROUND) && !(pl.flags & FL_ONLADDER)) {
pl.step_time = 0.0f;
return;
}
/* the footsteps call might overwrite this later */
self.fStepTime = time + 0.35;
pl.step_time = time + 0.35;
switch (serverkeyfloat("*bspversion")) {
case 30: /* HL */
Footsteps_HLBSP(self);
Footsteps_HLBSP(pl);
break;
case 46: /* Q3 */
case 47: /* RtCW */
case 1: /* RFVBSP */
Footsteps_VVBSP(self);
Footsteps_VVBSP(pl);
break;
default:
Footsteps_Default(self);
Footsteps_Default(pl);
}
/* switch between feet */
self.iStep = 1 - self.iStep;
pl.step = 1 - pl.step;
}
}

View file

@ -16,4 +16,4 @@
*/
void Skill_Init(void);
float Skill_GetValue(string);
float Skill_GetValue(string);

View file

@ -14,10 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef BULLETPENETRATION
var int iTotalPenetrations;
#endif
/* cast a single bullet shot */
void
TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
@ -29,9 +25,9 @@ TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
range = (vAngle * 8196);
traceline(vecPos, vecPos + range, MOVE_LAGGED | MOVE_HITMODEL, self);
if (trace_fraction >= 1.0f) {
if (trace_fraction >= 1.0f)
return;
}
if (trace_ent.takedamage == DAMAGE_YES) {
#ifdef CSTRIKE
@ -58,9 +54,8 @@ TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
}
#else
/* only headshots count in HL */
if (trace_surface_id == BODY_HEAD) {
if (trace_surface_id == BODY_HEAD)
iDamage *= 3;
}
#endif
Damage_Apply(trace_ent, self, iDamage, iWeapon, DMG_BULLET);
}
@ -116,7 +111,7 @@ TraceAttack_FireBullets(int iShots, vector vecPos, int iDamage, vector vecSpread
while (iShots > 0) {
vDir = aim(self, 100000);
#ifndef CSTRIKE
#ifndef BULLETPATTERNS
vDir += random(-1,1) * vecSpread[0] * v_right;
vDir += random(-1,1) * vecSpread[1] * v_up;
#else

26
src/server/traceattack.h Normal file
View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef BULLETPENETRATION
var int iTotalPenetrations;
#endif
void TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon);
void TraceAttack_FireBullets(int iShots, vector vecPos, int iDamage, vector vecSpread, int iWeapon);
#ifdef BULLETPENETRATION
void TraceAttack_SetPenetrationPower(int power);
#endif

View file

@ -76,5 +76,7 @@ class base_player
int old_a_ammo3;
int voted;
int step;
float step_time;
#endif
};