Skip to content

Commit

Permalink
Оживление r3_volumetric_smoke
Browse files Browse the repository at this point in the history
Co-Authored-By: JR <[email protected]>
Co-Authored-By: SkyLoaderr <[email protected]>
Co-Authored-By: Xottab_DUTY <[email protected]>
  • Loading branch information
4 people committed Feb 8, 2024
1 parent bf2ab2c commit 3507e91
Show file tree
Hide file tree
Showing 64 changed files with 996 additions and 1,503 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[volume]
EmittersNum = 4
Hemi = 1.0
ConfinementScale = 0.1 ;0.3 ;Турбулентность. 0 - поток гладкий, default - 0.6 (off)
GravityBuoyancy = 0.009 ;Вес положительный/отрицательный дыма
Decay = 0.994 ;Затухание дыма. 1 - дым не затухает, default - 0.994 (off)

[emitter00]
Type = SimpleGaussian
Radius = 0.06; 0.09 ;размер источника.чем больше число,тем меньше источник default - 0.15
Sigma = 1
FlowSpeed = 0.05 ;скорость потока
Density = 0.5; 0.6 ;плотность дыма
ApplyDensity = 1 ;источник генерирует вещество
ApplyImpulse = 1 ;источник применяет скорость

Position = 35.5, 7.0, 37.0 ;в локальных координатах
; FlowDirection = 0.0, 1.8, 0.8
FlowDirection = 0.0, 1.8, 0.4 ;направление потока в локальных координатах

[emitter01]:emitter00
Position = 35.5, 7.0, 39.0
; WorldPosition = 76.736, -16.126, 75.767
FlowDirection = 0.0, 1.8, -0.4

[emitter02]:emitter00
Position = 39, 7.0, 35.0
FlowDirection = -0.4, 1.8, 0.0

[emitter03]:emitter00
Position = 33, 7.0, 35.0
FlowDirection = 0.4, 1.8, 0.0
63 changes: 63 additions & 0 deletions Game/Resources_SoC_1.0006/gamedata/config/environment/fog/ts3.ltx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[volume]
EmittersNum = 4
Hemi = 0.0
ConfinementScale = 0.3 ;0.06; Турбулентность. 0 - поток гладкий, default - 0.6 (off)
GravityBuoyancy = 0.009 ;0.003 ;0.0015; Вес положительный/отрицательный дыма
Decay = 0.994 ;Затухание дыма. 1 - дым не затухает, default - 0.994 (off)

[emitter03]
Type = SimpleGaussian
Position = 45.0, 10.0, 40.0

; Radius = 0.15
Radius = 0.1 ;0.22
Sigma = 1
FlowSpeed = 0.05 ;0.4 ; скорость потока
FlowDirection = -1.2, 1.5, -0.8
Density = 0.5

ApplyDensity = 1
ApplyImpulse = 1

[emitter02]
Type = SimpleGaussian
Position = 40.0, 10.0, 40.0

; Radius = 0.15
Radius = 0.2 ;0.22
Sigma = 1
FlowSpeed = 0.05 ;0.4 ; скорость потока
FlowDirection = -1.2, 1.5, -0.8
Density = 1.0

ApplyDensity = 1
ApplyImpulse = 1

[emitter01]
Type = SimpleGaussian
Position = 49.0, 10.0, 54.0 ;в локальных координатах
Radius = 0.25 ;размер источника.чем больше число,тем меньше источник default - 0.15
Sigma = 1
FlowSpeed = 0.05 ;0.4 ; скорость потока
FlowDirection = -0.7, 1.5, -0.8 ;направление потока в локальных координатах
Density = 1.0 ;плотность дыма

; DraughtPeriod = 10.0 ; период колебаний скорости в секундах
; DraughtPhase = 0.0 ; фаза колебаний скорости [0..1]
; DraughtAmp = 0.5 ; aмплитуда колебаний [FlowSpeed*(1-DraughtAmp)..FlowSpeed*(1+DraughtAmp)]
ApplyDensity = 1 ;источник генерирует вещество
ApplyImpulse = 1 ;источник применяет скорость

[emitter00]
Type = SimpleGaussian
Position = 35.0, 10.0, 40.0

; Radius = 0.15
Radius = 0.22
Sigma = 1
FlowSpeed = 0.05 ;0.4 ; скорость потока
FlowDirection = -1.2, 1.5, -0.8
Density = 1.0

ApplyDensity = 1
ApplyImpulse = 1
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local adv_vid_opt_params = {
{ "r2_rain_drops", "check", 0, hint_colors.green , "video_settings_name_47", "video_settings_desc_47" },
{ "r2_visor_refl", "check", 0, hint_colors.green , "video_settings_name_65", "", },
--
-- { "r3_volumetric_smoke", "check", 0, hint_colors.green , "video_settings_name_55", "video_settings_desc_55" }, --Вообще выключен в движке, до лучших времен.
{ "r3_volumetric_smoke", "check", 0, hint_colors.green , "video_settings_name_55", ""--[["video_settings_desc_55"]] },
}

local control_init_funs = {
Expand Down
Binary file not shown.
6 changes: 4 additions & 2 deletions ogsr_engine/Layers/xrRender/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class light : public IRender_Light, public ISpatial
u32 bShadow : 1;
u32 bVolumetric : 1;
u32 bHudMode : 1;

} flags;
u32 bMoveable : 1;
} flags{};
Fvector position;
Fvector direction;
Fvector right;
Expand Down Expand Up @@ -136,6 +136,8 @@ class light : public IRender_Light, public ISpatial
virtual void set_hud_mode(bool b) { flags.bHudMode = b; }
virtual bool get_hud_mode() { return flags.bHudMode; };

virtual void set_moveable(bool b) override { flags.bMoveable = b; }

virtual void spatial_move();
virtual Fvector spatial_sector_point();

Expand Down
135 changes: 23 additions & 112 deletions ogsr_engine/Layers/xrRenderDX10/3DFluid/dx103DFluidBlenders.cpp
Original file line number Diff line number Diff line change
@@ -1,155 +1,84 @@
#include "stdafx.h"

#ifdef DX10_FLUID_ENABLE

#include "dx103DFluidBlenders.h"

#include "dx103DFluidManager.h"
#include "dx103DFluidRenderer.h"

namespace
{
// Volume texture width
class cl_textureWidth : public R_constant_setup
static class cl_textureWidth final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
float tW = (float)FluidManager.GetTextureWidth();
RCache.set_c(C, tW);
}
};
static cl_textureWidth binder_textureWidth;
} binder_textureWidth;

// Volume texture height
class cl_textureHeight : public R_constant_setup
static class cl_textureHeight final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
float tH = (float)FluidManager.GetTextureHeight();
RCache.set_c(C, tH);
}
};
static cl_textureHeight binder_textureHeight;
} binder_textureHeight;

// Volume texture depth
class cl_textureDepth : public R_constant_setup
static class cl_textureDepth final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
float tD = (float)FluidManager.GetTextureDepth();
RCache.set_c(C, tD);
}
};
static cl_textureDepth binder_textureDepth;
} binder_textureDepth;

class cl_gridDim : public R_constant_setup
static class cl_gridDim final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
float tW = (float)FluidManager.GetTextureWidth();
float tH = (float)FluidManager.GetTextureHeight();
float tD = (float)FluidManager.GetTextureDepth();
RCache.set_c(C, tW, tH, tD, 0.0f);
}
};
static cl_gridDim binder_gridDim;
} binder_gridDim;

class cl_recGridDim : public R_constant_setup
static class cl_recGridDim final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
float tW = (float)FluidManager.GetTextureWidth();
float tH = (float)FluidManager.GetTextureHeight();
float tD = (float)FluidManager.GetTextureDepth();
RCache.set_c(C, 1.0f / tW, 1.0f / tH, 1.0f / tD, 0.0f);
}
};
static cl_recGridDim binder_recGridDim;
} binder_recGridDim;

class cl_maxDim : public R_constant_setup
static class cl_maxDim final : public R_constant_setup
{
virtual void setup(R_constant* C)
void setup(R_constant* C) override
{
int tW = FluidManager.GetTextureWidth();
int tH = FluidManager.GetTextureHeight();
int tD = FluidManager.GetTextureDepth();
float tMax = (float)_max(tW, _max(tH, tD));
RCache.set_c(C, (float)tMax);
}
};
static cl_maxDim binder_maxDim;
} binder_maxDim;

/*
// decay simulation option
class cl_decay : public R_constant_setup
{
virtual void setup(R_constant* C)
{
float fDecay = FluidManager.GetDecay();
RCache.set_c( C, fDecay );
}
};
static cl_decay binder_decay;
// decay simulation ImpulseSize
class cl_impulseSize : public R_constant_setup
{
virtual void setup(R_constant* C)
{
float fIS = FluidManager.GetImpulseSize();
RCache.set_c( C, fIS );
}
};
static cl_impulseSize binder_impulseSize;
*/

void BindConstants(CBlender_Compile& C)
{
// Bind constants here

// TextureWidthShaderVariable = pEffect->GetVariableByName( "textureWidth")->AsScalar();
C.r_Constant("textureWidth", &binder_textureWidth);
// TextureHeightShaderVariable = pEffect->GetVariableByName( "textureHeight")->AsScalar();
C.r_Constant("textureHeight", &binder_textureHeight);
// TextureDepthShaderVariable = pEffect->GetVariableByName( "textureDepth")->AsScalar();
C.r_Constant("textureDepth", &binder_textureDepth);

// Renderer constants
// D3DXVECTOR3 recGridDim(1.0f/gridDim[0], 1.0f/gridDim[1], 1.0f/gridDim[2]);
// pEffect->GetVariableByName("gridDim")->AsVector()->SetFloatVector(gridDim);
C.r_Constant("gridDim", &binder_gridDim);
// pEffect->GetVariableByName("recGridDim")->AsVector()->SetFloatVector(recGridDim);
C.r_Constant("recGridDim", &binder_recGridDim);
// pEffect->GetVariableByName("maxGridDim")->AsScalar()->SetFloat(maxDim);
C.r_Constant("maxGridDim", &binder_maxDim);

// Each technique should set up these variables itself
/*
// For project, advect
//ModulateShaderVariable = pEffect->GetVariableByName( "modulate")->AsScalar();
//C.r_Constant( "modulate", &binder_decay);
// For gaussian
// Used to apply external impulse
//ImpulseSizeShaderVariable = pEffect->GetVariableByName( "size")->AsScalar();
//C.r_Constant( "size", &binder_impulseSize);
// Setup manually by technique
//ImpulseCenterShaderVariable = pEffect->GetVariableByName( "center")->AsVector();
//SplatColorShaderVariable = pEffect->GetVariableByName( "splatColor")->AsVector();
// For confinement
EpsilonShaderVariable = pEffect->GetVariableByName( "epsilon")->AsScalar();
// For confinement, advect
TimeStepShaderVariable = pEffect->GetVariableByName( "timestep")->AsScalar();
// For advect BFECC
ForwardShaderVariable = pEffect->GetVariableByName( "forward")->AsScalar();
HalfVolumeDimShaderVariable = pEffect->GetVariableByName( "halfVolumeDim")->AsVector();
// For render call
//DrawTextureShaderVariable = pEffect->GetVariableByName( "textureNumber")->AsScalar();
*/
}

void SetupSamplers(CBlender_Compile& C)
{
int smp = C.r_dx10Sampler("samPointClamp");
Expand Down Expand Up @@ -180,31 +109,24 @@ void SetupSamplers(CBlender_Compile& C)
C.i_dx10Filter(smp, D3DTEXF_LINEAR, D3DTEXF_LINEAR, D3DTEXF_LINEAR);
}
}

void SetupTextures(CBlender_Compile& C)
{
LPCSTR* TNames = FluidManager.GetEngineTextureNames();
LPCSTR* RNames = FluidManager.GetShaderTextureNames();

for (int i = 0; i < dx103DFluidManager::NUM_RENDER_TARGETS; ++i)
C.r_dx10Texture(RNames[i], TNames[i]);
C.r_dx10Texture(dx103DFluidConsts::m_pShaderTextureNames[i], dx103DFluidConsts::m_pEngineTextureNames[i]);

// Renderer
C.r_dx10Texture("sceneDepthTex", r2_RT_P);
// C.r_dx10Texture("colorTex", "Texture_color");
C.r_dx10Texture("colorTex", TNames[dx103DFluidManager::RENDER_TARGET_COLOR_IN]);
C.r_dx10Texture("colorTex", dx103DFluidConsts::m_pEngineTextureNames[dx103DFluidManager::RENDER_TARGET_COLOR_IN]);
C.r_dx10Texture("jitterTex", "$user$NVjitterTex");

C.r_dx10Texture("HHGGTex", "$user$NVHHGGTex");

C.r_dx10Texture("fireTransferFunction", "internal\\internal_fireTransferFunction");

TNames = dx103DFluidRenderer::GetRTNames();
RNames = dx103DFluidRenderer::GetResourceRTNames();

for (int i = 0; i < dx103DFluidRenderer::RRT_NumRT; ++i)
C.r_dx10Texture(RNames[i], TNames[i]);
C.r_dx10Texture(dx103DFluidConsts::m_pResourceRTNames[i], dx103DFluidConsts::m_pRTNames[i]);
}
} // namespace

void CBlender_fluid_advect::Compile(CBlender_Compile& C)
{
Expand Down Expand Up @@ -304,8 +226,6 @@ void CBlender_fluid_obst::Compile(CBlender_Compile& C)
switch (C.iElement)
{
case 0: // ObstStaticBox
// AABB
// C.r_Pass ("fluid_grid", "fluid_array", "fluid_obststaticbox", false,FALSE,FALSE,FALSE);
// OOBB
C.r_Pass("fluid_grid_oobb", "fluid_array_oobb", "fluid_obst_static_oobb", false, FALSE, FALSE, FALSE);
break;
Expand Down Expand Up @@ -357,9 +277,6 @@ void CBlender_fluid_obstdraw::Compile(CBlender_Compile& C)
case 0: // DrawTexture
C.r_Pass("fluid_grid", "null", "fluid_draw_texture", false, FALSE, FALSE, FALSE);
break;
// TechniqueDrawWhiteTriangles = pEffect->GetTechniqueByName( "DrawWhiteTriangles" );
// TechniqueDrawWhiteLines = pEffect->GetTechniqueByName( "DrawWhiteLines" );
// TechniqueDrawBox = pEffect->GetTechniqueByName( "DrawBox" );
}

C.r_CullMode(D3DCULL_NONE);
Expand All @@ -381,7 +298,6 @@ void CBlender_fluid_raydata::Compile(CBlender_Compile& C)
case 0: // CompRayData_Back
C.r_Pass("fluid_raydata_back", "null", "fluid_raydata_back", false, FALSE, FALSE, FALSE);
C.r_CullMode(D3DCULL_CW); // Front
// C.r_CullMode(D3DCULL_CCW); // Front
break;
case 1: // CompRayData_Front
C.r_Pass("fluid_raydata_front", "null", "fluid_raydata_front", false, FALSE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
Expand All @@ -398,16 +314,13 @@ void CBlender_fluid_raydata::Compile(CBlender_Compile& C)
C.RS.SetRS(D3DRS_BLENDOPALPHA, D3DBLENDOP_REVSUBTRACT); // DST - SRC

C.r_CullMode(D3DCULL_CCW); // Back
// C.r_CullMode(D3DCULL_CW); // Back
break;
case 2: // QuadDownSampleRayDataTexture
C.r_Pass("fluid_raycast_quad", "null", "fluid_raydatacopy_quad", false, FALSE, FALSE, FALSE);
C.r_CullMode(D3DCULL_CCW); // Back
break;
}

// C.PassSET_ZB(FALSE,FALSE);

BindConstants(C);
SetupSamplers(C);
SetupTextures(C);
Expand Down Expand Up @@ -453,5 +366,3 @@ void CBlender_fluid_raycast::Compile(CBlender_Compile& C)
// Constants must be bound before r_End()
C.r_End();
}

#endif
4 changes: 0 additions & 4 deletions ogsr_engine/Layers/xrRenderDX10/3DFluid/dx103DFluidBlenders.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifndef dx103DFluidBlenders_included
#define dx103DFluidBlenders_included
#pragma once

class CBlender_fluid_advect : public IBlender
Expand Down Expand Up @@ -81,5 +79,3 @@ class CBlender_fluid_raycast : public IBlender

virtual void Compile(CBlender_Compile& C);
};

#endif // dx103DFluidBlenders_included
Loading

0 comments on commit 3507e91

Please sign in to comment.