Jump to content

franck22000

Members
  • Posts

    271
  • Joined

  • Last visited

Posts posted by franck22000

  1. Hello, i am currently adding Gwen Gui into my game everything is working fine so far but i got a weird rendering artifact on some models (depending of the angle of the camera) if i render the Gui.

     

    Look at those images (dont pay attention to the weird rendering of the text):

     

    5686cf190928061.jpg f6e146190928094.jpg

     

    I have identified the code responsible of this in the openGL renderer of Gwen Gui, it is this code:

     

     

    glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(Vertex), (void*)&m_Vertices[0].r );
    glEnableClientState( GL_COLOR_ARRAY );

     

    if i comment this code portion the bug is solved but some part of the gui that need this is getting weird.

     

    Is there any solution to fix this small code portion ?

     

    Here is the the whole function if it can help:

     

     

    void OpenGL::Flush()
    {
    if ( m_iVertNum == 0 ) return;
    
    glVertexPointer( 3, GL_FLOAT,  sizeof(Vertex), (void*) &m_Vertices[0].x );
    glEnableClientState( GL_VERTEX_ARRAY );
    
    // This 2 lines make the weird rendering artifact
    glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(Vertex), (void*)&m_Vertices[0].r );
    glEnableClientState( GL_COLOR_ARRAY );
    
    glTexCoordPointer( 2, GL_FLOAT, sizeof(Vertex), (void*) &m_Vertices[0].u );
    glEnableClientState( GL_TEXTURE_COORD_ARRAY );
    
    glDrawArrays( GL_TRIANGLES, 0, (GLsizei) m_iVertNum );
    
    m_iVertNum = 0;
    glFlush();
    }

     

    Thanks !

  2. yes, as i discussed with you Josh i will try to do this technique :)

     

    It will be an FPS yes, a survival oriented FPS, the scene that you see is just a test, the final levels in the game will be much better :)

  3. Thanks, there is allready a sway shader on the vegetation, i have made a dynamic weather system and the tree are swaying according to the windforce, i have made a special shader for the grass too but it is not applied in the video.

  4. Let me contribute to this here is a comparison with and without lordhippo SSAO:

     

    post-16-0-57901700-1326187564_thumb.jpg

     

    post-16-0-08860000-1326187452_thumb.jpg

     

    and on this shot you can see the power of this shader (i have tweaked the shader to make the ssao appear more in dark areas and less in lighted areas.

     

    post-16-0-44054000-1326187765_thumb.jpg

  5. Here is a post for showing my work on my future FPS game (commercial game), I will tell the game concept later on, when everything will be decided.

     

    Here is some technichal aspect of my game engine:

     

    - Custom rendering pipeline (not using framework)

    - Numerous new post process effects ( improved ssao, film grain, echanced hdr, color correction...)

    - Custom scripting system

    - Custom DLL and functions used

    - Improved terrain features to be able to break vegetation layers trees for example

    - New sound system wich is supporting dynamic reverb effects, echo, doppler effect...

    - XML system for game components definitions (allowing a light modding support for the game)

     

     

    Let's begin with a video, showing my work on the day cycle, and the texturing work, this little scene is just a prototype made in 15 minutes :)

     

    http://www.youtube.com/watch?v=9ipMISDOZk4

     

    764e9a168650103.jpg da36f3168650232.jpg 934dc9168650364.jpg faf716168650448.jpg ab7140168650554.jpg

  6. Here is a new shader that i made for LE, Pencil Drawing Shader :D

     

    Just put this piece of code in the postfilter.frag shader in the end of the main() function just before "gl_FragColor = outputcolor;"

     

     

           float dpt=0;
    dpt+=texture2D( texture1, texcoord + vec2(	0,	pixelsize.y * 2.0	)).x;
    dpt+=texture2D( texture1, texcoord - vec2(	0,	pixelsize.y * 2.0	)).x;
    dpt+=texture2D( texture1, texcoord + vec2(	pixelsize.x * 2.0,	0	)).x;
    dpt+=texture2D( texture1, texcoord - vec2(	pixelsize.x * 2.0,	0	)).x;
    dpt/=4;
    
    if ((depth-dpt)>0.0001) 
    {
    	outputcolor=vec4(0.05,0.05,0.05,1.0); // Edges color
    }
    else
    {
    
      vec4 c = texture2D(texture0,texcoord);
    
      c += texture2D(texture0, texcoord+0.001);
      c += texture2D(texture0, texcoord+0.002);
      c += texture2D(texture0, texcoord+0.003);
      c += texture2D(texture0, texcoord+0.004);
      c += texture2D(texture0, texcoord+0.005);
      c += texture2D(texture0, texcoord+0.006);
    
      c.rgb = vec3((c.r+c.g+c.B)/2.0);
      vec4 graycolor = vec4(0.15,0.15,0.15,1.0);
    
    outputcolor=c*graycolor;
    }

     

    post-16-0-55394000-1316200189_thumb.png

  7. You need to generate a heighmap ( grayscale image ) then with this just drag the heightmap on the tool provided to make a stepmap :)

    But you will not have good result if you are not editing the heigthmap yourself, you need to work on the heigth map manually to have a good depth effect without too much artifacts.

  8. I made a clean demo to show the decals performance bug to Josh, so i hope it will be finally fixed in the next update since im fighting for weeks for it :)

     

    Please post your reports and the amount of FPS drop you have.

    Everything is explained in the demo.

     

    Posted in the bugtracker here: http://www.leadwerks.com/werkspace/tracker/issue-209-decal-performances-problem/

     

    DOWNLOAD:

     

     

     

    post-16-0-62024300-1316031349_thumb.png

     

    post-16-0-65856700-1316031363_thumb.png

     

     

    SOURCE CODE

     

    #include "engine.h"
    #include <iostream>
    #include <string>
    
    const int 	ScreenWidth = 800;
    const int 	ScreenHeight = 600;
    const char* AppTitle = "Decals Demo";
    
    void ErrOut( const std::string& message ) { std::cerr << message << std::endl; }
    
    //	-------------------------------
    int main( int argn, char* argv[] )
    {
    // Initialize
    if( !Initialize() )
    	return 1;        
    SetAppTitle( AppTitle ) ;
    
    // Set graphics mode        
    if( !Graphics(ScreenWidth,ScreenHeight) )
    {                
    	ErrOut( "Failed to set graphics mode."  );
    	return 1;        
    }
    
    // Create framework object and set it to a global object so other scripts can access it
    TFramework fw = CreateFramework();        
    if( fw == NULL )        
    {
    	ErrOut( "Failed to initialize engine." );                
    	return 1;        
    }        
    
    // Set Lua framework object        
    SetGlobalObject( "fw", fw );                
    
    // Set Lua framework variable        
    BP lua = GetLuaState();        
    lua_pushobject( lua, fw );        
    lua_setglobal( lua, "fw" );        
    lua_pop( lua, 1 );        
    
    // Get framework main camera        
    TCamera camera = GetLayerCamera( GetFrameworkLayer(0) );        
    PositionEntity( camera, Vec3(0,0,-2) );        
    
    // Create cube
    TMaterial material = LoadMaterial( "abstract::cobblestones.mat" );        
    TMesh mesh = CreateCube();        
    PaintEntity( mesh, material );        
    
    // Create ground
    TMesh ground = CreateCube();        
    ScaleEntity( ground, Vec3(10,1,10) );        
    PositionEntity( ground, Vec3(0,-2,0) );        
    PaintEntity( ground, material );        
    
    // Add some light
    TLight light = CreateDirectionalLight();        
    RotateEntity( light, Vec3(45,45,45) );        
    
    // Move the mouse cursor at the screen center and hide it
    MoveMouse(GraphicsWidth()  / 2, GraphicsHeight() / 2);
    HideMouse();
    
    // Other Variables
    TVec3 ViewCameraRotation = Vec3(0.0f,0.0f,0.0f);
    float Move = 0.0f;
    float Strafe = 0.0f;
    float MouseForceX = 0.0f;
    float MouseForceY = 0.0f;
    
    
    // Spin cube until user hits Escape
    while( !KeyHit() && !AppTerminate() )        
    {                
    	if( !AppSuspended() )
    	{
    
    		TurnEntity( mesh, Vec3( AppSpeed()*0.5f ) );     
    
    
    		// DECAL CODE
    		if (MouseHit(1))
    		{
    
    			TPick _Picked;
    
    			if (CameraPick( &_Picked, camera, Vec3(GraphicsWidth() / 2, GraphicsHeight() / 2, 100), 0.0f))
    			{
    
    				if (_Picked.entity != NULL)
    				{
    
    					TMesh _Decal = CreateDecal(_Picked.surface, TFormPoint(Vec3(_Picked.X, _Picked.Y, _Picked.Z), NULL, _Picked.entity), 0.020f);
    
    					EntityParent(_Decal , _Picked.entity, 0);
    					PaintEntity(_Decal , LoadMaterial("abstract::bullethole.mat"));
    
    					AddMesh(_Decal , _Picked.entity);
    					UpdateMesh(_Decal);
    
    				}
    
    			}
    
    		 }
    
    
    		// CAMERA MOVEMENT CODE
    		Move = 	(KeyDown(KEY_UP)-KeyDown(KEY_DOWN)) * 0.1f; 
    		Strafe =	(KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT)) * 0.1f; 
    
    		MouseForceX = Curve( MouseX() - GraphicsWidth() / 2.0f, MouseForceX, 2.0); 
    		MouseForceY = Curve( MouseY() - GraphicsHeight() / 2.0f, MouseForceY, 2.0);
    
    		LE::MoveMouse(GraphicsWidth()  / 2, GraphicsHeight() / 2);
    
    		ViewCameraRotation.X = ViewCameraRotation.X + MouseForceY / 8.0; 
    		ViewCameraRotation.Y = ViewCameraRotation.Y - MouseForceX / 8.0;
    
    		RotateEntity(camera, ViewCameraRotation);
    		MoveEntity(camera, Vec3 (Strafe*AppSpeed(), 0 , Move*AppSpeed()));
    
    
    		// Update FrameWork
    		UpdateFramework();                
    		RenderFramework();                
    
    
    		// TEXT
    		SetBlend(BLEND_ALPHA);
    		DrawText(1,15,"Move with arrowkeys, press mouseclick to drop a decal");
    		DrawText(1,30,"Put something like 20 decals on a surface and move the camera close to this surface to see the FPS drop.");
    		DrawText(1,45,"Then move the camera far from the surface to see the FPS getting back to a normal level.");
    
    		SetBlend(BLEND_NONE);
    
    		Flip( 0 );        
    	}
    }                
    
    return Terminate();
    }

  9. Here is a new shader for LE it's called cone step mapping ( CSM ) and it will give you a great relief effect for your materials :)

     

    - CSM is very fast, it's faster and much more efficient than parralax occlusion mapping.

    - CSM need a cone step map that you can generate ( it take the heightmap and generate cone step map from it ).

    - CSM will be very good for those who want to make static scenes without gameplay.

    - If you want to add this in your game, remember that decals will not apply correctly on the surface of your objects with this shader applied it can look bad, you will need to lower the depth to make it not too strange.

    - CSM rendering is better if you use the FXAA 3.11 anti-aliasing shader.

     

     

    SHADER UNIFORMS

     

    conestep_depth : You can change this value to ajust the depth of the effect, be gentle with that otherwise you will get too much artifacts.

     

     

    DOWNLOAD (version 1.0)

     

     

     

    STANDARD INSTALLATION

     

    1- Download the file in this post.

     

    2- Put the 2 Shaders Presets files in the "Mesh" folder of your shaders.pak

     

    3- Put this code in the Mesh.frag shader just before the Main() function:

     

    #ifdef LW_CONESTEP
    uniform sampler2D LW_CONESTEP;
    varying vec3 eyevec;
    
    uniform float conestep_depth = 0.08;
    
    void conestep_10step (sampler2D csmMap, inout vec3 dp, in vec3 ds)
    {
    
       float iz = max(abs(ds.x),abs(ds.y));
       float w = 1.2;
       vec4 t;
    
       // 10 Steps
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
    
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
    
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
       t=texture2D(csmMap,dp.xy);
       dp += ds * w * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
    
       return;
    }
    
    
    
    void conestep_exp(sampler2D csmMap, inout vec3 dp, vec3 ds, float dist_factor)
    {
    	float iz = max(abs(ds.x), abs(ds.y));
    	vec4  t = texture2D(csmMap,dp.xy);
    	float ht, old_ht;
    	float CR = 0.0;
    
    	while (t.r > dp.z)
    	{
    		CR = t.g * t.g;
    
    		dp += ds * (dist_factor + (t.r - dp.z) * CR) / (iz + CR);
    
    		t = texture2DLod(csmMap, dp.xy, 0.0);
    	}
    
    	ht = (t.r - dp.z);
    	dist_factor /= (iz + CR);
    	dp -= ds * dist_factor;
    
    	t = texture2D(csmMap,dp.xy);
    	old_ht = t.r - dp.z;
    
    	dp += ds * dist_factor * (1.0 - clamp (ht / (ht - old_ht), 0.0, 1.0));
    
    	t = texture2D(csmMap, dp.xy);
    	dp += ds * (t.r - dp.z) / (iz/(t.g*t.g) + 1.0);
    
    	return;
    }
    #endif

     

    4- Put this code in the Mesh.frag shader inside the Main() function just after the #ifdef LW_PARALLAXMAP section:

     

    #ifdef LW_CONESTEP
    	float a = -conestep_depth / eyevec.z;
    	vec3 s = vec3((eyevec * a).xy, 1);
    
    	float df = 0.1 * sqrt(length(fwidth(texcoord.xy)));
    
    	vec3 uv = vec3(texcoord.xy, 0);
    
    	// HIGH QUALITY
    	conestep_exp(LW_CONESTEP, uv, s, df);
    
    	// LOW QUALITY
    	//conestep_10step(LW_CONESTEP, uv, s);
    
    	texcoord = uv.xy;
    #endif

     

    5- It's done ! you can use the test material provided in the zip file downloaded on a 3D object to test the effect :D

     

     

    Here is 2 new screenshots to show you the effect at various angles:

     

     

     

     

  10. I have converted the last version of the famous anti-aliasing FXAA shader ( version 3.11 ) for you guys, just replace the code in the "edge_antialiasing.frag" with this code and it should work.

     

    Important: You need a GPU that support shader model 4.0 to get this shader working !

     

    You will see the quality is very nice and the performance impact is very light.

     

    Enjoy ! I may have some goodies like this for you in the future stay tuned ;)

     

     

     

    /*---------------------------------------------------------------------------------------------------------
    FXAA 3.11 for LeadWerks engine converted by Franck Poulain and originaly made by TIMOTHY LOTTES
    ---------------------------------------------------------------------------------------------------------*/
    
    #extension GL_EXT_gpu_shader4 : enable 
    
    
    
    // PARAMETERS
    #define FXAA_QUALITY__PRESET 13
    
    // IMPORTANT: You can find other parameters to tweak in the main() function of this shader
    
    
    // Dont touch this
    #define FXAA_GLSL_120
    #define FXAA_GREEN_AS_LUMA 1
    #define FXAA_FAST_PIXEL_OFFSET 0
    #define FXAA_GATHER4_ALPHA 0
    
    #define COLOR texture1
    uniform sampler2D COLOR;
    uniform vec2 buffersize;
    
    
    /*--------------------------------------------------------------------------*/
    #ifndef FXAA_GLSL_120
       #define FXAA_GLSL_120 0
    #endif
    
    
    /*==========================================================================*/
    #ifndef FXAA_GREEN_AS_LUMA
       #define FXAA_GREEN_AS_LUMA 0
    #endif
    /*--------------------------------------------------------------------------*/
    
    #ifndef FXAA_DISCARD
       #define FXAA_DISCARD 0
    #endif
    /*--------------------------------------------------------------------------*/
    #ifndef FXAA_FAST_PIXEL_OFFSET
       //
       // Used for GLSL 120 only.
       //
       // 1 = GL API supports fast pixel offsets
       // 0 = do not use fast pixel offsets
       //
       #ifdef GL_EXT_gpu_shader4
           #define FXAA_FAST_PIXEL_OFFSET 1
       #endif
       #ifdef GL_NV_gpu_shader5
           #define FXAA_FAST_PIXEL_OFFSET 1
       #endif
       #ifdef GL_ARB_gpu_shader5
           #define FXAA_FAST_PIXEL_OFFSET 1
       #endif
       #ifndef FXAA_FAST_PIXEL_OFFSET
           #define FXAA_FAST_PIXEL_OFFSET 0
       #endif
    #endif
    
    /*--------------------------------------------------------------------------*/
    #ifndef FXAA_GATHER4_ALPHA
       //
       // 1 = API supports gather4 on alpha channel.
       // 0 = API does not support gather4 on alpha channel.
       //
       #if (FXAA_HLSL_5 == 1)
           #define FXAA_GATHER4_ALPHA 1
       #endif
       #ifdef GL_ARB_gpu_shader5
           #define FXAA_GATHER4_ALPHA 1
       #endif
       #ifdef GL_NV_gpu_shader5
           #define FXAA_GATHER4_ALPHA 1
       #endif
       #ifndef FXAA_GATHER4_ALPHA
           #define FXAA_GATHER4_ALPHA 0
       #endif
    #endif
    
    
    
    #ifndef FXAA_QUALITY__PRESET
       #define FXAA_QUALITY__PRESET 13
    #endif
    
    
    /*============================================================================
    
                              FXAA QUALITY - PRESETS
    
    ============================================================================*/
    
    /*============================================================================
                        FXAA QUALITY - MEDIUM DITHER PRESETS
    ============================================================================*/
    
    #if (FXAA_QUALITY__PRESET == 10)
       #define FXAA_QUALITY__PS 3
       #define FXAA_QUALITY__P0 1.5
       #define FXAA_QUALITY__P1 3.0
       #define FXAA_QUALITY__P2 12.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 11)
       #define FXAA_QUALITY__PS 4
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 3.0
       #define FXAA_QUALITY__P3 12.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 12)
       #define FXAA_QUALITY__PS 5
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 4.0
       #define FXAA_QUALITY__P4 12.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 13)
       #define FXAA_QUALITY__PS 6
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 4.0
       #define FXAA_QUALITY__P5 12.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 14)
       #define FXAA_QUALITY__PS 7
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 4.0
       #define FXAA_QUALITY__P6 12.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 15)
       #define FXAA_QUALITY__PS 8
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 4.0
       #define FXAA_QUALITY__P7 12.0
    #endif
    
    
    
    #if (FXAA_QUALITY__PRESET == 20)
       #define FXAA_QUALITY__PS 3
       #define FXAA_QUALITY__P0 1.5
       #define FXAA_QUALITY__P1 2.0
       #define FXAA_QUALITY__P2 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 21)
       #define FXAA_QUALITY__PS 4
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 22)
       #define FXAA_QUALITY__PS 5
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 23)
       #define FXAA_QUALITY__PS 6
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 24)
       #define FXAA_QUALITY__PS 7
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 3.0
       #define FXAA_QUALITY__P6 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 25)
       #define FXAA_QUALITY__PS 8
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 4.0
       #define FXAA_QUALITY__P7 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 26)
       #define FXAA_QUALITY__PS 9
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 2.0
       #define FXAA_QUALITY__P7 4.0
       #define FXAA_QUALITY__P8 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 27)
       #define FXAA_QUALITY__PS 10
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 2.0
       #define FXAA_QUALITY__P7 2.0
       #define FXAA_QUALITY__P8 4.0
       #define FXAA_QUALITY__P9 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 28)
       #define FXAA_QUALITY__PS 11
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 2.0
       #define FXAA_QUALITY__P7 2.0
       #define FXAA_QUALITY__P8 2.0
       #define FXAA_QUALITY__P9 4.0
       #define FXAA_QUALITY__P10 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 29)
       #define FXAA_QUALITY__PS 12
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.5
       #define FXAA_QUALITY__P2 2.0
       #define FXAA_QUALITY__P3 2.0
       #define FXAA_QUALITY__P4 2.0
       #define FXAA_QUALITY__P5 2.0
       #define FXAA_QUALITY__P6 2.0
       #define FXAA_QUALITY__P7 2.0
       #define FXAA_QUALITY__P8 2.0
       #define FXAA_QUALITY__P9 2.0
       #define FXAA_QUALITY__P10 4.0
       #define FXAA_QUALITY__P11 8.0
    #endif
    
    #if (FXAA_QUALITY__PRESET == 39)
       #define FXAA_QUALITY__PS 12
       #define FXAA_QUALITY__P0 1.0
       #define FXAA_QUALITY__P1 1.0
       #define FXAA_QUALITY__P2 1.0
       #define FXAA_QUALITY__P3 1.0
       #define FXAA_QUALITY__P4 1.0
       #define FXAA_QUALITY__P5 1.5
       #define FXAA_QUALITY__P6 2.0
       #define FXAA_QUALITY__P7 2.0
       #define FXAA_QUALITY__P8 2.0
       #define FXAA_QUALITY__P9 2.0
       #define FXAA_QUALITY__P10 4.0
       #define FXAA_QUALITY__P11 8.0
    #endif
    
    
    
    /*============================================================================
    
                                   GLSL DEFINES
    
    ============================================================================*/
    
    
    #define FxaaSat(x) clamp(x, 0.0, 1.0)
    #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)
    
    
    #if (FXAA_FAST_PIXEL_OFFSET == 1)
           #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)
       #else
           #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)
    #endif
    
    
      #if (FXAA_GATHER4_ALPHA == 1)
           // use #extension GL_ARB_gpu_shader5 : enable
           #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)
           #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)
           #define FxaaTexGreen4(t, p) textureGather(t, p, 1)
           #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)
       #endif
    
    
    
    
    
    
    
    
    /*============================================================================
                      GREEN AS LUMA OPTION SUPPORT FUNCTION
    ============================================================================*/
    #if (FXAA_GREEN_AS_LUMA == 0)
       float FxaaLuma(vec4 rgba) { return rgba.w; }
    #else
       float FxaaLuma(vec4 rgba) { return rgba.y; }
    #endif    
    
    
    
    
    /*============================================================================
    
                                FXAA3 QUALITY - PC
    
    ============================================================================*/
    
    /*--------------------------------------------------------------------------*/
    vec4 FxaaPixelShader(vec2 pos, vec4 fxaaConsolePosPos, sampler2D tex, sampler2D fxaaConsole360TexExpBiasNegOne, sampler2D fxaaConsole360TexExpBiasNegTwo, vec2 fxaaQualityRcpFrame, vec4 fxaaConsoleRcpFrameOpt, vec4 fxaaConsoleRcpFrameOpt2, vec4 fxaaConsole360RcpFrameOpt2, float fxaaQualitySubpix, float fxaaQualityEdgeThreshold, float fxaaQualityEdgeThresholdMin, float fxaaConsoleEdgeSharpness, float fxaaConsoleEdgeThreshold, float fxaaConsoleEdgeThresholdMin, vec4 fxaaConsole360ConstDir) 
    {
    /*--------------------------------------------------------------------------*/
       vec2 posM;
       posM.x = pos.x;
       posM.y = pos.y;
       #if (FXAA_GATHER4_ALPHA == 1)
           #if (FXAA_DISCARD == 0)
               vec4 rgbyM = FxaaTexTop(tex, posM);
               #if (FXAA_GREEN_AS_LUMA == 0)
                   #define lumaM rgbyM.w
               #else
                   #define lumaM rgbyM.y
               #endif
           #endif
           #if (FXAA_GREEN_AS_LUMA == 0)
               vec4 luma4A = FxaaTexAlpha4(tex, posM);
               vec4 luma4B = FxaaTexOffAlpha4(tex, posM, ivec2(-1, -1));
           #else
               vec4 luma4A = FxaaTexGreen4(tex, posM);
               vec4 luma4B = FxaaTexOffGreen4(tex, posM, ivec2(-1, -1));
           #endif
           #if (FXAA_DISCARD == 1)
               #define lumaM luma4A.w
           #endif
           #define lumaE luma4A.z
           #define lumaS luma4A.x
           #define lumaSE luma4A.y
           #define lumaNW luma4B.w
           #define lumaN luma4B.z
           #define lumaW luma4B.x
       #else
           vec4 rgbyM = FxaaTexTop(tex, posM);
           #if (FXAA_GREEN_AS_LUMA == 0)
               #define lumaM rgbyM.w
           #else
               #define lumaM rgbyM.y
           #endif
           float lumaS = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 0, 1), fxaaQualityRcpFrame.xy));
           float lumaE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1, 0), fxaaQualityRcpFrame.xy));
           float lumaN = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 0,-1), fxaaQualityRcpFrame.xy));
           float lumaW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1, 0), fxaaQualityRcpFrame.xy));
       #endif
    /*--------------------------------------------------------------------------*/
       float maxSM = max(lumaS, lumaM);
       float minSM = min(lumaS, lumaM);
       float maxESM = max(lumaE, maxSM);
       float minESM = min(lumaE, minSM);
       float maxWN = max(lumaN, lumaW);
       float minWN = min(lumaN, lumaW);
       float rangeMax = max(maxWN, maxESM);
       float rangeMin = min(minWN, minESM);
       float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
       float range = rangeMax - rangeMin;
       float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
       bool earlyExit = range < rangeMaxClamped;
    /*--------------------------------------------------------------------------*/
       if(earlyExit)
           #if (FXAA_DISCARD == 1)
               discard;
           #else
               return rgbyM;
           #endif
    /*--------------------------------------------------------------------------*/
       #if (FXAA_GATHER4_ALPHA == 0)
           float lumaNW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1,-1), fxaaQualityRcpFrame.xy));
           float lumaSE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1, 1), fxaaQualityRcpFrame.xy));
           float lumaNE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1,-1), fxaaQualityRcpFrame.xy));
           float lumaSW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1, 1), fxaaQualityRcpFrame.xy));
       #else
           float lumaNE = FxaaLuma(FxaaTexOff(tex, posM, ivec2(1, -1), fxaaQualityRcpFrame.xy));
           float lumaSW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1, 1), fxaaQualityRcpFrame.xy));
       #endif
    /*--------------------------------------------------------------------------*/
       float lumaNS = lumaN + lumaS;
       float lumaWE = lumaW + lumaE;
       float subpixRcpRange = 1.0/range;
       float subpixNSWE = lumaNS + lumaWE;
       float edgeHorz1 = (-2.0 * lumaM) + lumaNS;
       float edgeVert1 = (-2.0 * lumaM) + lumaWE;
    /*--------------------------------------------------------------------------*/
       float lumaNESE = lumaNE + lumaSE;
       float lumaNWNE = lumaNW + lumaNE;
       float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
       float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
    /*--------------------------------------------------------------------------*/
       float lumaNWSW = lumaNW + lumaSW;
       float lumaSWSE = lumaSW + lumaSE;
       float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
       float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
       float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
       float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
       float edgeHorz = abs(edgeHorz3) + edgeHorz4;
       float edgeVert = abs(edgeVert3) + edgeVert4;
    /*--------------------------------------------------------------------------*/
       float subpixNWSWNESE = lumaNWSW + lumaNESE;
       float lengthSign = fxaaQualityRcpFrame.x;
       bool horzSpan = edgeHorz >= edgeVert;
       float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
    /*--------------------------------------------------------------------------*/
       if(!horzSpan) lumaN = lumaW;
       if(!horzSpan) lumaS = lumaE;
       if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
       float subpixB = (subpixA * (1.0/12.0)) - lumaM;
    /*--------------------------------------------------------------------------*/
       float gradientN = lumaN - lumaM;
       float gradientS = lumaS - lumaM;
       float lumaNN = lumaN + lumaM;
       float lumaSS = lumaS + lumaM;
       bool pairN = abs(gradientN) >= abs(gradientS);
       float gradient = max(abs(gradientN), abs(gradientS));
       if(pairN) lengthSign = -lengthSign;
       float subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
    /*--------------------------------------------------------------------------*/
       vec2 posB;
       posB.x = posM.x;
       posB.y = posM.y;
       vec2 offNP;
       offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
       offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
       if(!horzSpan) posB.x += lengthSign * 0.5;
       if( horzSpan) posB.y += lengthSign * 0.5;
    /*--------------------------------------------------------------------------*/
       vec2 posN;
       posN.x = posB.x - offNP.x * FXAA_QUALITY__P0;
       posN.y = posB.y - offNP.y * FXAA_QUALITY__P0;
       vec2 posP;
       posP.x = posB.x + offNP.x * FXAA_QUALITY__P0;
       posP.y = posB.y + offNP.y * FXAA_QUALITY__P0;
       float subpixD = ((-2.0)*subpixC) + 3.0;
       float lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
       float subpixE = subpixC * subpixC;
       float lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
    /*--------------------------------------------------------------------------*/
       if(!pairN) lumaNN = lumaSS;
       float gradientScaled = gradient * 1.0/4.0;
       float lumaMM = lumaM - lumaNN * 0.5;
       float subpixF = subpixD * subpixE;
       bool lumaMLTZero = lumaMM < 0.0;
    /*--------------------------------------------------------------------------*/
       lumaEndN -= lumaNN * 0.5;
       lumaEndP -= lumaNN * 0.5;
       bool doneN = abs(lumaEndN) >= gradientScaled;
       bool doneP = abs(lumaEndP) >= gradientScaled;
       if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P1;
       if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P1;
       bool doneNP = (!doneN) || (!doneP);
       if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P1;
       if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P1;
    /*--------------------------------------------------------------------------*/
       if(doneNP) {
           if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
           if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
           if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
           if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
           doneN = abs(lumaEndN) >= gradientScaled;
           doneP = abs(lumaEndP) >= gradientScaled;
           if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P2;
           if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P2;
           doneNP = (!doneN) || (!doneP);
           if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P2;
           if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P2;
    /*--------------------------------------------------------------------------*/
           #if (FXAA_QUALITY__PS > 3)
           if(doneNP) {
               if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
               if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
               if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
               if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
               doneN = abs(lumaEndN) >= gradientScaled;
               doneP = abs(lumaEndP) >= gradientScaled;
               if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P3;
               if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P3;
               doneNP = (!doneN) || (!doneP);
               if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P3;
               if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P3;
    /*--------------------------------------------------------------------------*/
               #if (FXAA_QUALITY__PS > 4)
               if(doneNP) {
                   if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                   if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                   if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                   if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                   doneN = abs(lumaEndN) >= gradientScaled;
                   doneP = abs(lumaEndP) >= gradientScaled;
                   if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P4;
                   if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P4;
                   doneNP = (!doneN) || (!doneP);
                   if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P4;
                   if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P4;
    /*--------------------------------------------------------------------------*/
                   #if (FXAA_QUALITY__PS > 5)
                   if(doneNP) {
                       if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                       if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                       if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                       if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                       doneN = abs(lumaEndN) >= gradientScaled;
                       doneP = abs(lumaEndP) >= gradientScaled;
                       if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P5;
                       if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P5;
                       doneNP = (!doneN) || (!doneP);
                       if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P5;
                       if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P5;
    /*--------------------------------------------------------------------------*/
                       #if (FXAA_QUALITY__PS > 6)
                       if(doneNP) {
                           if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                           if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                           if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                           if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                           doneN = abs(lumaEndN) >= gradientScaled;
                           doneP = abs(lumaEndP) >= gradientScaled;
                           if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P6;
                           if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P6;
                           doneNP = (!doneN) || (!doneP);
                           if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P6;
                           if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P6;
    /*--------------------------------------------------------------------------*/
                           #if (FXAA_QUALITY__PS > 7)
                           if(doneNP) {
                               if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                               if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                               if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                               if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                               doneN = abs(lumaEndN) >= gradientScaled;
                               doneP = abs(lumaEndP) >= gradientScaled;
                               if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P7;
                               if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P7;
                               doneNP = (!doneN) || (!doneP);
                               if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P7;
                               if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P7;
    /*--------------------------------------------------------------------------*/
       #if (FXAA_QUALITY__PS > 8)
       if(doneNP) {
           if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
           if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
           if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
           if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
           doneN = abs(lumaEndN) >= gradientScaled;
           doneP = abs(lumaEndP) >= gradientScaled;
           if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P8;
           if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P8;
           doneNP = (!doneN) || (!doneP);
           if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P8;
           if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P8;
    /*--------------------------------------------------------------------------*/
           #if (FXAA_QUALITY__PS > 9)
           if(doneNP) {
               if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
               if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
               if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
               if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
               doneN = abs(lumaEndN) >= gradientScaled;
               doneP = abs(lumaEndP) >= gradientScaled;
               if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P9;
               if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P9;
               doneNP = (!doneN) || (!doneP);
               if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P9;
               if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P9;
    /*--------------------------------------------------------------------------*/
               #if (FXAA_QUALITY__PS > 10)
               if(doneNP) {
                   if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                   if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                   if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                   if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                   doneN = abs(lumaEndN) >= gradientScaled;
                   doneP = abs(lumaEndP) >= gradientScaled;
                   if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P10;
                   if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P10;
                   doneNP = (!doneN) || (!doneP);
                   if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P10;
                   if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P10;
    /*--------------------------------------------------------------------------*/
                   #if (FXAA_QUALITY__PS > 11)
                   if(doneNP) {
                       if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                       if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                       if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                       if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                       doneN = abs(lumaEndN) >= gradientScaled;
                       doneP = abs(lumaEndP) >= gradientScaled;
                       if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P11;
                       if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P11;
                       doneNP = (!doneN) || (!doneP);
                       if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P11;
                       if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P11;
    /*--------------------------------------------------------------------------*/
                       #if (FXAA_QUALITY__PS > 12)
                       if(doneNP) {
                           if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
                           if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
                           if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                           if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                           doneN = abs(lumaEndN) >= gradientScaled;
                           doneP = abs(lumaEndP) >= gradientScaled;
                           if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P12;
                           if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P12;
                           doneNP = (!doneN) || (!doneP);
                           if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P12;
                           if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P12;
    /*--------------------------------------------------------------------------*/
                       }
                       #endif
    /*--------------------------------------------------------------------------*/
                   }
                   #endif
    /*--------------------------------------------------------------------------*/
               }
               #endif
    /*--------------------------------------------------------------------------*/
           }
           #endif
    /*--------------------------------------------------------------------------*/
       }
       #endif
    /*--------------------------------------------------------------------------*/
                           }
                           #endif
    /*--------------------------------------------------------------------------*/
                       }
                       #endif
    /*--------------------------------------------------------------------------*/
                   }
                   #endif
    /*--------------------------------------------------------------------------*/
               }
               #endif
    /*--------------------------------------------------------------------------*/
           }
           #endif
    /*--------------------------------------------------------------------------*/
       }
    /*--------------------------------------------------------------------------*/
    
    float dstN = posM.x - posN.x;
       float dstP = posP.x - posM.x;
       if(!horzSpan) dstN = posM.y - posN.y;
       if(!horzSpan) dstP = posP.y - posM.y;
    /*--------------------------------------------------------------------------*/
       bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
       float spanLength = (dstP + dstN);
       bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
       float spanLengthRcp = 1.0/spanLength;
    /*--------------------------------------------------------------------------*/
       bool directionN = dstN < dstP;
       float dst = min(dstN, dstP);
       bool goodSpan = directionN ? goodSpanN : goodSpanP;
       float subpixG = subpixF * subpixF;
       float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
       float subpixH = subpixG * fxaaQualitySubpix;
    /*--------------------------------------------------------------------------*/
    float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
       float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
       if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
       if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
       #if (FXAA_DISCARD == 1)
           return FxaaTexTop(tex, posM);
       #else
           return vec4(FxaaTexTop(tex, posM).xyz, lumaM);
       #endif
    }
    /*==========================================================================*/
    
    
    
    
    
    void main( void )
    {
    
    vec2 rcpFrame; 
    
    rcpFrame.x = 1.0 / buffersize.x;
    rcpFrame.y = 1.0 / buffersize.y;
    
    vec2 pos;
    pos.xy= gl_FragCoord.xy / buffersize.xy;
    
    vec4 ConsolePosPos = vec4(0.0,0.0,0.0,0.0);
    vec4 ConsoleRcpFrameOpt = vec4(0.0,0.0,0.0,0.0);
       vec4 ConsoleRcpFrameOpt2 = vec4(0.0,0.0,0.0,0.0);
       vec4 Console360RcpFrameOpt2 = vec4(0.0,0.0,0.0,0.0);
    
    
    // Only used on FXAA Quality.
       // Choose the amount of sub-pixel aliasing removal.
       // This can effect sharpness.
       //   1.00 - upper limit (softer)
       //   0.75 - default amount of filtering
       //   0.50 - lower limit (sharper, less sub-pixel aliasing removal)
       //   0.25 - almost off
       //   0.00 - completely off
    float QualitySubpix = 0.75;
    
       // The minimum amount of local contrast required to apply algorithm.
       //   0.333 - too little (faster)
       //   0.250 - low quality
       //   0.166 - default
       //   0.125 - high quality 
       //   0.033 - very high quality (slower)
    float QualityEdgeThreshold = 0.033;
    
    // You dont need to touch theses variables it have no visible effect
    float QualityEdgeThresholdMin = 0.0;
    float ConsoleEdgeSharpness = 8.0;
       float ConsoleEdgeThreshold = 0.125;
    float ConsoleEdgeThresholdMin = 0.05;
       vec4  Console360ConstDir = vec4(1.0, -1.0, 0.25, -0.25);
    
    gl_FragColor=FxaaPixelShader(pos, ConsolePosPos, COLOR, COLOR, COLOR, rcpFrame, ConsoleRcpFrameOpt, ConsoleRcpFrameOpt2, Console360RcpFrameOpt2, QualitySubpix, QualityEdgeThreshold, QualityEdgeThresholdMin, ConsoleEdgeSharpness, ConsoleEdgeThreshold, ConsoleEdgeThresholdMin, Console360ConstDir);
    }

×
×
  • Create New...