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
How to change the Bit Depth
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- NoreoAlles
- Party member
- Posts: 130
- Joined: Mon Jan 03, 2022 5:42 pm
How to change the Bit Depth
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Re: How to change the Bit Depth
Just use the shader for it: https://www.shadertoy.com/view/MtcXD4
(I cannot translate it for the Löve)
(I cannot translate it for the Löve)
- zorg
- Party member
- Posts: 3470
- 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.
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.
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.
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."
"If each mistake being made is a new one, then progress is being made."
- zorg
- Party member
- Posts: 3470
- 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 3 guests