Dolphin, the GameCube and Wii emulator - Forums

Full Version: Is it not possible to use the % operator in the custom shaders?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Dr. Spankenstein

Hi folks,

I've got a working shader that creates a scanline effect over an image in Cg. The problem is that the modulo/remainder operator doesn't seem to work when using the shader with Dolphin.

Can anyone please explain why this is the case?
drk says try using fmod

Dr. Spankenstein

(03-03-2010, 10:04 AM)skid Wrote: [ -> ]drk says try using fmod

fmod works correctly, thank you.

Is it possible to obtain the following in a shader:

1) The image input size (Wii game's input resolution)

2) The texture size for samplerRECT (E.g. 512x512, 64x64 etc.)

in order to line up the scanlines correctly?

Thanks.
The following works with Force 4:3 mode at 640x480:

Code:
#define LINES_ON      1
#define LINES_OFF     1
#define OFF_INTENSITY 0.5

uniform samplerRECT samp0 : register(s0);

void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
{
    float y_InputSize = 480;
    float y_OutputSize = 480;
    float y_TextureSize = 480;

       float pixelRatio = 20;    //y_OutputSize  * (y_TextureSize / y_InputSize);    

    float mod = fmod(floor(uv0.y * pixelRatio), LINES_ON + LINES_OFF) < LINES_ON ? 1.0 : OFF_INTENSITY;

       ocol0 = texRECT(samp0, uv0) * mod;
}

This code is adopted from an HLSL shader by someone other than myself.
Don't know, doc.

How about making each scanline 1 pixel tall and drawn on every other line? Not a true scan-line shader but should look pretty good. At least we would get uniform thickness and spacing.

Dr. Spankenstein

(03-03-2010, 01:05 PM)skid Wrote: [ -> ]Don't know, doc.

How about making each scanline 1 pixel tall and drawn on every other line? Not a true scan-line shader but should look pretty good. At least we would get uniform thickness and spacing.

That won't work as the image is still scaled to the screen.

Changing:

Code:
float mod = fmod(floor(uv0.y * pixelRatio), LINES_ON + LINES_OFF) < LINES_ON ? 1.0 : OFF_INTENSITY;

to

Code:
float mod = fmod(uv0.y, 2) < 1 ? 1.0 : OFF_INTENSITY;

does what you ask but doesn't work due to image scaling.