Skip to content

Commit 85a35db

Browse files
committed
Add files from OpenGL render by Armada
1 parent 1bfc3d2 commit 85a35db

File tree

100 files changed

+19596
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+19596
-7
lines changed

src/Layers/xrRender/FBasicVisual.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void dxRender_Visual::Load(const char* N, IReader* data, u32)
4646
{
4747
R_ASSERT2(hdr.format_version == xrOGF_FormatVersion, "Invalid visual version");
4848
Type = hdr.type;
49-
// if (hdr.shader_id) shader = GlobalEnv.Render->getShader (hdr.shader_id);
49+
// if (hdr.shader_id) shader = GEnv.Render->getShader (hdr.shader_id);
5050
if (hdr.shader_id)
5151
shader = ::RImplementation.getShader(hdr.shader_id);
5252
vis.box.set(hdr.bb.min, hdr.bb.max);

src/Layers/xrRender/ParticleGroup.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void CParticleGroup::SItem::Clear()
185185
GetVisuals(visuals);
186186
for (auto it = visuals.begin(); it != visuals.end(); it++)
187187
{
188-
// GlobalEnv.Render->model_Delete(*it);
188+
// GEnv.Render->model_Delete(*it);
189189
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
190190
GEnv.Render->model_Delete(pVisual);
191191
*it = nullptr;
@@ -284,14 +284,14 @@ void CParticleGroup::SItem::Stop(BOOL def_stop)
284284
{
285285
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
286286
{
287-
// GlobalEnv.Render->model_Delete(*it);
287+
// GEnv.Render->model_Delete(*it);
288288
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
289289
GEnv.Render->model_Delete(pVisual);
290290
*it = nullptr;
291291
}
292292
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
293293
{
294-
// GlobalEnv.Render->model_Delete(*it);
294+
// GEnv.Render->model_Delete(*it);
295295
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
296296
GEnv.Render->model_Delete(pVisual);
297297
*it = nullptr;
@@ -427,7 +427,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
427427
else
428428
{
429429
rem_cnt++;
430-
// GlobalEnv.Render->model_Delete(*it);
430+
// GEnv.Render->model_Delete(*it);
431431
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
432432
GEnv.Render->model_Delete(pVisual);
433433
*it = nullptr;

src/Layers/xrRender/SkeletonCustom.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void CKinematics::Load(const char* N, IReader* data, u32 dwFlags)
197197
// m_lod->Type==MT_NORMAL,lod_name.c_str());
198198
/*
199199
strconcat(name_load, short_name, ":lod:1");
200-
m_lod = GlobalEnv.Render->model_CreateChild(name_load, LD);
200+
m_lod = GEnv.Render->model_CreateChild(name_load, LD);
201201
VERIFY(m_lod->Type==MT_SKELETON_GEOMDEF_PM || m_lod->Type==MT_SKELETON_GEOMDEF_ST);
202202
*/
203203
}
@@ -746,7 +746,7 @@ void CKinematics::CalculateWallmarks()
746746
{
747747
// append wm to WallmarkEngine
748748
if (GEnv.Render->ViewBase.testSphere_dirty(wm->m_Bounds.P, wm->m_Bounds.R))
749-
// GlobalEnv.Render->add_SkeletonWallmark (wm);
749+
// GEnv.Render->add_SkeletonWallmark (wm);
750750
::RImplementation.add_SkeletonWallmark(wm);
751751
}
752752
else
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "stdafx.h"
2+
#pragma hdrstop
3+
4+
#include "Layers/xrRender/ResourceManager.h"
5+
#include "Layers/xrRender/blenders/Blender_Recorder.h"
6+
#include "Layers/xrRender/blenders/Blender.h"
7+
#include "Layers/xrRender/tss.h"
8+
9+
void fix_texture_name(LPSTR fn);
10+
11+
void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask, u32 Fail, u32 Pass, u32 ZFail)
12+
{
13+
RS.SetRS( D3DRS_STENCILENABLE, BC(Enable) );
14+
if (!Enable) return;
15+
RS.SetRS( D3DRS_STENCILFUNC, Func);
16+
RS.SetRS( D3DRS_STENCILMASK, Mask);
17+
RS.SetRS( D3DRS_STENCILWRITEMASK, WriteMask);
18+
RS.SetRS( D3DRS_STENCILFAIL, Fail);
19+
RS.SetRS( D3DRS_STENCILPASS, Pass);
20+
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
21+
}
22+
23+
void CBlender_Compile::r_StencilRef(u32 Ref)
24+
{
25+
RS.SetRS( D3DRS_STENCILREF, Ref);
26+
}
27+
28+
void CBlender_Compile::r_CullMode(D3DCULL Mode)
29+
{
30+
RS.SetRS( D3DRS_CULLMODE, (u32)Mode);
31+
}
32+
33+
void CBlender_Compile::i_Comparison(u32 s, u32 func)
34+
{
35+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
36+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, func);
37+
}
38+
39+
void CBlender_Compile::r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide)
40+
{
41+
u32 s = r_Sampler(name, texture, b_ps1x_ProjectiveDivide, D3DTADDRESS_CLAMP, D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_LINEAR);
42+
if (u32(-1) != s)
43+
{
44+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
45+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, (u32)D3D_COMPARISON_LESS_EQUAL);
46+
}
47+
}
48+
49+
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)
50+
{
51+
RS.Invalidate ();
52+
ctable.clear ();
53+
passTextures.clear ();
54+
passMatrices.clear ();
55+
passConstants.clear ();
56+
dwStage = 0;
57+
58+
// Setup FF-units (Z-buffer, blender)
59+
PassSET_ZB (bZtest,bZwrite);
60+
PassSET_Blend (bABlend,abSRC,abDST,aTest,aRef);
61+
PassSET_LightFog (FALSE,bFog);
62+
63+
// Create shaders
64+
SPS* ps = RImplementation.Resources->_CreatePS(_ps);
65+
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
66+
SGS* gs = RImplementation.Resources->_CreateGS(_gs);
67+
dest.ps = ps;
68+
dest.vs = vs;
69+
dest.gs = gs;
70+
#ifdef USE_DX11
71+
dest.hs = RImplementation.Resources->_CreateHS("null");
72+
dest.ds = RImplementation.Resources->_CreateDS("null");
73+
#endif
74+
ctable.merge (&ps->constants);
75+
ctable.merge (&vs->constants);
76+
ctable.merge (&gs->constants);
77+
78+
// Last Stage - disable
79+
if (0==stricmp(_ps,"null")) {
80+
RS.SetTSS (0,D3DTSS_COLOROP,D3DTOP_DISABLE);
81+
RS.SetTSS (0,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
82+
}
83+
}
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
#include "stdafx.h"
2+
#include "./glRainBlender.h"
3+
4+
void CBlender_rain::Compile(CBlender_Compile& C)
5+
{
6+
IBlender::Compile (C);
7+
8+
switch (C.iElement)
9+
{
10+
case 0: // Test
11+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
12+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
13+
C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, FALSE);
14+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
15+
16+
C.r_Sampler_rtf ("s_position", r2_RT_P);
17+
C.r_Sampler_rtf ("s_normal", r2_RT_N);
18+
C.r_Sampler_clw ("s_material", r2_material);
19+
C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
20+
C.r_Sampler ("s_lmap", r2_sunmask);
21+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
22+
23+
jitter (C);
24+
25+
//C.r_Sampler ("s_water", "water\\water_water");
26+
27+
//C.r_Sampler ("s_water", "water\\water_studen");
28+
C.r_Sampler ("s_water", "water\\water_normal");
29+
30+
C.r_End ();
31+
32+
break;
33+
34+
case 1: // Patch normals
35+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
36+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
37+
C.r_Pass ("stub_notransform_2uv", "rain_patch_normal_nomsaa", false, TRUE, FALSE, FALSE);
38+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
39+
40+
C.r_Sampler_rtf ("s_position", r2_RT_P);
41+
C.r_Sampler_rtf ("s_normal", r2_RT_N);
42+
C.r_Sampler_clw ("s_material", r2_material);
43+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
44+
C.r_Sampler ("s_lmap", r2_sunmask);
45+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
46+
47+
C.r_Sampler_rtf ("s_diffuse", r2_RT_albedo);
48+
49+
jitter (C);
50+
51+
// C.r_Sampler ("s_water", "water\\water_water");
52+
53+
//C.r_Sampler ("s_water", "water\\water_studen");
54+
//C.r_Sampler ("s_water", "water\\water_normal");
55+
56+
C.r_Sampler ("s_water", "water\\water_SBumpVolume");
57+
//C.r_Sampler ("s_waterFall", "water\\water_normal");
58+
C.r_Sampler ("s_waterFall", "water\\water_flowing_nmap");
59+
60+
C.r_End ();
61+
62+
break;
63+
64+
case 2: // Apply normals
65+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
66+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
67+
C.r_Pass ("stub_notransform_2uv", "rain_apply_normal_nomsaa", false, TRUE, FALSE, FALSE);
68+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
69+
70+
C.r_Sampler_rtf ("s_position", r2_RT_P);
71+
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
72+
C.r_Sampler_clw ("s_material", r2_material);
73+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
74+
C.r_Sampler ("s_lmap", r2_sunmask);
75+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
76+
77+
jitter (C);
78+
79+
// C.r_Sampler ("s_water", "water\\water_water");
80+
81+
//C.r_Sampler ("s_water", "water\\water_studen");
82+
C.r_Sampler ("s_patched_normal", r2_RT_accum);
83+
84+
// Normal can be packed into R and G
85+
if (RImplementation.o.dx10_gbuffer_opt)
86+
C.r_ColorWriteEnable( true, true, false, false );
87+
else
88+
C.r_ColorWriteEnable( true, true, true, false );
89+
90+
C.r_End ();
91+
92+
break;
93+
94+
case 3: // Apply gloss
95+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
96+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
97+
C.r_Pass ("stub_notransform_2uv", "rain_apply_gloss_nomsaa", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
98+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
99+
100+
C.r_Sampler_rtf ("s_position", r2_RT_P);
101+
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
102+
C.r_Sampler_clw ("s_material", r2_material);
103+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
104+
C.r_Sampler ("s_lmap", r2_sunmask);
105+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
106+
107+
jitter (C);
108+
109+
// C.r_Sampler ("s_water", "water\\water_water");
110+
111+
//C.r_Sampler ("s_water", "water\\water_studen");
112+
C.r_Sampler ("s_patched_normal", r2_RT_accum);
113+
114+
//C.r_ColorWriteEnable( false, false, false, true );
115+
116+
C.RS.SetRS(D3DRS_SRCBLEND, D3DBLEND_ZERO );
117+
C.RS.SetRS(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR );
118+
119+
C.r_End ();
120+
121+
break;
122+
}
123+
}
124+
125+
void CBlender_rain_msaa::SetDefine( LPCSTR Name, LPCSTR Definition )
126+
{
127+
this->Name = Name;
128+
this->Definition = Definition;
129+
}
130+
131+
void CBlender_rain_msaa::Compile(CBlender_Compile& C)
132+
{
133+
IBlender::Compile (C);
134+
135+
if( Name )
136+
GEnv.Render->m_MSAASample = atoi( Definition );
137+
else
138+
GEnv.Render->m_MSAASample = -1;
139+
140+
switch (C.iElement)
141+
{
142+
case 0: // Patch normals
143+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
144+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
145+
C.r_Pass ("stub_notransform_2uv", "rain_patch_normal_msaa", false, TRUE, FALSE, FALSE);
146+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
147+
148+
C.r_Sampler_rtf ("s_position", r2_RT_P);
149+
C.r_Sampler_rtf ("s_normal", r2_RT_N);
150+
C.r_Sampler_clw ("s_material", r2_material);
151+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
152+
C.r_Sampler ("s_lmap", r2_sunmask);
153+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
154+
155+
C.r_Sampler_rtf ("s_diffuse", r2_RT_albedo);
156+
157+
jitter (C);
158+
159+
// C.r_Sampler ("s_water", "water\\water_water");
160+
161+
//C.r_Sampler ("s_water", "water\\water_studen");
162+
//C.r_Sampler ("s_water", "water\\water_normal");
163+
164+
C.r_Sampler ("s_water", "water\\water_SBumpVolume");
165+
//C.r_dx10Texture ("s_waterFall", "water\\water_normal");
166+
C.r_Sampler ("s_waterFall", "water\\water_flowing_nmap");
167+
168+
C.r_End ();
169+
170+
break;
171+
172+
case 1: // Apply normals
173+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
174+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
175+
C.r_Pass ("stub_notransform_2uv", "rain_apply_normal_msaa", false, TRUE, FALSE, FALSE);
176+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
177+
178+
C.r_Sampler_rtf ("s_position", r2_RT_P);
179+
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
180+
C.r_Sampler_clw ("s_material", r2_material);
181+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
182+
C.r_Sampler ("s_lmap", r2_sunmask);
183+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
184+
185+
jitter (C);
186+
187+
// C.r_Sampler ("s_water", "water\\water_water");
188+
189+
//C.r_Sampler ("s_water", "water\\water_studen");
190+
C.r_Sampler("s_patched_normal", r2_RT_accum);
191+
192+
// Normal can be packed into R and G
193+
if (RImplementation.o.dx10_gbuffer_opt)
194+
C.r_ColorWriteEnable( true, true, false, false );
195+
else
196+
C.r_ColorWriteEnable( true, true, true, false );
197+
198+
C.r_End ();
199+
200+
break;
201+
202+
case 2: // Apply gloss
203+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
204+
//C.r_Pass ("stub_notransform_2uv", "rain_layer", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
205+
C.r_Pass ("stub_notransform_2uv", "rain_apply_gloss_msaa", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE);
206+
C.PassSET_ZB (TRUE,FALSE,TRUE ); // force inverted Z-Buffer
207+
208+
C.r_Sampler_rtf ("s_position", r2_RT_P);
209+
//C.r_Sampler_rtf ("s_normal", r2_RT_N);
210+
C.r_Sampler_clw ("s_material", r2_material);
211+
//C.r_Sampler_rtf ("s_accumulator", r2_RT_accum);
212+
C.r_Sampler ("s_lmap", r2_sunmask);
213+
C.r_Sampler_cmp ("s_smap", r2_RT_smap_depth);
214+
215+
jitter (C);
216+
217+
// C.r_Sampler ("s_water", "water\\water_water");
218+
219+
//C.r_Sampler ("s_water", "water\\water_studen");
220+
C.r_Sampler("s_patched_normal", r2_RT_accum);
221+
222+
//C.r_ColorWriteEnable( false, false, false, true );
223+
224+
C.RS.SetRS(D3DRS_SRCBLEND, D3DBLEND_ZERO );
225+
C.RS.SetRS(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR );
226+
227+
C.r_End ();
228+
229+
break;
230+
}
231+
GEnv.Render->m_MSAASample = -1;
232+
}
233+

0 commit comments

Comments
 (0)