mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
SMAA edge detection shader
This commit is contained in:
parent
e332dd07d6
commit
43b0cb2415
6 changed files with 73 additions and 16 deletions
|
@ -575,15 +575,15 @@ SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; Addres
|
|||
#else
|
||||
#define mad(a, b, c) (a * b + c)
|
||||
#endif
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4
|
||||
#define bool2 bvec2
|
||||
#define bool3 bvec3
|
||||
#define bool4 bvec4
|
||||
//#define float2 vec2
|
||||
//#define float3 vec3
|
||||
//#define float4 vec4
|
||||
//#define int2 ivec2
|
||||
//#define int3 ivec3
|
||||
//#define int4 ivec4
|
||||
//#define bool2 bvec2
|
||||
//#define bool3 bvec3
|
||||
//#define bool4 bvec4
|
||||
#endif
|
||||
|
||||
#if !defined(SMAA_HLSL_3) && !defined(SMAA_HLSL_4) && !defined(SMAA_HLSL_4_1) && !defined(SMAA_GLSL_3) && !defined(SMAA_GLSL_4) && !defined(SMAA_CUSTOM_SL)
|
||||
|
|
|
@ -54,5 +54,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
// base color with tone mapping and other post processing applied
|
||||
float4 color = tex2D( samp0, tCoords );
|
||||
|
||||
|
||||
|
||||
result.color = color;
|
||||
}
|
||||
|
|
|
@ -28,16 +28,22 @@ If you have questions concerning this license or the applicable additional terms
|
|||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
//#include "renderprogs/SMAA.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
#define SMAA_INCLUDE_PS 1
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0);
|
||||
uniform sampler2D samp1 : register(s1);
|
||||
uniform sampler2D samp0 : register(s0); // _currentColor
|
||||
uniform sampler2D samp1 : register(s1); // TODO _predictColor
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
|
@ -52,7 +58,22 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float2 tCoords = fragment.texcoord0;
|
||||
|
||||
// base color with tone mapping and other post processing applied
|
||||
float4 color = tex2D( samp0, tCoords );
|
||||
//float4 color = tex2D( samp0, tCoords );
|
||||
//color.rgb *= 1.0;
|
||||
|
||||
float4 offset[3];
|
||||
offset[0] = fragment.texcoord1;
|
||||
offset[1] = fragment.texcoord2;
|
||||
offset[2] = fragment.texcoord3;
|
||||
|
||||
float4 color = float4( 1.0 );
|
||||
color.rg = SMAALumaEdgeDetectionPS( tCoords,
|
||||
offset,
|
||||
samp0
|
||||
#if SMAA_PREDICATION
|
||||
, samp1
|
||||
#endif
|
||||
);
|
||||
|
||||
result.color = color;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2015 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -28,7 +29,12 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
struct VS_IN {
|
||||
#define SMAA_INCLUDE_VS 1
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
|
@ -36,12 +42,17 @@ struct VS_IN {
|
|||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUT {
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 texcoord3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result ) {
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
|
||||
//result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );
|
||||
|
@ -49,4 +60,11 @@ void main( VS_IN vertex, out VS_OUT result ) {
|
|||
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
|
||||
float4 offset[3];
|
||||
SMAAEdgeDetectionVS( vertex.texcoord, offset );
|
||||
|
||||
result.texcoord1 = offset[0];
|
||||
result.texcoord2 = offset[1];
|
||||
result.texcoord3 = offset[2];
|
||||
}
|
|
@ -555,6 +555,11 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
|
|||
src.AddDefine( "USE_HALF_LAMBERT" );
|
||||
}
|
||||
|
||||
// SMAA configuration
|
||||
src.AddDefine( "SMAA_GLSL_3" );
|
||||
src.AddDefine( "SMAA_RT_METRICS rpScreenCorrectionFactor " );
|
||||
src.AddDefine( "SMAA_PRESET_HIGH" );
|
||||
|
||||
idList< idCGBlock > blocks;
|
||||
|
||||
blocks.SetNum( 100 );
|
||||
|
|
|
@ -4991,9 +4991,18 @@ void RB_PostProcess( const void* data )
|
|||
|
||||
renderProgManager.BindShader_SMAA_EdgeDetection();
|
||||
|
||||
// set SMAA_RT_METRICS = rpScreenCorrectionFactor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / glConfig.nativeScreenWidth;
|
||||
screenCorrectionParm[1] = 1.0f / glConfig.nativeScreenHeight;
|
||||
screenCorrectionParm[2] = glConfig.nativeScreenWidth;
|
||||
screenCorrectionParm[3] = glConfig.nativeScreenHeight;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
}
|
||||
|
||||
#if 0
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->grainImage1->Bind();
|
||||
|
||||
|
@ -5027,5 +5036,7 @@ void RB_PostProcess( const void* data )
|
|||
// Draw
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#endif
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue