Skip to content

Commit

Permalink
Add files from OpenGL render by Armada
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 9, 2018
1 parent 1bfc3d2 commit 85a35db
Show file tree
Hide file tree
Showing 100 changed files with 19,596 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/FBasicVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void dxRender_Visual::Load(const char* N, IReader* data, u32)
{
R_ASSERT2(hdr.format_version == xrOGF_FormatVersion, "Invalid visual version");
Type = hdr.type;
// if (hdr.shader_id) shader = GlobalEnv.Render->getShader (hdr.shader_id);
// if (hdr.shader_id) shader = GEnv.Render->getShader (hdr.shader_id);
if (hdr.shader_id)
shader = ::RImplementation.getShader(hdr.shader_id);
vis.box.set(hdr.bb.min, hdr.bb.max);
Expand Down
8 changes: 4 additions & 4 deletions src/Layers/xrRender/ParticleGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void CParticleGroup::SItem::Clear()
GetVisuals(visuals);
for (auto it = visuals.begin(); it != visuals.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
// GEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
GEnv.Render->model_Delete(pVisual);
*it = nullptr;
Expand Down Expand Up @@ -284,14 +284,14 @@ void CParticleGroup::SItem::Stop(BOOL def_stop)
{
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
// GEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
GEnv.Render->model_Delete(pVisual);
*it = nullptr;
}
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
// GEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
GEnv.Render->model_Delete(pVisual);
*it = nullptr;
Expand Down Expand Up @@ -427,7 +427,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
else
{
rem_cnt++;
// GlobalEnv.Render->model_Delete(*it);
// GEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
GEnv.Render->model_Delete(pVisual);
*it = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/SkeletonCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void CKinematics::Load(const char* N, IReader* data, u32 dwFlags)
// m_lod->Type==MT_NORMAL,lod_name.c_str());
/*
strconcat(name_load, short_name, ":lod:1");
m_lod = GlobalEnv.Render->model_CreateChild(name_load, LD);
m_lod = GEnv.Render->model_CreateChild(name_load, LD);
VERIFY(m_lod->Type==MT_SKELETON_GEOMDEF_PM || m_lod->Type==MT_SKELETON_GEOMDEF_ST);
*/
}
Expand Down Expand Up @@ -746,7 +746,7 @@ void CKinematics::CalculateWallmarks()
{
// append wm to WallmarkEngine
if (GEnv.Render->ViewBase.testSphere_dirty(wm->m_Bounds.P, wm->m_Bounds.R))
// GlobalEnv.Render->add_SkeletonWallmark (wm);
// GEnv.Render->add_SkeletonWallmark (wm);
::RImplementation.add_SkeletonWallmark(wm);
}
else
Expand Down
83 changes: 83 additions & 0 deletions src/Layers/xrRenderGL/Blender_Recorder_GL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "stdafx.h"
#pragma hdrstop

#include "Layers/xrRender/ResourceManager.h"
#include "Layers/xrRender/blenders/Blender_Recorder.h"
#include "Layers/xrRender/blenders/Blender.h"
#include "Layers/xrRender/tss.h"

void fix_texture_name(LPSTR fn);

void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask, u32 Fail, u32 Pass, u32 ZFail)
{
RS.SetRS( D3DRS_STENCILENABLE, BC(Enable) );
if (!Enable) return;
RS.SetRS( D3DRS_STENCILFUNC, Func);
RS.SetRS( D3DRS_STENCILMASK, Mask);
RS.SetRS( D3DRS_STENCILWRITEMASK, WriteMask);
RS.SetRS( D3DRS_STENCILFAIL, Fail);
RS.SetRS( D3DRS_STENCILPASS, Pass);
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
}

void CBlender_Compile::r_StencilRef(u32 Ref)
{
RS.SetRS( D3DRS_STENCILREF, Ref);
}

void CBlender_Compile::r_CullMode(D3DCULL Mode)
{
RS.SetRS( D3DRS_CULLMODE, (u32)Mode);
}

void CBlender_Compile::i_Comparison(u32 s, u32 func)
{
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, func);
}

void CBlender_Compile::r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide)
{
u32 s = r_Sampler(name, texture, b_ps1x_ProjectiveDivide, D3DTADDRESS_CLAMP, D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_LINEAR);
if (u32(-1) != s)
{
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, (u32)D3D_COMPARISON_LESS_EQUAL);
}
}

void CBlender_Compile::r_Pass (LPCSTR _vs, LPCSTR _gs, LPCSTR _ps, bool bFog, BOOL bZtest, BOOL bZwrite, BOOL bABlend, D3DBLEND abSRC, D3DBLEND abDST, BOOL aTest, u32 aRef)
{
RS.Invalidate ();
ctable.clear ();
passTextures.clear ();
passMatrices.clear ();
passConstants.clear ();
dwStage = 0;

// Setup FF-units (Z-buffer, blender)
PassSET_ZB (bZtest,bZwrite);
PassSET_Blend (bABlend,abSRC,abDST,aTest,aRef);
PassSET_LightFog (FALSE,bFog);

// Create shaders
SPS* ps = RImplementation.Resources->_CreatePS(_ps);
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
SGS* gs = RImplementation.Resources->_CreateGS(_gs);
dest.ps = ps;
dest.vs = vs;
dest.gs = gs;
#ifdef USE_DX11
dest.hs = RImplementation.Resources->_CreateHS("null");
dest.ds = RImplementation.Resources->_CreateDS("null");
#endif
ctable.merge (&ps->constants);
ctable.merge (&vs->constants);
ctable.merge (&gs->constants);

// Last Stage - disable
if (0==stricmp(_ps,"null")) {
RS.SetTSS (0,D3DTSS_COLOROP,D3DTOP_DISABLE);
RS.SetTSS (0,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
}
}
233 changes: 233 additions & 0 deletions src/Layers/xrRenderGL/GL Rain/glRainBlender.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#include "stdafx.h"
#include "./glRainBlender.h"

void CBlender_rain::Compile(CBlender_Compile& C)
{
IBlender::Compile (C);

switch (C.iElement)
{
case 0: // Test
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, FALSE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

jitter (C);

//C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
C.r_Sampler ("s_water", "water\\water_normal");

C.r_End ();

break;

case 1: // Patch normals
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_patch_normal_nomsaa", false, TRUE, FALSE, FALSE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

C.r_Sampler_rtf ("s_diffuse", r2_RT_albedo);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
//C.r_Sampler ("s_water", "water\\water_normal");

C.r_Sampler ("s_water", "water\\water_SBumpVolume");
//C.r_Sampler ("s_waterFall", "water\\water_normal");
C.r_Sampler ("s_waterFall", "water\\water_flowing_nmap");

C.r_End ();

break;

case 2: // Apply normals
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_apply_normal_nomsaa", false, TRUE, FALSE, FALSE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
C.r_Sampler ("s_patched_normal", r2_RT_accum);

// Normal can be packed into R and G
if (RImplementation.o.dx10_gbuffer_opt)
C.r_ColorWriteEnable( true, true, false, false );
else
C.r_ColorWriteEnable( true, true, true, false );

C.r_End ();

break;

case 3: // Apply gloss
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_apply_gloss_nomsaa", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
C.r_Sampler ("s_patched_normal", r2_RT_accum);

//C.r_ColorWriteEnable( false, false, false, true );

C.RS.SetRS(D3DRS_SRCBLEND, D3DBLEND_ZERO );
C.RS.SetRS(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR );

C.r_End ();

break;
}
}

void CBlender_rain_msaa::SetDefine( LPCSTR Name, LPCSTR Definition )
{
this->Name = Name;
this->Definition = Definition;
}

void CBlender_rain_msaa::Compile(CBlender_Compile& C)
{
IBlender::Compile (C);

if( Name )
GEnv.Render->m_MSAASample = atoi( Definition );
else
GEnv.Render->m_MSAASample = -1;

switch (C.iElement)
{
case 0: // Patch normals
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_patch_normal_msaa", false, TRUE, FALSE, FALSE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

C.r_Sampler_rtf ("s_diffuse", r2_RT_albedo);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
//C.r_Sampler ("s_water", "water\\water_normal");

C.r_Sampler ("s_water", "water\\water_SBumpVolume");
//C.r_dx10Texture ("s_waterFall", "water\\water_normal");
C.r_Sampler ("s_waterFall", "water\\water_flowing_nmap");

C.r_End ();

break;

case 1: // Apply normals
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_apply_normal_msaa", false, TRUE, FALSE, FALSE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
C.r_Sampler("s_patched_normal", r2_RT_accum);

// Normal can be packed into R and G
if (RImplementation.o.dx10_gbuffer_opt)
C.r_ColorWriteEnable( true, true, false, false );
else
C.r_ColorWriteEnable( true, true, true, false );

C.r_End ();

break;

case 2: // Apply gloss
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass ("stub_notransform_2uv", "rain_apply_gloss_msaa", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer

C.r_Sampler_rtf ("s_position", r2_RT_P);
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
C.r_Sampler_clw ("s_material", r2_material);
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
C.r_Sampler ("s_lmap", r2_sunmask);
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);

jitter (C);

// C.r_Sampler ("s_water", "water\\water_water");

//C.r_Sampler ("s_water", "water\\water_studen");
C.r_Sampler("s_patched_normal", r2_RT_accum);

//C.r_ColorWriteEnable( false, false, false, true );

C.RS.SetRS(D3DRS_SRCBLEND, D3DBLEND_ZERO );
C.RS.SetRS(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR );

C.r_End ();

break;
}
GEnv.Render->m_MSAASample = -1;
}

Loading

0 comments on commit 85a35db

Please sign in to comment.