• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Site › Dolphin Patches (Archive) v
« Previous 1 ... 3 4 5 6 7

Is it not possible to use the % operator in the custom shaders?
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Is it not possible to use the % operator in the custom shaders?
03-02-2010, 09:15 PM
#1
Dr. Spankenstein
Unregistered
 
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?
03-03-2010, 10:04 AM
#2
skid Offline
skidau / skid_au
**********
Developers (Some Administrators and Super Moderators)
Posts: 2,004
Threads: 8
Joined: Aug 2009
drk says try using fmod
Find
03-03-2010, 11:02 AM
#3
Dr. Spankenstein
Unregistered
 
(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.
03-03-2010, 01:05 PM (This post was last modified: 03-03-2010, 01:06 PM by skid.)
#4
skid Offline
skidau / skid_au
**********
Developers (Some Administrators and Super Moderators)
Posts: 2,004
Threads: 8
Joined: Aug 2009
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.
Find
03-03-2010, 10:25 PM
#5
Dr. Spankenstein
Unregistered
 
(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.
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode