WIP- Colour Map Shader

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

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.
dpJudas
 
 
Posts: 2933
Joined: Sat May 28, 2016 1:01 pm

Re: WIP- Colour Map Shader

Post by dpJudas »

Hmm, I'll have to check the code when I get home then. I did create a health shader that I posted somewhere on the forum which does use a texture. So it can be done - somehow. :)
dpJudas
 
 
Posts: 2933
Joined: Sat May 28, 2016 1:01 pm

Re: WIP- Colour Map Shader

Post by dpJudas »

The syntax is like the following in the GLDEFS file:

Code: Select all

hardwareshader postprocess scene
{
	Name "healthshader"
	Shader "healthshader.glsl" 330
	Uniform float saturation
	Uniform vec3 saturationColor
	Texture SillyTexture "textures/eyeofromero.png"
}
This declares a SillyTexture uniform that you can then sample from in the GLSL file:

Code: Select all

void main()
{
	vec4 c = texture(InputTexture, TexCoord);
	vec4 sillyc = texture(SillyTexture, vec2(TexCoord.x, 1.0 - TexCoord.y));
	c.rgb += sillyc.rgb * sillyc.a;
	c.rgb = mix(saturationColor * dot(c.rgb, vec3(0.3,0.56,0.14)), c.rgb, saturation);
	FragColor = c;
}
I've attached the example pk3 illustrating its use. Hope that helps. :)
You do not have the required permissions to view the files attached to this post.
User avatar
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: WIP- Colour Map Shader

Post by Pixel Eater »

Oh that looks nice and simple. Now I need a morning coffee to get me started (_)3 Cheers dpJudas!
User avatar
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: WIP- Colour Map Shader

Post by Pixel Eater »

Ok that definitely solved half of the problem I've had. It now looks palettized, banding and all (which will hopefully go away), but the colours are all messed up. I guess I've made the wrong style LUT for ZDoom :|

Here was the latest one, it had even less banding:
Last edited by Pixel Eater on Mon Aug 13, 2018 4:23 pm, edited 1 time in total.
User avatar
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: WIP- Colour Map Shader

Post by Pixel Eater »

ColourmapLUT_demo.pk3
This is a demonstration of how close I am to getting this thing to work. Even with a LUT that is just a yellow gradient, it is able remove the banding by recovering the luminance from the true-colour input texture.
If anyone can please describe how one makes a look-up table that can be read by GZDoom I would be eternally grateful :wub:

This is a mock-up of what this shader will be capable of when finished:

(Click to animate)
You do not have the required permissions to view the files attached to this post.
Last edited by Pixel Eater on Mon Aug 13, 2018 4:25 pm, edited 1 time in total.
User avatar
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: WIP- Colour Map Shader

Post by Pixel Eater »

Probably a better example:



Open these up in individual tabs and swap between them and you can see large differences. The palette shader looks quite rough just like software mode and the third image appears faded because the hardware renderer ignores DooM's colourmap. Contrastingly, in the last example the pinky demon is in permanant overbright colours even in low light. The colourmap shader in the middle will keep the neatness of truecolour rendering and mix in colouring that's true to DooM.
Last edited by Pixel Eater on Mon Aug 13, 2018 4:28 pm, edited 1 time in total.
User avatar
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: WIP- Colour Map Shader

Post by Pixel Eater »

Thanks to all those who've helped, I have a working version up now: Troo Cullers

Return to “Assets (and other stuff)”