Jump to content

OpenGL 4.5 on Intel HD 4400


Souper

Recommended Posts

I've got an Intel HD 4400 graphics card and i need to run No Man's Sky, which means i need OpenGL 4.5. I cannot upgrade in any physical or monetary way from my current setup. I am becoming desperate. My game just crashes after the no man's sky logo. No error, nothing, just an instant exit. I did however get this in a report:

 

Spoiler

#version 450 compatibility 
#define D_PLATFORM_PC
#define D_VERTEX

// VERTEX SHADER:    SHADERS/LINE3D.SHADER.BIN
// CONTEXT:    LINE3D
// =================================================================================================
#define D_VERTEX
////////////////////////////////////////////////////////////////////////////////
///
///     @file       Im3dFragment.shader.h
///     @author     
///     @date       
///
///     @brief      Immediate Mode Fragment
///
///     Copyright (c) 2009 Hello Games Ltd. All Rights Reserved.
///
////////////////////////////////////////////////////////////////////////////////

// =================================================================================================

#ifndef D_DEFINES
#define D_DEFINES


// =================================================================================================
// Platform defines
// =================================================================================================
#ifdef D_PLATFORM_PC

    #pragma optionNV(strict on)
    #extension GL_ARB_gpu_shader5 : enable
    #extension GL_ARB_fragment_coord_conventions : enable
    #extension GL_ARB_derivative_control : enable

    #ifdef D_FRAGMENT
    //{
        //layout( origin_upper_left, pixel_center_integer ) in vec4 gl_FragCoord;
    //}
    #endif

#elif defined(D_PLATFORM_ORBIS)

    // use this with sdk 2.0 compiler 
   // #pragma argument (allow-scratch-buffer-spill)

    //define these flags so they don't get ignored in build process and in the comb mask
    //this is because materials, vertex layouts and shaders need to be synced on 360 to avoid patching
    #ifdef _F27_
    #endif
    #ifdef _F28_
    #endif
    #ifdef _F29_
    #endif
    #ifdef _F21_
    #endif
    #ifdef _F02_
    #endif
    #ifdef _F03_
    #endif
    #if defined( _F01_ ) || defined( D_LOD0 ) || defined( D_LOD1 ) || defined( D_LOD2 ) || defined( D_LOD3) || defined( D_LOD4 ) 
    #endif
    #ifdef _F01_
    #endif
    #ifdef _F09_
    #endif
    #ifdef _F10_
    #endif


    // disable warnings for unused parameters. This happens a lot because of defining different things.
    #pragma warning (disable: 5203)

    // temp thing to know what things are still required on ps4.
    #define D_PLATFORM_ORBIS_FIX

#endif

// =================================================================================================
// Basic Types
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define JOINT_TYPE    vec4

    //#define CONST         const
    #define STATIC_CONST  const

#elif defined(D_PLATFORM_ORBIS)

    #define JOINT_TYPE      int4
    #define float           float
    #define vec2            float2
    #define vec3            float3
    #define vec4            float4
    #define ivec2           int2
    #define ivec3           int3
    #define ivec4           int4
    // NOTE: 
    // operator[] accesses rows, not columns 
    // matrix constructors interpret the passed vectors as row vectors, not column vectors
    #define mat2            row_major float2x2
    #define mat3            row_major float3x3
    #define mat4            row_major float4x4

    //#define CONST           
    #define STATIC_CONST    static const
   // #define const           ERROR, DON'T USE CONST FOR PS4. USE STATIC_CONST INSTEAD FOR A COMPILED IN CONSTANT. OTHERWISE IT TRIES TO PUT IT IN A CONSTANT BUFFER AND FOR SOME REASON IT DOESN'T WORK.


#endif

// =================================================================================================
// Functions
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define saturate( V )  min( max( V, 0.0) , 1.0)
    #define atan2( Y, X )  atan( Y, X )
    #define invsqrt( X )   inversesqrt( X )

    // These can be deleted if ARB_derivative_control can be used
    //#define dFdxFine    dFdx
    //#define dFdyFine    dFdy

#elif defined(D_PLATFORM_ORBIS)

    #define mix             lerp
    #define fract           frac
    #define dFdx            ddx
    #define dFdy            ddy
    #define dFdxFine        ddx_fine
    #define dFdyFine        ddy_fine
#define mod                fmod
    #define saturate( V )   ( min( max( V, 0.0) , 1.0) )
    #define invsqrt( X )    rsqrt( X )

#endif


// =================================================================================================
// Samplers and textures
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SAMPLER2DSHADOW( NAME, REG )    uniform sampler2DShadow NAME

    #define SAMPLER2DARG( NAME )            in sampler2D NAME
    #define SAMPLER2DPARAM( NAME )          NAME
    #define SAMPLER2DARRAYARG( NAME )       in sampler2DArray NAME

    #define SAMPLERCUBE( NAME )             samplerCube NAME
    #define SAMPLERCUBEARG( NAME )          in samplerCube NAME
    #define SAMPLERCUBEPARAM( NAME )        NAME

    

    #define SAMPLER2DARRAYPARAM( NAME )     NAME

    // TEMP while switching ps4 over to srt
    #define SAMPLER2D( NAME )               sampler2D       NAME
    #define SAMPLER2D_TEMP( NAME, INDEX )   uniform sampler2D       NAME
    #define SAMPLER2DARRAY( NAME )          sampler2DArray  NAME
    #define SAMPLER3D( NAME )               sampler3D       NAME
    #define SAMPLER2DSHADOW_SRT( NAME )     sampler2DShadow NAME


#elif defined(D_PLATFORM_ORBIS)

    #define SAMPLERCUBE( NAME, REG )        SamplerState NAME##SS : register( s##REG ); TextureCube NAME##TU : register( t##REG )

    #define SAMPLER2D( NAME )               Texture2D NAME; SamplerState NAME##SS
    #define SAMPLER2DSHADOW_SRT( NAME )     Texture2D NAME; SamplerComparisonState NAME##SS  //SAMPLER2D( NAME )
    #define SAMPLER3D( NAME )               Texture3D NAME; SamplerState NAME##SS


    #define SAMPLER2DARRAY( NAME )          Texture2D_Array NAME; SamplerState NAME##SS
    #define SAMPLER2DARRAYARG( NAME )       Texture2D_Array NAME, SamplerState NAME##SS
    #define SAMPLER2DARRAYPARAM( NAME )     NAME, NAME##SS

    #define SAMPLER2DPARAM( NAME )          NAME, NAME##SS
    #define SAMPLER2DARG( NAME )            Texture2D NAME, SamplerState NAME##SS

    #define texture2D( T, C )                T.Sample( T##SS, C )

    #define texture2DLod( T, C, N )         T.SampleLOD( T##SS, C, N )
    #define texture2DArray(  T, C )         T.Sample( T##SS, C )
    #define texture3DLod( T, C, N )         T.SampleLOD( T##SS, C, N )

    //#define shadow2D( T, C )                vec3( C.z > T.Sample( T##SS, C.xy ).x ? 1.0 : 0.0 )                    
    //#define shadow2D( T, C )                T.GatherCmp( T##SS, C.xy, C.z )
    //#define shadow2D( T, C )                T.SampleCmpLOD0( T##SS, C.xy, C.z )
    #define shadow2D( T, C )                T.SampleCmp( T##SS, C.xy, C.z )
    #define textureCube( T, C )                T##TU.Sample( T##SS, C )
    #define textureCubeLod( T, C, N )        T##TU.Sample( T##SS, C, N )
    #define textureGrad( T, C, DDX, DDY )   T.SampleGradient( T##SS, C, DDX, DDY )                    

#endif

// =================================================================================================
// Matrices
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define MUL( INPUT_A, INPUT_B )         (INPUT_A * INPUT_B)
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#elif defined(D_PLATFORM_ORBIS)

    #define MUL( INPUT_A, INPUT_B )         mul( INPUT_B, INPUT_A )
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#endif

// =================================================================================================
// Arrays (workaround AMD shader compiler issues by making arrays have global scope)
// =================================================================================================

#if defined(D_PLATFORM_ORBIS)

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]

#else

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]

#endif


// =================================================================================================
// Input and Output
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define UNIFORM( TYPE, NAME )           uniform TYPE NAME
    #define UNIFORM_SRT( TYPE, NAME )       uniform TYPE NAME

    #define DECLARE_INPUT
    #define DECLARE_OUTPUT
    #define DECLARE_END  
    #define DECLARE_PTR( TYPE, NAME )       TYPE  NAME;

    #define INPUT(   TYPE, NAME, REG )      in    TYPE NAME;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      in    TYPE NAME;
    #define OUTPUT(  TYPE, NAME, REG )      out   TYPE NAME;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE    layout ( location = 0 ) out uvec4 out_color0
    #define FRAGMENT_COLOUR_UVEC4           out_color0
    #define FRAGMENT_COLOUR                 gl_FragColor
    #define FRAGMENT_COLOUR0                gl_FragData[ 0 ]
    #define FRAGMENT_COLOUR1                gl_FragData[ 1 ]
    #define FRAGMENT_COLOUR2                gl_FragData[ 2 ]
    #define FRAGMENT_COLOUR3                gl_FragData[ 3 ]
    #define FRAGMENT_DEPTH                  gl_FragDepth

    #define IN(  VAR )                      VAR
    #define OUT( VAR )                      VAR
    #define DEREF_PTR( VAR )                VAR

    #define OUT_VERTEX_SCREEN_POSITION 
    #define IN_SCREEN_POSITION 
    #define VERTEX_SCREEN_POSITION          gl_Position

#elif defined(D_PLATFORM_ORBIS)

    #define UNIFORM( TYPE, NAME )           ConstantBuffer NAME##CB{ TYPE NAME; };
    #define UNIFORM_SRT( TYPE, NAME )       ConstantBuffer NAME##CB{ TYPE NAME : S_SRT_DATA; };

    #define DECLARE_OUTPUT                  struct cOutput {
    #define DECLARE_INPUT                   struct cInput  {
    #define DECLARE_END                     };
    #define DECLARE_PTR( TYPE, NAME )       TYPE* NAME;

    #define INPUT(   TYPE, NAME, REG )               TYPE NAME : REG;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      nointerp TYPE NAME : REG;        
    #define OUTPUT(  TYPE, NAME, REG )      TYPE NAME : REG;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE
    #define FRAGMENT_COLOUR_UVEC4           Out.mColour
    #define FRAGMENT_COLOUR                 Out.mColour
    #define FRAGMENT_COLOUR0                Out.mColour0
    #define FRAGMENT_COLOUR1                Out.mColour1
    #define FRAGMENT_COLOUR2                Out.mColour2
    #define FRAGMENT_COLOUR3                Out.mColour3
    #define FRAGMENT_DEPTH                  Out.mDepth

    #define IN(  VAR )                      In.VAR

    #define OUT( VAR )                      Out.VAR

// TODO get rid of this - don't pass struct through functinos, pass members.
    #define DEREF_PTR( VAR )                *VAR


    #define OUT_VERTEX_SCREEN_POSITION      OUTPUT( vec4, mScreenPositionVec4, S_POSITION )
    #define IN_SCREEN_POSITION              INPUT ( vec4, mScreenPositionVec4, S_POSITION )
    #define VERTEX_SCREEN_POSITION          OUT( mScreenPositionVec4 )

#endif

// =================================================================================================
// Main
// =================================================================================================
#ifdef D_PLATFORM_PC


    #define VERTEX_MAIN                     void main( void )
    #define VERTEX_MAIN_SRT                 uniform UniformBuffer lUniforms; void main( void )

    #define FRAGMENT_MAIN_COLOUR            void main( void )
    #define VOID_MAIN_COLOUR                void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH      void main( void )

    #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_SRT           uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT    uniform UniformBuffer lUniforms; void main( void )

    #define VOID_MAIN_COLOUR_SRT               uniform UniformBuffer lUniforms; void main( void )

#elif defined( D_PLATFORM_ORBIS )

    #define VERTEX_MAIN                     void main( cInput In, out cOutput Out )
    #define VERTEX_MAIN_SRT                 void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )


#define FRAGMENT_MAIN_COLOUR            struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out )
#define VOID_MAIN_COLOUR                struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                           void main( cInput In, out cOutput Out )
#define FRAGMENT_MAIN_COLOUR_DEPTH      struct cOutput { vec4  mColour : S_TARGET_OUTPUT; float mDepth  : S_DEPTH_OUTPUT; };    [RE_Z] void main( cInput In, out cOutput Out )

    #if !defined( D_ATTRIBUTES )
#define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_OUTPUT;    }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_GE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_LE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_SRT                                                                                                           void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_EARLYZ_SRT                                                                            [FORCE_EARLY_DEPTH_STENCIL]void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
    
    #else
        
        #pragma PSSL_target_output_format(target 1 FMT_32_AR)
    
        #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT  struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;  \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;  \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;  \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3;  \
                                                                 float mDepth   : S_DEPTH_OUTPUT; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )

        #define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
                                                    
        #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [FORCE_EARLY_DEPTH_STENCIL] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )                                                    
    #endif


#endif


// =================================================================================================
// Viewport
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) A.xy

#elif defined(D_PLATFORM_ORBIS)

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) ( float2( A.x, 1.0 - A.y ) )

#endif

#endif


STATIC_CONST float radius      = 1.0;
STATIC_CONST float invScrRatio = 1280.0 / 720.0;

#define D_PARTICLE_UNIFORMS

////////////////////////////////////////////////////////////////////////////////
///
///     @file       CommonVertex.h
///     @author     User
///     @date       
///
///     @brief      CommonVertex
///
///     Copyright (c) 2008 Hello Games Ltd. All Rights Reserved.
///
////////////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------------------------
//      Compilation defines 


//-----------------------------------------------------------------------------
//      Include files


//-----------------------------------------------------------------------------
//      Global Data

////////////////////////////////////////////////////////////////////////////////
///
///     @file       CommonUniforms.h
///     @author     User
///     @date       
///
///     @brief      CommonUniforms
///
///     Copyright (c) 2008 Hello Games Ltd. All Rights Reserved.
///
////////////////////////////////////////////////////////////////////////////////


#ifndef D_COMMONUNIFORMS2_H
#define D_COMMONUNIFORMS2_H

// =================================================================================================

#ifndef D_DEFINES
#define D_DEFINES


// =================================================================================================
// Platform defines
// =================================================================================================
#ifdef D_PLATFORM_PC

    #pragma optionNV(strict on)
    #extension GL_ARB_gpu_shader5 : enable
    #extension GL_ARB_fragment_coord_conventions : enable
    #extension GL_ARB_derivative_control : enable

    #ifdef D_FRAGMENT
    //{
        //layout( origin_upper_left, pixel_center_integer ) in vec4 gl_FragCoord;
    //}
    #endif

#elif defined(D_PLATFORM_ORBIS)

    // use this with sdk 2.0 compiler 
   // #pragma argument (allow-scratch-buffer-spill)

    //define these flags so they don't get ignored in build process and in the comb mask
    //this is because materials, vertex layouts and shaders need to be synced on 360 to avoid patching
    #ifdef _F27_
    #endif
    #ifdef _F28_
    #endif
    #ifdef _F29_
    #endif
    #ifdef _F21_
    #endif
    #ifdef _F02_
    #endif
    #ifdef _F03_
    #endif
    #if defined( _F01_ ) || defined( D_LOD0 ) || defined( D_LOD1 ) || defined( D_LOD2 ) || defined( D_LOD3) || defined( D_LOD4 ) 
    #endif
    #ifdef _F01_
    #endif
    #ifdef _F09_
    #endif
    #ifdef _F10_
    #endif


    // disable warnings for unused parameters. This happens a lot because of defining different things.
    #pragma warning (disable: 5203)

    // temp thing to know what things are still required on ps4.
    #define D_PLATFORM_ORBIS_FIX

#endif

// =================================================================================================
// Basic Types
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define JOINT_TYPE    vec4

    //#define CONST         const
    #define STATIC_CONST  const

#elif defined(D_PLATFORM_ORBIS)

    #define JOINT_TYPE      int4
    #define float           float
    #define vec2            float2
    #define vec3            float3
    #define vec4            float4
    #define ivec2           int2
    #define ivec3           int3
    #define ivec4           int4
    // NOTE: 
    // operator[] accesses rows, not columns 
    // matrix constructors interpret the passed vectors as row vectors, not column vectors
    #define mat2            row_major float2x2
    #define mat3            row_major float3x3
    #define mat4            row_major float4x4

    //#define CONST           
    #define STATIC_CONST    static const
   // #define const           ERROR, DON'T USE CONST FOR PS4. USE STATIC_CONST INSTEAD FOR A COMPILED IN CONSTANT. OTHERWISE IT TRIES TO PUT IT IN A CONSTANT BUFFER AND FOR SOME REASON IT DOESN'T WORK.


#endif

// =================================================================================================
// Functions
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define saturate( V )  min( max( V, 0.0) , 1.0)
    #define atan2( Y, X )  atan( Y, X )
    #define invsqrt( X )   inversesqrt( X )

    // These can be deleted if ARB_derivative_control can be used
    //#define dFdxFine    dFdx
    //#define dFdyFine    dFdy

#elif defined(D_PLATFORM_ORBIS)

    #define mix             lerp
    #define fract           frac
    #define dFdx            ddx
    #define dFdy            ddy
    #define dFdxFine        ddx_fine
    #define dFdyFine        ddy_fine
#define mod                fmod
    #define saturate( V )   ( min( max( V, 0.0) , 1.0) )
    #define invsqrt( X )    rsqrt( X )

#endif


// =================================================================================================
// Samplers and textures
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SAMPLER2DSHADOW( NAME, REG )    uniform sampler2DShadow NAME

    #define SAMPLER2DARG( NAME )            in sampler2D NAME
    #define SAMPLER2DPARAM( NAME )          NAME
    #define SAMPLER2DARRAYARG( NAME )       in sampler2DArray NAME

    #define SAMPLERCUBE( NAME )             samplerCube NAME
    #define SAMPLERCUBEARG( NAME )          in samplerCube NAME
    #define SAMPLERCUBEPARAM( NAME )        NAME

    

    #define SAMPLER2DARRAYPARAM( NAME )     NAME

    // TEMP while switching ps4 over to srt
    #define SAMPLER2D( NAME )               sampler2D       NAME
    #define SAMPLER2D_TEMP( NAME, INDEX )   uniform sampler2D       NAME
    #define SAMPLER2DARRAY( NAME )          sampler2DArray  NAME
    #define SAMPLER3D( NAME )               sampler3D       NAME
    #define SAMPLER2DSHADOW_SRT( NAME )     sampler2DShadow NAME


#elif defined(D_PLATFORM_ORBIS)

    #define SAMPLERCUBE( NAME, REG )        SamplerState NAME##SS : register( s##REG ); TextureCube NAME##TU : register( t##REG )

    #define SAMPLER2D( NAME )               Texture2D NAME; SamplerState NAME##SS
    #define SAMPLER2DSHADOW_SRT( NAME )     Texture2D NAME; SamplerComparisonState NAME##SS  //SAMPLER2D( NAME )
    #define SAMPLER3D( NAME )               Texture3D NAME; SamplerState NAME##SS


    #define SAMPLER2DARRAY( NAME )          Texture2D_Array NAME; SamplerState NAME##SS
    #define SAMPLER2DARRAYARG( NAME )       Texture2D_Array NAME, SamplerState NAME##SS
    #define SAMPLER2DARRAYPARAM( NAME )     NAME, NAME##SS

    #define SAMPLER2DPARAM( NAME )          NAME, NAME##SS
    #define SAMPLER2DARG( NAME )            Texture2D NAME, SamplerState NAME##SS

    #define texture2D( T, C )                T.Sample( T##SS, C )

    #define texture2DLod( T, C, N )         T.SampleLOD( T##SS, C, N )
    #define texture2DArray(  T, C )         T.Sample( T##SS, C )
    #define texture3DLod( T, C, N )         T.SampleLOD( T##SS, C, N )

    //#define shadow2D( T, C )                vec3( C.z > T.Sample( T##SS, C.xy ).x ? 1.0 : 0.0 )                    
    //#define shadow2D( T, C )                T.GatherCmp( T##SS, C.xy, C.z )
    //#define shadow2D( T, C )                T.SampleCmpLOD0( T##SS, C.xy, C.z )
    #define shadow2D( T, C )                T.SampleCmp( T##SS, C.xy, C.z )
    #define textureCube( T, C )                T##TU.Sample( T##SS, C )
    #define textureCubeLod( T, C, N )        T##TU.Sample( T##SS, C, N )
    #define textureGrad( T, C, DDX, DDY )   T.SampleGradient( T##SS, C, DDX, DDY )                    

#endif

// =================================================================================================
// Matrices
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define MUL( INPUT_A, INPUT_B )         (INPUT_A * INPUT_B)
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#elif defined(D_PLATFORM_ORBIS)

    #define MUL( INPUT_A, INPUT_B )         mul( INPUT_B, INPUT_A )
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#endif

// =================================================================================================
// Arrays (workaround AMD shader compiler issues by making arrays have global scope)
// =================================================================================================

#if defined(D_PLATFORM_ORBIS)

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]

#else

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]

#endif


// =================================================================================================
// Input and Output
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define UNIFORM( TYPE, NAME )           uniform TYPE NAME
    #define UNIFORM_SRT( TYPE, NAME )       uniform TYPE NAME

    #define DECLARE_INPUT
    #define DECLARE_OUTPUT
    #define DECLARE_END  
    #define DECLARE_PTR( TYPE, NAME )       TYPE  NAME;

    #define INPUT(   TYPE, NAME, REG )      in    TYPE NAME;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      in    TYPE NAME;
    #define OUTPUT(  TYPE, NAME, REG )      out   TYPE NAME;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE    layout ( location = 0 ) out uvec4 out_color0
    #define FRAGMENT_COLOUR_UVEC4           out_color0
    #define FRAGMENT_COLOUR                 gl_FragColor
    #define FRAGMENT_COLOUR0                gl_FragData[ 0 ]
    #define FRAGMENT_COLOUR1                gl_FragData[ 1 ]
    #define FRAGMENT_COLOUR2                gl_FragData[ 2 ]
    #define FRAGMENT_COLOUR3                gl_FragData[ 3 ]
    #define FRAGMENT_DEPTH                  gl_FragDepth

    #define IN(  VAR )                      VAR
    #define OUT( VAR )                      VAR
    #define DEREF_PTR( VAR )                VAR

    #define OUT_VERTEX_SCREEN_POSITION 
    #define IN_SCREEN_POSITION 
    #define VERTEX_SCREEN_POSITION          gl_Position

#elif defined(D_PLATFORM_ORBIS)

    #define UNIFORM( TYPE, NAME )           ConstantBuffer NAME##CB{ TYPE NAME; };
    #define UNIFORM_SRT( TYPE, NAME )       ConstantBuffer NAME##CB{ TYPE NAME : S_SRT_DATA; };

    #define DECLARE_OUTPUT                  struct cOutput {
    #define DECLARE_INPUT                   struct cInput  {
    #define DECLARE_END                     };
    #define DECLARE_PTR( TYPE, NAME )       TYPE* NAME;

    #define INPUT(   TYPE, NAME, REG )               TYPE NAME : REG;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      nointerp TYPE NAME : REG;        
    #define OUTPUT(  TYPE, NAME, REG )      TYPE NAME : REG;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE
    #define FRAGMENT_COLOUR_UVEC4           Out.mColour
    #define FRAGMENT_COLOUR                 Out.mColour
    #define FRAGMENT_COLOUR0                Out.mColour0
    #define FRAGMENT_COLOUR1                Out.mColour1
    #define FRAGMENT_COLOUR2                Out.mColour2
    #define FRAGMENT_COLOUR3                Out.mColour3
    #define FRAGMENT_DEPTH                  Out.mDepth

    #define IN(  VAR )                      In.VAR

    #define OUT( VAR )                      Out.VAR

// TODO get rid of this - don't pass struct through functinos, pass members.
    #define DEREF_PTR( VAR )                *VAR


    #define OUT_VERTEX_SCREEN_POSITION      OUTPUT( vec4, mScreenPositionVec4, S_POSITION )
    #define IN_SCREEN_POSITION              INPUT ( vec4, mScreenPositionVec4, S_POSITION )
    #define VERTEX_SCREEN_POSITION          OUT( mScreenPositionVec4 )

#endif

// =================================================================================================
// Main
// =================================================================================================
#ifdef D_PLATFORM_PC


    #define VERTEX_MAIN                     void main( void )
    #define VERTEX_MAIN_SRT                 uniform UniformBuffer lUniforms; void main( void )

    #define FRAGMENT_MAIN_COLOUR            void main( void )
    #define VOID_MAIN_COLOUR                void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH      void main( void )

    #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_SRT           uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT    uniform UniformBuffer lUniforms; void main( void )

    #define VOID_MAIN_COLOUR_SRT               uniform UniformBuffer lUniforms; void main( void )

#elif defined( D_PLATFORM_ORBIS )

    #define VERTEX_MAIN                     void main( cInput In, out cOutput Out )
    #define VERTEX_MAIN_SRT                 void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )


#define FRAGMENT_MAIN_COLOUR            struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out )
#define VOID_MAIN_COLOUR                struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                           void main( cInput In, out cOutput Out )
#define FRAGMENT_MAIN_COLOUR_DEPTH      struct cOutput { vec4  mColour : S_TARGET_OUTPUT; float mDepth  : S_DEPTH_OUTPUT; };    [RE_Z] void main( cInput In, out cOutput Out )

    #if !defined( D_ATTRIBUTES )
#define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_OUTPUT;    }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_GE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_LE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_SRT                                                                                                           void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_EARLYZ_SRT                                                                            [FORCE_EARLY_DEPTH_STENCIL]void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
    
    #else
        
        #pragma PSSL_target_output_format(target 1 FMT_32_AR)
    
        #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT  struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;  \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;  \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;  \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3;  \
                                                                 float mDepth   : S_DEPTH_OUTPUT; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )

        #define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
                                                    
        #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [FORCE_EARLY_DEPTH_STENCIL] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )                                                    
    #endif


#endif


// =================================================================================================
// Viewport
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) A.xy

#elif defined(D_PLATFORM_ORBIS)

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) ( float2( A.x, 1.0 - A.y ) )

#endif

#endif


struct PerFrameUniforms
{
    vec4    gLightPositionVec4;                 // EShaderConst_LightPositionVec4
    vec4    gLightDirectionVec4;                // EShaderConst_LightDirectionVec4
    vec3    gViewPositionVec3;                  // EShaderConst_ViewPositionVec3
    float   gfTime;                             // EShaderConst_Time
    vec4    gClipPlanesVec4;                    // EShaderConst_ClipPlanesVec4
    vec4    gClipPlanesRVec4;                   // EShaderConst_ClipPlanesRVec4

    mat4    gCameraMat4;                        // EShaderConst_CameraMat4

    vec4    gFrameBufferSizeVec4;   
    vec4    gFoVValuesVec4;                     // EShaderConst_FoVValuesVec4
    vec4    gShadowSizeVec4;   
    vec4    gShadowFadeParamVec4;   
    mat4    gViewMat4;                          // EShaderConst_ViewMat4

    //
    // These are per pass really. Probably just rename PerFrame to PerPass.
    //
    //mat4    gProjectionMat4;                    // EShaderConst_ProjectionMat4
    //mat4    gCameraMat4;                        // EShaderConst_CameraMat4
    //mat4    gaShadowMat4[ 2 ];   // EShaderConst_ShadowMat4
    //vec4    gClipPlanesVec4;                    // EShaderConst_ClipPlanesVec4

    //SAMPLER2D( gDualPMapFront );    // 32 bytes each
    //SAMPLER2D( gDualPMapBack );
    //SAMPLER2D( gCloudShadowMap );

    //SAMPLER2D( gFadeNoiseMap );

    //SAMPLER2D( gCausticMap );
    //SAMPLER2D( gCausticOffsetMap );

    // how to set samplers

    // putting these here would require removing them from the shader and material, and making them part of the common global
    // list so they can be set like the ones above... i think.
    // Fog
    //vec4 gSkyColourVec4;
    //vec4 gHorizonColourVec4;
    //vec4 gSunColourVec4;
    //vec4 gWaterColourNearVec4;
    //vec4 gWaterColourFarVec4;
    //vec4 gWaterFogVec4;
    //vec4 gHeightFogParamsVec4;
    //vec4 gHeightFogColourVec4;
    //vec4 gSpaceHorizonColourVec4;
    //vec4 gFogColourVec4;
    //vec4 gFogParamsVec4;
    //vec4 gScatteringParamsVec4;
    //vec4 gSpaceFogWavelength1Vec4;
    //vec4 gSpaceFogWavelength2Vec4;
    //vec4 gSpaceFogWavelength3Vec4;
    //vec4 gSpaceSkyColourVec4;
    //vec4 gFogFadeHeightsVec4;
    //vec4 gSunPositionVec4;
};

struct CommonPerMeshUniforms
{    
    // These are planet specific. Should they be here?
    vec4 gPlanetPositionVec4;

    // Stop these being compiled in when recolouring as the recolour shader needs ALL tex units.

    mat4    gInverseModelMat4;                     // EShaderConst_InverseModelMat4 = 0
    mat4    gWorldMat4;                            // EShaderConst_WorldMat4
    mat4    gWorldViewProjectionMat4;              // EShaderConst_WorldViewProjectionMat4
    mat4    gWorldNormalMat4;                      // EShaderConst_WorldNormalMat4

#ifdef D_FADE
    float   gfFadeValue;                           // EShaderConst_FadeTime
#else
    float   fdFadeValueDummy;
#endif
    
#if defined( D_SKINNING_UNIFORMS ) && defined( D_PLATFORM_ORBIS )
    vec4   gaSkinMatrixRowsVec4[ 75 * 3 ];        
#endif

    //float   gfShadowBias;                       // EShaderConst_ShadowBias
     
   //  have particle shader use a particlecommon instead of uber, and put these into it.
#if defined( D_PARTICLE_UNIFORMS ) && defined( D_PLATFORM_ORBIS )
    vec4    gaParticleCornersVec4[ 4 ];            // EShaderConst_ParticleCornersVec4
    vec4    gaParticlePositionsVec4[ 32 ];         // EShaderConst_ParticlePositionsVec4
    vec4    gaParticleSizeAndRotationsVec4[ 32 ];  // EShaderConst_ParticleSizeAndRotationsVec4
    vec4    gaParticleNormalsVec4[ 32 ];           // EShaderConst_ParticleNormalsVec4
    vec4    gaParticleColoursVec4[ 32 ];           // EShaderConst_ParticleColoursVec4
#endif

        // This stuff is here atm because of shadows. The shadow shader is one thing, but renders twice, with these needing to be set differently.
    // ideally we don't want them set per mesh though, probably a SRT for 'percamera' or something
    // 
    //
    mat4    gProjectionMat4;                    // EShaderConst_ProjectionMat4
    mat4    gViewProjectionMat4;                   // EShaderConst_ViewProjectionMat4
    mat4    gInverseViewMat4;                   // EShaderConst_InverseViewMat4
    mat4    gInverseProjectionMat4;             // EShaderConst_InverseProjectionMat4
    mat4    gInverseViewProjectionMat4;         // EShaderConst_InverseViewProjectionMat4
    mat4    gaShadowMat4[ 3 ];                  // EShaderConst_ShadowMat4
    vec4    gShadowProjScaleVec4[3];            // EShaderConst_ShadowProjScaleVec4
    vec4    gLightColourVec4;                   // EShaderConst_LightColourVec4
       vec4    gGenericParam0Vec4;                    // EShaderConst_GenericParam0Vec4
       
    // These shouldn't be per mesh, the should be per rendertarget. BUT we need to add them to the enum
    // in egShader and SetPErRenderTargetUniforms for that to work and we're trying to do a build for sony
    // so that will have to wait. (also probably need a way of setting per RT uniforms from Game).
    vec4    gScanParamsPosVec4;
    vec4    gScanParamsCfg1Vec4;
    vec4    gScanParamsCfg2Vec4;
    vec4    gScanParamsCfg3Vec4;
    vec4    gScanColourVec4;

        vec4 gSpotlightPositionVec4;
    vec4 gSpotlightDirectionVec4;
    
};

#if defined( D_PARTICLE_UNIFORMS ) && defined( D_PLATFORM_PC )
uniform vec4    gaParticleCornersVec4[4];            // EShaderConst_ParticleCornersVec4
uniform vec4    gaParticlePositionsVec4[32];         // EShaderConst_ParticlePositionsVec4
uniform vec4    gaParticleSizeAndRotationsVec4[32];  // EShaderConst_ParticleSizeAndRotationsVec4
uniform vec4    gaParticleNormalsVec4[32];           // EShaderConst_ParticleNormalsVec4
uniform vec4    gaParticleColoursVec4[32];           // EShaderConst_ParticleColoursVec4
#endif


#endif


////////////////////////////////////////////////////////////////////////////////
///
///     @file       Common.h
///     @author     User
///     @date       
///
///     @brief      Common
///
///     Copyright (c) 2008 Hello Games Ltd. All Rights Reserved.
///
////////////////////////////////////////////////////////////////////////////////

#ifndef D_COMMON_H
#define D_COMMON_H


STATIC_CONST vec3 kGammaOutVec3 = vec3( 1.0 / 2.2 );
STATIC_CONST vec3 kGammaInVec3  = vec3( 2.2 );
STATIC_CONST vec4 RGBToHSV_K    = vec4( 0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0 );
STATIC_CONST vec4 HSVToRGB_K    = vec4( 1.0,  2.0 / 3.0, 1.0 / 3.0,  3.0 );


//-----------------------------------------------------------------------------
///
///     GammaCorrect
///
//-----------------------------------------------------------------------------
vec3 
GammaCorrectInput(
    in vec3 lColourVec3 )
{
    vec3 lCorrectColourVec3;

    lCorrectColourVec3 = pow( lColourVec3, kGammaInVec3 );

    return lCorrectColourVec3;
}


//-----------------------------------------------------------------------------
///
///     GammaCorrect
///
//-----------------------------------------------------------------------------
vec3 
GammaCorrectOutput(
    in vec3 lColourVec3 )
{
    vec3 lCorrectColourVec3;

    lCorrectColourVec3 = pow( lColourVec3, kGammaOutVec3 );

    return lCorrectColourVec3;
}


//-----------------------------------------------------------------------------
///
///     RGBToHSV
///
//-----------------------------------------------------------------------------
vec3 
RGBToHSV(
    vec3 lRGB )
{
    //vec4 p = mix( vec4(lRGB.bg, RGBToHSV_K.wz), vec4(lRGB.gb, RGBToHSV_K.xy), step(lRGB.b, lRGB.g) );
    //vec4 q = mix( vec4(p.xyw, lRGB.r), vec4(lRGB.r, p.yzx), step(p.x, lRGB.r) );
    // This variant is faster, since it generates conditional moves
    vec4 p = lRGB.g < lRGB.b ? vec4(lRGB.bg, RGBToHSV_K.wz) : vec4(lRGB.gb, RGBToHSV_K.xy);
    vec4 q = lRGB.r < p.x ? vec4(p.xyw, lRGB.r) : vec4(lRGB.r, p.yzx);    
    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}


//-----------------------------------------------------------------------------
///
///     HSVToRGB
///
///     @brief     http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
///
//-----------------------------------------------------------------------------
vec3 
HSVToRGB(
    vec3 lHSV )
{
    vec3 p = abs(fract(lHSV.xxx + HSVToRGB_K.xyz) * 6.0 - HSVToRGB_K.www);
    return lHSV.z * mix(HSVToRGB_K.xxx, saturate(p - HSVToRGB_K.xxx), lHSV.y);
}


//-----------------------------------------------------------------------------
///
///     BrightnessVibranceContrast
///
//-----------------------------------------------------------------------------
vec3 BrightnessVibranceContrast(
    vec3  lInputColour,
    float lfBrightness,
    float lfVibrance,
    float lfContrast)
{
    vec3 lBrtResult     = lInputColour * lfBrightness;

    // get lum
    vec3 lLuma          = vec3( dot(lBrtResult, vec3( 0.2125, 0.7154, 0.0721 )) );

    // get saturation
    float lfMaxCol      = max( lBrtResult.r, max(lBrtResult.g, lBrtResult.b) );
    float lfMinCol      = min( lBrtResult.r, min(lBrtResult.g, lBrtResult.b) );
    float lfCurSatV     = lfMaxCol - lfMinCol;

    // lerp by 1 + (1 - vibrance) - current saturation
    float lfVibranceMix = (1.0 + (lfVibrance * (1.0 - (sign(lfVibrance) * lfCurSatV))));
    vec3 lVibResult     = mix( lLuma, lBrtResult, lfVibranceMix );

    // lerp from mid gray for contrast
    vec3 lContrastBase  = vec3( 0.5, 0.5, 0.5 );
    vec3 lConResult     = mix( lContrastBase , lVibResult, lfContrast );

    return lConResult;
}


//-----------------------------------------------------------------------------
///
///     Desaturate
///
//-----------------------------------------------------------------------------
vec3 Desaturate( vec3 color, float lfAmount )
{
    vec3 gray = vec3( dot( vec3( 0.299, 0.587, 0.114 ), color) );
    return mix( color, gray, lfAmount );
}


// improved rgb lerp by @stormoid
// https://www.shadertoy.com/view/lsdGzN
//---------------Improved RGB--------------

/*
    The idea behind this function is to avoid the low saturation area in the
    rgb color space. This is done by getting the direction to that diagonal
    and displacing the interpolated color by it's inverse while scaling it
    by saturation error and desired lightness. 

    I find it behaves very well under most circumstances, the only instance
    where it doesn't behave ideally is when the hues are very close to 180 
    degrees apart, since the method I am using to find the displacement vector
    does not compensate for non-curving motion. I tried a few things to 
    circumvent this problem but none were cheap and effective enough..
*/

//Changes the strength of the displacement
#define DSP_STR 1.5

//-----------------------------------------------------------------------------
float _getsat( vec3 lColour )
{
    float mi = min(min(lColour.x, lColour.y), lColour.z);
    float ma = max(max(lColour.x, lColour.y), lColour.z);
    return (ma - mi) / (ma + 1e-7);
}

vec3 NmzRgbLerp( vec3 a, vec3 b, float x )
{
    // interpolated base color (with singularity fix)
    vec3 ic = mix( a, b, x ) + vec3( 1e-6, 0.0, 0.0 );

    // saturation difference from ideal scenario
    float sd = abs( _getsat( ic ) - mix( _getsat( a ), _getsat( b ), x ) );

    // displacement direction
    vec3 dir = normalize( 
        vec3( 2.0 * ic.x - ic.y - ic.z, 
              2.0 * ic.y - ic.x - ic.z, 
              2.0 * ic.z - ic.y - ic.x ) 
        );

    // simple Lighntess
    float lgt = dot( vec3( 1.0 ), ic );

    // extra scaling factor for the displacement
    float ff = dot( dir, normalize( ic ) );

    // displace the color
    ic += DSP_STR * dir * sd * ff * lgt;
    return clamp( ic, 0.0, 1.0 );
}


//-----------------------------------------------------------------------------
///
///     Inverse
///
//-----------------------------------------------------------------------------
mat4
Inverse(
    const mat4 lInMat4 )
{
#ifdef D_PLATFORM_PC
    return inverse( lInMat4 );
#else
    float det = determinant( lInMat4 );
    det = 1.0f / det;

    mat4 M = lInMat4;
    mat4 IM;
    IM[0][0] = det * ( M[1][2]*M[2][3]*M[3][1] - M[1][3]*M[2][2]*M[3][1] + M[1][3]*M[2][1]*M[3][2] - M[1][1]*M[2][3]*M[3][2] - M[1][2]*M[2][1]*M[3][3] + M[1][1]*M[2][2]*M[3][3] );
    IM[0][1] = det * ( M[0][3]*M[2][2]*M[3][1] - M[0][2]*M[2][3]*M[3][1] - M[0][3]*M[2][1]*M[3][2] + M[0][1]*M[2][3]*M[3][2] + M[0][2]*M[2][1]*M[3][3] - M[0][1]*M[2][2]*M[3][3] );
    IM[0][2] = det * ( M[0][2]*M[1][3]*M[3][1] - M[0][3]*M[1][2]*M[3][1] + M[0][3]*M[1][1]*M[3][2] - M[0][1]*M[1][3]*M[3][2] - M[0][2]*M[1][1]*M[3][3] + M[0][1]*M[1][2]*M[3][3] );
    IM[0][3] = det * ( M[0][3]*M[1][2]*M[2][1] - M[0][2]*M[1][3]*M[2][1] - M[0][3]*M[1][1]*M[2][2] + M[0][1]*M[1][3]*M[2][2] + M[0][2]*M[1][1]*M[2][3] - M[0][1]*M[1][2]*M[2][3] );
    IM[1][0] = det * ( M[1][3]*M[2][2]*M[3][0] - M[1][2]*M[2][3]*M[3][0] - M[1][3]*M[2][0]*M[3][2] + M[1][0]*M[2][3]*M[3][2] + M[1][2]*M[2][0]*M[3][3] - M[1][0]*M[2][2]*M[3][3] );
    IM[1][1] = det * ( M[0][2]*M[2][3]*M[3][0] - M[0][3]*M[2][2]*M[3][0] + M[0][3]*M[2][0]*M[3][2] - M[0][0]*M[2][3]*M[3][2] - M[0][2]*M[2][0]*M[3][3] + M[0][0]*M[2][2]*M[3][3] );
    IM[1][2] = det * ( M[0][3]*M[1][2]*M[3][0] - M[0][2]*M[1][3]*M[3][0] - M[0][3]*M[1][0]*M[3][2] + M[0][0]*M[1][3]*M[3][2] + M[0][2]*M[1][0]*M[3][3] - M[0][0]*M[1][2]*M[3][3] );
    IM[1][3] = det * ( M[0][2]*M[1][3]*M[2][0] - M[0][3]*M[1][2]*M[2][0] + M[0][3]*M[1][0]*M[2][2] - M[0][0]*M[1][3]*M[2][2] - M[0][2]*M[1][0]*M[2][3] + M[0][0]*M[1][2]*M[2][3] );
    IM[2][0] = det * ( M[1][1]*M[2][3]*M[3][0] - M[1][3]*M[2][1]*M[3][0] + M[1][3]*M[2][0]*M[3][1] - M[1][0]*M[2][3]*M[3][1] - M[1][1]*M[2][0]*M[3][3] + M[1][0]*M[2][1]*M[3][3] );
    IM[2][1] = det * ( M[0][3]*M[2][1]*M[3][0] - M[0][1]*M[2][3]*M[3][0] - M[0][3]*M[2][0]*M[3][1] + M[0][0]*M[2][3]*M[3][1] + M[0][1]*M[2][0]*M[3][3] - M[0][0]*M[2][1]*M[3][3] );
    IM[2][2] = det * ( M[0][1]*M[1][3]*M[3][0] - M[0][3]*M[1][1]*M[3][0] + M[0][3]*M[1][0]*M[3][1] - M[0][0]*M[1][3]*M[3][1] - M[0][1]*M[1][0]*M[3][3] + M[0][0]*M[1][1]*M[3][3] );
    IM[2][3] = det * ( M[0][3]*M[1][1]*M[2][0] - M[0][1]*M[1][3]*M[2][0] - M[0][3]*M[1][0]*M[2][1] + M[0][0]*M[1][3]*M[2][1] + M[0][1]*M[1][0]*M[2][3] - M[0][0]*M[1][1]*M[2][3] );
    IM[3][0] = det * ( M[1][2]*M[2][1]*M[3][0] - M[1][1]*M[2][2]*M[3][0] - M[1][2]*M[2][0]*M[3][1] + M[1][0]*M[2][2]*M[3][1] + M[1][1]*M[2][0]*M[3][2] - M[1][0]*M[2][1]*M[3][2] );
    IM[3][1] = det * ( M[0][1]*M[2][2]*M[3][0] - M[0][2]*M[2][1]*M[3][0] + M[0][2]*M[2][0]*M[3][1] - M[0][0]*M[2][2]*M[3][1] - M[0][1]*M[2][0]*M[3][2] + M[0][0]*M[2][1]*M[3][2] );
    IM[3][2] = det * ( M[0][2]*M[1][1]*M[3][0] - M[0][1]*M[1][2]*M[3][0] - M[0][2]*M[1][0]*M[3][1] + M[0][0]*M[1][2]*M[3][1] + M[0][1]*M[1][0]*M[3][2] - M[0][0]*M[1][1]*M[3][2] );
    IM[3][3] = det * ( M[0][1]*M[1][2]*M[2][0] - M[0][2]*M[1][1]*M[2][0] + M[0][2]*M[1][0]*M[2][1] - M[0][0]*M[1][2]*M[2][1] - M[0][1]*M[1][0]*M[2][2] + M[0][0]*M[1][1]*M[2][2] );

    return IM;
#endif
}

#endif

#ifdef _F19_
struct CommonVertexUniforms
{
    vec4 gCustomParams01Vec4;
};
UNIFORM( CommonVertexUniforms, gCommonVertexUniforms );
#endif

STATIC_CONST float kfScaleUpFactor = 1.001;

//-----------------------------------------------------------------------------
///
///     CalcWorldPos
///
///     @brief      CalcWorldPos
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcWorldPos( 
    in mat4 lWorldMat4,
    in vec4 lLocalPositionVec4 )
{
    return MUL( lWorldMat4, lLocalPositionVec4 );
}

#ifdef D_INSTANCE
//-----------------------------------------------------------------------------
///
///     CalcWorldPosInstanced
///
///     @brief      CalcWorldPosInstanced
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcWorldPosInstanced( 
    in mat4 lWorldMat4,
    in mat4 lWorldInstanceMat4,
    in vec4 lLocalPositionVec4 )
{
    vec4 lWorldPositionVec4 = MUL( lWorldMat4, lLocalPositionVec4 );
    return MUL( lWorldInstanceMat4, lWorldPositionVec4 );
}
#endif

//-----------------------------------------------------------------------------
///
///     CalcScreenPosFromWorld
///
///     @brief      CalcScreenPosFromWorld
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcScreenPosFromWorld( 
    in mat4 lViewMatrix4,
    in mat4 lProjectionMatrix4,
    in vec4 lWorldPositionVec4 )
{    
    vec4 lViewPositionVec4 = MUL( lViewMatrix4, lWorldPositionVec4 );
    return MUL( lProjectionMatrix4, lViewPositionVec4 );
}


//-----------------------------------------------------------------------------
///
///     CalcScreenPosFromWorld
///
///     @brief      CalcScreenPosFromWorld
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcScreenPosFromWorld( 
    in mat4 lViewProjectionMatrix4,
    in vec4 lWorldPositionVec4 )
{    
    return MUL( lViewProjectionMatrix4, lWorldPositionVec4 );
}

//-----------------------------------------------------------------------------
///
///     CalcScreenPosFromLocal
///
///     @brief      CalcScreenPosFromLocal
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcScreenPosFromLocal( 
    in vec4 lLocalPositionVec4 )
{    
    mat4 lTemp;
    vec4 lWorldPositionVec4 = CalcWorldPos( lTemp, lLocalPositionVec4 );
    return CalcScreenPosFromWorld( lTemp, lTemp, lWorldPositionVec4 );
}

//-----------------------------------------------------------------------------
///
///     CalcScreenPosFromLocal
///
///     @brief      CalcScreenPosFromLocal
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcScreenPosFromLocal( 
    in mat4 lWorldViewProjectionMatrix4,
    in vec4 lLocalPositionVec4 )
{    
    return MUL( lWorldViewProjectionMatrix4, lLocalPositionVec4 );
}

#ifdef _F19_ 

//-----------------------------------------------------------------------------
///
///     CalcBillboardPos
///
///     @brief      CalcBillboardPosFromDirection
///
///     @param      in vec4 lDirection
///     @param      in vec4 lLocalPositionVec4
///     @param      in float lfSphereFactor
///     @param      in mat4 lWorldMat4
///     @param      out vec4 lOutWorldPositionVec4
///     @return     vec4
///
//-----------------------------------------------------------------------------
vec4 
CalcBillboardPos( 
    in mat4   lCameraMatrix4,
    in vec4   lLocalPositionVec4,
    in float  lfSphereFactor,
    in mat4   lWorldMat4,
    in vec4   lShearParamsVec4,
    out vec4  lOutWorldPositionVec4 ) 
{
    vec3 lUpVector;
    vec3 lCamUp    = MAT4_GET_COLUMN( lCameraMatrix4, 1 );
    vec3 lCamRight = MAT4_GET_COLUMN( lCameraMatrix4, 0 );
    vec3 lCamAt    = MAT4_GET_COLUMN( lCameraMatrix4, 2 );
    vec3 lCamPos   = MAT4_GET_COLUMN( lCameraMatrix4, 3 );
    vec3 lWorldPos = MAT4_GET_COLUMN( lWorldMat4, 3 );
    vec3 lMatUpVector = MAT4_GET_COLUMN( lWorldMat4, 1 );


#if defined( _F44_ )
    // imposters will keep pointing 'up' even if the camera rolls
    lCamUp    = normalize( MAT4_GET_COLUMN( lWorldMat4, 1 ) );
    lCamRight = normalize( cross( lCamUp, lCamAt ) );

    // make sure that an orthonormal frame is created
    // ==> make these 3 vectors pairwise orthogonal to each other
    lCamAt    = normalize( cross( lCamRight, lCamUp ) );
    lUpVector = lCamUp;
#else
    lCamRight = MAT4_GET_COLUMN( lCameraMatrix4, 0 );
    lCamAt    = MAT4_GET_COLUMN( lCameraMatrix4, 2 );
    lCamUp    = MAT4_GET_COLUMN( lCameraMatrix4, 1 );

#ifdef D_INSTANCE
    // undo the shear... I am not sure this is a super great way to do this...
    lMatUpVector = MAT4_GET_COLUMN( lWorldMat4, 1 ) - lShearParamsVec4.x * MAT4_GET_COLUMN( lWorldMat4, 0 ) - lShearParamsVec4.y * MAT4_GET_COLUMN( lWorldMat4, 2 );
#endif
    
    lUpVector = mix( lMatUpVector, lCamUp, lfSphereFactor );

    lUpVector      = normalize( lUpVector );

#endif

    //                                | Cylinder Values                                       | Sphere Values      
    mat3 lBillboardMat3;    

#ifdef _F46_
    vec3 lWorldAt     = MAT4_GET_COLUMN( lWorldMat4, 2 );
    MAT3_SET_COLUMN( lBillboardMat3, 2, lWorldAt );
    MAT3_SET_COLUMN( lBillboardMat3, 1, normalize( cross( lWorldAt, ( lCamPos - lWorldPos ) ) ) );
    MAT3_SET_COLUMN( lBillboardMat3, 0, normalize( cross( MAT3_GET_COLUMN( lBillboardMat3, 1 ), MAT3_GET_COLUMN( lBillboardMat3, 2 ) ) ) );
#else
    MAT3_SET_COLUMN( lBillboardMat3, 2, normalize( mix( normalize( lCamPos - lWorldPos ), lCamAt, lfSphereFactor*lfSphereFactor*lfSphereFactor) ) ); 
    MAT3_SET_COLUMN( lBillboardMat3, 0, normalize( mix( cross( lUpVector, MAT3_GET_COLUMN( lBillboardMat3, 2 ) ),  lCamRight, lfSphereFactor) ) );
    MAT3_SET_COLUMN( lBillboardMat3, 1, lUpVector );
#endif

    vec4 lBillboardPositionVec4;
    lBillboardPositionVec4.xyz = MUL( lBillboardMat3, lLocalPositionVec4.xyz ).xyz; //transform by billboard's orthonormal basis
    lBillboardPositionVec4.w   = 1.0;

    lOutWorldPositionVec4 = lBillboardPositionVec4;
    vec3 lWorldMatScale = vec3( length( MAT4_GET_COLUMN_VEC4( lWorldMat4, 0 ) ), length( lMatUpVector ), length( MAT4_GET_COLUMN_VEC4( lWorldMat4, 2 ) ) );
    lOutWorldPositionVec4.xyz *= lWorldMatScale;
    lOutWorldPositionVec4.xyz += lWorldPos.xyz;

    mat4 lOriginModelInvMat4;

    lOriginModelInvMat4      = Inverse( lWorldMat4 );
    MAT4_SET_COLUMN( lOriginModelInvMat4, 0, normalize( MAT4_GET_COLUMN_VEC4( lOriginModelInvMat4, 0 ) ) );
    MAT4_SET_COLUMN( lOriginModelInvMat4, 1, normalize( MAT4_GET_COLUMN_VEC4( lOriginModelInvMat4, 1 ) ) );
    MAT4_SET_COLUMN( lOriginModelInvMat4, 2, normalize( MAT4_GET_COLUMN_VEC4( lOriginModelInvMat4, 2 ) ) );

    MAT4_SET_POS( lOriginModelInvMat4, vec4( 0.0, 0.0, 0.0, 1.0 ) );
        
    lBillboardPositionVec4 = MUL( lOriginModelInvMat4, lBillboardPositionVec4 );

#ifdef D_INSTANCE
    lOutWorldPositionVec4.xyz += lLocalPositionVec4.y * ( MAT4_GET_COLUMN( lWorldMat4, 0 ) * lShearParamsVec4.x + MAT4_GET_COLUMN( lWorldMat4, 2 ) * lShearParamsVec4.y );
#endif

    return lBillboardPositionVec4;
}

#ifdef _F12_

//-----------------------------------------------------------------------------
///
///     CalcBatchedBillboardMat4
///
///     @brief      CalcBatchedBillboardMat4
///
///     @param      in vec4 lTexCoords
///     @param      in mat4 lWorldMat
///     @return     mat4
///
//-----------------------------------------------------------------------------
mat4
CalcBatchedBillboardMat4(
    in  mat4 lGlobalWorldMat,
    in  vec4 lTexCoords, 
    in  vec4 lLocalPosVec4,
    in  mat4 lWorldMat4,
    out   vec4 lOutCenterVec4 )
{
    vec2 lBillboardPositionVec2;
    vec4 lLocalPositionVec4;
    vec4 lCenterPositionVec4;
    mat4 lBillboardWorldMat4;

    lLocalPositionVec4 = lLocalPosVec4;

    // Calculate center position as offset from local position, using UVs
    lBillboardPositionVec2 = lTexCoords.xy;
    lBillboardPositionVec2 = vec2( lBillboardPositionVec2.x - 0.5,  0.5 - lBillboardPositionVec2.y);
    
#ifdef D_INSTANCE
    // Scale
    lBillboardPositionVec2.x *= length( MAT4_GET_COLUMN( lGlobalWorldMat, 0 ) );
    lBillboardPositionVec2.y *= length( MAT4_GET_COLUMN( lGlobalWorldMat, 1 ) );

    lLocalPositionVec4.xyz = MUL( lGlobalWorldMat, lLocalPositionVec4 ).xyz;
#endif

    // Calculate offset of center position from model position
    lCenterPositionVec4.xy = lLocalPositionVec4.xy - lBillboardPositionVec2.xy;
    lCenterPositionVec4.z  = lLocalPositionVec4.z;

    lBillboardWorldMat4  = lWorldMat4;

    vec4 lTransPos = MUL( lBillboardWorldMat4, vec4(lCenterPositionVec4.xyz, 1.0));

    MAT4_SET_POS( lBillboardWorldMat4, lTransPos );

    lOutCenterVec4 = vec4(lBillboardPositionVec2.xy, 0.0, 1.0);

    return lBillboardWorldMat4;
}

#endif

//-----------------------------------------------------------------------------
///
///     CalcBillboardValues
///
///     @brief      CalcBillboardValues
///
///     @param      in  vec4 lLocalPositionVec4
///     @param      in  mat4 lWorldMat4
///     @param      in  vec4 lTexCoordsVec4
///     @param      out vec4 lOutLocalPositionVec4
///     @param      out vec4 lOutWorldPositionVec4
///     @param      out vec3 lOutLocalNormalVec3
///     @param      out vec3 lOutWorldNormalVec3
///     @return     void
///
//-----------------------------------------------------------------------------
void 
CalcBillboardValues(
    in  mat4   lCameraMatrix,
    in  mat4   lGlobalWorldMat,
    in  vec4   lLocalPositionVec4,   
    in  vec4   lCustomParams01Vec4,   
    in  mat4   lWorldMat4,
    in  vec4   lTexCoordsVec4,
    in  vec4   lShearParamsVec4,
    out   vec4   lOutLocalPositionVec4,
    out   vec4   lOutWorldPositionVec4,
    out   vec3   lOutLocalNormalVec3,
    out   vec3   lOutWorldNormalVec3 )
{
#ifdef D_INSTANCE
    mat4 lCombinedWorldMat4 = MUL( lWorldMat4, lGlobalWorldMat );
#else    
    mat4 lCombinedWorldMat4 = lGlobalWorldMat;
#endif    
    
#ifdef _F12_
    {
        mat4 lBillboardWorldMat4;
        vec4 lBillboardLocalCenterVec4;
        lBillboardWorldMat4 = CalcBatchedBillboardMat4( lGlobalWorldMat,  lTexCoordsVec4, lLocalPositionVec4, lWorldMat4, lBillboardLocalCenterVec4 );

        lOutLocalPositionVec4  = CalcBillboardPos( lCameraMatrix, lBillboardLocalCenterVec4, lCustomParams01Vec4.x, lBillboardWorldMat4, lShearParamsVec4, lOutWorldPositionVec4 );
        lOutWorldPositionVec4  = MUL( lBillboardWorldMat4, vec4(lOutLocalPositionVec4.xyz, 1.0));   
        lOutLocalNormalVec3    = normalize( lOutLocalPositionVec4.xyz );

        // Calculate normal
        float  lfRadius        = length( MAT4_GET_COLUMN( lGlobalWorldMat, 0 ) ) * 0.5;
        vec3   lMidPointVec3   = MAT4_GET_COLUMN( lBillboardWorldMat4, 3 );
        vec3   lSphereApexVec3 = lMidPointVec3 - ( MAT4_GET_COLUMN( lCameraMatrix, 2 ) * lfRadius);
        lOutWorldNormalVec3    = normalize( lOutWorldPositionVec4.xyz - lSphereApexVec3 );
    }            
#else
    {
        // Billboarding for mesh which is already a single quad
        lOutLocalPositionVec4 = CalcBillboardPos( lCameraMatrix, lLocalPositionVec4, lCustomParams01Vec4.x, lCombinedWorldMat4, lShearParamsVec4, lOutWorldPositionVec4 );
#if 0
        // Original and test code to check results            
        // lOutWorldPositionVec4 = CalcWorldPos( lWorldMat4, lOutLocalPositionVec4 ); 
        vec4 lOutWorldPositionVec4_2 = CalcWorldPos( lWorldMat4, lOutLocalPositionVec4 );         
        float lfDiff = abs(lOutWorldPositionVec4_2.x - lOutWorldPositionVec4.x) + abs(lOutWorldPositionVec4_2.y - lOutWorldPositionVec4.y) + abs(lOutWorldPositionVec4_2.z - lOutWorldPositionVec4.z);
        if (lfDiff > 0.001)     
        {
            _SCE_BREAK();
        }
#endif        
        // Calculate normal
        float  lfRadius        = length( MAT4_GET_COLUMN( lCombinedWorldMat4, 0 ) ) * 0.5;
        vec3   lMidPointVec3   = MAT4_GET_COLUMN( lCombinedWorldMat4, 3 );
        vec3   lSphereApexVec3 = lMidPointVec3 - ( MAT4_GET_COLUMN( lCameraMatrix, 2 ) * lfRadius);
        lOutWorldNormalVec3    = normalize( lOutWorldPositionVec4.xyz - lSphereApexVec3 );
    }
#endif
}

#endif


//-----------------------------------------------------------------------------
///
///     CalcWorldVec
///
///     @brief      CalcWorldVec
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec3 
CalcWorldVec( 
    in mat4 lWorldNormalMat4,
    in vec3 lLocalVec3 )
{
    return MUL( lWorldNormalMat4, vec4( lLocalVec3, 1.0 ) ).xyz;
    //return lLocalVec3;
}

#ifdef D_INSTANCE
//-----------------------------------------------------------------------------
///
///     CalcWorldVecInstanced
///
///     @brief      CalcWorldVecInstanced
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec3 
CalcWorldVecInstanced( 
    in mat4 lWorldNormalMat4,
    in mat4 lWorldInstancedMat4,
    in vec3 lLocalVec3 )
{
    mat4 lWorldInstancedNormalMat4;
    lWorldInstancedNormalMat4 = mat4( normalize(vec3(lWorldInstancedMat4[0][0], lWorldInstancedMat4[0][1], lWorldInstancedMat4[0][2])), 0.0,   
                                      normalize(vec3(lWorldInstancedMat4[1][0], lWorldInstancedMat4[1][1], lWorldInstancedMat4[1][2])), 0.0,   
                                      normalize(vec3(lWorldInstancedMat4[2][0], lWorldInstancedMat4[2][1], lWorldInstancedMat4[2][2])), 0.0,   
                                                     0.0,                        0.0,                       0.0,                            1.0 ); 
    vec3 lWorldNormal = MUL( lWorldNormalMat4, vec4( lLocalVec3, 1.0 ) ).xyz;
    return MUL( lWorldInstancedNormalMat4, vec4( lWorldNormal, 1.0 ) ).xyz;
}
#endif

//-----------------------------------------------------------------------------
///
///     CalcTanToWorldMat
///
///     @brief      CalcTanToWorldMat
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
mat3 
CalcTanToWorldMat( 
    in vec3 lTangentVec3, 
    in vec3 lBitangentVec3, 
    in vec3 lNormalVec3 )
{
    return mat3( lTangentVec3, lBitangentVec3, lNormalVec3 );
}

//-----------------------------------------------------------------------------
///
///     CalcTanVec
///
///     @brief      CalcTanVec
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
#ifdef _F20_

vec3 
CalcTanVec( 
    in vec3 lViewPositionVec3,
    in vec4 lWorldPositionVec4, 
    in vec3 lTangentVec3, 
    in vec3 lBitangentVec3, 
    in vec3 lNormalVec3 )
{
    vec3 lResultVec3;
    vec3 lDirectionVec3;

    lDirectionVec3 = lViewPositionVec3 - lWorldPositionVec4.xyz;

    lResultVec3.x = dot( lDirectionVec3, lTangentVec3 );
    lResultVec3.y = dot( lDirectionVec3, lBitangentVec3 );
    lResultVec3.z = dot( lDirectionVec3, lNormalVec3 );
    
    return lResultVec3;
}

#endif

//-----------------------------------------------------------------------------
///
///     ApplyRotation
///
///     @brief      ApplyRotation
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
#ifdef _F17_
vec3 
ApplyRotation( 
    float lfTheta, 
    vec3   lLocalPositionVec3 )
{
    mat3 lRotationMat3;

    float lfCosTheta = cos( lfTheta * 3.0 );
    float lfSinTheta = sin( lfTheta * 3.0 );

    MAT3_SET_COLUMN( lRotationMat3, 0, vec3( lfCosTheta, 0.0, lfSinTheta ) );
    MAT3_SET_COLUMN( lRotationMat3, 1, vec3( 0.0, 1.0, 0.0 ) );
    MAT3_SET_COLUMN( lRotationMat3, 2, vec3( -lfSinTheta, 0.0, lfCosTheta ) );

    return MUL( lRotationMat3, lLocalPositionVec3 );
}
#endif

//-----------------------------------------------------------------------------
///
///     CalcScreenPosFromWorld
///
///     @brief      CalcScreenPosFromWorld
///
///     @param      void
///     @return     Nothing.
///
//-----------------------------------------------------------------------------
vec4 
CalcCompressedVertexWorldPosition( 
    in mat4 lWorldMatrix,
    in vec4 lLocalPositionVec4 )
{    
    // [peter] NOT USED ANYMORE? IF YES, NEED TO REWRITE MATRIX ACCESSOR TO BE PLATFORM INDEPENDENT

    //ALEXCHECK - multiplication order
    vec4 lWorldPositionVec4;
    mat4 lWorldMat4 = lWorldMatrix;

    // Scale up slightly to hide cracks
    lWorldMat4[0][0] *= kfScaleUpFactor;
    lWorldMat4[1][1] *= kfScaleUpFactor;
    lWorldMat4[2][2] *= kfScaleUpFactor;

    // Strip scale from model position and add this first
    lWorldPositionVec4  = lLocalPositionVec4;
    lWorldPositionVec4 += vec4( lWorldMat4[ 3 ][ 0 ] / lWorldMat4[ 0 ][ 0 ], lWorldMat4[ 3 ][ 1 ] / lWorldMat4[ 1 ][ 1 ], lWorldMat4[ 3 ][ 2 ] / lWorldMat4[ 2 ][ 2 ], 0.0 );

    // Scale up world position
    lWorldMat4[3]       = vec4( 0.0, 0.0, 0.0, 1.0 );
    lWorldPositionVec4  = MUL( lWorldMat4, lWorldPositionVec4 );

    return lWorldPositionVec4;
}


//-----------------------------------------------------------------------------
///
///     CalcDualParaboloidScreenPosition
///
///     @brief      CalcDualParaboloidScreenPosition
///
///     @param      in mat4 lViewMat4
///     @param      in vec4 lWorldPositionVec4
///     @param      in vec2 lClipPlanes
///     @return     vec4
///
//-----------------------------------------------------------------------------
vec4 
CalcDualParaboloidScreenPosition( 
    in mat4 lViewMat4,
    in vec4 lWorldPositionVec4,
    in vec2 lClipPlanes )
{
    vec4 lScreenSpacePositionVec4 = MUL( lViewMat4, lWorldPositionVec4 );                        // transform vertex into the maps basis
    
    // Our Camera At is backwards
    lScreenSpacePositionVec4.z = -lScreenSpacePositionVec4.z;

    //Next we need to find the vector from the the vertex to the origin of the paraboloid, which is simply:
    float L = length( lScreenSpacePositionVec4.xyz );                                        // determine the distance between (0,0,0) and the vertex
    lScreenSpacePositionVec4.xyz = lScreenSpacePositionVec4.xyz / L;                                // divide the vertex position by the distance 

    //Now we need to find the x and y coordinates of the point where the incident ray intersects the paraboloid surface.
    lScreenSpacePositionVec4.z = lScreenSpacePositionVec4.z + 1.0;                            // add the reflected vector to find the normal vector
    lScreenSpacePositionVec4.x = lScreenSpacePositionVec4.x / lScreenSpacePositionVec4.z;    // divide x coord by the new z-value
    lScreenSpacePositionVec4.y = lScreenSpacePositionVec4.y / lScreenSpacePositionVec4.z;    // divide y coord by the new z-value

    // Finally we set the z value as the distance from the vertex to the origin of the paraboloid, scaled and biased by the near and far planes of the paraboloid 'camera'.                    
    lScreenSpacePositionVec4.z = (L - lClipPlanes.x) / (lClipPlanes.y - lClipPlanes.x);  // set a depth value for correct z-buffering
    lScreenSpacePositionVec4.w = 1;                                                                     // set w to 1 so there is no w divide

    return lScreenSpacePositionVec4;
}

//-----------------------------------------------------------------------------
///
///     OctahedronNormalEncode
///
///     @brief      OctahedronNormalEncode
///
///     @param      vec3 lNormal
///     @return     vec2
///
//-----------------------------------------------------------------------------
vec2
OctahedronNormalEncode( 
    vec3 lNormal )
{
    vec2 lEncoded;
    lNormal /= ( abs( lNormal.x ) + abs( lNormal.y ) + abs( lNormal.z ) );

    if( lNormal.z > 0.0 )
    {
        lEncoded = vec2( lNormal.x, lNormal.y );
    }
    else
    {
        lEncoded = vec2( 1.0 - abs( lNormal.y ), 1.0 - abs( lNormal.x ) );

        lEncoded.x *= lNormal.x < 0.0 ? -1.0 : 1.0;
        lEncoded.y *= lNormal.y < 0.0 ? -1.0 : 1.0;
    }

    return lEncoded;
}

//-----------------------------------------------------------------------------
///
///     OctahedronNormalDecode
///
///     @brief      OctahedronNormalDecode
///
///     @param      vec2 lEncoded
///     @return     vec3
///
//-----------------------------------------------------------------------------
vec3 
OctahedronNormalDecode( 
    vec2 lEncoded )
{
    vec3 lNormal;
    lNormal.z = 1.0 - abs( lEncoded.x ) - abs( lEncoded.y );

    if( lNormal.z >= 0.0 )
    {
        lNormal.xy = lEncoded.xy;
    }
    else
    {
        lNormal.x = 1.0 - abs( lEncoded.y );
        lNormal.y = 1.0 - abs( lEncoded.x );

        lNormal.x *= lEncoded.x < 0.0 ? -1.0 : 1.0;
        lNormal.y *= lEncoded.y < 0.0 ? -1.0 : 1.0;
    }

    lNormal = normalize( lNormal );

    return lNormal;
}
////////////////////////////////////////////////////////////////////////////////
///
///     @file       CommonUniforms.h
///     @author     User
///     @date       
///
///     @brief      CommonUniforms
///
///     Copyright (c) 2008 Hello Games Ltd. All Rights Reserved.
///
////////////////////////////////////////////////////////////////////////////////


#ifndef D_COMMONUNIFORMS2_H
#define D_COMMONUNIFORMS2_H

// =================================================================================================

#ifndef D_DEFINES
#define D_DEFINES


// =================================================================================================
// Platform defines
// =================================================================================================
#ifdef D_PLATFORM_PC

    #pragma optionNV(strict on)
    #extension GL_ARB_gpu_shader5 : enable
    #extension GL_ARB_fragment_coord_conventions : enable
    #extension GL_ARB_derivative_control : enable

    #ifdef D_FRAGMENT
    //{
        //layout( origin_upper_left, pixel_center_integer ) in vec4 gl_FragCoord;
    //}
    #endif

#elif defined(D_PLATFORM_ORBIS)

    // use this with sdk 2.0 compiler 
   // #pragma argument (allow-scratch-buffer-spill)

    //define these flags so they don't get ignored in build process and in the comb mask
    //this is because materials, vertex layouts and shaders need to be synced on 360 to avoid patching
    #ifdef _F27_
    #endif
    #ifdef _F28_
    #endif
    #ifdef _F29_
    #endif
    #ifdef _F21_
    #endif
    #ifdef _F02_
    #endif
    #ifdef _F03_
    #endif
    #if defined( _F01_ ) || defined( D_LOD0 ) || defined( D_LOD1 ) || defined( D_LOD2 ) || defined( D_LOD3) || defined( D_LOD4 ) 
    #endif
    #ifdef _F01_
    #endif
    #ifdef _F09_
    #endif
    #ifdef _F10_
    #endif


    // disable warnings for unused parameters. This happens a lot because of defining different things.
    #pragma warning (disable: 5203)

    // temp thing to know what things are still required on ps4.
    #define D_PLATFORM_ORBIS_FIX

#endif

// =================================================================================================
// Basic Types
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define JOINT_TYPE    vec4

    //#define CONST         const
    #define STATIC_CONST  const

#elif defined(D_PLATFORM_ORBIS)

    #define JOINT_TYPE      int4
    #define float           float
    #define vec2            float2
    #define vec3            float3
    #define vec4            float4
    #define ivec2           int2
    #define ivec3           int3
    #define ivec4           int4
    // NOTE: 
    // operator[] accesses rows, not columns 
    // matrix constructors interpret the passed vectors as row vectors, not column vectors
    #define mat2            row_major float2x2
    #define mat3            row_major float3x3
    #define mat4            row_major float4x4

    //#define CONST           
    #define STATIC_CONST    static const
   // #define const           ERROR, DON'T USE CONST FOR PS4. USE STATIC_CONST INSTEAD FOR A COMPILED IN CONSTANT. OTHERWISE IT TRIES TO PUT IT IN A CONSTANT BUFFER AND FOR SOME REASON IT DOESN'T WORK.


#endif

// =================================================================================================
// Functions
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define saturate( V )  min( max( V, 0.0) , 1.0)
    #define atan2( Y, X )  atan( Y, X )
    #define invsqrt( X )   inversesqrt( X )

    // These can be deleted if ARB_derivative_control can be used
    //#define dFdxFine    dFdx
    //#define dFdyFine    dFdy

#elif defined(D_PLATFORM_ORBIS)

    #define mix             lerp
    #define fract           frac
    #define dFdx            ddx
    #define dFdy            ddy
    #define dFdxFine        ddx_fine
    #define dFdyFine        ddy_fine
#define mod                fmod
    #define saturate( V )   ( min( max( V, 0.0) , 1.0) )
    #define invsqrt( X )    rsqrt( X )

#endif


// =================================================================================================
// Samplers and textures
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SAMPLER2DSHADOW( NAME, REG )    uniform sampler2DShadow NAME

    #define SAMPLER2DARG( NAME )            in sampler2D NAME
    #define SAMPLER2DPARAM( NAME )          NAME
    #define SAMPLER2DARRAYARG( NAME )       in sampler2DArray NAME

    #define SAMPLERCUBE( NAME )             samplerCube NAME
    #define SAMPLERCUBEARG( NAME )          in samplerCube NAME
    #define SAMPLERCUBEPARAM( NAME )        NAME

    

    #define SAMPLER2DARRAYPARAM( NAME )     NAME

    // TEMP while switching ps4 over to srt
    #define SAMPLER2D( NAME )               sampler2D       NAME
    #define SAMPLER2D_TEMP( NAME, INDEX )   uniform sampler2D       NAME
    #define SAMPLER2DARRAY( NAME )          sampler2DArray  NAME
    #define SAMPLER3D( NAME )               sampler3D       NAME
    #define SAMPLER2DSHADOW_SRT( NAME )     sampler2DShadow NAME


#elif defined(D_PLATFORM_ORBIS)

    #define SAMPLERCUBE( NAME, REG )        SamplerState NAME##SS : register( s##REG ); TextureCube NAME##TU : register( t##REG )

    #define SAMPLER2D( NAME )               Texture2D NAME; SamplerState NAME##SS
    #define SAMPLER2DSHADOW_SRT( NAME )     Texture2D NAME; SamplerComparisonState NAME##SS  //SAMPLER2D( NAME )
    #define SAMPLER3D( NAME )               Texture3D NAME; SamplerState NAME##SS


    #define SAMPLER2DARRAY( NAME )          Texture2D_Array NAME; SamplerState NAME##SS
    #define SAMPLER2DARRAYARG( NAME )       Texture2D_Array NAME, SamplerState NAME##SS
    #define SAMPLER2DARRAYPARAM( NAME )     NAME, NAME##SS

    #define SAMPLER2DPARAM( NAME )          NAME, NAME##SS
    #define SAMPLER2DARG( NAME )            Texture2D NAME, SamplerState NAME##SS

    #define texture2D( T, C )                T.Sample( T##SS, C )

    #define texture2DLod( T, C, N )         T.SampleLOD( T##SS, C, N )
    #define texture2DArray(  T, C )         T.Sample( T##SS, C )
    #define texture3DLod( T, C, N )         T.SampleLOD( T##SS, C, N )

    //#define shadow2D( T, C )                vec3( C.z > T.Sample( T##SS, C.xy ).x ? 1.0 : 0.0 )                    
    //#define shadow2D( T, C )                T.GatherCmp( T##SS, C.xy, C.z )
    //#define shadow2D( T, C )                T.SampleCmpLOD0( T##SS, C.xy, C.z )
    #define shadow2D( T, C )                T.SampleCmp( T##SS, C.xy, C.z )
    #define textureCube( T, C )                T##TU.Sample( T##SS, C )
    #define textureCubeLod( T, C, N )        T##TU.Sample( T##SS, C, N )
    #define textureGrad( T, C, DDX, DDY )   T.SampleGradient( T##SS, C, DDX, DDY )                    

#endif

// =================================================================================================
// Matrices
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define MUL( INPUT_A, INPUT_B )         (INPUT_A * INPUT_B)
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#elif defined(D_PLATFORM_ORBIS)

    #define MUL( INPUT_A, INPUT_B )         mul( INPUT_B, INPUT_A )
    #define PLATFORM_TRANSPOSE
    #define MAT4_SET_POS( M, P )            M[ 3 ] = P
    #define MAT4_SET_TRANSLATION( M, T )    M[ 3 ].xyz = T
    #define MAT4_GET_COLUMN( M, C )         M[ C ].xyz
    #define MAT3_GET_COLUMN( M, C )         M[ C ]
    #define MAT4_GET_COLUMN_VEC4( M, C )    M[ C ]

    #define MAT3_SET_COLUMN( M, C, V )      M[ C ] = V;
    #define MAT4_SET_COLUMN( M, C, V )      M[ C ] = V;

#endif

// =================================================================================================
// Arrays (workaround AMD shader compiler issues by making arrays have global scope)
// =================================================================================================

#if defined(D_PLATFORM_ORBIS)

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _UNIFORMS._ELEMENT[_INDEX]

#else

#define ARRAY_LOOKUP_FS( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]
#define ARRAY_LOOKUP_FP( _UNIFORMS, _ELEMENT, _INDEX)   _ELEMENT[_INDEX]

#endif


// =================================================================================================
// Input and Output
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define UNIFORM( TYPE, NAME )           uniform TYPE NAME
    #define UNIFORM_SRT( TYPE, NAME )       uniform TYPE NAME

    #define DECLARE_INPUT
    #define DECLARE_OUTPUT
    #define DECLARE_END  
    #define DECLARE_PTR( TYPE, NAME )       TYPE  NAME;

    #define INPUT(   TYPE, NAME, REG )      in    TYPE NAME;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      in    TYPE NAME;
    #define OUTPUT(  TYPE, NAME, REG )      out   TYPE NAME;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE    layout ( location = 0 ) out uvec4 out_color0
    #define FRAGMENT_COLOUR_UVEC4           out_color0
    #define FRAGMENT_COLOUR                 gl_FragColor
    #define FRAGMENT_COLOUR0                gl_FragData[ 0 ]
    #define FRAGMENT_COLOUR1                gl_FragData[ 1 ]
    #define FRAGMENT_COLOUR2                gl_FragData[ 2 ]
    #define FRAGMENT_COLOUR3                gl_FragData[ 3 ]
    #define FRAGMENT_DEPTH                  gl_FragDepth

    #define IN(  VAR )                      VAR
    #define OUT( VAR )                      VAR
    #define DEREF_PTR( VAR )                VAR

    #define OUT_VERTEX_SCREEN_POSITION 
    #define IN_SCREEN_POSITION 
    #define VERTEX_SCREEN_POSITION          gl_Position

#elif defined(D_PLATFORM_ORBIS)

    #define UNIFORM( TYPE, NAME )           ConstantBuffer NAME##CB{ TYPE NAME; };
    #define UNIFORM_SRT( TYPE, NAME )       ConstantBuffer NAME##CB{ TYPE NAME : S_SRT_DATA; };

    #define DECLARE_OUTPUT                  struct cOutput {
    #define DECLARE_INPUT                   struct cInput  {
    #define DECLARE_END                     };
    #define DECLARE_PTR( TYPE, NAME )       TYPE* NAME;

    #define INPUT(   TYPE, NAME, REG )               TYPE NAME : REG;
    #define INPUT_NOINTERP(   TYPE, NAME, REG )      nointerp TYPE NAME : REG;        
    #define OUTPUT(  TYPE, NAME, REG )      TYPE NAME : REG;

    #define FRAGMENT_COLOUR_UVEC4_DEFINE
    #define FRAGMENT_COLOUR_UVEC4           Out.mColour
    #define FRAGMENT_COLOUR                 Out.mColour
    #define FRAGMENT_COLOUR0                Out.mColour0
    #define FRAGMENT_COLOUR1                Out.mColour1
    #define FRAGMENT_COLOUR2                Out.mColour2
    #define FRAGMENT_COLOUR3                Out.mColour3
    #define FRAGMENT_DEPTH                  Out.mDepth

    #define IN(  VAR )                      In.VAR

    #define OUT( VAR )                      Out.VAR

// TODO get rid of this - don't pass struct through functinos, pass members.
    #define DEREF_PTR( VAR )                *VAR


    #define OUT_VERTEX_SCREEN_POSITION      OUTPUT( vec4, mScreenPositionVec4, S_POSITION )
    #define IN_SCREEN_POSITION              INPUT ( vec4, mScreenPositionVec4, S_POSITION )
    #define VERTEX_SCREEN_POSITION          OUT( mScreenPositionVec4 )

#endif

// =================================================================================================
// Main
// =================================================================================================
#ifdef D_PLATFORM_PC


    #define VERTEX_MAIN                     void main( void )
    #define VERTEX_MAIN_SRT                 uniform UniformBuffer lUniforms; void main( void )

    #define FRAGMENT_MAIN_COLOUR            void main( void )
    #define VOID_MAIN_COLOUR                void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH      void main( void )

    #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_SRT           uniform UniformBuffer lUniforms; void main( void )
    #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT    uniform UniformBuffer lUniforms; void main( void )

    #define VOID_MAIN_COLOUR_SRT               uniform UniformBuffer lUniforms; void main( void )

#elif defined( D_PLATFORM_ORBIS )

    #define VERTEX_MAIN                     void main( cInput In, out cOutput Out )
    #define VERTEX_MAIN_SRT                 void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )


#define FRAGMENT_MAIN_COLOUR            struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out )
#define VOID_MAIN_COLOUR                struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                           void main( cInput In, out cOutput Out )
#define FRAGMENT_MAIN_COLOUR_DEPTH      struct cOutput { vec4  mColour : S_TARGET_OUTPUT; float mDepth  : S_DEPTH_OUTPUT; };    [RE_Z] void main( cInput In, out cOutput Out )

    #if !defined( D_ATTRIBUTES )
#define FRAGMENT_MAIN_COLOUR_DEPTH_SRT     struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_OUTPUT;    }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_GE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_GE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_DEPTH_LE_SRT  struct cOutput { vec4 mColour : S_TARGET_OUTPUT; float mDepth : S_DEPTH_LE_OUTPUT; }; [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )
#define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour : S_TARGET_OUTPUT; };                                    [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_SRT                                                                                                           void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
#define VOID_MAIN_COLOUR_EARLYZ_SRT                                                                            [FORCE_EARLY_DEPTH_STENCIL]void main( cInput In, UniformBuffer lUniforms : S_SRT_DATA )
    
    #else
        
        #pragma PSSL_target_output_format(target 1 FMT_32_AR)
    
        #define FRAGMENT_MAIN_COLOUR_DEPTH_SRT  struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;  \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;  \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;  \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3;  \
                                                                 float mDepth   : S_DEPTH_OUTPUT; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  )

        #define FRAGMENT_MAIN_COLOUR_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [RE_Z] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )
                                                    
        #define FRAGMENT_MAIN_COLOUR_EARLYZ_SRT        struct cOutput { vec4  mColour0 : S_TARGET_OUTPUT0;    \
                                                                 vec4  mColour1 : S_TARGET_OUTPUT1;    \
                                                                 vec4  mColour2 : S_TARGET_OUTPUT2;    \
                                                                 vec4  mColour3 : S_TARGET_OUTPUT3; }; \
                                                [FORCE_EARLY_DEPTH_STENCIL] void main( cInput In, out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA )                                                    
    #endif


#endif


// =================================================================================================
// Viewport
// =================================================================================================
#ifdef D_PLATFORM_PC

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) A.xy

#elif defined(D_PLATFORM_ORBIS)

    #define SCREENSPACE_AS_RENDERTARGET_UVS( A ) ( float2( A.x, 1.0 - A.y ) )

#endif

#endif


struct PerFrameUniforms
{
    vec4    gLightPositionVec4;                 // EShaderConst_LightPositionVec4
    vec4    gLightDirectionVec4;                // EShaderConst_LightDirectionVec4
    vec3    gViewPositionVec3;                  // EShaderConst_ViewPositionVec3
    float   gfTime;                             // EShaderConst_Time
    vec4    gClipPlanesVec4;                    // EShaderConst_ClipPlanesVec4
    vec4    gClipPlanesRVec4;                   // EShaderConst_ClipPlanesRVec4

    mat4    gCameraMat4;                        // EShaderConst_CameraMat4

    vec4    gFrameBufferSizeVec4;   
    vec4    gFoVValuesVec4;                     // EShaderConst_FoVValuesVec4
    vec4    gShadowSizeVec4;   
    vec4    gShadowFadeParamVec4;   
    mat4    gViewMat4;                          // EShaderConst_ViewMat4

    //
    // These are per pass really. Probably just rename PerFrame to PerPass.
    //
    //mat4    gProjectionMat4;                    // EShaderConst_ProjectionMat4
    //mat4    gCameraMat4;                        // EShaderConst_CameraMat4
    //mat4    gaShadowMat4[ 2 ];   // EShaderConst_ShadowMat4
    //vec4    gClipPlanesVec4;                    // EShaderConst_ClipPlanesVec4

    //SAMPLER2D( gDualPMapFront );    // 32 bytes each
    //SAMPLER2D( gDualPMapBack );
    //SAMPLER2D( gCloudShadowMap );

    //SAMPLER2D( gFadeNoiseMap );

    //SAMPLER2D( gCausticMap );
    //SAMPLER2D( gCausticOffsetMap );

    // how to set samplers

    // putting these here would require removing them from the shader and material, and making them part of the common global
    // list so they can be set like the ones above... i think.
    // Fog
    //vec4 gSkyColourVec4;
    //vec4 gHorizonColourVec4;
    //vec4 gSunColourVec4;
    //vec4 gWaterColourNearVec4;
    //vec4 gWaterColourFarVec4;
    //vec4 gWaterFogVec4;
    //vec4 gHeightFogParamsVec4;
    //vec4 gHeightFogColourVec4;
    //vec4 gSpaceHorizonColourVec4;
    //vec4 gFogColourVec4;
    //vec4 gFogParamsVec4;
    //vec4 gScatteringParamsVec4;
    //vec4 gSpaceFogWavelength1Vec4;
    //vec4 gSpaceFogWavelength2Vec4;
    //vec4 gSpaceFogWavelength3Vec4;
    //vec4 gSpaceSkyColourVec4;
    //vec4 gFogFadeHeightsVec4;
    //vec4 gSunPositionVec4;
};

struct CommonPerMeshUniforms
{    
    // These are planet specific. Should they be here?
    vec4 gPlanetPositionVec4;

    // Stop these being compiled in when recolouring as the recolour shader needs ALL tex units.

    mat4    gInverseModelMat4;                     // EShaderConst_InverseModelMat4 = 0
    mat4    gWorldMat4;                            // EShaderConst_WorldMat4
    mat4    gWorldViewProjectionMat4;              // EShaderConst_WorldViewProjectionMat4
    mat4    gWorldNormalMat4;                      // EShaderConst_WorldNormalMat4

#ifdef D_FADE
    float   gfFadeValue;                           // EShaderConst_FadeTime
#else
    float   fdFadeValueDummy;
#endif
    
#if defined( D_SKINNING_UNIFORMS ) && defined( D_PLATFORM_ORBIS )
    vec4   gaSkinMatrixRowsVec4[ 75 * 3 ];        
#endif

    //float   gfShadowBias;                       // EShaderConst_ShadowBias
     
   //  have particle shader use a particlecommon instead of uber, and put these into it.
#if defined( D_PARTICLE_UNIFORMS ) && defined( D_PLATFORM_ORBIS )
    vec4    gaParticleCornersVec4[ 4 ];            // EShaderConst_ParticleCornersVec4
    vec4    gaParticlePositionsVec4[ 32 ];         // EShaderConst_ParticlePositionsVec4
    vec4    gaParticleSizeAndRotationsVec4[ 32 ];  // EShaderConst_ParticleSizeAndRotationsVec4
    vec4    gaParticleNormalsVec4[ 32 ];           // EShaderConst_ParticleNormalsVec4
    vec4    gaParticleColoursVec4[ 32 ];           // EShaderConst_ParticleColoursVec4
#endif

        // This stuff is here atm because of shadows. The shadow shader is one thing, but renders twice, with these needing to be set differently.
    // ideally we don't want them set per mesh though, probably a SRT for 'percamera' or something
    // 
    //
    mat4    gProjectionMat4;                    // EShaderConst_ProjectionMat4
    mat4    gViewProjectionMat4;                   // EShaderConst_ViewProjectionMat4
    mat4    gInverseViewMat4;                   // EShaderConst_InverseViewMat4
    mat4    gInverseProjectionMat4;             // EShaderConst_InverseProjectionMat4
    mat4    gInverseViewProjectionMat4;         // EShaderConst_InverseViewProjectionMat4
    mat4    gaShadowMat4[ 3 ];                  // EShaderConst_ShadowMat4
    vec4    gShadowProjScaleVec4[3];            // EShaderConst_ShadowProjScaleVec4
    vec4    gLightColourVec4;                   // EShaderConst_LightColourVec4
       vec4    gGenericParam0Vec4;                    // EShaderConst_GenericParam0Vec4
       
    // These shouldn't be per mesh, the should be per rendertarget. BUT we need to add them to the enum
    // in egShader and SetPErRenderTargetUniforms for that to work and we're trying to do a build for sony
    // so that will have to wait. (also probably need a way of setting per RT uniforms from Game).
    vec4    gScanParamsPosVec4;
    vec4    gScanParamsCfg1Vec4;
    vec4    gScanParamsCfg2Vec4;
    vec4    gScanParamsCfg3Vec4;
    vec4    gScanColourVec4;

        vec4 gSpotlightPositionVec4;
    vec4 gSpotlightDirectionVec4;
    
};

#if defined( D_PARTICLE_UNIFORMS ) && defined( D_PLATFORM_PC )
uniform vec4    gaParticleCornersVec4[4];            // EShaderConst_ParticleCornersVec4
uniform vec4    gaParticlePositionsVec4[32];         // EShaderConst_ParticlePositionsVec4
uniform vec4    gaParticleSizeAndRotationsVec4[32];  // EShaderConst_ParticleSizeAndRotationsVec4
uniform vec4    gaParticleNormalsVec4[32];           // EShaderConst_ParticleNormalsVec4
uniform vec4    gaParticleColoursVec4[32];           // EShaderConst_ParticleColoursVec4
#endif


#endif

//-----------------------------------------------------------------------------
///
///     CustomPerMaterialUniforms
///
///     @brief      CustomPerMaterialUniforms
///
///     Stuff that is only used for these types of meshes.
//-----------------------------------------------------------------------------
struct CustomPerMaterialUniforms
{
    SAMPLER2D( gDiffuseMap );
};

struct CustomPerMeshUniforms
{
    vec4 gColour;
};

//
// This is the SRT buffer that everything gets uploaded to (on PS4). PC just functions as normal.
//
struct UniformBuffer
{
    //DECLARE_PTR( CommonPerMaterialUniforms, mpCommonPerMaterial )    // sematics currently crash the compiler so the parser is hardcoded to look for names.  
    DECLARE_PTR( PerFrameUniforms,          mpPerFrame )    // sematics currently crash the compiler so the parser is hardcoded to look for names.  
    DECLARE_PTR( CommonPerMeshUniforms,     mpCommonPerMesh )        // sematics currently crash the compiler so the parser is hardcoded to look for names.  
    DECLARE_PTR( CustomPerMeshUniforms,     mpCustomPerMesh )        // sematics currently crash the compiler so the parser is hardcoded to look for names.  
    DECLARE_PTR( CustomPerMaterialUniforms, mpCustomPerMaterial )     
};

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // D_VERTEX
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#if defined( D_VERTEX )

           
//-----------------------------------------------------------------------------
///
///     Input
///
///     @brief  Input
///
//-----------------------------------------------------------------------------
DECLARE_INPUT

    INPUT(  vec4, mkLocalPositionVec4, POSITION0 )

    INPUT( vec4, mkLocalNormalVec4,     TEXCOORD0     )
    INPUT( vec4, mkCustom1Vec4,            TEXCOORD1     )
    INPUT( vec4, mkCustom2Vec4,            TEXCOORD2     )
    INPUT( vec4, mkColourVec4,            TEXCOORD3     )

DECLARE_END                                    


//-----------------------------------------------------------------------------
///
///     Output
///
///     @brief  Output
///
//-----------------------------------------------------------------------------
DECLARE_OUTPUT

    OUT_VERTEX_SCREEN_POSITION
    OUTPUT( vec2,  mfTexCoord, TEXCOORD1 )
    OUTPUT( float, mfFade,     TEXCOORD2 )
    OUTPUT( float, mfLogZ,     TEXCOORD3 )
    OUTPUT( vec4,  mColourVec4,TEXCOORD4 )
    

DECLARE_END                                       
         


vec4
GetLinePosition(
    vec4 lScreenPositionA,
    vec4 lScreenPositionB,
    vec2 lOffset )
{
    vec2 lineDirProj;

    //  line direction in screen space (perspective division required)
    lineDirProj = radius * normalize( lScreenPositionA.xy/lScreenPositionA.ww - lScreenPositionB.xy/lScreenPositionB.ww );

    // small trick to avoid inversed line condition when points are not on the same side of Z plane
    if( sign(lScreenPositionA.w) != sign(lScreenPositionB.w) )
        lineDirProj = -lineDirProj;
        
    vec4 vMVP     = lScreenPositionA;

    // offset position in screen space along line direction and orthogonal direction
    vMVP.xy += lineDirProj.xy                            * lOffset.xx * vec2(1.0,invScrRatio);
    vMVP.xy += lineDirProj.yx    * vec2( 1.0, -1.0 )        * lOffset.yy * vec2(1.0,invScrRatio);

    return vMVP;
}

VERTEX_MAIN_SRT
 {   
    vec4 OffsetUV;
    vec4 laPosition[3];
    vec4 laScreenPosition[3];
    vec3 lTemp = vec3(0.0);
    
    laPosition[0] = IN( mkLocalPositionVec4 );
    laPosition[1] = IN( mkLocalNormalVec4 );
    laPosition[2] = IN( mkCustom1Vec4 );

    laScreenPosition[0] = CalcScreenPosFromWorld( lUniforms.mpPerFrame.gViewMat4, lUniforms.mpCommonPerMesh.gProjectionMat4, laPosition[0] );
    laScreenPosition[1] = CalcScreenPosFromWorld( lUniforms.mpPerFrame.gViewMat4, lUniforms.mpCommonPerMesh.gProjectionMat4, laPosition[1] );
    laScreenPosition[2] = CalcScreenPosFromWorld( lUniforms.mpPerFrame.gViewMat4, lUniforms.mpCommonPerMesh.gProjectionMat4, laPosition[2] );

    OffsetUV = IN( mkCustom2Vec4 );

    // scale
    //OffsetUV.y *= lUniforms.mpCommonPerMesh.gaParticleSizeAndRotationsVec4[ 0 ].x;

    vec4 lFinalScreenPosition;

    vec4 vMVP_A  = GetLinePosition( laScreenPosition[0], laScreenPosition[1], vec2( 0.0, OffsetUV.y ) );
    vec4 vMVP_B  = GetLinePosition( laScreenPosition[0], laScreenPosition[2], vec2( 0.0, -OffsetUV.y ) );

    lFinalScreenPosition    = (vMVP_A + vMVP_B) * 0.5;

    vec2 lNormal = normalize( ( (vMVP_A.xy + vMVP_B.xy) * 0.5)  - laScreenPosition[0].xy  );
    
    // Keep the size constant regardless of distance. (pre multiply by homogenous w as it will get divided by W by the hardware after this.
    //float lfScale = ( lUniforms.mpCustomPerMaterial.gLineWidthPixels.x / lUniforms.mpPerFrame.gFrameBufferSizeVec4.y ) * lFinalScreenPosition.w; 
    float lfScale = ( abs( OffsetUV.y ) / lUniforms.mpPerFrame.gFrameBufferSizeVec4.y ) * lFinalScreenPosition.w; 

    lFinalScreenPosition.xy = (laScreenPosition[0].xy + (lNormal * vec2(1.0,invScrRatio) * lfScale ));

    OUT( mfTexCoord ) = OffsetUV.zw;
    OUT(mfFade) = ARRAY_LOOKUP_FP(lUniforms.mpCommonPerMesh, gaParticleSizeAndRotationsVec4, 0).y;

    // Write the log z on the fragment shader
    OUT( mfLogZ )          = lFinalScreenPosition.z;
    OUT( mColourVec4 )     = IN( mkColourVec4 );
    VERTEX_SCREEN_POSITION = lFinalScreenPosition;                                    
 }                                                 

#endif

 //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // D_FRAGMENT
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#if defined( D_FRAGMENT )

DECLARE_INPUT
    IN_SCREEN_POSITION

    INPUT( vec2,  mfTexCoord, TEXCOORD1 )
    INPUT( float, mfFade,     TEXCOORD2 )
    INPUT( float, mfLogZ,      TEXCOORD3 )
    INPUT( vec4,  mColourVec4,TEXCOORD4 )

DECLARE_END

    /*
struct cOutput 

    vec4  mColour : S_TARGET_OUTPUT; 
    float mDepth  : S_DEPTH_OUTPUT; 
};    
*/
//void main( PS_IN In,  out cOutput Out, UniformBuffer lUniforms : S_SRT_DATA  ) 
FRAGMENT_MAIN_COLOUR_DEPTH_SRT
{                                                  
    vec4 lAlbedo;
    
    lAlbedo = texture2D( lUniforms.mpCustomPerMaterial.gDiffuseMap, IN( mfTexCoord ) );
  //  lAlbedo *= In.Color; 
    
    FRAGMENT_COLOUR = lAlbedo * IN( mColourVec4 );//lUniforms.mpCustomPerMesh.gColour;//vec4( 1.0, 0.0, 0.0, 1.0 );//
    FRAGMENT_DEPTH  = log2( IN( mfLogZ ) ) * lUniforms.mpPerFrame.gClipPlanesVec4.w;
}      

#endif


----------------------------------------
ERROR----------------------------------------
ERROR: 0:1: '' :  Incorrect GLSL version: 450
WARNING: 0:35: '#extension' :  'GL_ARB_derivative_control' is not supported
ERROR: 0:1000: 'lCorrectColourVec3' : undeclared identifier 
ERROR: 0:1000: 'assign' :  cannot convert from '3-component vector of float' to 'float'
ERROR: 0:1017: 'lCorrectColourVec3' : undeclared identifier 
ERROR: 0:1017: 'assign' :  cannot convert from '3-component vector of float' to 'float'
WARNING: 0:1171: 'inverse' : function is not available in current GLSL version 
ERROR: 0:1307: 'lTemp' : undeclared identifier 
ERROR: 0:1307: 'CalcWorldPos' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:1307: '=' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:1308: 'CalcScreenPosFromWorld' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:1719: 'lWorldPositionVec4' : undeclared identifier 
ERROR: 0:1719: 'assign' :  cannot convert from 'in 4-component vector of float' to 'float'
ERROR: 0:1720: 'assign' :  cannot convert from '4-component vector of float' to 'float'
ERROR: 0:1724: 'assign' :  cannot convert from '4X4 (default)row_major matrix of float' to 'float'
WARNING: 0:1764: 'assign' : implicit type conversion allowed from GLSL 1.20 
ERROR: 0:1788: 'lEncoded' : undeclared identifier 
ERROR: 0:1788: 'assign' :  cannot convert from '2-component vector of float' to 'float'
ERROR: 0:1792: 'lEncoded' : undeclared identifier 
ERROR: 0:1792: 'assign' :  cannot convert from '2-component vector of float' to 'float'
ERROR: 0:1795: 'y' : vector field selection out of range 
ERROR: 0:1798: 'lEncoded' : undeclared identifier 
ERROR: 0:1816: 'lNormal' : undeclared identifier 
ERROR: 0:1816: 'z' : vector field selection out of range 
ERROR: 0:1818: 'z' : vector field selection out of range 
ERROR: 0:1820: 'xy' : vector field selection out of range 
ERROR: 0:1820: 'assign' :  cannot convert from '2-component vector of float' to 'float'
ERROR: 0:1825: 'y' : vector field selection out of range 
ERROR: 0:1828: 'y' : vector field selection out of range 
ERROR: 0:2457: 'lineDirProj' : undeclared identifier 
ERROR: 0:2457: 'assign' :  cannot convert from '2-component vector of float' to 'float'
ERROR: 0:2466: 'xy' : vector field selection out of range 
ERROR: 0:2467: 'yx' : vector field selection out of range 
ERROR: 0:2479: 'mkLocalPositionVec4' : undeclared identifier 
ERROR: 0:2479: 'assign' :  cannot convert from 'float' to '4-component vector of float'
ERROR: 0:2480: 'mkLocalNormalVec4' : undeclared identifier 
ERROR: 0:2480: 'assign' :  cannot convert from 'float' to '4-component vector of float'
ERROR: 0:2481: 'mkCustom1Vec4' : undeclared identifier 
ERROR: 0:2481: 'assign' :  cannot convert from 'float' to '4-component vector of float'
ERROR: 0:2483: 'lUniforms' : undeclared identifier 
ERROR: 0:2483: 'mpPerFrame' : illegal vector field selection 
ERROR: 0:2483: 'gViewMat4' : illegal vector field selection 
ERROR: 0:2483: 'mpCommonPerMesh' : illegal vector field selection 
ERROR: 0:2483: 'gProjectionMat4' : illegal vector field selection 
ERROR: 0:2483: 'CalcScreenPosFromWorld' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:2483: 'assign' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:2484: 'mpPerFrame' : illegal vector field selection 
ERROR: 0:2484: 'gViewMat4' : illegal vector field selection 
ERROR: 0:2484: 'mpCommonPerMesh' : illegal vector field selection 
ERROR: 0:2484: 'gProjectionMat4' : illegal vector field selection 
ERROR: 0:2484: 'CalcScreenPosFromWorld' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:2484: 'assign' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:2485: 'mpPerFrame' : illegal vector field selection 
ERROR: 0:2485: 'gViewMat4' : illegal vector field selection 
ERROR: 0:2485: 'mpCommonPerMesh' : illegal vector field selection 
ERROR: 0:2485: 'gProjectionMat4' : illegal vector field selection 
ERROR: 0:2485: 'CalcScreenPosFromWorld' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:2485: 'assign' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:2487: 'OffsetUV' : undeclared identifier 
ERROR: 0:2487: 'mkCustom2Vec4' : undeclared identifier 
ERROR: 0:2494: 'y' : vector field selection out of range 
ERROR: 0:2495: 'y' : vector field selection out of range 
ERROR: 0:2497: 'lFinalScreenPosition' : undeclared identifier 
ERROR: 0:2497: 'assign' :  cannot convert from '4-component vector of float' to 'float'
ERROR: 0:2503: 'y' : vector field selection out of range 
ERROR: 0:2503: 'mpPerFrame' : illegal vector field selection 
ERROR: 0:2503: 'gFrameBufferSizeVec4' : illegal vector field selection 
ERROR: 0:2503: 'y' : vector field selection out of range 
ERROR: 0:2503: 'w' : vector field selection out of range 
ERROR: 0:2505: 'xy' : vector field selection out of range 
ERROR: 0:2505: 'assign' :  cannot convert from '2-component vector of float' to 'float'
ERROR: 0:2507: 'mfTexCoord' : undeclared identifier 
ERROR: 0:2507: 'zw' : vector field selection out of range 
ERROR: 0:2508: 'mfFade' : undeclared identifier 
ERROR: 0:2511: 'mfLogZ' : undeclared identifier 
ERROR: 0:2511: 'z' : vector field selection out of range 
ERROR: 0:2512: 'mColourVec4' : undeclared identifier 
ERROR: 0:2512: 'mkColourVec4' : undeclared identifier 
ERROR: 0:2513: 'assign' :  cannot convert from 'float' to 'Position 4-component vector of float'

 

 

Link to comment
Share on other sites

The HD 4400 only supports OpenGl 4.3, no way to upgrade that. The minimum specs on steam clearly say "GTX 480/HD 7870", those are way, way better than the integrated graphics in your CPU and also support OpenGl 4.5. Your PC is simply not compatible, read the specs before you buy. Maybe you can still get a refund...

Edited by Elthy
Link to comment
Share on other sites

1 hour ago, Elthy said:

The HD 4400 only supports OpenGl 4.3, no way to upgrade that. The minimum specs on steam clearly say "GTX 480/HD 7870", those are way, way better than the integrated graphics in your CPU and also support OpenGl 4.5. Your PC is simply not compatible, read the specs before you buy. Maybe you can still get a refund...

What if the devs make it 4.3 compatible?

Link to comment
Share on other sites

54 minutes ago, Alphasus said:

Wouldn't matter because the GPU is too slow.

Well, i'm used to low end systems because i'm poor and can tolerate framerates as low as 5 fps so yeah i think i'm good

Link to comment
Share on other sites

11 minutes ago, Souper said:

Well, i'm used to low end systems because i'm poor and can tolerate framerates as low as 5 fps so yeah i think i'm good

That is the minimum requirements. Try to refund the game... people with i7 5960x's and dual 980ti's can't hold 60 fps. That is 40 times faster than an hd 4400 GPU wise. If Ultra is 5 times more intensive than minimum, you will get less than 7 fps at best. A GTX 480 is 6 times as fast as your iGPU, and its minimum. Don't expect much above 5 FPS ever, and expect to be below it.

Edited by Alphasus
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...