Skip to content

Commit

Permalink
OpenGL: fixed unpacking color in 'editor' shader, added fxaa shader a…
Browse files Browse the repository at this point in the history
…nd blender
  • Loading branch information
SkyLoaderr committed Nov 12, 2018
1 parent 1bbfb51 commit 359ddb8
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/editor.vs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ v2p _main (vf i)
v2p o;

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

return o;
}
Binary file added res/gamedata/shaders/gl/fxaa.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/fxaa_main.ps
Binary file not shown.
15 changes: 15 additions & 0 deletions res/gamedata/shaders/gl/fxaa_main.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"
#include "iostructs\v_TL.h"

uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)

//////////////////////////////////////////////////////////////////////////////////////////
// Vertex
v2p_TL _main (v_TL I)
{
v2p O;
O.HPos = float4 (I.P.x * screen_res.z * 2 - 1, (I.P.y * screen_res.w * 2 - 1)* -1, 0, 1);
O.Tex0 = I.Tex0;

return O;
}
21 changes: 21 additions & 0 deletions src/Layers/xrRenderPC_GL/blender_fxaa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "stdafx.h"
#pragma hdrstop

#include "blender_fxaa.h"

CBlender_FXAA::CBlender_FXAA() { description.CLS = 0; }
CBlender_FXAA::~CBlender_FXAA() { }

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

switch (C.iElement)
{
case 0:
C.r_Pass("fxaa_main", "fxaa_main", false, FALSE, FALSE);
C.r_Sampler_rtf("s_base0", r2_RT_generic0);
C.r_End();
break;
}
}
14 changes: 14 additions & 0 deletions src/Layers/xrRenderPC_GL/blender_fxaa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

class CBlender_FXAA : public IBlender
{
public:
LPCSTR getComment() override { return "FXAA"; }
BOOL canBeDetailed() override { return FALSE; }
BOOL canBeLMAPped() override { return FALSE; }

void Compile(CBlender_Compile& C) override;

CBlender_FXAA();
virtual ~CBlender_FXAA();
};
10 changes: 10 additions & 0 deletions src/Layers/xrRenderPC_GL/gl_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "blender_bloom_build.h"
#include "blender_luminance.h"
#include "blender_ssao.h"
//#include "blender_fxaa.h"
#include "Layers/xrRenderDX10/dx10MinMaxSMBlender.h"
#include "Layers/xrRenderDX10/MSAA/dx10MSAABlender.h"
#include "Layers/xrRenderDX10/DX10 Rain/dx10RainBlender.h"
Expand Down Expand Up @@ -295,6 +296,10 @@ CRenderTarget::CRenderTarget()
b_combine = new CBlender_combine();
b_ssao = new CBlender_SSAO_noMSAA();

// xxx: Add fxaa blender to project
//FXAA
//b_fxaa = new CBlender_FXAA();

if (RImplementation.o.dx10_msaa)
{
int bound = RImplementation.o.dx10_msaa_samples;
Expand Down Expand Up @@ -602,6 +607,10 @@ CRenderTarget::CRenderTarget()
u_setrt(Device.dwWidth, Device.dwHeight, HW.pBaseRT, 0, 0, HW.pBaseZB);
}

//FXAA
//s_fxaa.create(b_fxaa, "gl" DELIMITER "fxaa");
//g_fxaa.create(FVF::F_V, RCache.Vertex.Buffer(), RCache.QuadIB);

// HBAO
if (RImplementation.o.ssao_opt_data)
{
Expand Down Expand Up @@ -959,6 +968,7 @@ CRenderTarget::~CRenderTarget()
xr_delete(b_accum_point);
xr_delete(b_accum_direct);
xr_delete(b_ssao);
//xr_delete(b_fxaa); //FXAA

if (RImplementation.o.dx10_msaa)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Layers/xrRenderPC_GL/gl_rendertarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class CRenderTarget : public IRender_Target
IBlender* b_accum_reflected_msaa[8];
IBlender* b_ssao;
IBlender* b_ssao_msaa[8];
IBlender* b_fxaa;

#ifdef DEBUG
struct dbg_line_t {
Fvector P0,P1;
Expand Down Expand Up @@ -121,6 +123,10 @@ class CRenderTarget : public IRender_Target
ref_shader s_ssao;
ref_shader s_ssao_msaa[8];

//FXAA
ref_shader s_fxaa;
ref_geom g_fxaa;

// Accum
ref_shader s_accum_mask;
ref_shader s_accum_direct;
Expand Down

0 comments on commit 359ddb8

Please sign in to comment.