Trippy perlin distortion/color tweak postprocess & texture
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
Trippy perlin distortion/color tweak postprocess & texture
Hey Folks,
I wanted to share my first GZDoom shader project I've been working on.
It's a multi-function shader that supports various effects which can be combined together. They are mostly based on a 3d simplex (perlin) noise function such as texture distortion and tint, in addition to some trippy effects like lerping the hue, saturation, or value.
I've exposed all the uniforms to ZScript and also hooked them up to CVars to make it easy to tweak these parameters at runtime. I added a description of what these CVars do to the README.
Here are some screencaps showing some of the different effects:
Perlin-based texture distortion - the distortion factor, time scale, and 2d noise scale is adjustable.
Perlin-based subtractive pattern and tint - combined with distortion I think this might make a pretty good shader for being inside a fluid, like swimming in water/nukage. I know it's not the first one to do this but I do like the naturalistic look of the perlin noise.
Animated shifting of hue, saturation, and value -
My math for animating these properties is just in zscript so should be easy to modify. Currently you can toggle the animation of H, S & V separately.
Thanks to Major Cooke, I grabbed his distortion shader to figure out the boilerplate I needed to get all of this hooked up.
Feel free to use this for your own mods, etc as I've released it under an MIT-style license. The code is here: https://github.com/fadookie/gzdoom-shaders - you can load it as a file in unpacked pk3 format. I also uploaded a pk3.
I would appreciate a credit if you use it (not required by license though)! Also let me know if you have any feature requests, if I have time I will look into it. I am not a shader expert but I am trying to learn and improve my skills!
I wanted to share my first GZDoom shader project I've been working on.
It's a multi-function shader that supports various effects which can be combined together. They are mostly based on a 3d simplex (perlin) noise function such as texture distortion and tint, in addition to some trippy effects like lerping the hue, saturation, or value.
I've exposed all the uniforms to ZScript and also hooked them up to CVars to make it easy to tweak these parameters at runtime. I added a description of what these CVars do to the README.
Here are some screencaps showing some of the different effects:
Perlin-based texture distortion - the distortion factor, time scale, and 2d noise scale is adjustable.
Perlin-based subtractive pattern and tint - combined with distortion I think this might make a pretty good shader for being inside a fluid, like swimming in water/nukage. I know it's not the first one to do this but I do like the naturalistic look of the perlin noise.
Animated shifting of hue, saturation, and value -
My math for animating these properties is just in zscript so should be easy to modify. Currently you can toggle the animation of H, S & V separately.
Thanks to Major Cooke, I grabbed his distortion shader to figure out the boilerplate I needed to get all of this hooked up.
Feel free to use this for your own mods, etc as I've released it under an MIT-style license. The code is here: https://github.com/fadookie/gzdoom-shaders - you can load it as a file in unpacked pk3 format. I also uploaded a pk3.
I would appreciate a credit if you use it (not required by license though)! Also let me know if you have any feature requests, if I have time I will look into it. I am not a shader expert but I am trying to learn and improve my skills!
Last edited by Eliot_L on Thu Mar 15, 2018 3:01 am, edited 1 time in total.
- Pixel Eater
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Trippy perlin distortion/color tweak postprocess shader
Nice distortion! That would look good on the surface of water too if that's possible
I've been working on a hue shifting shader too but it's been giving me issues, GRR
I've been working on a hue shifting shader too but it's been giving me issues, GRR
Re: Trippy perlin distortion/color tweak postprocess shader
Thanks! 3d simplex noise is a bit heavy on the GPU but modern desktops seem to handle it fine. You can optimize it more using a texture lookup to pre-bake the permutation table but I don't think that would be possible inside the GZDoom hardware shader system.
Feel free to take my hue shift code if it's helpful.
And yeah I think doing this as a floor shader would be possible, if you can figure out how to project it like a regular texture. Should be doable although I don't know how off the top of my head - maybe just use the fragment UV as input to noise function instead of screen coordinates.
Feel free to take my hue shift code if it's helpful.
And yeah I think doing this as a floor shader would be possible, if you can figure out how to project it like a regular texture. Should be doable although I don't know how off the top of my head - maybe just use the fragment UV as input to noise function instead of screen coordinates.
- Pixel Eater
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Trippy perlin distortion/color tweak postprocess shader
You can attach a .png file to your shader for sure, maybe other types as well. It's a bit more work if you need an animation but not too difficult.
Just pop it in a subfolder named 'Textures' then link to it in GLDefs as so:
Then in the shader code use either the regular texture function or texelFetch to get the colour of a coordinate:
I only ever use zero for <miplevel>.
Cheers for the offer, but it's actually the lum weighting that's holding my hue shader back
Just pop it in a subfolder named 'Textures' then link to it in GLDefs as so:
Code: Select all
HardwareShader PostProcess scene
{
Name "ShaderName"
Shader "Shaders/ShaderFile.fp" 330
Texture "TextureName" "Textures/TextureFile.png"
}
Code: Select all
texture( TextureName, <xcoord>, <ycoord> ) //when providing "float" style coordinates, or
texelFetch( TextureName, <xcoord>, <ycoord>, <miplevel> ) //for integer/pixel coordinates.
Cheers for the offer, but it's actually the lum weighting that's holding my hue shader back
Re: Trippy perlin distortion/color tweak postprocess shader
Cool- good to know! I think I'll stick with current implementation for now unless someone complains about performance, I've used the same function on a pretty old MacBook (2010) GPU and it works ok. So I think this is pretty reasonable as is unless someone's on very limited HW or running multiple postprocess effects.
- Pixel Eater
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Trippy perlin distortion/color tweak postprocess shader
Don't change anything based on this but I'm getting pretty significant lag on a late 2013 iMac. The 'stat gpu' console command shows that I'm getting just above 16 milliseconds delay. Most other shaders are around 1-3ms. Going bare-bones, no other processing, still has a lot of jerkiness. Treat this only as an anecdote though because it could just be my system
Re: Trippy perlin distortion/color tweak postprocess shader
Thanks for the info. I have not profiled it on integrated GPUs so that might be an issue.
Also, the procedural texture idea totally works! Code is pushed to repo.
Also, the procedural texture idea totally works! Code is pushed to repo.
- Pixel Eater
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Trippy perlin distortion/color tweak postprocess & textu
Glad I could be of help.
Whoa neat!
Whoa neat!
- Berserker
- Posts: 27
- Joined: Sat Dec 15, 2018 8:11 pm
- Graphics Processor: nVidia with Vulkan support
- Location: In my head, creating non-stop
Re: Trippy perlin distortion/color tweak postprocess & textu
Hi there !
I've been searching for an effect like this for my water and just found the perfect one !
But I'm still a rookie with coding, so could you just please tell me how do you put the distortion effect to a water pool when you swim in it ?
Thanks and very nice job !
I've been searching for an effect like this for my water and just found the perfect one !
But I'm still a rookie with coding, so could you just please tell me how do you put the distortion effect to a water pool when you swim in it ?
Thanks and very nice job !
- Armaetus
- Posts: 1255
- Joined: Fri Mar 13, 2009 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10 Home
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Location: New York State
- Contact:
Re: Trippy perlin distortion/color tweak postprocess & textu
I suppose this could be applied to the default liquid texture flats somehow?
Re: Trippy perlin distortion/color tweak postprocess & textu
Thanks! Sorry I did not see this before, I have not been checking my forums.Berserker wrote:Hi there !
I've been searching for an effect like this for my water and just found the perfect one !
But I'm still a rookie with coding, so could you just please tell me how do you put the distortion effect to a water pool when you swim in it ?
Thanks and very nice job !
You can use ZScript to control the variables used by the shader to blend the various effects on and off. Have a look at my player class for some examples of this, although it contains some additional stuff you shouldn't need for hooking them up to the console. The available CVars are listed in the README.
As for how to wire this up, I don't know for sure (it may be better to ask on the ZScript forum), but generally I'd do something like so on each tick:
- If player was on dry land, check if they just entered water (Maybe HitWater can help with this?)
- If they did, begin a linear interpolation (lerp) of shader CVars you want (probably tint and distortion factor) from 0 to target value. You can do a 1-dimensional lerp like this function. Here's a good explanation of interpolation functions.
- On subsequent ticks, increment some counter and feed it into the lerp function again, then use the lerp output to update the CVars, until they reach their target values.
- Keep checking to see when the player exits the water. When they exit, repeat the process again, but lerp from max value back to 0.
Yes, that's what I've done in my demo. I used GLFDEFS to override the patches for the FWATER1 - FWATER4 animation frames and it just uses the shader instead.Armaetus wrote:I suppose this could be applied to the default liquid texture flats somehow?
- Ozymandias81
- Posts: 2063
- Joined: Thu Jul 04, 2013 8:01 am
- Graphics Processor: nVidia with Vulkan support
- Location: Mount Olympus, Mars
- Contact:
Re: Trippy perlin distortion/color tweak postprocess & textu
Hey everyone, late necrobump but it is for a good reason. I am trying to implement an effect for Jazz Jackrabbit Doom that mimicks the Hookah-Smoking caterpillar attack, most of the on-screen code is there, but the trippy effect is not.
What I need is to turn this awesome shader a "pickupable" effect which doesn't involve making a new playerclass for the purpose, since the mod must work also on Zandronum and due the fact that zscript gets ignored there, it can't happen with player itself. So let's say, a pickupable shroom effect that has an additive duration, anyone can help with?
What I need is to turn this awesome shader a "pickupable" effect which doesn't involve making a new playerclass for the purpose, since the mod must work also on Zandronum and due the fact that zscript gets ignored there, it can't happen with player itself. So let's say, a pickupable shroom effect that has an additive duration, anyone can help with?
-
- Posts: 384
- Joined: Mon May 09, 2016 1:38 am
- Location: Anywhere but here
- Contact:
Re: Trippy perlin distortion/color tweak postprocess & textu
Sounds like it'd be real nice for underwater and System Shock 1-esque berserk stuff.