..:: PCSX2 Forums ::..

Full Version: Custom Shaders for GSdx
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just make as many as you want. XD
i have a problem with colored fxaa
when i change the name in shader.fx and load gsdx (5403), in the console i can read :

pcsx2-5406-windows-x86\shader.fx(1992,32): error X3004: undeclared identifier 'TextureSampler'
and when i press pg up, in the console it tells me "GSdx: Post-processing shader is now enabled." but no change on the screen.


i tried an other fx in the first page, it works

is there a solution ?

edit: i tried all effects.

they "work" but results are sometimes a little "blurry", it gives me more colour but less sharp. i dont know if it's normal or not.

colored fxaa is the only that wont launch
i used a nvidia 670, i7 @ 4.5ghz, 6go


edit2: i can make screenshots if it can help
Ok i did some tests

-so with GSDX dx9 i had this error "pcsx2-5406-windows-x86\shader.fx(1992,32): error X3004: undeclared identifier 'TextureSampler'"
and the effect didnt work

-i tried with GSDX dx11 (10?) and now it's this error "pcsx2-5390-windows-x86\shader.fx(2004,10): warning X3206: 'FxaaPixelShader': implicit truncation of vector type
and...it works i can enable it.
It looks good, good sharpness & colors but i dont know if its perfectly fonctionnal because of the "error message" in the console...
I wasn't really thinking about DX9 back then, corrected the error now as well as a warning which was made by a slight typo, not much affecting the result anyway through. Re-download if you want.
thank you

your fx does miracle on gran turismo 4, i dont know if you know it !
Can someone explain how to get this thing works? the explanation on first page doesn't seems friendly for newbie like me Sad
Before that download latest Git HERE. Re-configure everything as usual.

Step by step:

1. Pick and download your shader choice.

2. Extract it inside your PCSX2 directory where the main executables were placed.

3. Rename it to shader.fx

4. In game, press Home key.

(Optional)

If you want it to be automatically enabled instead of pressing Home key, find gsdx.ini inside inis folder, open it and add (without quotes) "shaderfx=1"

Good Luck! Laugh
Also, check the console and if you see any error or warning about shader.fx if you see no effect. Cuz that might be why. XD
This super-simple shader makes movies kinda censored. Just for the fun of it as it has no useful purpose. Smile

shader.fx
Code:
/*
    Censor shader
*/

#ifdef SHADER_MODEL

#define dx 0.04
#define dy 0.04

Texture2D Texture;
SamplerState TextureSampler;

struct PS_INPUT
{
    float4 p : SV_Position;
    float2 t : TEXCOORD0;
};

struct PS_OUTPUT
{
    float4 c : SV_Target0;
};

PS_OUTPUT ps_main(PS_INPUT input)
{
    PS_OUTPUT output;
    float2 pos = input.t;
    float2 coord = float2(dx * floor(pos.x / dx), dy * floor(pos.y / dy));

      output.c.a = 1.0;
    output.c.xyz = Texture.Sample(TextureSampler, coord).xyz;
    return output;
}

#endif
Also here is the shader for lens effect. Gives Crysis 2 feeling in some games.

shader.fx
Code:
/*
    Lens shader
*/

#ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency

Texture2D Texture;
SamplerState TextureSampler;

struct PS_INPUT
{
    float4 p : SV_Position;
    float2 t : TEXCOORD0;
};

struct PS_OUTPUT
{
    float4 c : SV_Target0;
};

PS_OUTPUT ps_main(PS_INPUT input)
{
    PS_OUTPUT output;
    float2 pos = input.t;

    float k = -0.6; // lens distortion coefficient
    float kcube = 0.45;  // cubic distortion value
    
    float r2 = (pos.x-0.5) * (pos.x-0.5) + (pos.y-0.5) * (pos.y-0.5);      
    float f = 0;

    //only compute the cubic distortion if necessary
    if (kcube == 0.0) f = 1 + r2 * k;
    else f = 1 + r2 * (k + kcube * sqrt(r2));
    
    // get the right pixel for the current position
    float2 coord = float2(f*(pos.x - 0.5) + 0.5, f*(pos.y - 0.5) + 0.5);

    output.c.a = 1.0;
    output.c.xyz = Texture.Sample(TextureSampler, coord).xyz;
    return output;
}

#endif