Dithering

This commit is contained in:
2025-05-14 23:26:47 +03:00
parent e5cbc4ca5f
commit 120a70cf42
5 changed files with 36 additions and 14 deletions

View File

@ -51,10 +51,11 @@ main :: proc() {
w, h := rl.GetScreenWidth(), rl.GetScreenHeight()
pixelize: i32 = 2
pixelize: i32 = 3
target := rl.LoadRenderTexture(w / pixelize, h / pixelize)
posttarget := rl.LoadRenderTexture(w / pixelize, h / pixelize)
palette := rl.LoadTexture("assets/gfx/blood-crow-1x.png")
palette := rl.LoadTexture("assets/gfx/bluem0ld-1x.png")
rl.SetTextureFilter(palette, .POINT)
@ -145,6 +146,8 @@ main :: proc() {
w, h = rl.GetScreenWidth(), rl.GetScreenHeight()
rl.UnloadRenderTexture(target)
target = rl.LoadRenderTexture(w / pixelize, h / pixelize)
rl.UnloadRenderTexture(posttarget)
posttarget = rl.LoadRenderTexture(w / pixelize, h / pixelize)
}
rl.UpdateCamera(&cam, .FIRST_PERSON)
delta := rl.GetFrameTime()
@ -197,27 +200,34 @@ main :: proc() {
rl.EndShaderMode()
rl.EndMode3D()
rl.EndTextureMode()
rl.BeginDrawing()
// rl.BeginDrawing()
rl.BeginTextureMode(posttarget)
rl.BeginShaderMode(posterizer)
rl.SetShaderValueTexture(posterizer, poster_palette, palette)
rl.DrawTexturePro(
target.texture,
rl.Rectangle{0, f32(h / pixelize), f32(w / pixelize), -f32(h / pixelize)},
{0, 0, f32(w), f32(h)},
{},
0,
rl.WHITE,
)
// rl.DrawTexturePro(
// target.depth,
// target.texture,
// rl.Rectangle{0, f32(h / pixelize), f32(w / pixelize), -f32(h / pixelize)},
// {0, 0, f32(w), f32(h)},
// {},
// 0,
// rl.WHITE,
// )
rl.DrawTexture(target.texture, 0, 0, rl.WHITE)
rl.EndShaderMode()
// rl.DrawTexture(palette, 0, 0, rl.WHITE)
rl.EndTextureMode()
rl.BeginDrawing()
// rl.BeginTextureMode(posttarget)
// rl.BeginShaderMode(posterizer)
// rl.SetShaderValueTexture(posterizer, poster_palette, palette)
rl.DrawTexturePro(
posttarget.texture,
rl.Rectangle{0, 0, f32(w / pixelize), f32(h / pixelize)},
{0, 0, f32(w), f32(h)},
{},
0,
rl.WHITE,
)
rl.EndDrawing()
}
}