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

WIP- Colour Map Shader

Post by Pixel Eater »

I'm stuck on this project and hope someone can help me. I am using Old Video Shader as a template and replacing it's guts with a modified copy of the Palette shader code. The aim is to replace the brightness values from the Palette shader with the information from the true colour render.
I can get it to run but it's tinting everything based on the lower left corner. Even when I comment out my portion of the code it behaves similarly, only darker. It does seem to be slightly palette aware though.

This link downloads what I have so far but with my lines disabled, so it should behave the same as the built in Palette shader (it doesn't):
colourmap_shader_broken.pk3
(1.99 KiB) Downloaded 112 times
gldefs.txt:
Spoiler:
shaders/PostProcess/ColourMap.fp:
Spoiler:
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: WIP- Colour Map Shader

Post by Rachael »

First and foremost, the palette table requires support code from the C++ side - I have no doubt it can be done shader side but it will require inputting the palette data in some way and then it's a lot of extra work to make it work.

Secondly, can you use some screenshots to explain what you mean? I am sorry but reading what you are trying to do is just very confusing.
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 »

Sorry for the confusion! If you think about it as using the Color/Luminosity blend modes in Photoshop between the Palette shader and the dry output does that make more sense? In doing that it should only utilize the colour map part of the Palette shader's effect.
Notice the colour banding is removed from the last pane:
shader-demo.png
Won't the background C++ stuff already be in place for the current Palette shader? This is only a tweak on the output of that...
Last edited by Pixel Eater on Thu Oct 12, 2017 7:15 am, edited 1 time in total.
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: WIP- Colour Map Shader

Post by Rachael »

Okay, I see what you are doing now. You're applying True-Color's luminosity to Paletted's Saturation/Hue.

One of the bigger problems you have is the PaletteLUT table (is a texture) is not populated until the first time you type "gl_tonemap 5" - I suppose I could add in an argument for custom shaders to force it to be populated when the shader is activated.

What other problems are you having besides this?
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 »

Okay, I see what you are doing now. You're applying True-Color's luminosity to Paletted's Saturation/Hue.
That's better than I could ever put it :)
One of the bigger problems you have is the PaletteLUT table (is a texture) is not populated until the first time you type "gl_tonemap 5" - I suppose I could add in an argument for custom shaders to force it to be populated when the shader is activated.
That sounds like it would be helpful. Does that override custom palettes?
What other problems are you having besides this?
This is what I get when I omit my blending code (for a basic Palette shader):


And this is when I include it:


The colour of the tint changes depending on what occupies the lower left corner of the screen.
Last edited by Pixel Eater on Mon Aug 13, 2018 4:21 pm, edited 1 time in total.
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: WIP- Colour Map Shader

Post by Rachael »

It's quite likely that PaletteLUT is not actually being passed to the shader - this will require further modification on the C++ side.
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 Rachael. I will submit a feature request then 8-)
*Dun!
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 »

I've had an idea: can I embed a custom image into the .pk3 file to use instead of PaletteLUT? I have an extended colour map which I designed and proposed in this feature request that I could reuse for this project. If I could, it would mean I would no longer be overlaying a 24bit image with an 8bit colour map :ninja:

Actually it would be cool if I could store different versions and be able to select them from the menu. Sounds like another feature request :P
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: WIP- Colour Map Shader

Post by Rachael »

You can do it but keep in mind that PaletteLUT is made a certain way and is nowhere near the same format as a real COLORMAP.
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 »

I'm guessing PaletteLUT is generated on startup because I can't find it in gzdoom.pk3 or by searching this site. Is there a way to export it while Doom is running, maybe even by drawing it to screen and taking a screenshot? At that point, will embedding it into the .pk3 file's root directory cause the line "uniform sampler2D PaletteLUT;" to work correctly or is it more complicated than that?
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: WIP- Colour Map Shader

Post by Rachael »

There is no way to export it - it is dynamically generated. It is also referenced by pointer, not by name, so you cannot access it anyhow.

It is possible, however, to create a program that's embedded into GZDoom's source code and create a PNG of it after it's generated. Graf could probably easily do it if he had the time and desire, I could do it with a great deal more difficulty but eventually I'd figure it out, but unfortunately I have a lot of projects as it is that I've been putting off that I really need to get to.
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 »

No worries and thank you for all your help, I appreciate it :mrgreen:

I might go for plan B and request an additional option to go alongside Palette Exponent and Order that blends the luminosity back in. I had hoped to play with perceptually weighting the luminance or matching the visibility of software Doom but I won't be able to experiment with those in that situation. Which is why I wanted to have it as a 'standalone' working prototype 8-)
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 »

I've had an idea: can I embed a custom image into the .pk3 file to use instead of PaletteLUT?
You can do it but keep in mind that PaletteLUT is made a certain way and is nowhere near the same format as a real COLORMAP.
Could you please expand on how that is achieved? I have created a custom LUT file (hopefully in the right configuration :P ) and placed it in a .pk3 file, called it by typing "uniform sampler2D *filename*;" and then mapped it to the screen. All I get is a regular view of E1M1. Does the LUT file need to be in a certain directory?
dpJudas
 
 
Posts: 3040
Joined: Sat May 28, 2016 1:01 pm

Re: WIP- Colour Map Shader

Post by dpJudas »

The filename is the name of a lump. I can't remember exactly which naming rules it uses - you might have to type the full path of the file within the .pk3 - i.e. with a slash in front or maybe place it in a subfolder so that there is a path component in the filename.
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 »

Hmm, I've just tried every permutation I can think of: "./graphics/", "/graphics/", using the .png file extension, enclosing it in quotation marks and all again within gldefs instead of the shader.

Here's the LUT I've made, does it look to be the correct format?:
Last edited by Pixel Eater on Mon Aug 13, 2018 4:22 pm, edited 1 time in total.
Post Reply

Return to “Assets (and other stuff)”