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 Can you provide a visual example?
Kingmaker Add an emission texture to your material.
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).
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.
Kinnie
There is already a postprocess shader to reduce the number of colors:
https://github.com/saltern/Godot-Shaders/blob/main/AdaptToPalette.gdshader
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
Then how is it that source-ports such as Quakespasm are able to support fullbright colors?
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
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 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
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 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
Here is an example with a 3D sprite
Kingmaker
And here are the original image files.
texture
emission
mask
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
The point is that I'm trying to do this in a similar fashion to how its done in blender
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
So will that give the same results as in this picture?
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
what sort of parameters?
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
Understood, thank you for your help 🙂
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...
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 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.
shader_type spatial;
uniform sampler2D tex;
void fragment() {
vec4 t = texture(tex, UV);
ALBEDO = t.rgb;
EMISSION = ALBEDO * t.a;
}
© 2022 - 2024 — McMap. All rights reserved.