mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Support clamping in polymost1Frag.glsl and use it for sprites
git-svn-id: https://svn.eduke32.com/eduke32@7783 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/include/polymost.h # source/build/src/polymost1Frag.glsl # source/build/src/voxmodel.cpp
This commit is contained in:
parent
a55e19ed83
commit
1664310159
6 changed files with 52 additions and 2 deletions
|
@ -59,6 +59,10 @@ void polymost_resetVertexPointers(void);
|
|||
void polymost_disableProgram(void);
|
||||
void polymost_resetProgram(void);
|
||||
void polymost_setTexturePosSize(vec4f_t const &texturePosSize);
|
||||
void polymost_setHalfTexelSize(vec2f_t const &halfTexelSize);
|
||||
char polymost_getClamp();
|
||||
void polymost_setClamp(char clamp);
|
||||
void polymost_setVisibility(float visibility);
|
||||
void polymost_setFogEnabled(char fogEnabled);
|
||||
void polymost_useColorOnly(char useColorOnly);
|
||||
void polymost_usePaletteIndexing(char usePaletteIndexing);
|
||||
|
|
|
@ -8897,6 +8897,7 @@ killsprite:
|
|||
{
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
polymost_setClamp(true);
|
||||
|
||||
for (i = spritesortcnt; i < numSprites; ++i)
|
||||
{
|
||||
|
@ -8909,6 +8910,7 @@ killsprite:
|
|||
}
|
||||
}
|
||||
|
||||
polymost_setClamp(false);
|
||||
for (i = 0; i < maskwallcnt;)
|
||||
{
|
||||
if (polymost_maskWallHasTranslucency((uwalltype *) &wall[thewall[maskwall[maskwallcnt-1]]]))
|
||||
|
@ -8973,6 +8975,11 @@ killsprite:
|
|||
_equation p1eq = equation(pos.x, pos.y, dot.x, dot.y);
|
||||
_equation p2eq = equation(pos.x, pos.y, dot2.x, dot2.y);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (videoGetRenderMode() == REND_POLYMOST)
|
||||
polymost_setClamp(true);
|
||||
#endif
|
||||
|
||||
i = spritesortcnt;
|
||||
while (i)
|
||||
{
|
||||
|
@ -9057,9 +9064,17 @@ killsprite:
|
|||
}
|
||||
|
||||
debugmask_add(maskwall[maskwallcnt], thewall[maskwall[maskwallcnt]]);
|
||||
#ifdef USE_OPENGL
|
||||
if (videoGetRenderMode() == REND_POLYMOST)
|
||||
polymost_setClamp(false);
|
||||
#endif
|
||||
renderDrawMaskedWall(maskwallcnt);
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (videoGetRenderMode() == REND_POLYMOST)
|
||||
polymost_setClamp(true);
|
||||
#endif
|
||||
while (spritesortcnt)
|
||||
{
|
||||
--spritesortcnt;
|
||||
|
@ -9072,7 +9087,10 @@ killsprite:
|
|||
}
|
||||
#ifdef USE_OPENGL
|
||||
if (videoGetRenderMode() == REND_POLYMOST)
|
||||
{
|
||||
glDepthMask(GL_TRUE);
|
||||
polymost_setClamp(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef POLYMER
|
||||
|
|
|
@ -2083,6 +2083,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
float const xpanning = (float)sext->xpanning * (1.f/256.f);
|
||||
float const ypanning = (float)sext->ypanning * (1.f/256.f);
|
||||
|
||||
char prevClamp = polymost_getClamp();
|
||||
polymost_setClamp(false);
|
||||
polymost_usePaletteIndexing(false);
|
||||
polymost_setTexturePosSize({ 0.f, 0.f, 1.f, 1.f });
|
||||
|
||||
|
@ -2264,6 +2266,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
polymost_setClamp(prevClamp);
|
||||
polymost_usePaletteIndexing(true);
|
||||
polymost_resetVertexPointers();
|
||||
|
||||
|
|
|
@ -171,6 +171,8 @@ static vec2f_t polymost1PalswapPos = { 0.f, 0.f };
|
|||
static GLint polymost1PalswapSizeLoc = -1;
|
||||
static vec2f_t polymost1PalswapSize = { 0.f, 0.f };
|
||||
static vec2f_t polymost1PalswapInnerSize = { 0.f, 0.f };
|
||||
static GLint polymost1ClampLoc = -1;
|
||||
static float polymost1Clamp = 0.f;
|
||||
static GLint polymost1ShadeLoc = -1;
|
||||
static float polymost1Shade = 0.f;
|
||||
static GLint polymost1NumShadesLoc = -1;
|
||||
|
@ -528,6 +530,7 @@ static void polymost_setCurrentShaderProgram(uint32_t programID)
|
|||
polymost1HalfTexelSizeLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_halfTexelSize");
|
||||
polymost1PalswapPosLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_palswapPos");
|
||||
polymost1PalswapSizeLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_palswapSize");
|
||||
polymost1ClampLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_clamp");
|
||||
polymost1ShadeLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_shade");
|
||||
polymost1NumShadesLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_numShades");
|
||||
polymost1VisFactorLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_visFactor");
|
||||
|
@ -548,6 +551,7 @@ static void polymost_setCurrentShaderProgram(uint32_t programID)
|
|||
glUniform2f(polymost1HalfTexelSizeLoc, polymost1HalfTexelSize.x, polymost1HalfTexelSize.y);
|
||||
glUniform2f(polymost1PalswapPosLoc, polymost1PalswapPos.x, polymost1PalswapPos.y);
|
||||
glUniform2f(polymost1PalswapSizeLoc, polymost1PalswapInnerSize.x, polymost1PalswapInnerSize.y);
|
||||
glUniform1f(polymost1ClampLoc, polymost1Clamp);
|
||||
glUniform1f(polymost1ShadeLoc, polymost1Shade);
|
||||
glUniform1f(polymost1NumShadesLoc, polymost1NumShades);
|
||||
glUniform1f(polymost1VisFactorLoc, polymost1VisFactor);
|
||||
|
@ -611,6 +615,21 @@ static void polymost_setPalswapSize(uint32_t width, uint32_t height)
|
|||
glUniform2f(polymost1PalswapSizeLoc, polymost1PalswapInnerSize.x, polymost1PalswapInnerSize.y);
|
||||
}
|
||||
|
||||
char polymost_getClamp()
|
||||
{
|
||||
return polymost1Clamp;
|
||||
}
|
||||
|
||||
void polymost_setClamp(char clamp)
|
||||
{
|
||||
if (currentShaderProgramID != polymost1CurrentShaderProgramID ||
|
||||
clamp == polymost1Clamp)
|
||||
return;
|
||||
|
||||
polymost1Clamp = clamp;
|
||||
glUniform1f(polymost1ClampLoc, polymost1Clamp);
|
||||
}
|
||||
|
||||
static void polymost_setShade(int32_t shade)
|
||||
{
|
||||
if (currentShaderProgramID != polymost1CurrentShaderProgramID)
|
||||
|
@ -6579,6 +6598,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
|
||||
globvis = 0;
|
||||
globvis2 = 0;
|
||||
polymost_setClamp(true);
|
||||
polymost_setVisibility(globvis2);
|
||||
|
||||
int32_t const ogpicnum = globalpicnum;
|
||||
|
@ -6792,6 +6812,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
polymost_setClamp(false);
|
||||
|
||||
#ifdef POLYMER
|
||||
if (videoGetRenderMode() == REND_POLYMER)
|
||||
|
|
|
@ -21,6 +21,8 @@ uniform vec2 u_halfTexelSize;
|
|||
uniform vec2 u_palswapPos;
|
||||
uniform vec2 u_palswapSize;
|
||||
|
||||
uniform float u_clamp;
|
||||
|
||||
uniform float u_shade;
|
||||
uniform float u_numShades;
|
||||
uniform float u_visFactor;
|
||||
|
@ -61,7 +63,7 @@ void main()
|
|||
vec2 newCoord = mix(gl_TexCoord[0].xy,mix(vec2(coordX,coordY),vec2(coordY,coordX),u_usePalette),u_npotEmulation);
|
||||
vec2 transitionBlend = fwidth(floor(newCoord.xy));
|
||||
transitionBlend = fwidth(transitionBlend)+transitionBlend;
|
||||
vec2 texCoord = mix(fract(newCoord.xy), abs(c_one-mod(newCoord.xy+c_one, c_two)), transitionBlend);
|
||||
vec2 texCoord = mix(mix(fract(newCoord.xy), abs(c_one-mod(newCoord.xy+c_one, c_two)), transitionBlend), clamp(newCoord.xy, c_zero, c_one), u_clamp);
|
||||
texCoord = clamp(u_texturePosSize.zw*texCoord, u_halfTexelSize, u_texturePosSize.zw-u_halfTexelSize);
|
||||
vec4 color = texture2D(s_texture, u_texturePosSize.xy+texCoord);
|
||||
|
||||
|
|
|
@ -1131,6 +1131,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
#endif
|
||||
const float phack[2] = { 0, 1.f/256.f };
|
||||
|
||||
char prevClamp = polymost_getClamp();
|
||||
polymost_setClamp(false);
|
||||
if (!m->texid[globalpal])
|
||||
m->texid[globalpal] = gloadtex(m->mytex, m->mytexx, m->mytexy, m->is8bit, globalpal);
|
||||
|
||||
|
@ -1180,7 +1182,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
}
|
||||
|
||||
GLInterface.Draw(DT_QUADS, qstart, qdone * 4);
|
||||
|
||||
polymost_setClamp(prevClamp);
|
||||
//------------
|
||||
glDisable(GL_CULL_FACE);
|
||||
// glPopAttrib();
|
||||
|
|
Loading…
Reference in a new issue