View unanswered posts | View active topics It is currently Mon Nov 18, 2019 11:55 pm



This topic is locked, you cannot edit posts or make further replies.  [ 158 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next
The unofficial BSNES pixel shader thread 
Author Message
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post The unofficial BSNES pixel shader thread
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.



Mon Mar 24, 2008 12:43 pm
Profile
Regular
User avatar

Joined: Thu Jul 29, 2004 8:55 am
Posts: 265
Location: The Netherlands
Reply with quote
Post 
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"


Mon Mar 24, 2008 1:02 pm
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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.



Mon Mar 24, 2008 1:38 pm
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
EDIT: Bet me to it, Verdauga Greeneyes

Quote:
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


Mon Mar 24, 2008 1:38 pm
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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.


Mon Mar 24, 2008 1:46 pm
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Quote:
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.


Quote:
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.


Mon Mar 24, 2008 1:54 pm
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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.


Mon Mar 24, 2008 2:25 pm
Profile
Hazed
User avatar

Joined: Tue Nov 08, 2005 12:40 pm
Posts: 96
Reply with quote
Post 
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.



Mon Mar 24, 2008 6:28 pm
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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 :)


Mon Mar 24, 2008 6:45 pm
Profile
Hazed
User avatar

Joined: Tue Nov 08, 2005 12:40 pm
Posts: 96
Reply with quote
Post 
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.


Mon Mar 24, 2008 6:47 pm
Profile
Reply with quote
Post 
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


Mon Mar 24, 2008 6:58 pm
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Quote:
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().

Quote:
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.....


Mon Mar 24, 2008 10:13 pm
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Quote:
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.


Tue Mar 25, 2008 1:33 pm
Profile
Trooper
User avatar

Joined: Mon Feb 20, 2006 3:11 am
Posts: 394
Location: Space
Reply with quote
Post 
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.

_________________
Kega Fusion Supporter | bsnes Supporter | Regen Supporter


Tue Mar 25, 2008 4:47 pm
Profile
Buzzkill Gil

Joined: Wed Jan 12, 2005 7:14 pm
Posts: 4248
Reply with quote
Post 
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!


Tue Mar 25, 2008 8:50 pm
Profile
Reply with quote
Post 
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.


Tue Mar 25, 2008 10:07 pm
Seen it all
User avatar

Joined: Mon Jan 03, 2005 5:04 pm
Posts: 2302
Location: Germany
Reply with quote
Post 
A GoodSNES ROM name! :o

_________________
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list


Tue Mar 25, 2008 10:30 pm
Profile WWW
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
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.


Tue Mar 25, 2008 11:18 pm
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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)


Tue Mar 25, 2008 11:56 pm
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Code:
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.

Quote:
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.



Quote:
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.


Wed Mar 26, 2008 12:11 am
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Update 2 uploaded.


Wed Mar 26, 2008 12:24 am
Profile
Regular
User avatar

Joined: Tue Mar 07, 2006 10:32 am
Posts: 347
Location: The Netherlands
Reply with quote
Post 
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.


Wed Mar 26, 2008 1:50 am
Profile
has wat u liek
User avatar

Joined: Tue Sep 11, 2007 2:54 pm
Posts: 559
Location: Banland.
Reply with quote
Post 
Quote:
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.


Wed Mar 26, 2008 4:23 am
Profile
Hazed
User avatar

Joined: Tue Nov 08, 2005 12:40 pm
Posts: 96
Reply with quote
Post 
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.


Wed Mar 26, 2008 8:35 am
Profile
Trooper
User avatar

Joined: Tue Apr 19, 2005 11:08 pm
Posts: 376
Location: DFW area, TX USA
Reply with quote
Post 
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 ;)


Wed Mar 26, 2008 9:02 am
Profile WWW
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 158 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.