PDA

View Full Version : [TEC] Pixel Shader


onelifecrisis
05-17-09, 01:43 AM
So a few months ago I was modding Oblivion and I discovered that by combining the official SDK-type-thing with a modder-made modding tool :doh: I could write my own pixel shader and have the game use it! :rock: I'd never written a pixel shader before but it wasn't too difficult and I managed to get some pretty cool effects going even without really knowing much about it. So it got me wondering... can this be done with other games? Is there some sort of tool out there that lets me tell D3D to apply my own personal post-processing effect to every frame before it's sent to the screen? If anyone knows anything about this and can point me to places where I can find or read about such tools, I'd really appreciate it!

Hitman
05-17-09, 02:21 AM
I can't help you with that, but I just wanted to ask what does SH3 use pixel shader for? :DL I know SH4 uses it for the radar display, but SH3?

onelifecrisis
05-17-09, 02:28 AM
I can't help you with that, but I just wanted to ask what does SH3 use pixel shader for? :DL I know SH4 uses it for the radar display, but SH3?

I've no idea. AFAIK the only post-processing effect in SH3 is that "bloom" thing you get by pressing Shift+PgUp, but I don't know whether that's done with a pixel shader. Perhaps you misunderstood me: I don't want to edit existing pixel shader effects, I want to add new post-processing effects. The thing about post-processing is that simple effects are possible without knowing anything about the game engine/variables. It's like using photoshop. You can take the finished frame and apply some effect to it (e.g. glow, or black and white, or whatever you can code) based soley on the information in the frame buffer.

Hitman
05-17-09, 03:18 AM
Wow excellent :o Post process filters and sun light reflection effects in the water in SH4 are on of the key visual differences between both games ... if you could add one that would already be amazing :yeah:

The other major grip I have with SH3 is the 3D models of the crew, which for me have always bee inmersion killers...but Racerboy suggested that it *might* be possible to port them over from SH4 to SH3 :D

Anvart
05-17-09, 03:21 AM
In SH4 use of HLSL files is hardcoded (and by name)...

onelifecrisis
05-17-09, 03:26 AM
Wow excellent :o Post process filters and sun light reflection effects in the water in SH4 are on of the key visual differences between both games ... if you could add one that would already be amazing :yeah:

Heh, definitely no way to do that I'm afraid. Sunlight on the water would require much more information than just what is in the frame buffer. No, I'm talking about very simple post-processing effects such as simple bloom methods, desaturated colours, simple cel shaders, that sort of thing. You can't do anything fancy using only the frame buffer.

Hitman
05-17-09, 03:40 AM
Yes I know reflections are hardcoded, sorry I just listed the main things I see as sifferences and wanted to say that if one of them (post process) can be implemented in SH3 that would already improve a lot the looks of the game :yep:

Do you have SH4? The post process filters there are apparently simple, but do a lot to improve image eye-candy. Contrast is higher, colours are somehow deeper and livelier...I really like it a lot and would love to see it in SH3 :DL

Anvart
05-17-09, 03:46 AM
...

Do you have SH4? The post process filters there are apparently simple, ...
Only user adjustable part ...

onelifecrisis
05-17-09, 03:55 AM
No, I don't have SH4.

Contrast is higher, colours are somehow deeper and livelier...

Yeah, you can do that sort of thing with just the frame buffer. :yep:

But I dunno how to tack-on the pixel shader. I doubt it's possible, but you never know. I mean if someone can make a D3D hack that allows adjustable resolution in SH3... :hmmm:

Letum
05-17-09, 03:55 AM
I might have an idea or two....
What is SH3's native directx version?

onelifecrisis
05-17-09, 03:57 AM
I might have an idea or two....

:DL

What is SH3's native directx version?

:doh:

Umm... 9 point something?

Letum
05-17-09, 04:27 AM
No, sorry.
I didn't get anywhere.

Hitman
05-17-09, 04:30 AM
I might have an idea or two....
What is SH3's native directx version?

The hi-res tweak for SH3 does not specify, it just says DX 9, probably Seeadler will be able to tell with more precission. That said, and come to think of it, if the screen resolution instructions can be "intercepted" and resized via an external DLL, as the hi-res tweak does, then I suppose that the same technic can be used to change other parameters, right? :DL

Another idea (Brainstorming): If the currently built-in AA modifier (SHIFT+Page Up/down) is using some sort of post processing filter, may be the parameters for it are somewhere in an external file. If we find this file, we could use the in-game built tool to provide other effects :hmmm:

onelifecrisis
05-17-09, 04:52 AM
My googling is starting to maybe get somewhere (http://www.codeguru.com/cpp/g-m/directx/directx8/article.php/c11453) but I'm searching blindly here.

Letum, care to at least spell out the basics of whatever your idea was? :DL

Letum
05-17-09, 05:00 AM
I was having a play about with the ENB Seris (http://boris-vorontsov.narod.ru/index_en.html). The files there have been
known to work with a variety of DirectX games that they where not designed
for. SH3, it seams, is not one of them.

Anvart
05-17-09, 05:46 AM
...
if the screen resolution instructions can be "intercepted" and resized via an external DLL, as the hi-res tweak does, then I suppose that the same technic can be used to change other parameters, right? :DL

It's called hooking ..., right?

Another idea (Brainstorming): If the currently built-in AA modifier (SHIFT+Page Up/down) is using some sort of post processing filter, may be the parameters for it are somewhere in an external file. If we find this file, we could use the in-game built tool to provide other effects :hmmm:
... hardcoded in executable files ... hook this call and execute new dll, right?
Ну ... можно и штаны через голову одевать ...
If interestingly, you can use (for example) 3D Ripper DX for capture some shaders code (SP v. 1.1) from memory ...

Letum
05-17-09, 08:06 AM
I ran 3dripperDX and the shaders output file gets longer when the shift+pgup
mode is on, so yes, it is a post-processed shader effect.

Letum
05-17-09, 08:17 AM
Whilst we are innovating a little....
I came across SH3's water tile.
Does anyone know if this is stored in a .dat file? Which one?

http://www.b3tards.com/u/57a418c694bc7c6296b3/water.jpg

Hitman
05-17-09, 11:25 AM
Mmmm the model for the waves is stored somewhere, recenly Seeadler or OLC (Can't remember who) showed a polygon model of the SH3 sea, and it was exactly what you are showing, but without texture. :hmmm:

Seeadler
05-17-09, 12:55 PM
All of this can be done theoretically with DirectX API Hooking.
Theoretically, because DirectX programs does not always follow the guidelines by Microsoft, because programmers may have used certain techniques to bypass DX functions to obtain a speed advantage in their games.

If someone is interested in such things, a tool for Morrowind use hooking techniques and is open-source:
http://morrgraphext.wiki.sourceforge.net/Misc

The mentioned Oblivion Shader Editor is also open-source:
http://timeslip.chorrol.com/

onelifecrisis
05-18-09, 04:54 PM
Thanks Seeadler.

I found this (http://www.gamedev.net/community/forums/topic.asp?topic_id=359794). Could it be used? If so, any idea how to change it to apply a custom pixel shader? Looking at that code I'm completely lost. :-?

Seeadler
05-19-09, 08:20 PM
I found this (http://www.gamedev.net/community/forums/topic.asp?topic_id=359794). Could it be used?
I've tested it with SH3 but it don't work because these applications manually load D3D9.dll via LoadLibrary as described as limitations in the linked thread.

SH3 needs a d3d9.dll wrapper instead of a DX dll injection, a d3d9.dll wrapper like the one for the high-res fix. This wrapper must done the same work for high-res (otherwise this feature get lost) and the desired custom shader functions.

d3d9.dll wrapper example:
http://www.codeguru.com/cpp/g-m/directx/directx8/article.php/c11453

Seeadler
05-23-09, 11:49 AM
I've got a very basic D3D hook in work, it's not stable, sometimes the dll injection don't work (particularly with Vista) but I can overwrite the BeginScene() and EndScene() funtion a for example. To implement post-processing effects, a little bit more must be done, but yes it seems be possible.:smug:

http://foto.arcor-online.net/palb/alben/91/3063991/1280_6537326162646161.jpg

onelifecrisis
05-23-09, 09:07 PM
Impressive! :DL

johan_d
06-12-09, 09:44 AM
Nice, then a postprocess effect to let the scene look like Das Boot or perhaps old movies, and we are set!

Azrael Valedhel
07-26-09, 09:54 AM
So... is anyone doing anything with this? :) It could be pretty cool to e.g. change colors of the scene. Make some kind of bloom effect maybe?

flakmonkey
07-26-09, 01:16 PM
Nice, then a postprocess effect to let the scene look like Das Boot or perhaps old movies, and we are set!


Just a side note, most modern lcd monitors come with a bunch of effects like b&w/sepia/cartoon etc, its pretty easy to get that movie look by applying one of these effects and tweaking the contrast.

Anvart
07-26-09, 02:25 PM
one-two of tonns ...
DX-Tweaker 2005.1
3D-Analyze 2.36b