Dolphin, the GameCube and Wii emulator - Forums

Full Version: GLSL Shaders - CRT Emulating old televisions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Yeah.. no. Read the wiki page on the dolphin wiki on gcode again, it describes that you need to do it differently.
Are you referring to the Microsoft.cpp.x64.User?

I don't have any of those folders in my project, how are they added?

[Image: VS2010_3.PNG]
You probably haven't "Open[ed] the Property Manager" (somewhere in the view menu maybe?).
In Visual C++ 2010 Express it's "Project->Properties" or [ALT]+[F7]
Found it in hiding in 'Other Windows':

View -> Other Windows -> Property Manager

Everything now builds absolutely fine with no errors (just warnings) Smile

Thanks for taking the time to help out with this.

I'll look into the converting the shader when I get some spare time next weekend.
Can anyone get this to openGL shader to work with Dolphin?

Code:
// lerp = mix
// #define works correctly

#define PI 3.14159265f        

uniform samplerRECT samp0 : register(s0);

uniform float ScanlineAmount = 2.0f;
uniform float ScanlineScale = 0.2f;
uniform float ScanlineBrightScale = 1.0f;
uniform float ScanlineBrightOffset = 1.0f;
uniform float ScanlineOffset = 0.0f;
uniform float ScanlineHeight = 1.0f;

void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
{
    float4 BaseTexel = texRECT(samp0, uv0).rgba;

    float RawHeight = 1080.0f;

    float2 ScanCoord = uv0;

    // -- Scanline Simulation --
    float InnerSine = ScanCoord.y * RawHeight * ScanlineScale;
    float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * RawHeight);
    float3 ScanBrightness = mix(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAmount);
    float3 Scanned = BaseTexel.rgb * ScanBrightness;

    // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
    float3 Floor = float3(0.0f, 0.0f, 0.0f);    
    Scanned = Floor + (1.0f - Floor) * Scanned;

    ocol0 = float4(Scanned, BaseTexel.a);
    //ocol0 = BaseTexel;
}

I can get it to work outside of Dolphin (with HLSL and XNA) but no luck so far with GLSL. It is a simple as I could make for scanlines.
I know what the problem is....

Dolphin doesn't like all those uniform parameters. This will work:

Code:
// lerp = mix
// #define works correctly

#define PI 3.14159265f        

uniform samplerRECT samp0 : register(s0);

void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
{
    float4 BaseTexel = texRECT(samp0, uv0).rgba;

    float RawHeight = 480.0f;

    float2 ScanCoord = uv0;

float ScanlineAmount = 2.0f;
float ScanlineScale = 0.2f;
float ScanlineBrightScale = 1.0f;
float ScanlineBrightOffset = 1.0f;
float ScanlineOffset = 0.0f;
float ScanlineHeight = 1.0f;

    // -- Scanline Simulation --
    float InnerSine = ScanCoord.y * RawHeight * ScanlineScale;
    float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * RawHeight);
    float3 ScanBrightness = mix(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAmount);
    float3 Scanned = BaseTexel.rgb * ScanBrightness;

    // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
    float3 Floor = float3(0.0f, 0.0f, 0.0f);    
    Scanned = Floor + (1.0f - Floor) * Scanned;

    ocol0 = float4(Scanned, BaseTexel.a);
    //ocol0 = BaseTexel;
}
I just get a black screen when I use this shader.
Try changing the following settings:

float ScanlineScale = 0.2f;
float ScanlineBrightScale = 1.0f;
float ScanlineBrightOffset = 1.0f;
float ScanlineHeight = 1.0f;

A sensible range for each one is [0, 1]

I can post screens of different settings at the weekend if that helps?
Pages: 1 2 3 4