How to change the Bit Depth

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
NoreoAlles
Citizen
Posts: 85
Joined: Mon Jan 03, 2022 5:42 pm

How to change the Bit Depth

Post by NoreoAlles »

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 :P
hippity hoppity, your code is now my property
(thanks btw)
User avatar
darkfrei
Party member
Posts: 733
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to change the Bit Depth

Post by darkfrei »

Just use the shader for it: https://www.shadertoy.com/view/MtcXD4

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

Re: How to change the Bit Depth

Post by zorg »

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 :3True 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.
User avatar
ReFreezed
Party member
Posts: 578
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: How to change the Bit Depth

Post by ReFreezed »

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."
User avatar
zorg
Party member
Posts: 3262
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to change the Bit Depth

Post by zorg »

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 :3True 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests