Skip to content

Commit

Permalink
Update changes from upstream ioq3
Browse files Browse the repository at this point in the history
  • Loading branch information
smallmodel committed Dec 1, 2024
1 parent 71450fb commit e6e5dbd
Show file tree
Hide file tree
Showing 25 changed files with 1,122 additions and 464 deletions.
5 changes: 2 additions & 3 deletions code/renderergl2/glsl/depthblur_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa
#endif

float zLimit = 5.0 / zFar;
int i, j;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
for (j = 1; j < BLUR_SIZE; j++)
for (int j = 1; j < BLUR_SIZE; j++)
{
vec2 offset = direction * (float(j) - 0.25) + nudge;
#if defined(USE_DEPTH)
Expand Down
54 changes: 40 additions & 14 deletions code/renderergl2/glsl/generic_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ attribute vec4 attr_TexCoord0;
attribute vec4 attr_TexCoord1;
#endif

uniform vec4 u_DiffuseTexMatrix;
uniform vec4 u_DiffuseTexOffTurb;
#if defined(USE_TCMOD)
uniform vec4 u_DiffuseTexMatrix0;
uniform vec4 u_DiffuseTexMatrix1;
uniform vec4 u_DiffuseTexMatrix2;
uniform vec4 u_DiffuseTexMatrix3;
uniform vec4 u_DiffuseTexMatrix4;
uniform vec4 u_DiffuseTexMatrix5;
uniform vec4 u_DiffuseTexMatrix6;
uniform vec4 u_DiffuseTexMatrix7;
#endif

#if defined(USE_TCGEN) || defined(USE_RGBAGEN)
uniform vec3 u_LocalViewOrigin;
Expand Down Expand Up @@ -140,19 +148,28 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3
#endif

#if defined(USE_TCMOD)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix[8])
{
float amplitude = offTurb.z;
float phase = offTurb.w * 2.0 * M_PI;
vec2 st2;
st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x);
st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y);

vec2 st2 = st;
vec2 offsetPos = vec2(position.x + position.z, position.y);

vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase));

return st2 + texOffset * amplitude;

st2 = vec2(st2.x * texMatrix[0].x + st2.y * texMatrix[0].y + texMatrix[0].z,
st2.x * texMatrix[1].x + st2.y * texMatrix[1].y + texMatrix[1].z);
st2 += texMatrix[0].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[1].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[2].x + st2.y * texMatrix[2].y + texMatrix[2].z,
st2.x * texMatrix[3].x + st2.y * texMatrix[3].y + texMatrix[3].z);
st2 += texMatrix[2].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[3].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[4].x + st2.y * texMatrix[4].y + texMatrix[4].z,
st2.x * texMatrix[5].x + st2.y * texMatrix[5].y + texMatrix[5].z);
st2 += texMatrix[4].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[5].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[6].x + st2.y * texMatrix[6].y + texMatrix[6].z,
st2.x * texMatrix[7].x + st2.y * texMatrix[7].y + texMatrix[7].z);
st2 += texMatrix[6].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[7].w * 2.0 * M_PI));

return st2;
}
#endif

Expand Down Expand Up @@ -236,7 +253,16 @@ void main()
#endif

#if defined(USE_TCMOD)
var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);
vec4 diffuseTexMatrix[8];
diffuseTexMatrix[0] = u_DiffuseTexMatrix0;
diffuseTexMatrix[1] = u_DiffuseTexMatrix1;
diffuseTexMatrix[2] = u_DiffuseTexMatrix2;
diffuseTexMatrix[3] = u_DiffuseTexMatrix3;
diffuseTexMatrix[4] = u_DiffuseTexMatrix4;
diffuseTexMatrix[5] = u_DiffuseTexMatrix5;
diffuseTexMatrix[6] = u_DiffuseTexMatrix6;
diffuseTexMatrix[7] = u_DiffuseTexMatrix7;
var_DiffuseTex = ModTexCoords(tex, position, diffuseTexMatrix);
#else
var_DiffuseTex = tex;
#endif
Expand Down
48 changes: 36 additions & 12 deletions code/renderergl2/glsl/lightall_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ uniform vec3 u_LocalViewOrigin;
#endif

#if defined(USE_TCMOD)
uniform vec4 u_DiffuseTexMatrix;
uniform vec4 u_DiffuseTexOffTurb;
uniform vec4 u_DiffuseTexMatrix0;
uniform vec4 u_DiffuseTexMatrix1;
uniform vec4 u_DiffuseTexMatrix2;
uniform vec4 u_DiffuseTexMatrix3;
uniform vec4 u_DiffuseTexMatrix4;
uniform vec4 u_DiffuseTexMatrix5;
uniform vec4 u_DiffuseTexMatrix6;
uniform vec4 u_DiffuseTexMatrix7;
#endif

uniform mat4 u_ModelViewProjectionMatrix;
Expand Down Expand Up @@ -114,19 +120,28 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3
#endif

#if defined(USE_TCMOD)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix[8])
{
float amplitude = offTurb.z;
float phase = offTurb.w * 2.0 * M_PI;
vec2 st2;
st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x);
st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y);

vec2 st2 = st;
vec2 offsetPos = vec2(position.x + position.z, position.y);

vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase));
st2 = vec2(st2.x * texMatrix[0].x + st2.y * texMatrix[0].y + texMatrix[0].z,
st2.x * texMatrix[1].x + st2.y * texMatrix[1].y + texMatrix[1].z);
st2 += texMatrix[0].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[1].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[2].x + st2.y * texMatrix[2].y + texMatrix[2].z,
st2.x * texMatrix[3].x + st2.y * texMatrix[3].y + texMatrix[3].z);
st2 += texMatrix[2].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[3].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[4].x + st2.y * texMatrix[4].y + texMatrix[4].z,
st2.x * texMatrix[5].x + st2.y * texMatrix[5].y + texMatrix[5].z);
st2 += texMatrix[4].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[5].w * 2.0 * M_PI));

st2 = vec2(st2.x * texMatrix[6].x + st2.y * texMatrix[6].y + texMatrix[6].z,
st2.x * texMatrix[7].x + st2.y * texMatrix[7].y + texMatrix[7].z);
st2 += texMatrix[6].w * sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(texMatrix[7].w * 2.0 * M_PI));

return st2 + texOffset * amplitude;
return st2;
}
#endif

Expand Down Expand Up @@ -183,7 +198,16 @@ void main()
#endif

#if defined(USE_TCMOD)
var_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);
vec4 diffuseTexMatrix[8];
diffuseTexMatrix[0] = u_DiffuseTexMatrix0;
diffuseTexMatrix[1] = u_DiffuseTexMatrix1;
diffuseTexMatrix[2] = u_DiffuseTexMatrix2;
diffuseTexMatrix[3] = u_DiffuseTexMatrix3;
diffuseTexMatrix[4] = u_DiffuseTexMatrix4;
diffuseTexMatrix[5] = u_DiffuseTexMatrix5;
diffuseTexMatrix[6] = u_DiffuseTexMatrix6;
diffuseTexMatrix[7] = u_DiffuseTexMatrix7;
var_TexCoords.xy = ModTexCoords(texCoords, position, diffuseTexMatrix);
#else
var_TexCoords.xy = texCoords;
#endif
Expand Down
14 changes: 0 additions & 14 deletions code/renderergl2/glsl/shaders.cmake

This file was deleted.

9 changes: 7 additions & 2 deletions code/renderergl2/glsl/shadowmask_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,19 @@ void main()

vec4 shadowpos = u_ShadowMvp * biasPos;

if ( depth >= 0.999 )
{
result = 1.0;
}
else
#if defined(USE_SHADOW_CASCADE)
if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
{
#endif
{
shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5);
result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z);
#if defined(USE_SHADOW_CASCADE)
}
#if defined(USE_SHADOW_CASCADE)
else
{
shadowpos = u_ShadowMvp2 * biasPos;
Expand Down
3 changes: 1 addition & 2 deletions code/renderergl2/glsl/ssao_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN

float invZFar = 1.0 / zFar;
float zLimit = 20.0 * invZFar;
int i;
for (i = 0; i < NUM_SAMPLES; i++)
for (int i = 0; i < NUM_SAMPLES; i++)
{
vec2 offset = rmat * poissonDisc[i] * offsetScale;
float sampleDiff = getLinearDepth(depthMap, tex + offset, zFarDivZNear) - sampleZ;
Expand Down
Loading

0 comments on commit e6e5dbd

Please sign in to comment.