The unofficial BSNES pixel shader thread

Anything else related to bsnes goes there.
Locked
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

The unofficial BSNES pixel shader thread

Post by mudlord »

Okay here's where all discussions on hardware based filters using shaders for BSNES are based. (whether they are technically based or not)

For those that don't know, I worked out a simple method to get shaders working under BSNES (any version). All it involves is this pack, and the enclosed patch..

To use shaders:

* Apply the patch
* Copy one shader file (shader.fx) to the same directory as BSNES.
Last edited by mudlord on Thu Jun 05, 2008 11:51 am, edited 5 times in total.
ShadowFX
Regular
Posts: 265
Joined: Thu Jul 29, 2004 8:55 am
Location: The Netherlands

Post by ShadowFX »

Sorry for interruping this thread but I would like to know what a shader exactly is/does, and what the difference is between the shader filters in bsnes and the filters used in, say ZSNES.
"Change is inevitable; progress is optional"
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

The only difference between a shader and a normal filter is that a shaders are computed using your graphics card's shading units rather than your CPU. This means you need a graphics card that supports shader version 1.4 or higher to use them. The advantage is, of course, to offload the task of filtering to the GPU, leaving your CPU to deal with the task of emulating the SNES (and running your operating system :P).

Edit: changed 'version 2 or higher' to 'version 1.4 or higher'.
Last edited by Verdauga Greeneyes on Mon Mar 24, 2008 1:47 pm, edited 1 time in total.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

EDIT: Bet me to it, Verdauga Greeneyes

The only difference between a shader and a normal filter is that a shaders are computed using your graphics card's shading units rather than your CPU. This means you need a graphics card that supports shader version 2 or higher to use them.


Just a note, you can do Shader Model 1.4 shaders :P
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

mudlord wrote:Just a note, you can do Shader Model 1.4 shaders :P


Aah, so that's the version I was looking for :P I tried 1.0, 1.1, 1.2 and 1.3.. I guess it only matters for the simplest of shaders, though. Should I make my scanline shader use PS 1.4?

Edit: by the way, do you think it would be possible to add debugging messages to the implementation? Right now it just fails silently, which can be frustrating for more complex shaders.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

by the way, do you think it would be possible to add debugging messages to the implementation? Right now it just fails silently, which can be frustrating for more complex shaders.


Yeah, okay, I'll make a simple logger that logs to a logfile the execution.


Should I make my scanline shader use PS 1.4?


If you can do shaders in DX8.1 shader style ASM, be my guest. Otherwise its best to use PS 2.0, if you rather use plain HLSL instead of ASM.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

I've done ARB shader programs before, so I should be able to figure it out - need some time to read the reference pages though.
Palin
Hazed
Posts: 96
Joined: Tue Nov 08, 2005 12:40 pm

Post by Palin »

Has anyone done any side by side testing to see what, if any, difference this is making for performance/quality?

There's a little voice in my head that says "this sounds like a cool idea" but I'm a sucker for placebos.
Last edited by Palin on Mon Mar 24, 2008 6:47 pm, edited 2 times in total.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

Palin wrote:Has anyone done any side by side testing to see what, if any, difference this is making for performance/quality?

There's a little voice in my head that says "this sounds like a cool idea" but I'm a sucker for placebos.


In general mudlord's wrapper DLL seems to be slowing bsnes down by about 2fps for me. That said, as long as the graphics card can perform the filtering fast enough, that should be the extent of the speed hit; whereas enabling the more complex filters in bsnes slows it down significantly. Shaders also offer the advantage that they are distributed separately from bsnes, so licensing should be less of an issue. For instance, I should be able to whip up a 2xSaI shader pretty quickly. It's still worth talking about licensing issues, but it won't effect bsnes directly. To get back to your question, speed-wise it offers an advantage iff (if and only if) we can make fast shaders for the more complex filters; right now that makes it hard to test :)
Palin
Hazed
Posts: 96
Joined: Tue Nov 08, 2005 12:40 pm

Post by Palin »

Ok, after downloading this looks like a sort of proof of concept. I'm impressed. I do suffer about an 8% performance hit when I use them though.

Image

Haha, I need to play all of my games like this.
ZH/Franky

Post by ZH/Franky »

Palin wrote:Ok, after downloading this looks like a sort of proof of concept. I'm impressed. I do suffer about an 8% performance hit when I use them though.

Image

Haha, I need to play all of my games like this.

Whoa, talk about simulating a "play while drunk" situation :P
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

I do suffer about an 8% performance hit when I use them though.


There's little I can do about that, unfortunately.

That said, for the people interested in how it works in detail, it uses derived classes of IDirect3DDevice9 and IDirect3D9, with modified functions for Present(), CreateDevice(), SetFVF(), and SetRenderTarget().

Whoa, talk about simulating a "play while drunk" situation


I'm hoping to add a timer uniform to allow for realtime effects, such as wave cycling.....
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

To get back to your question, speed-wise it offers an advantage iff (if and only if) we can make fast shaders for the more complex filters; right now that makes it hard to test


I managed to make the DLL popup a small error message box when theres a error in shader syntax, pointing out the exact issue :P . Which should help greatly in debugging....My plans though in making a logfile weren't so successful (the config file will be created but text wouldn't be written. :( ) for some insanely odd occasion, when my config file class worked fine in a test EXE....

I'll upload the updated DLL when I can.
King Of Chaos
Trooper
Posts: 394
Joined: Mon Feb 20, 2006 3:11 am
Location: Space

Post by King Of Chaos »

Palin wrote:Ok, after downloading this looks like a sort of proof of concept. I'm impressed. I do suffer about an 8% performance hit when I use them though.

Image

Haha, I need to play all of my games like this.

Kinda reminds me of the drunk/drugged Yoshi in SMW2.
Gil_Hamilton
Buzzkill Gil
Posts: 4267
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

King Of Chaos wrote:
Palin wrote:Ok, after downloading this looks like a sort of proof of concept. I'm impressed. I do suffer about an 8% performance hit when I use them though.

Image

Haha, I need to play all of my games like this.

Kinda reminds me of the drunk/drugged Yoshi in SMW2.
I said it in the monster thread, and I'll say it here...

Touch Fuzzy, get dizzy!
byuu

Post by byuu »

Gil_Hamilton wrote:
King Of Chaos wrote:
Palin wrote:Ok, after downloading this looks like a sort of proof of concept. I'm impressed. I do suffer about an 8% performance hit when I use them though.

Image

Haha, I need to play all of my games like this.

Kinda reminds me of the drunk/drugged Yoshi in SMW2.
I said it in the monster thread, and I'll say it here...

Touch Fuzzy, get dizzy!


Sorry, just wanted to get in on quoting the large JPEG.

While we're at it ...

Image

Image

There we go, much better.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

A GoodSNES ROM name! :o
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Update one up.

Includes a new wave shader with dynamic alteration.

Word of warning about this shader: It can mess with your head in games like SMW. Please don't blame me if you keep losing.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

mudlord wrote:Update one up.

Includes a new wave shader with dynamic alteration.

Word of warning about this shader: It can mess with your head in games like SMW. Please don't blame me if you keep losing.


Hehe, trippy; thanks for the update. How does the new Timer work? I looked at your wave shader, but all it seems to do is initialise it to 1. Does this assignment happen only once, at the start of execution, or is it a periodic thing? Does the Timer increase every frame, and does it use modulus or does it simply overflow from time to time?

Oh, and could you put a list of Uniforms in either the first post or a readme in the shaderpack? (perhaps that would be the best place to answer my questions about the timer, too)
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Code: Select all

effect->SetFloat(timehandle,Timer);

int nTime = timeGetTime();
nTimeElapsed += nTime - nTimeStart;
nTimeStart = nTime;
if(nTimeElapsed > 100)
{
nTimeElapsed = 0;
Timer += 0.01f;
}


Thats basically the gist. All it does is increment every time Present() is called, every 100 milliseconds.

looked at your wave shader, but all it seems to do is initialise it to 1. Does this assignment happen only once, at the start of execution, or is it a periodic thing?


Yup, its initialised at the start of execution.



Oh, and could you put a list of Uniforms in either the first post or a readme in the shaderpack? (perhaps that would be the best place to answer my questions about the timer, too)


Sure.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Update 2 uploaded.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

Many thanks for the readme, should help a bundle.

'This contains the results of the previous pass. In the first pass, it will contain the results of the last but one pass from the previous frame.'
So.. technically, we should be able to interpolate two subsequent frames? Perhaps a topic of future discussion.. (though I bet we'd need at least a framerate counter or some such to make anything useful with it)

One last request, because I forgot it wasn't in there (you posted the list before on bsnes' mother thread): could you add a uniform that holds the size of tex1? tex2's size is the screen resolution, I presume, which is already provided for.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

One last request, because I forgot it wasn't in there (you posted the list before on bsnes' mother thread): could you add a uniform that holds the size of tex1? tex2's size is the screen resolution, I presume, which is already provided for.


Added.
Palin
Hazed
Posts: 96
Joined: Tue Nov 08, 2005 12:40 pm

Post by Palin »

Just curious; someone mentioned a while back that HQ2X is too complicated to implement as a shader, is that true? Not that I expect you to tackle a monster like that, but it'd be really damn awesome. Especially awesome if it's combined with OpenGL renderer shader support in the near future.
FirebrandX
Trooper
Posts: 376
Joined: Tue Apr 19, 2005 11:08 pm
Location: DFW area, TX USA
Contact:

Post by FirebrandX »

I'd very much like to try a scanline shader if someone can make it.

BTW I notice no "sharpening" of the image when I use the sharpen shader. Perhaps it doesn't work with point filtering?

I did confirm the shaders do work on my system by testing the drunken wave one. That's a Vista 64-bit test done for ya ;)
Locked