Trippy perlin distortion/color tweak postprocess & texture

Trippy perlin distortion/color tweak postprocess & texture

Postby Eliot_L » Tue Mar 13, 2018 1:19 pm

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.
Image

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.
Image

Animated shifting of hue, saturation, and value -
Image

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 4:01 am, edited 1 time in total.
User avatar
Eliot_L
 
Joined: 08 Mar 2018
Discord: eliot#4974
Twitch ID: EliotL

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Pixel Eater » Tue Mar 13, 2018 11:46 pm

Nice distortion! That would look good on the surface of water too if that's possible :D

I've been working on a hue shifting shader too but it's been giving me issues, GRR :?
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Eliot_L » Wed Mar 14, 2018 11:14 am

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.
User avatar
Eliot_L
 
Joined: 08 Mar 2018
Discord: eliot#4974
Twitch ID: EliotL

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Pixel Eater » Wed Mar 14, 2018 4:51 pm

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:
Code: Select allExpand view
HardwareShader PostProcess scene
{
   Name "ShaderName"
   Shader "Shaders/ShaderFile.fp" 330
   Texture "TextureName" "Textures/TextureFile.png"
}

Then in the shader code use either the regular texture function or texelFetch to get the colour of a coordinate:
Code: Select allExpand view
texture( TextureName, <xcoord>, <ycoord> ) //when providing "float" style coordinates, or

texelFetch( TextureName, <xcoord>, <ycoord>, <miplevel> ) //for integer/pixel coordinates.
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 :)
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Eliot_L » Wed Mar 14, 2018 7:44 pm

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.
User avatar
Eliot_L
 
Joined: 08 Mar 2018
Discord: eliot#4974
Twitch ID: EliotL

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Pixel Eater » Wed Mar 14, 2018 8:32 pm

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 :shrug:
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.

Re: Trippy perlin distortion/color tweak postprocess shader

Postby Eliot_L » Thu Mar 15, 2018 2:41 am

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.
Image
User avatar
Eliot_L
 
Joined: 08 Mar 2018
Discord: eliot#4974
Twitch ID: EliotL

Re: Trippy perlin distortion/color tweak postprocess & textu

Postby Pixel Eater » Thu Mar 15, 2018 8:52 pm

Glad I could be of help.

Whoa neat! :woh:
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.

Re: Trippy perlin distortion/color tweak postprocess & textu

Postby Berserker » Sat Dec 15, 2018 9:14 pm

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 !
Berserker
 
Joined: 15 Dec 2018


Return to Shaders

Who is online

Users browsing this forum: supervadim and 1 guest