## How to change the Bit Depth

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
NoreoAlles
Citizen
Posts: 85
Joined: Mon Jan 03, 2022 5:42 pm

### How to change the Bit Depth

Hey, i want to make a low-res retro game and i am wondering how to change the bit-depth per pixel.
I am displaying a high bit per Pixel depth image and thought changing this: "t.window.depth = nil " in the conf.lua file to 4 instead of nil would result in a 4 bit version of same image being displayed

Thanks
hippity hoppity, your code is now my property
(thanks btw)
darkfrei
Party member
Posts: 730
Joined: Sat Feb 08, 2020 11:09 pm

### Re: How to change the Bit Depth

(I cannot translate it for the Löve)
zorg
Party member
Posts: 3262
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: How to change the Bit Depth

You don't. You use assets that only use certain colors, and your problem is solved.
Also, t.window.depth is not color depth; as https://love2d.org/wiki/Config_Files says, it's the precision of the depth buffer.

The above linked shader also seems to do way more than just emulating a lower color depth though.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
ReFreezed
Party member
Posts: 570
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

### Re: How to change the Bit Depth

Well, you can change the bit depth with different PixelFormats for canvases, but it doesn't give you much control, and some formats are not available on all platforms. You should be using shaders for this, or as zorg says, just limit the colors used in the textures directly.

darkfrei's linked shader just emulates a low screen resolution, which I'm guessing is not what you're asking for.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
zorg
Party member
Posts: 3262
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: How to change the Bit Depth

By the way, a simple shader for this could be something like this:

Code: Select all

vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords)
{
float colordepth = 8;
vec4 texturecolor = Texel(tex, texture_coords);
vec4 output = floor((texturecolor * color) * colordepth) / colordepth;
return output;
}

Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

### Who is online

Users browsing this forum: No registered users and 43 guests