Skip to content

Commit

Permalink
do alpha writing internally
Browse files Browse the repository at this point in the history
  • Loading branch information
meetric1 committed Aug 8, 2024
1 parent bd38a2b commit f9096f7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion binary/src/flex_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IMesh* _build_water_anisotropy(int id, FlexRendererThreadData data) {
// Frustrum culling
Vector4D dst;
Vector4DMultiply(data.view_projection_matrix, Vector4D(particle_pos.x, particle_pos.y, particle_pos.z, 1), dst);
if (dst.z < 0 || -dst.x - dst.w > data.radius || dst.x - dst.w > data.radius || -dst.y - dst.w > data.radius || dst.y - dst.w > data.radius) continue;
if (dst.z < data.radius || -dst.x - dst.w > data.radius || dst.x - dst.w > data.radius || -dst.y - dst.w > data.radius || dst.y - dst.w > data.radius) continue;

// PVS Culling
if (!engine->IsBoxVisible(particle_pos, particle_pos)) continue;
Expand Down
2 changes: 1 addition & 1 deletion binary/src/shaders/GWaterNormals.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SHADER_FALLBACK{
SHADER_DRAW {
SHADOW_STATE {
pShaderShadow->VertexShaderVertexFormat(VERTEX_GWATER2, 1, 0, 0);
//pShaderShadow->EnableAlphaWrites(true);
pShaderShadow->EnableAlphaWrites(true); // we write to the alpha channel

DECLARE_STATIC_VERTEX_SHADER(GWaterNormals_vs30);
SET_STATIC_VERTEX_SHADER(GWaterNormals_vs30);
Expand Down
1 change: 1 addition & 0 deletions binary/src/shaders/GWaterSmooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SHADER_DRAW {
pShaderShadow->VertexShaderVertexFormat(flags, 1, 0, 0);
pShaderShadow->EnableTexture(SHADER_SAMPLER0, true);
pShaderShadow->EnableTexture(SHADER_SAMPLER1, true);
pShaderShadow->EnableAlphaWrites(true); // We use and update the alpha channel

DECLARE_STATIC_VERTEX_SHADER(GWaterVolumetric_vs30);
SET_STATIC_VERTEX_SHADER(GWaterVolumetric_vs30);
Expand Down
5 changes: 1 addition & 4 deletions lua/gwater2_shaders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ hook.Add("PostDrawOpaqueRenderables", "gwater2_render", function(depth, sky, sky
render.ClearRenderTarget(cache_depth, Color(0, 0, 0, 0))
render.ClearRenderTarget(cache_absorption, Color(0, 0, 0, 0))
render.ClearRenderTarget(cache_bloom, Color(0, 0, 0, 0))
render.OverrideAlphaWriteEnable(true, true) -- TODO(?): do this internally in shader shadow/dynamic state

-- cached variables
local scrw = ScrW()
Expand Down Expand Up @@ -163,9 +162,7 @@ hook.Add("PostDrawOpaqueRenderables", "gwater2_render", function(depth, sky, sky
water:SetTexture("$depthtexture", cache_absorption)
render.SetMaterial(water)
gwater2.renderer:DrawWater()
render.RenderFlashlights( function() gwater2.renderer:DrawWater() end )

render.OverrideAlphaWriteEnable(false, false)
render.RenderFlashlights(function() gwater2.renderer:DrawWater() end)

render.SetMaterial(water_mist)
gwater2.renderer:DrawDiffuse()
Expand Down

0 comments on commit f9096f7

Please sign in to comment.