Page 4 of 5

Re: Shader Help Thread

Posted: Fri Sep 07, 2018 12:37 am
by Dr. Van Nostrand
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

Re: Shader Help Thread

Posted: Fri Sep 07, 2018 12:42 am
by Pixel Eater
lol wow the effect is way too fast as I had it originally!
Yeah I think I went cross-eyed the first time :lol:

Re: Shader Help Thread

Posted: Thu Sep 20, 2018 7:39 pm
by Pixel Eater
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?

Re: Shader Help Thread

Posted: Sun Nov 11, 2018 2:23 pm
by Cherno
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?

Re: Shader Help Thread

Posted: Sun Nov 25, 2018 11:03 am
by Cherno
I know that MD3s can use materials, but can they also use custom shaders?

Re: Shader Help Thread

Posted: Mon Feb 18, 2019 1:33 pm
by SPZ1
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?

Re: Shader Help Thread

Posted: Tue Mar 26, 2019 2:36 pm
by RSSwizard
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?

Re: Shader Help Thread

Posted: Wed Mar 27, 2019 12:23 am
by Pixel Eater
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?
Give this one a try instead:

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 );
}
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?
There's scan lines in Retroshader and some other neat stuff.

I'm slowly working on a new Screem that will have them too:

It's also enabling pixelation with a softening filter.

Re: Shader Help Thread

Posted: Sat Apr 06, 2019 6:38 pm
by furyweb
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.

Re: Shader Help Thread

Posted: Mon Jun 10, 2019 9:02 am
by Mav3r1ck
I'm looking for custom smooth liquid shaders for flats and waterfalls. Would someone be able to direct me to these types of shaders?

Re: Shader Help Thread

Posted: Mon Sep 09, 2019 10:40 pm
by Talon1024
On the [wiki]GLDEFS[/wiki] wiki page, it says:
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
Is this list up to date? And where in the GZDoom source code are these values defined and passed to user shaders for textures?

Re: Shader Help Thread

Posted: Sun Oct 27, 2019 3:54 pm
by Gabenslair
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.

Re: Shader Help Thread

Posted: Mon Oct 28, 2019 2:22 am
by Nash
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".

Re: Shader Help Thread

Posted: Sat Apr 11, 2020 1:29 pm
by Xabis
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.

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;
Also this is compiled into the shader in the cpp:

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;
};
Is this possible?

Re: Shader Help Thread

Posted: Wed May 06, 2020 4:11 pm
by Mav3r1ck
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.