Quake-style fullbright colors
Asked Answered
K

27

0

Would it be possible to create a shader that mimics the fullbright colors used in the original quake, i.e. colors in a palette that are not affected by shadows?

Kingmaker answered 23/2 at 22:14 Comment(0)
D
0

Kingmaker Can you provide a visual example?

Diesis answered 23/2 at 23:5 Comment(0)
K
0

Kingmaker answered 24/2 at 5:1 Comment(0)
D
0

Kingmaker Add an emission texture to your material.

Diesis answered 24/2 at 9:39 Comment(0)
K
0

There are many ways, I recommend you read the docs or some other text about shading.
For starters, use lambert and maybe disable specular. If you don't want shading you can use unshaded or disable receive shadows in material.
You may still want ambient light, since quake used baked shadows.
And Color correction should be linear.

Check the options in your material and in world environment node.

An emission texture is another alternative, but it could end up looking too bright.

You can't reserve colors in a palette, if you use unshaded the colors will be the ones in the Albedo texture, but any calculated color will be in 24-32 bits, and that's because of modern hardware. You could however use a postprocess shader to reduce the number of colors through an algorithm, but a palette of selected colors would be too computationaly expensive, think of, tones in a "curve" instead (10-20-30-40 / 8-16-24 / 3-5-7).

Kinnie answered 24/2 at 10:3 Comment(0)
B
0

If you're in Godot 3.5, oversaturation is an option too. You can turn the color settings in the wheel to "raw" and "overload" the values for super bright colors but be aware, this can cause some weird effects if using, say bloom settings with a world environment.

Bodwell answered 24/2 at 19:15 Comment(0)
K
0

Kinnie
There is already a postprocess shader to reduce the number of colors:
https://github.com/saltern/Godot-Shaders/blob/main/AdaptToPalette.gdshader

Kingmaker answered 25/2 at 18:50 Comment(0)
D
0

Kingmaker Modern GPUs don't run indexed color modes. You can't achieve the effect the same way they did back then using palettes. Emission texture/mask is the way to go here.

Diesis answered 25/2 at 19:8 Comment(0)
K
0

Diesis
Then how is it that source-ports such as Quakespasm are able to support fullbright colors?

Kingmaker answered 25/2 at 21:48 Comment(0)
D
0

Kingmaker You should ask them. Afaik GLQuake didn't support fullbrights precisely for the reason I mentioned above. It can be done only in software rasterizers (which original Quake engine was). The whole concept of fullbright colors is tied with indexed display modes. It makes no sense in full RGBA mode modern GPUs operate in. Quakespasm may be doing some tricks or conversions but I'd say it's not worth the effort if you don't need to be compatible with original Quake asset formats. The effect itself (and better) can and should be done with emission textures or masks. In fact having a part of indexed palette reserved for incandescent colors is a primitive version of an emission texture.

If your texture assets use indexed color you'll need to convert them into RGBA anyway if you intend to use them with Godot. While doing so it wouldn't be hard to generate a mask for fullbright pixels as well.

Diesis answered 25/2 at 22:5 Comment(0)
K
0

Diesis
If I do need to use emission maps, will I be able to apply emission maps to texture tiles on level geometry as well?

Kingmaker answered 25/2 at 23:1 Comment(0)
D
1

Kingmaker If I do need to use emission maps, will I be able to apply emission maps to texture tiles on level geometry as well?

No reason not to be able to. Level geometry is just meshes. Apply Godot's standard material to them, map the emission property and that's it. You don't even need a custom shader unless you want to render the emission in an unusual way.

If you want to mimic the fullbright "logic" more closely, instead of a RGB emission map you can use only a single channel (grayscale) mask. In that case you'll need a custom shader with light function that reads the mask texture and sets the diffuse illumination to full brightness for masked-in pixels. Then those pixels will never be darkened. They'll always just render out as they are in the albedo texture, effectively acting as Quake's fullbright colors. The only difference is that you mask-in actual texture pixels instead of specific color entries in the palette, i.e. you can make arbitrary texture parts fullbright, regardless of their color. This is obviously better than being limited to specific colors.

Diesis answered 25/2 at 23:54 Comment(0)
K
0

Diesis
So after experimenting in Godot, I cant help but notice that emission-maps behaves very differently than they do in Blender. In Blender; the emission map creates the desired effect, but in Godot; it just turns the effected part of the texture one color.

Kingmaker answered 27/2 at 4:13 Comment(0)
D
0

Kingmaker Let's see some visuals, including maps. Note that I also suggested alternative way that emulates Quake's approach more closely without emission maps.

Diesis answered 27/2 at 9:32 Comment(0)
K
0

Diesis
Here is an example with a 3D sprite

Kingmaker answered 27/2 at 17:45 Comment(0)
K
0

Kingmaker
And here are the original image files.
texture
emission
mask

Kingmaker answered 27/2 at 17:56 Comment(0)
D
0

Kingmaker Not sure what this demonstrates. If emission is stronger than you want it, darken the emission texture. You also might want to use a texture similar to albedo, not all white.

Diesis answered 27/2 at 18:4 Comment(0)
K
0

Diesis
The point is that I'm trying to do this in a similar fashion to how its done in blender

Kingmaker answered 27/2 at 18:11 Comment(0)
D
0

Kingmaker You can do it in the exact same fashion just need to adjust the texture intensity because Godot's renderer and Blender's renderer may calculate things differently as former is a realtime renderer and latter is not.

Godot's standard material has the emission intensity multiplier property. So try to play with it to get the similar looking results. You also may want to disable environment/ambient illumination when tuning things.

Diesis answered 27/2 at 19:53 Comment(0)
K
0

Diesis
So will that give the same results as in this picture?

Kingmaker answered 27/2 at 19:56 Comment(0)
D
0

Kingmaker So will that give the same results as in this picture?

It's easy enough to test it out.
That look is 100% doable with emission and a bit of parameter adjustment.

Diesis answered 27/2 at 20:1 Comment(0)
K
0

Diesis
what sort of parameters?

Kingmaker answered 27/2 at 21:53 Comment(0)
D
0

Kingmaker what sort of parameters?

Stuff under "Emission" section in standard material properties.
Everything you need was answered multiple times in this thread. Time to stop asking questions and start doing things 😉

Diesis answered 27/2 at 22:5 Comment(0)
K
0

Diesis
Understood, thank you for your help 🙂

Kingmaker answered 27/2 at 22:13 Comment(0)
C
0

Kingmaker They likely pipe the textures to emission channel. Might be further enhanced with some clever color management and LUTs.

Mind, in case of your spider here, the eyes are clearly meant to be emission but you can mix multiple textures cleverly via shaders/graph. you can also instead go with emission for the eyes and albedo for the rest, then use prebaked light maps to influence the albedo too. Skip using directional lights and rely more on lightmaps and ambient lighting...

Collincolline answered 28/2 at 6:14 Comment(0)
K
0

Okay, after asking around elsewhere I finally found a method that works best

  • I create a second StandardMaterial pass
  • Set the transparency mode to Alpha-Scissor
  • Set the shading mode to Unshaded
  • For the Albedo texture, I create a version of the base texture where only the fullbright pixels are visible
Kingmaker answered 8/3 at 21:43 Comment(0)
D
0

Kingmaker With this you introduce an additional shader pass and an additional texture. Why do it like that when you can do it with a single pass and a single texture as I described above.

Diesis answered 8/3 at 22:5 Comment(0)
D
0

Kingmaker

shader_type spatial;

uniform sampler2D tex;

void fragment() {
	vec4 t = texture(tex, UV);
	ALBEDO = t.rgb;
	EMISSION = ALBEDO * t.a;
}
Diesis answered 8/3 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.