mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
OpenGL modes: factor out shade factor calculation.
This also means that the "r_shadescale_unbounded 0" option will work in Polymer (except on models). git-svn-id: https://svn.eduke32.com/eduke32@3286 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
13bff37caa
commit
884302bea1
3 changed files with 12 additions and 10 deletions
|
@ -93,6 +93,13 @@ extern float alphahackarray[MAXTILES];
|
|||
|
||||
extern int32_t r_usenewshading;
|
||||
|
||||
static inline float getshadefactor(int32_t shade)
|
||||
{
|
||||
int32_t shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
|
||||
float clamped_shade = min(max(shade*shadescale, 0), shadebound);
|
||||
return ((float)(numshades-clamped_shade))/(float)numshades;
|
||||
}
|
||||
|
||||
typedef struct pthtyp_t
|
||||
{
|
||||
struct pthtyp_t *next;
|
||||
|
|
|
@ -3781,8 +3781,7 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
|
|||
pth = gltexcache(picnum, palnum, 0);
|
||||
glpics[i] = pth ? pth->glpic : 0;
|
||||
|
||||
glcolors[i][0] = glcolors[i][1] = glcolors[i][2] =
|
||||
((float)(numshades-min(max(shade*shadescale,0),numshades)))/((float)numshades);
|
||||
glcolors[i][0] = glcolors[i][1] = glcolors[i][2] = getshadefactor(shade);
|
||||
|
||||
if (pth && (pth->flags & 2))
|
||||
{
|
||||
|
@ -3871,8 +3870,7 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
|
|||
drawingskybox = i + 1;
|
||||
pth = gltexcache(tilenum, palnum, 4);
|
||||
|
||||
color[0] = color[1] = color[2] =
|
||||
((float)(numshades-min(max(shade*shadescale,0),numshades)))/((float)numshades);
|
||||
color[0] = color[1] = color[2] = getshadefactor(shade);
|
||||
|
||||
if (pth && (pth->flags & 2))
|
||||
{
|
||||
|
@ -4495,7 +4493,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
material->diffusemodulation[0] =
|
||||
material->diffusemodulation[1] =
|
||||
material->diffusemodulation[2] =
|
||||
(GLubyte)(((float)(numshades-min(max((shade * shadescale),0),numshades)))/((float)numshades) * 0xFF);
|
||||
(GLubyte)(getshadefactor(shade) * 0xFF);
|
||||
|
||||
if (pth->flags & 2)
|
||||
{
|
||||
|
|
|
@ -2289,9 +2289,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
|||
|
||||
{
|
||||
float pc[4];
|
||||
int32_t shadebound = (shadescale_unbounded || globalshade>=numshades) ? numshades : numshades-1;
|
||||
f = ((float)(numshades-min(max((globalshade * shadescale),0),shadebound)))/((float)numshades);
|
||||
pc[0] = pc[1] = pc[2] = f;
|
||||
pc[0] = pc[1] = pc[2] = getshadefactor(globalshade);
|
||||
switch (method&3)
|
||||
{
|
||||
default:
|
||||
|
@ -5948,7 +5946,6 @@ void polymost_fillpolygon(int32_t npoints)
|
|||
pthtyp *pth;
|
||||
float f,a=0.0;
|
||||
int32_t i;
|
||||
int32_t shadebound = (shadescale_unbounded || globalshade>=numshades) ? numshades : numshades-1;
|
||||
|
||||
globalx1 = mulscale16(globalx1,xyaspect);
|
||||
globaly2 = mulscale16(globaly2,xyaspect);
|
||||
|
@ -5972,7 +5969,7 @@ void polymost_fillpolygon(int32_t npoints)
|
|||
pth = gltexcache(globalpicnum,globalpal,0);
|
||||
bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
|
||||
|
||||
f = ((float)(numshades-min(max((globalshade * shadescale),0),shadebound)))/((float)numshades);
|
||||
f = getshadefactor(globalshade);
|
||||
switch ((globalorientation>>7)&3)
|
||||
{
|
||||
case 0:
|
||||
|
|
Loading…
Reference in a new issue