Skip to content

Commit

Permalink
xrRender: Rain: Skip rain smap resolve if no rain is rendered
Browse files Browse the repository at this point in the history
+ Minor refactoring
  • Loading branch information
vTurbine committed Jun 1, 2023
1 parent 7d4b92e commit 36370cc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/Layers/xrRenderPC_GL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ set(SRC_FILES
"../xrRender_R2/r3_rendertarget_mark_msaa_edges.cpp"
"../xrRender_R2/r3_rendertarget_phase_ssao.cpp"
"../xrRender_R2/r3_rendertarget_phase_smap_D.cpp"
"../xrRender_R2/r3_rendertarget_phase_rain.cpp"
"../xrRender_R2/r3_rendertarget_phase_occq.cpp"
"../xrRender_R2/r3_rendertarget_phase_scene.cpp"
"../xrRender_R2/render_phase_sun.cpp"
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
<ClCompile Include="..\xrRender_R2\r3_rendertarget_draw_rain.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_mark_msaa_edges.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_occq.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_rain.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_scene.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_smap_D.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_ssao.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,6 @@
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_occq.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_rain.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_scene.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@
<ClCompile Include="..\xrRender_R2\r3_rendertarget_draw_rain.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_mark_msaa_edges.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_occq.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_rain.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_scene.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_smap_D.cpp" />
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_ssao.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,6 @@
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_occq.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_rain.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
<ClCompile Include="..\xrRender_R2\r3_rendertarget_phase_scene.cpp">
<Filter>Core_Target</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender_R2/r2.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct render_rain : public i_render_phase

light RainLight;
u32 context_id{ R_dsgraph_structure::INVALID_CONTEXT_ID };
float rain_factor{ 0.0f };
};

struct render_sun : public i_render_phase
Expand Down
32 changes: 18 additions & 14 deletions src/Layers/xrRender_R2/r3_R_rain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ static int facetable[6][4] =

void render_rain::init()
{
o.active = ps_r2_ls_flags.test(R3FLAG_DYN_WET_SURF);
o.active &= (!Device.vCameraPositionSaved.similar(Device.vCameraPosition, EPS_L) ||
!Device.vCameraDirectionSaved.similar(Device.vCameraDirection, EPS_L) ||
RainLight.frame_render == 0);
rain_factor = g_pGamePersistent->Environment().CurrentEnv.rain_density;

o.active = ps_r2_ls_flags.test(R3FLAG_DYN_WET_SURF);
o.active &= rain_factor >= EPS_L;
o.active &= !Device.vCameraPositionSaved.similar(Device.vCameraPosition, EPS_L) ||
!Device.vCameraDirectionSaved.similar(Device.vCameraDirection, EPS_L);

if (!o.active)
return;
Expand All @@ -63,13 +65,6 @@ void render_rain::init()
//////////////////////////////////////////////////////////////////////////
void render_rain::calculate()
{
float fRainFactor = g_pGamePersistent->Environment().CurrentEnv.rain_density;
if (fRainFactor < EPS_L)
{
RainLight.frame_render = 0;
return;
}

// static const float source_offset = 40.f;

static const float source_offset = 10000.f;
Expand Down Expand Up @@ -332,8 +327,17 @@ void render_rain::flush()
cmd_list_imm.set_xform_project(Device.mProject);

// Accumulate
RImplementation.Target->phase_rain(cmd_list_imm); // TODO: move into this class as well
RImplementation.Target->draw_rain(cmd_list_imm, RainLight);
if (rain_factor >= EPS_L)
{
PIX_EVENT_CTX(cmd_list_imm, RainApply);

RainLight.frame_render = Device.dwFrame;
cmd_list_imm.set_pass_targets(
RImplementation.Target->rt_Color, /*rt_Normal*/
nullptr,
nullptr,
RImplementation.Target->rt_MSAADepth
);
RImplementation.Target->draw_rain(cmd_list_imm, RainLight);
RainLight.frame_render = Device.dwFrame;
}
}
8 changes: 0 additions & 8 deletions src/Layers/xrRender_R2/r3_rendertarget_phase_rain.cpp

This file was deleted.

0 comments on commit 36370cc

Please sign in to comment.