Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a706b76
Fix GL pixel types for 16-bit and float textures
ZehMatt Oct 10, 2026
72ba55c
Fix ViewSetup not defaulting DoBloomAndToneMapping to true
ZehMatt Oct 10, 2026
bea8d8f
Port HDR enable state to HardwareConfig
ZehMatt Oct 10, 2026
bbf259c
Port MaterialSystem.ReloadMaterials
ZehMatt Oct 10, 2026
19c3ba8
Port Map_CheckForHDR and EnableHDR
ZehMatt Oct 10, 2026
d44840d
Load the HDR face lump when HDR is enabled
ZehMatt Oct 10, 2026
f04d90f
Port integer HDR lightmap writers
ZehMatt Oct 10, 2026
5f1f94f
Port RGBA16161616 and RGBA16161616F conversions
ZehMatt Oct 10, 2026
669b07e
Port Sky_DX9 and Sky_HDR_DX9 shaders
ZehMatt Oct 10, 2026
ae2ac7e
Port ModelInfo.IsModelVertexLit
ZehMatt Oct 10, 2026
fbab607
Port occlusion queries
ZehMatt Oct 10, 2026
46d3b51
Port tone mapping scale blending
ZehMatt Oct 10, 2026
1fe9cac
Port MatRenderContext.PushRenderTargetAndViewport
ZehMatt Oct 10, 2026
c94aa12
Port bloom and luminance compare shaders
ZehMatt Oct 10, 2026
5e9fbba
Port HDR bloom and auto exposure post processing
ZehMatt Oct 10, 2026
cb19a59
Port Map_CheckFeatureFlags
ZehMatt Oct 10, 2026
6dc4845
Port StaticPropMgr.PropHasBakedLightingDisabled
ZehMatt Oct 10, 2026
13176b9
Port VertexBuilder.Specular4ub
ZehMatt Oct 10, 2026
5b3c664
Port disk baked static prop lighting
ZehMatt Oct 10, 2026
b4b6e91
Port MatRenderContext.SetRenderTarget
ZehMatt Oct 10, 2026
5c0a564
Fix BaseVSShader.IsHDREnabled always returning false
ZehMatt Oct 10, 2026
ca053da
Port ShaderAPIGl46.CurrentTime
ZehMatt Oct 10, 2026
e6bd7dd
Port BaseShader.UsingEditor
ZehMatt Oct 10, 2026
65acb12
Port BaseVSShader pixel constant gamma and W var helpers
ZehMatt Oct 10, 2026
65bcab8
Port Water shader
ZehMatt Oct 10, 2026
196ea1b
Fix water vertex shaders missing the bone matrices block
ZehMatt Oct 10, 2026
b849525
Split GLSL vertex includes and remove dead shader code
ZehMatt Oct 10, 2026
02880cc
Fix screen space rectangles using the D3D9 half pixel offset
ZehMatt Oct 10, 2026
a104b17
Fix CdllEngineInterface.Con_NPrintf doing nothing
ZehMatt Oct 10, 2026
77b510d
Set default bloom scale to 0.5, 1 as a default is too strong
ZehMatt Oct 10, 2026
3a420dd
Fix render targets ignoring sRGB read like D3D9
ZehMatt Oct 10, 2026
824c1b1
Fix textures loaded in full never getting their reflectivity
ZehMatt Oct 10, 2026
0703180
Fix LightcacheGetStatic checking light styles instead of dlights
ZehMatt Oct 10, 2026
53e55d7
Fix AvgLightColor reading the end of the lighting lump
ZehMatt Oct 10, 2026
8a786ad
Deploy game assets as Game.Assets content items
ZehMatt Oct 10, 2026
1a2ce5e
Re-enable cubemap reflections in LightmappedGeneric
ZehMatt Oct 10, 2026
81fd8dc
Add fog volume and water box queries to the render view
ZehMatt Oct 10, 2026
c2e5b37
Add user clip planes to MatRenderContext and the GL ShaderAPI
ZehMatt Oct 10, 2026
a1c54cb
Fix EnableClipping starting disabled and not reapplying clip planes
ZehMatt Oct 10, 2026
6a00346
Implement SetFogZ in MatRenderContext and the GL ShaderAPI
ZehMatt Oct 10, 2026
db2d7b7
Port the water reflection and refraction views
ZehMatt Oct 11, 2026
23ba9b7
Fix world surfaces never being sorted by water
ZehMatt Oct 11, 2026
42f25dd
Port the AnimatedTexture material proxy
ZehMatt Oct 11, 2026
f3868af
Port scene fog state to the material system and GL ShaderAPI
ZehMatt Oct 11, 2026
9f8636c
Enable pixel fog with radial support in the stock shaders
ZehMatt Oct 11, 2026
25abc1e
Port water fog volume state to the render view
ZehMatt Oct 11, 2026
e94823e
Port world, skybox and water fog to the view renderer
ZehMatt Oct 11, 2026
0536bcb
Size water render targets to the frame buffer like GMod
ZehMatt Oct 11, 2026
a9f0b36
Fix ClearBuffers ignoring color writes and desyncing masks
ZehMatt Oct 11, 2026
af1285c
Fix water distortion going the wrong way vertically in GL
ZehMatt Oct 11, 2026
8dd3e61
Port sky_camera so the 3D skybox gets networked
ZehMatt Oct 11, 2026
07158d8
Render the 3D skybox into water reflections
ZehMatt Oct 11, 2026
c0e2d70
Fix empty world node surface index reading past the end
ZehMatt Oct 11, 2026
68b0d39
Fix world render lists surviving level shutdown
ZehMatt Oct 11, 2026
949082c
Fix g_hTonemapControllerInUse being readonly
marchc1 Oct 11, 2026
3c5ddc3
Merge remote-tracking branch 'upstream/main' into pr/160
marchc1 Oct 11, 2026
7571a65
fix screenspace dx9 stub
marchc1 Oct 11, 2026
459bca3
fix alphatest not translating in VcsTranslator
marchc1 Oct 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Game.Assets/Game.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
<ProjectReference Include="..\Source.Common\Source.Common.csproj" />
<ProjectReference Include="..\Source.GUI.Controls\Source.GUI.Controls.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="**\*" Exclude="**\*.cs;**\*.csproj;obj\**;bin\**;**\*_bak\**;sourceengine\**;platform\**;hl2\resource\**;hl2\gamemodes\**;hl2\lua\**;hl2\cache\workshop\**;hl2\maps\**;hl2\steam.inf;hl2\garrysmod_*.vpk;hl2\cfg\autoexec.cfg" CopyToOutputDirectory="PreserveNewest" />
<None Remove="@(Content)" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions Game.Assets/hl2/shaders/bloomadd_gl460.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#version 460

in vec2 vs_BaseTexCoord;

layout(std140, binding = 3) uniform source_pixel_sharedUBO {
bool isAlphaTesting;
int alphaTestFunc;
float alphaTestRef;
};

out vec4 fragColor;

layout(binding = 0) uniform sampler2D TexSampler;

void main()
{
vec4 result = texture(TexSampler, vs_BaseTexCoord);
result.a = 1.0;

if(isAlphaTesting){
switch(alphaTestFunc){
case 0: discard; break;
case 1: if(result.a >= alphaTestRef){ discard; } break;
case 2: if(result.a != alphaTestRef){ discard; } break;
case 3: if(result.a > alphaTestRef){ discard; } break;
case 4: if(result.a <= alphaTestRef){ discard; } break;
case 5: if(result.a == alphaTestRef){ discard; } break;
case 6: if(result.a < alphaTestRef){ discard; } break;
}
}

fragColor = result;
}
61 changes: 61 additions & 0 deletions Game.Assets/hl2/shaders/blurfilter_gl460.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#version 460

in vec2 vs_CoordTap0;
in vec2 vs_CoordTap1;
in vec2 vs_CoordTap2;
in vec2 vs_CoordTap3;
in vec2 vs_CoordTap1Neg;
in vec2 vs_CoordTap2Neg;
in vec2 vs_CoordTap3Neg;

layout(std140, binding = 6) uniform source_ps_constants {
vec4 ps_const[256];
};

out vec4 fragColor;

layout(binding = 0) uniform sampler2D TexSampler;

#define psTapOffs0 ps_const[0].xy
#define psTapOffs1 ps_const[1].xy
#define psTapOffs2 ps_const[2].xy
#define scale_factor ps_const[3].xyz

void main()
{
vec4 s0, s1, s2, s3, s4, s5, s6, color;

s0 = texture(TexSampler, vs_CoordTap0);
s1 = texture(TexSampler, vs_CoordTap1);
s2 = texture(TexSampler, vs_CoordTap2);
s3 = texture(TexSampler, vs_CoordTap3);
s4 = texture(TexSampler, vs_CoordTap1Neg);
s5 = texture(TexSampler, vs_CoordTap2Neg);
s6 = texture(TexSampler, vs_CoordTap3Neg);

color = s0 * 0.2013;
color += (s1 + s4) * 0.2185;
color += (s2 + s5) * 0.0821;
color += (s3 + s6) * 0.0461;

vec2 coordTap4 = vs_CoordTap0 + psTapOffs0;
vec2 coordTap5 = vs_CoordTap0 + psTapOffs1;
vec2 coordTap6 = vs_CoordTap0 + psTapOffs2;
vec2 coordTap4Neg = vs_CoordTap0 - psTapOffs0;
vec2 coordTap5Neg = vs_CoordTap0 - psTapOffs1;
vec2 coordTap6Neg = vs_CoordTap0 - psTapOffs2;

s1 = texture(TexSampler, coordTap4);
s2 = texture(TexSampler, coordTap5);
s3 = texture(TexSampler, coordTap6);
s4 = texture(TexSampler, coordTap4Neg);
s5 = texture(TexSampler, coordTap5Neg);
s6 = texture(TexSampler, coordTap6Neg);

color += (s1 + s4) * 0.0262;
color += (s2 + s5) * 0.0162;
color += (s3 + s6) * 0.0102;
color.xyz *= scale_factor.xyz;

fragColor = color;
}
41 changes: 41 additions & 0 deletions Game.Assets/hl2/shaders/blurfilter_gl460.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 460

layout(location = 0) in vec3 v_Position;
layout(location = 10) in vec2 v_TexCoord;

layout(std140, binding = 5) uniform source_vs_constants {
vec4 vs_const[256];
};

#define vsTapOffs0 vs_const[48].xy
#define vsTapOffs1 vs_const[49].xy
#define vsTapOffs2 vs_const[50].xy

out vec2 vs_CoordTap0;
out vec2 vs_CoordTap1;
out vec2 vs_CoordTap2;
out vec2 vs_CoordTap3;
out vec2 vs_CoordTap1Neg;
out vec2 vs_CoordTap2Neg;
out vec2 vs_CoordTap3Neg;

vec2 FlipV(vec2 uv)
{
return vec2(uv.x, 1.0 - uv.y);
}

#include "common_clipplanes_gl460.vs"

void main()
{
gl_Position = vec4(v_Position, 1.0);
WriteUserClipDistances(gl_Position);

vs_CoordTap0 = FlipV(v_TexCoord);
vs_CoordTap1 = FlipV(v_TexCoord + vsTapOffs0);
vs_CoordTap2 = FlipV(v_TexCoord + vsTapOffs1);
vs_CoordTap3 = FlipV(v_TexCoord + vsTapOffs2);
vs_CoordTap1Neg = FlipV(v_TexCoord - vsTapOffs0);
vs_CoordTap2Neg = FlipV(v_TexCoord - vsTapOffs1);
vs_CoordTap3Neg = FlipV(v_TexCoord - vsTapOffs2);
}
14 changes: 14 additions & 0 deletions Game.Assets/hl2/shaders/common_clipplanes_gl460.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef COMMON_CLIPPLANES_GL460_VS
#define COMMON_CLIPPLANES_GL460_VS

layout(std140, binding = 7) uniform source_clip_planes {
vec4 clipPlanes[2];
};

void WriteUserClipDistances(vec4 projPos)
{
gl_ClipDistance[0] = dot(projPos, clipPlanes[0]);
gl_ClipDistance[1] = dot(projPos, clipPlanes[1]);
}

#endif
45 changes: 27 additions & 18 deletions Game.Assets/hl2/shaders/common_gl460.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#define cFlashlightScreenScale ps_const[31] // .zw are currently unused
#define flFlashlightNoLambertValue cFlashlightColor.w // This is either 0.0 or 2.0

#define HDR_INPUT_MAP_SCALE 16.0

#define TONEMAP_SCALE_NONE 0
#define TONEMAP_SCALE_LINEAR 1
#define TONEMAP_SCALE_GAMMA 2
Expand Down Expand Up @@ -119,11 +117,6 @@ vec4 TextureCombine(vec4 baseColor, vec4 detailColor, int combine_mode, float fB
return baseColor;
}

vec3 lerp5(vec3 f1, vec3 f2, float i1, float i2, float x)
{
return f1 + (f2 - f1) * (x - i1) / (i2 - i1);
}

vec3 TextureCombinePostLighting(vec3 lit_baseColor, vec4 detailColor, int combine_mode, float fBlendFactor)
{
if (combine_mode == TCOMBINE_RGB_ADDITIVE_SELFILLUM)
Expand Down Expand Up @@ -158,7 +151,13 @@ float CalcRangeFog(float flProjPosZ, float flFogStartOverRange, float flFogMaxDe
return clamp(min(flFogMaxDensity, (flProjPosZ * flFogOORange) - flFogStartOverRange), 0.0, 1.0);
}

float CalcPixelFogFactor(int iPIXELFOGTYPE, vec4 fogParams, float flEyePosZ, float flWorldPosZ, float flProjPosZ)
float CalcRadialFog_NonFixedFunction(vec3 vWorldPos, vec3 vEyePos, float flFogMaxDensity, float flFogEndOverRange, float flFogOORange)
{
float flDistance = distance(vEyePos.xyz, vWorldPos.xyz);
return min(flFogMaxDensity, clamp((flDistance * flFogOORange) - flFogEndOverRange, 0.0, 1.0));
}

float CalcPixelFogFactor(int iPIXELFOGTYPE, vec4 fogParams, vec3 vEyePos, vec3 vWorldPos, float flProjPosZ)
{
float retVal = 0.0;
if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE)
Expand All @@ -169,31 +168,42 @@ float CalcPixelFogFactor(int iPIXELFOGTYPE, vec4 fogParams, float flEyePosZ, flo
{
retVal = CalcRangeFog(flProjPosZ, fogParams.x, fogParams.z, fogParams.w);
}
else if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE_RADIAL)
{
float flFogMaxDensity = fogParams.z;
float flFogEndOverRange = fogParams.x;
float flFogOORange = fogParams.w;

retVal = CalcRadialFog_NonFixedFunction(vWorldPos, vEyePos, flFogMaxDensity, flFogEndOverRange, flFogOORange);
}
else if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) //height fog
{
retVal = CalcWaterFogAlpha(fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w);
retVal = CalcWaterFogAlpha(fogParams.y, vEyePos.z, vWorldPos.z, flProjPosZ, fogParams.w);
}

return retVal;
}

//g_FogParams not defined by default, but this is the same layout for every shader that does define it
#define g_FogEndOverRange g_FogParams.x
#define g_WaterZ g_FogParams.y
#define g_FogMaxDensity g_FogParams.z
#define g_FogOORange g_FogParams.w
float CalcPixelFogFactor(int iPIXELFOGTYPE, vec4 fogParams, float flEyePosZ, float flWorldPosZ, float flProjPosZ)
{
if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE_RADIAL)
return CalcPixelFogFactor(PIXEL_FOG_TYPE_RANGE, fogParams, vec3(0.0, 0.0, flEyePosZ), vec3(0.0, 0.0, flWorldPosZ), flProjPosZ);

return CalcPixelFogFactor(iPIXELFOGTYPE, fogParams, vec3(0.0, 0.0, flEyePosZ), vec3(0.0, 0.0, flWorldPosZ), flProjPosZ);
}

vec3 BlendPixelFog(vec3 vShaderColor, float pixelFogFactor, vec3 vFogColor, int iPIXELFOGTYPE)
{
if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE || iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE_RADIAL) //either range fog or no fog depending on fog parameters and whether this is ps20 or ps2b
if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE || iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE_RADIAL)
{
pixelFogFactor = clamp(pixelFogFactor, 0.0, 1.0);
return mix(vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor); //squaring the factor will get the middle range mixing closer to hardware fog
return mix(vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor);
}
else if (iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT)
{
return mix(vShaderColor.rgb, vFogColor.rgb, clamp(pixelFogFactor, 0.0, 1.0));
}

return vShaderColor;
}

Expand Down Expand Up @@ -235,8 +245,7 @@ vec4 FinalOutput(vec4 vShaderColor, float pixelFogFactor, int iPIXELFOGTYPE, int
else
result.a = vShaderColor.a;

// TODO: fog
// result.rgb = BlendPixelFog(result.rgb, pixelFogFactor, g_LinearFogColor.rgb, iPIXELFOGTYPE);
result.rgb = BlendPixelFog(result.rgb, pixelFogFactor, g_LinearFogColor.rgb, iPIXELFOGTYPE);

result.rgb = SRGBOutput(result.rgb); //SRGB in pixel shader conversion

Expand Down
40 changes: 0 additions & 40 deletions Game.Assets/hl2/shaders/common_gl460.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ const vec3 bumpBasis[3] = vec3[3](
vec3( -0.40824833512306213, 0.70710676908493042, OO_SQRT_3 ),
vec3( -0.40824821591377258, -0.7071068286895752, OO_SQRT_3 )
);
const vec3 bumpBasisTranspose[3] = vec3[3](
vec3( 0.81649661064147949, -0.40824833512306213, -0.40824833512306213 ),
vec3( 0.0, 0.70710676908493042, -0.7071068286895752 ),
vec3( OO_SQRT_3, OO_SQRT_3, OO_SQRT_3 )
);

vec3 CalcReflectionVectorUnnormalized(vec3 normal, vec3 eyeVector)
{
Expand All @@ -32,45 +27,11 @@ vec3 Vec3TangentToWorld(vec3 iTangentVector, vec3 iWorldNormal, vec3 iWorldTange
return vWorldVector.xyz; // Return without normalizing
}

vec3 Vec3TangentToWorldNormalized(vec3 iTangentVector, vec3 iWorldNormal, vec3 iWorldTangent, vec3 iWorldBinormal)
{
return normalize(Vec3TangentToWorld(iTangentVector, iWorldNormal, iWorldTangent, iWorldBinormal));
}

vec3 LinearToGamma(vec3 f3linear)
{
return pow(f3linear, vec3(1.0 / 2.2));
}

vec3 GammaToLinear(vec3 gamma)
{
return pow(gamma, vec3(2.2));
}

#ifndef AA_CLAMP
#define AA_CLAMP 0
#endif

#if (AA_CLAMP==1)
vec2 ComputeLightmapCoordinates(vec4 Lightmap1and2Coord, vec2 Lightmap3Coord)
{
vec2 result = clamp(Lightmap1and2Coord.xy, 0.0, 1.0) * Lightmap1and2Coord.wz * 0.99;
result += Lightmap3Coord;
return result;
}

void ComputeBumpedLightmapCoordinates(vec4 Lightmap1and2Coord, vec2 Lightmap3Coord,
out vec2 bumpCoord1,
out vec2 bumpCoord2,
out vec2 bumpCoord3)
{
vec2 result = clamp(Lightmap1and2Coord.xy, 0.0, 1.0) * Lightmap1and2Coord.wz * 0.99;
result += Lightmap3Coord;
bumpCoord1 = result + vec2(Lightmap1and2Coord.z, 0);
bumpCoord2 = result + 2.0 * vec2(Lightmap1and2Coord.z, 0);
bumpCoord3 = result + 3.0 * vec2(Lightmap1and2Coord.z, 0);
}
#else
vec2 ComputeLightmapCoordinates(vec4 Lightmap1and2Coord, vec2 Lightmap3Coord)
{
return Lightmap1and2Coord.xy;
Expand All @@ -85,6 +46,5 @@ void ComputeBumpedLightmapCoordinates(vec4 Lightmap1and2Coord, vec2 Lightmap3Coo
bumpCoord2 = Lightmap1and2Coord.wz; // reversed order!!!
bumpCoord3 = Lightmap3Coord.xy;
}
#endif

#endif // COMMON_GL460_GLSL
Loading
Loading