Simple Shader for Simple Sprite

Thu Nov 04, 2021 7:01 pm

Hi everyone!
What is the way to make any shader affect some Sprite like "TESTX0"? If possible of course!

Thank you all!

Re: Simple Shader for Simple Sprite

Fri Nov 05, 2021 2:55 pm

It is done by a reasonably simple GLDEFS entry.

This is one that I found in some mod or other:
Code:
HardwareShader sprite TRL1A0
{
   shader "shaders/glowscan.fp"
   Speed 3.0
   texture glowscan "ShaderTex/glowscan/glowscn1.jpg"
}

The individual parameters (the stuff inside the {}) will vary from shader to shader, but the above seems to be the basic format.

Re: Simple Shader for Simple Sprite

Fri Nov 05, 2021 6:29 pm

GZDoom Shader support allow me to make something like that?

https://lindenreidblog.com/2018/03/05/h ... -tutorial/

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 4:36 am

No. GZDoom shaders cannot currently do anything other than sample their own textures - they absolutely cannot be used to draw a model on top of everything else, and can't sample the background color to distort where it gets drawn.

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 6:17 am

Model? There is no model in that example but images. :?

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 6:50 am

... the images in the example represent models. Regardless, the latter point is what's important: Model, sprite, or texture, the shader can't get the information from the pixel behind it.

8-)

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 7:04 am

Do you mean "gzdoom shader can't"?
Just to get things right. GLSL Shader can BUT gzdoom doesn't. Like Gzdoom PBR works with some limitations, Gzdoom Hardware Shaders also has limitations.
Oooh :(

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 7:10 am

As far as I know, in GZDoom, your two options would be:
1) a shader that affects only the visible pixels of the sprite - and nothing behind it (as people have said), even if what is behind it is viewed through any transparent pixels that might be present in the sprite (which, fortunately for me, is actually what I wanted in the sprites I was trying things out with)

2) a shader that affects the whole screen with (a post process shader). I think Blade of Agony might even have a whole screen heat-shimmer shader.

As for what is available in GLSL but not in GZDoom, sorry, I have no idea.

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 7:26 am

1) - I did, since 2009 :wink:
Spoiler:


2) - Yuck

3) - That IS what i need to know cus i am considering to pay a pro dude to make this Shader for me.

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 8:10 am

If material shaders could sample the pixels of the world behind it, we would already have gotten Enjay's favorite water distortion effect by now... ;)

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 8:59 am

Maybe one day. :lol:

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 9:40 am

Logan MTM wrote:Do you mean "gzdoom shader can't"?
Just to get things right. GLSL Shader can BUT gzdoom doesn't. Like Gzdoom PBR works with some limitations, Gzdoom Hardware Shaders also has limitations.
Oooh :(

"GZDoom shaders" are still GLSL. Rendering APIs¹ specify that reading from the framebuffer² you're rendering to is undefined behaviour, so there's nothing GZDoom can do about this.
Every single thing that does an effect like this (including the very article you linked) copies the current contents of the framebuffer into a separate texture, then use that to render the effect.
This would be unfeasible to do during actor rendering, and would certainly hurt performance- besides, you need to apply the effect after everything's been rendered, so doing this with an actor wouldn't work at all anyway.

¹ (e.g., OGL, Vk, D3D, Metal, etc.)
² (i.e., image(s))

[Edit] Improved the wording of some phrases.
Last edited by phantombeta on Sat Nov 06, 2021 10:03 am, edited 1 time in total.

Re: Simple Shader for Simple Sprite

Sat Nov 06, 2021 9:58 am

Thank you guys! :mrgreen:

Wondering How FillSphectre Works... :!: