0 downloads 4 views May 17, 2026
profile

PinePix by Minki the Avali

project thumbnail

PinePix -- CC:Graphics pixel mode helper for Pine3D


This module adds pixel mode rendering and directional lighting on top of stock Pine3D. It requires CraftOS-PC / CC:Graphics mod (term.setGraphicsMode must exist).

Pine3D itself is unchanged - you will need to place betterblittle.lua and Pine3D.lua inside this directory to run the example.

==> https://github.com/Xella37/Pine3D

FEATURES


Pixel mode (256-colour framebuffer)

  • Switches the terminal to CraftOS-PC graphics mode 2.
  • The Pine3D color buffer is blitted to the screen as raw pixels.
  • The 16 CC palette entries are replicated at 80%, 65%, and 50% brightness
  • to give 64 usable palette slots for shading.

Directional lighting

  • Each polygon is dot-product shaded against a world-space light direction.
  • Four shade levels: full, 80%, 65%, 50%.
  • The light vector is transformed into each object's model space so shading
  • stays correct as objects rotate.

Winding fix

  • Pine3D culls faces designed for interior (dungeon) rendering.
  • Both pixel mode and teletext mode include a v1<->v2 winding swap so that
  • outward-facing geometry renders correctly from an exterior camera.

Pixel font

  • gfx.drawString draws 3x5 pixel text directly to the framebuffer.
  • Supports A-Z, 0-9, and a handful of symbols. Input is uppercased
  • automatically.

QUICK SETUP


  local Pine3D = require("Pine3D")
  local gfx    = require("gfx")

  local frame = Pine3D.newFrame()
  gfx.setFrame(frame)   -- let gfx resize the buffer when switching modes

  gfx.enable()          -- switch to pixel mode (no-op if unsupported)

API SUMMARY


  gfx.setFrame(frame)                          -- register the Pine3D frame

  gfx.enable()                                 -- switch to pixel mode

  gfx.disable()                                -- switch back to teletext mode

  gfx.isActive()                               -- returns true if in pixel mode

  gfx.supported()                              -- returns true if CraftOS-PC

  gfx.setLight(x, y, z)                        -- set world-space light direction

  gfx.shadeObjects(objs)     -> saved          -- pre-render: shade + fix winding

  gfx.restoreObjects(objs, saved)              -- post-render: undo shadeObjects

  gfx.fixWinding(objs)       -> saved          -- pre-render: fix winding only

  gfx.restoreWinding(objs, saved)              -- post-render: undo fixWinding

  gfx.renderBuffer(colorValues, w, h)          -- blit color buffer to screen

  gfx.drawString(px, py, str, colorIdx, scale) -- draw pixel text
comments
You can login with Discord to leave comments and reply to others!
There are no comments yet