Page 1 of 1

Help a n00b understand shaders!

Posted: Mon Dec 07, 2009 18:34
by Janitor
So Graf's implementation of custom shaders seems like it could be useful, but unfortunately I don't have a clue how to start using them, or even what could be accomplished with them. So here are some questions in no particular order:

(1) The syntax appears to be GLSL specific. Could one potentially borrow code from other open source graphics programs to achieve certain effects? For example, one effect I'd like to see if it is possible would be to add bloom/HDR to my custom skyboxes.

(2) I think it's a safe assumption that abusing shaders or using them extensively could cause some performance issues? Is this a correct understanding?

(3) I've seen it mentioned that reflective effects could be achieved. Could it also be possible to apply reflective or shiny surfaces to model skins? Could it be possible to make brightmaps for model skins?

(4) Graf has an example shader in GZDoom.pk3 now, can someone give me an idea of what exactly this does?

(5) In general, what are some of the things that can be done with these custom shaders? what are their limitations?

Re: Help a n00b understand shaders!

Posted: Mon Dec 07, 2009 19:44
by Logan MTM
ShadersExample.zip
(691 Bytes) Downloaded 127 times

Re: Help a n00b understand shaders!

Posted: Mon Dec 07, 2009 19:48
by Graf Zahl
Janitor wrote:So Graf's implementation of custom shaders seems like it could be useful, but unfortunately I don't have a clue how to start using them, or even what could be accomplished with them. So here are some questions in no particular order:

(1) The syntax appears to be GLSL specific. Could one potentially borrow code from other open source graphics programs to achieve certain effects? For example, one effect I'd like to see if it is possible would be to add bloom/HDR to my custom skyboxes.
The problem here is that to add such effects it's not enough to add some shader code. It needs support from within the engine. And frankly, I have no idea how to do that. I'm not a graphics effects expert, unfortunately.
(2) I think it's a safe assumption that abusing shaders or using them extensively could cause some performance issues? Is this a correct understanding?
Yes, shader abuse can easily bring down performance. Extensive use of shaders does not. If you use a modern graphics card (GF8xxx or better, ATI Radeon HD) everything is rendered using shaders.

(3) I've seen it mentioned that reflective effects could be achieved. Could it also be possible to apply reflective or shiny surfaces to model skins? Could it be possible to make brightmaps for model skins?
Reflectiveness is, like HDR/Bloom, something that needs support from within the engine so it can't be done easily.

Brightmaps for model skins are technically doable but it needs an extension to MODELDEF to work,
(4) Graf has an example shader in GZDoom.pk3 now, can someone give me an idea of what exactly this does?
It's just an alternate warping algorithm, nothing special.


(5) In general, what are some of the things that can be done with these custom shaders? what are their limitations?
They are mostly for texture manipulation. So you can do all kinds of warping effects or lighting effects.

Re: Help a n00b understand shaders!

Posted: Mon Dec 07, 2009 20:16
by Janitor
Thanks for the fast replies!

Alright, well, this at least gives me a place to start. I think making shiny things is something worth looking into, I'll see what I can do on that. Is it an engine limitation in the sense that it's 100% not at all possible, or possible but in the kind of way that's comparable to pulling teeth? In terms of texture manipulation, could this be used to make a kind of 'ripple' effect for liquid surfaces?

Re: Help a n00b understand shaders!

Posted: Tue Dec 08, 2009 18:10
by Janitor
Double post :S

So here's a link that contains some files that create a rippling effect on textures using GLSL. I figure I can just move this code into my /shaders directory in my PK3 to create a kind of rippling effect for water surfaces:

http://lists.apple.com/archives/quartzc ... 00009.html

I havent tried this yet, so I have no idea if this will actually work. I'm not going to have the chance to try this until later tonight. If anyone has the opportunity to try this, or if anyone is familiar enough with GLSL to let me know what I might need to make this work, that would be awesome

Re: Help a n00b understand shaders!

Posted: Tue Dec 08, 2009 18:13
by Graf Zahl
Sorry, no. That thing seems to be a fullscreen postprocessing effect.

Besides, it uses 2 textures and not in a way that's compatible with GZDoom.

Re: Help a n00b understand shaders!

Posted: Wed Dec 09, 2009 4:38
by DaniJ
Although, it should be possible to implement something similar but working in texture space rather than screen space. You could get around the texture issue by combining both textures in one, after all you're doing the texel look up in a shader so you can handle the wrapping manually. Not an easy one to start with though I will say.