Skip to content

Commit 359ddb8

Browse files
committed
OpenGL: fixed unpacking color in 'editor' shader, added fxaa shader and blender
1 parent 1bbfb51 commit 359ddb8

File tree

8 files changed

+67
-1
lines changed

8 files changed

+67
-1
lines changed

res/gamedata/shaders/gl/editor.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ v2p _main (vf i)
77
v2p o;
88

99
o.P = mul (m_WVP, i.P); // xform, input in world coords
10-
o.C = tfactor*i.C;
10+
o.C = tfactor*unpack_D3DCOLOR(i.C);
1111

1212
return o;
1313
}

res/gamedata/shaders/gl/fxaa.ps

42 KB
Binary file not shown.
1.33 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "common.h"
2+
#include "iostructs\v_TL.h"
3+
4+
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
5+
6+
//////////////////////////////////////////////////////////////////////////////////////////
7+
// Vertex
8+
v2p_TL _main (v_TL I)
9+
{
10+
v2p O;
11+
O.HPos = float4 (I.P.x * screen_res.z * 2 - 1, (I.P.y * screen_res.w * 2 - 1)* -1, 0, 1);
12+
O.Tex0 = I.Tex0;
13+
14+
return O;
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "stdafx.h"
2+
#pragma hdrstop
3+
4+
#include "blender_fxaa.h"
5+
6+
CBlender_FXAA::CBlender_FXAA() { description.CLS = 0; }
7+
CBlender_FXAA::~CBlender_FXAA() { }
8+
9+
void CBlender_FXAA::Compile(CBlender_Compile& C)
10+
{
11+
IBlender::Compile(C);
12+
13+
switch (C.iElement)
14+
{
15+
case 0:
16+
C.r_Pass("fxaa_main", "fxaa_main", false, FALSE, FALSE);
17+
C.r_Sampler_rtf("s_base0", r2_RT_generic0);
18+
C.r_End();
19+
break;
20+
}
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
class CBlender_FXAA : public IBlender
4+
{
5+
public:
6+
LPCSTR getComment() override { return "FXAA"; }
7+
BOOL canBeDetailed() override { return FALSE; }
8+
BOOL canBeLMAPped() override { return FALSE; }
9+
10+
void Compile(CBlender_Compile& C) override;
11+
12+
CBlender_FXAA();
13+
virtual ~CBlender_FXAA();
14+
};

src/Layers/xrRenderPC_GL/gl_rendertarget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "blender_bloom_build.h"
1111
#include "blender_luminance.h"
1212
#include "blender_ssao.h"
13+
//#include "blender_fxaa.h"
1314
#include "Layers/xrRenderDX10/dx10MinMaxSMBlender.h"
1415
#include "Layers/xrRenderDX10/MSAA/dx10MSAABlender.h"
1516
#include "Layers/xrRenderDX10/DX10 Rain/dx10RainBlender.h"
@@ -295,6 +296,10 @@ CRenderTarget::CRenderTarget()
295296
b_combine = new CBlender_combine();
296297
b_ssao = new CBlender_SSAO_noMSAA();
297298

299+
// xxx: Add fxaa blender to project
300+
//FXAA
301+
//b_fxaa = new CBlender_FXAA();
302+
298303
if (RImplementation.o.dx10_msaa)
299304
{
300305
int bound = RImplementation.o.dx10_msaa_samples;
@@ -602,6 +607,10 @@ CRenderTarget::CRenderTarget()
602607
u_setrt(Device.dwWidth, Device.dwHeight, HW.pBaseRT, 0, 0, HW.pBaseZB);
603608
}
604609

610+
//FXAA
611+
//s_fxaa.create(b_fxaa, "gl" DELIMITER "fxaa");
612+
//g_fxaa.create(FVF::F_V, RCache.Vertex.Buffer(), RCache.QuadIB);
613+
605614
// HBAO
606615
if (RImplementation.o.ssao_opt_data)
607616
{
@@ -959,6 +968,7 @@ CRenderTarget::~CRenderTarget()
959968
xr_delete(b_accum_point);
960969
xr_delete(b_accum_direct);
961970
xr_delete(b_ssao);
971+
//xr_delete(b_fxaa); //FXAA
962972

963973
if (RImplementation.o.dx10_msaa)
964974
{

src/Layers/xrRenderPC_GL/gl_rendertarget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class CRenderTarget : public IRender_Target
5050
IBlender* b_accum_reflected_msaa[8];
5151
IBlender* b_ssao;
5252
IBlender* b_ssao_msaa[8];
53+
IBlender* b_fxaa;
54+
5355
#ifdef DEBUG
5456
struct dbg_line_t {
5557
Fvector P0,P1;
@@ -121,6 +123,10 @@ class CRenderTarget : public IRender_Target
121123
ref_shader s_ssao;
122124
ref_shader s_ssao_msaa[8];
123125

126+
//FXAA
127+
ref_shader s_fxaa;
128+
ref_geom g_fxaa;
129+
124130
// Accum
125131
ref_shader s_accum_mask;
126132
ref_shader s_accum_direct;

0 commit comments

Comments
 (0)