Tech News
← Back to articles

Tonemaps

read original related products more articles

Good day.

One of the first things you learn about shaders is that color values range from 0.0 to 1.0. This is known as 8-bit “unorm” color, because each channel has 256 color values, is unsigned (meaning no negatives) and normalized to the 0.0 to 1.0 range. Most of the time, we don’t need to think about this because 8-bits is enough for outputting colors to the screen. Sometimes, blending 8-bit colors is just not enough though. Today I want to show demonstration when you should care and what to do about it.

Here’s an exaggerated 6-bit version to show how much of a difference this can make:

6-bit colors vs floating-point colors

Before I write my tutorials, I usually do a quick Google search to see what resources already exist so that I can focus my efforts where they are most needed. “Tonemapping” has quite a few tutorials already, but they don’t seem to fit well in a GM context. My tutorial on the new surface formats are particularly relevant here!

GM Shaders Mini: Formats Xor · March 11, 2023 Hello folks! It’s been a while, but I’m back! GameMaker recently added new “surface formats”. If you’re wondering what this is, you’ve come to the right place. Today, I want to cover what all this means and how you can use it! Formats Until now, GM has only supported one texture format: RGBA8unorm. Read full story

I’ll make some references to these surface formats today so make sure you’re familiar with the topic. Let’s go!

Overexposure

Imagine you have a sun shader. Something like this:

//Set the sun color. vec3 sun_color = vec3(1.0, 0.5, 0.2); //Set the brightness as the inverse of the distance to the center. //Assuming v_vTexcoord ranges from 0 to 1. float brightness = 1.0 / length(v_vTexcoord - 0.5); //Output the resulting color. gl_FragColor = vec4(sun_color * brightness, 1.0);

... continue reading