Shader Help Thread
Moderators: GZDoom Developers, Raze Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
-
- Posts: 11
- Joined: Sun May 10, 2015 4:33 pm
- Graphics Processor: nVidia with Vulkan support
Re: Shader Help Thread
Ah I see... I've clearly got a lot to learn. I hadn't touched most of these newer features yet. Thanks again!
lol wow the effect is way too fast as I had it originally! Here's a more subtle version in case anyone else is looking for a simple underwater warp shader
lol wow the effect is way too fast as I had it originally! Here's a more subtle version in case anyone else is looking for a simple underwater warp shader
You do not have the required permissions to view the files attached to this post.
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Shader Help Thread
Yeah I think I went cross-eyed the first timelol wow the effect is way too fast as I had it originally!
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Shader Help Thread
I wonder if someone can explain how the alpha property works for texture shaders? It's always seemed non-linear to me and impossible to counteract. Something I've just tried doing is actually causing me to be suspicious it's a bug but I want to make sure I'm not missing something.
So I have a 3D floor with the line opacity property set to 254. I have the software fuzz shader being applied to it's texture, multiplying the pixels' alpha (ie. colour.a) by values between 0.1875 and 0.65625. But what I get are low alpha values being shunted to zero (or lower?) instead. Previously I've assumed it was my error and just abandoned projects until I can figure it out, only now I'm using someone else's proven code verbatim.
You can see the detail is greatly reduced in the bridge compared to the spectre even though they share identical code. Are we supposed to treat colour.a differently in custom shaders?
So I have a 3D floor with the line opacity property set to 254. I have the software fuzz shader being applied to it's texture, multiplying the pixels' alpha (ie. colour.a) by values between 0.1875 and 0.65625. But what I get are low alpha values being shunted to zero (or lower?) instead. Previously I've assumed it was my error and just abandoned projects until I can figure it out, only now I'm using someone else's proven code verbatim.
You can see the detail is greatly reduced in the bridge compared to the spectre even though they share identical code. Are we supposed to treat colour.a differently in custom shaders?
-
- Posts: 1318
- Joined: Tue Dec 06, 2016 11:25 am
Re: Shader Help Thread
Hello, I have a question regarding shaders in zDoom. First of all, I have writen my own shaders before in some Unity projects so the basic concepts are not new to me.
I would like to know if it's possible to have a material for a md3 model that shows it's bitmap texture mapped to the viewport, as opposed to being uv-mapped to the model's local vertices. So, if the model moves on screen, the triangle(s) in question would just show a different part of the texture. If you remember the "fake specular" effect in Alone in the Dark (for thing like metallic and reflective surfaces), you know what I'm talking about.
The effect can be seen here, in the small mirror item:
https://www.youtube.com/watch?v=9lWaQe8 ... .be&t=1497
Can this be done?
I would like to know if it's possible to have a material for a md3 model that shows it's bitmap texture mapped to the viewport, as opposed to being uv-mapped to the model's local vertices. So, if the model moves on screen, the triangle(s) in question would just show a different part of the texture. If you remember the "fake specular" effect in Alone in the Dark (for thing like metallic and reflective surfaces), you know what I'm talking about.
The effect can be seen here, in the small mirror item:
https://www.youtube.com/watch?v=9lWaQe8 ... .be&t=1497
Can this be done?
-
- Posts: 1318
- Joined: Tue Dec 06, 2016 11:25 am
Re: Shader Help Thread
I know that MD3s can use materials, but can they also use custom shaders?
-
- Posts: 332
- Joined: Wed Aug 02, 2017 3:01 pm
- Location: Illinois
Re: Shader Help Thread
Instead of making a new thread I'm bumping this one
I'm looking to make a shader to rotate a graphic at the center but have been unsuccessful. I tried modifying the shader that is in the wiki all sorts of ways but the results were just varied wave patterns. Is this even possible?
I'm looking to make a shader to rotate a graphic at the center but have been unsuccessful. I tried modifying the shader that is in the wiki all sorts of ways but the results were just varied wave patterns. Is this even possible?
-
- Posts: 237
- Joined: Mon Jan 11, 2016 3:55 pm
Re: Shader Help Thread
All im interested in is using those screen shaders like the Blaarg CRT stuff from zsnes.
Old school scanlines and rf artifacts like a vcr recording.
How do you get that going in zdoom?
Old school scanlines and rf artifacts like a vcr recording.
How do you get that going in zdoom?
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Shader Help Thread
Give this one a try instead:SPZ1 wrote:I'm looking to make a shader to rotate a graphic at the center but have been unsuccessful. I tried modifying the shader that is in the wiki all sorts of ways but the results were just varied wave patterns. Is this even possible?
Code: Select all
uniform float timer ;
const float pi = 3.14159265358979323846 ;
vec4 Process( vec4 colour )
{
vec2 pos = gl_TexCoord[0].st - .5 ;
float hyp = sqrt( pos.x * pos.x + pos.y * pos.y );
if( hyp < .5 ) //narrows the effect. max is .707 but just comment out this line at that point.
{
float rad = atan( pos.y / pos.x ) + timer ; //try radians( 45 ) instead of timer for a fixed angle.
rad += pi * ( .5 - sign( pos.x ) * .5 );
pos.x = cos( rad );
pos.y = sin( rad );
pos *= hyp ;
}
return getTexel( pos + .5 );
}
There's scan lines in Retroshader and some other neat stuff.RSSwizard wrote:All im interested in is using those screen shaders like the Blaarg CRT stuff from zsnes.
Old school scanlines and rf artifacts like a vcr recording.
How do you get that going in zdoom?
I'm slowly working on a new Screem that will have them too:
It's also enabling pixelation with a softening filter.
-
- Posts: 34
- Joined: Thu Aug 30, 2018 3:23 pm
- Location: UK
Re: Shader Help Thread
Is it possible to add a shader just to the HUD weapon rather than the whole screen. I was hoping to get the Retro pixel shader working just on the weapons rather than the whole screen.
Thanks.
Thanks.
-
- Posts: 262
- Joined: Thu Jul 16, 2015 11:09 pm
Re: Shader Help Thread
I'm looking for custom smooth liquid shaders for flats and waterfalls. Would someone be able to direct me to these types of shaders?
-
-
- Posts: 375
- Joined: Mon Jun 27, 2016 7:26 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
Re: Shader Help Thread
On the [wiki]GLDEFS[/wiki] wiki page, it says:
Is this list up to date? And where in the GZDoom source code are these values defined and passed to user shaders for textures?The following uniform variables are always available to your shaders:
int fogenabled
vec4 fogcolor
vec3 dlightcolor
vec3 camerapos
float desaturation_factor
vec4 topglowcolor
vec4 bottomglowcolor
int texturemode
sampler2D tex
float timer
If you wish to use the timer uniform, you must define it yourself at the top of your shader file.
If the DYNLIGHT define is defined, the following uniform variables available:
ivec3 lightrange
vec4 lights[256]
Only if MAXLIGHTS128 is not defined
vec4 lights[128]
Only if MAXLIGHTS128 is defined
The following varying variables are always available to your shaders:
float lightlevel
vec2 glowdist
vec4 pixelpos
vec4 fogparm
-
- Posts: 11
- Joined: Sat Jul 07, 2018 12:18 pm
Re: Shader Help Thread
Is there a possibe way to have "shaders" encased in a texture?
Say I wanted to have this foggy glass texture that when viewed through blurs part of the screen to give the illusion that its affecting all them light beams and stuff.
Say I wanted to have this foggy glass texture that when viewed through blurs part of the screen to give the illusion that its affecting all them light beams and stuff.
-
-
- Posts: 17454
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: Shader Help Thread
Material textures do not have access to the current screen colour and depth, so no that's currently not possible. Those two things are needed to do any effects that seemingly affect what is "behind" a texture - for example, refraction behind a glass or water, or "heat haze".
-
- Posts: 63
- Joined: Wed Mar 06, 2013 7:15 pm
Re: Shader Help Thread
Is there anyway to get the viewport coordinates?
I want to create a shader, where the image is fixed to the viewport, not the 3d world. i.e: the texture bits shown is based on where the pixels are on the 2d rendered scene if that makes sense?
Essentially i want to create a nifty portal-type effect. Maybe like a space background or something, where the spacey background is fixed no matter where it is observed from or how the player angles the camera.
I do see these uniforms, but this is mainly the texture coords and camera coords i believe.
Also this is compiled into the shader in the cpp:
Is this possible?
I want to create a shader, where the image is fixed to the viewport, not the 3d world. i.e: the texture bits shown is based on where the pixels are on the 2d rendered scene if that makes sense?
Essentially i want to create a nifty portal-type effect. Maybe like a space background or something, where the spacey background is fixed no matter where it is observed from or how the player angles the camera.
I do see these uniforms, but this is mainly the texture coords and camera coords i believe.
Code: Select all
layout(location = 0) out vec4 vTexCoord;
layout(location = 1) out vec4 vColor;
layout(location = 2) out vec4 pixelpos;
layout(location = 3) out vec3 glowdist;
layout(location = 4) out vec3 gradientdist;
layout(location = 5) out vec4 vWorldNormal;
layout(location = 6) out vec4 vEyeNormal;
Code: Select all
layout(std140) uniform ViewpointUBO {
mat4 ProjectionMatrix;
mat4 ViewMatrix;
mat4 NormalViewMatrix;
vec4 uCameraPos;
vec4 uClipLine;
float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
int uPalLightLevels;
int uViewHeight; // Software fuzz scaling
float uClipHeight;
float uClipHeightDirection;
int uShadowmapFilter;
};
-
- Posts: 262
- Joined: Thu Jul 16, 2015 11:09 pm
Re: Shader Help Thread
I wanna add warp3 and warp4 shaders but I get a bad syntax error when booting up the game to test them. How do I properly add them in?
EDIT: Nvm, I made a topic for this issue.
EDIT: Nvm, I made a topic for this issue.