This addon just a library.
See usage there.
Caution
You should avoid drawing two planes in the same position, as this may cause artifacts with the depth buffer.
See lua/pixelated_examples folder.
| Enum | Value |
|---|---|
Pixelated.LAYOUT_SQUARE |
1 |
Pixelated.LAYOUT_OFFSET_SQUARE |
2 |
Pixelated.LAYOUT_ARROW |
3 |
Pixelated.LAYOUT_TRIANGULAR |
4 |
Caution
Unfortunately, LAYOUT_TRIANGULAR is currently broken.
-- cull : boolean
-- depthTest : boolean
-- writeDepth : boolean
-- linearBaseTexture : boolean
-- linearPixelMask : boolean
function Pixelated.SetSettings(cull, depthTest, writeDepth, linearBaseTexture, linearPixelMask)This function sets a few internal vars. Usually you dont need calling that.
-- luma : number
function Pixelated.SetPixelLuma(luma)Sets sub-pixel brightness. Recommended values from 1 to 4.
-- typ : Pixelated.LAYOUT_*
-- offset : number
function Pixelated.SetPixelLayout(typ, offset)Sets sub-pixel layout. Check up the enums
-- texture : ITexture | string
-- width : number = texture:Width() or 64 if texture is string
-- height : number = texture:Height() or 64 if texture is string
function Pixelated.SetPixelMask(texture, width, height)Sets sub-pixel mask. Built-in textures:
- pixelated/pixelstripes1.vtf Presented in screenshots, default
- pixelated/pixelstripes2.vtf
- pixelated/pixelstripes3.vtf
function Pixelated.SetDefaultPixelMask()Restores original sub-pixel mask and their width with height.
-- texture : ITexture | string
-- width : number = texture:Width() or 512 if texture is string
-- height : number = texture:Height() or 512 if texture is string
function Pixelated.SetBaseTexture(texture, width, height)Sets the base texture.
-- depthEnable : boolean? = true
function Pixelated.StartDraw(depthEnable)Start the drawing shader, setup rendering context.
depthEnable can usually be set to false if you already have a surface on which the shader is drawn.
See pixelated_mediascreen.lua
function Pixelated.EndDraw()End the drawing. restores rendering context
-- func : function
-- useDepthPass : boolean? or function?
-- depthEnable : boolean?
function Pixelated.DrawWithFunc(func, useDepthPass)Combines StartDraw and EndDraw, and also writes (if true or a function is passed to useDepthPass) to the depth buffer.
Passes depthEnable to Pixelated.StartDraw.
-- pos : vector
-- ang : angle
-- scale : number
function Pixelated.Start3D2D(pos, ang, scale)Does the same thing as cam.Start3D2D, but for the Pixelated functions.
function Pixelated.End3D2D()Does the same thing as cam.End3D2D, but for the Pixelated functions.
-- r : Color? or number? = 255
-- g : number? = 255
-- b : number? = 255
-- a : number? = 255
function Pixelated.SetDrawColor(r, g, b, a)Sets the drawing color, for DrawRect, DrawTexturedRect and DrawTexturedRectUV.
-- x : number
-- y : number
-- w : number
-- h : number
function Pixelated.DrawRect(x, y, w, h)Draws a rectangle, but with vgui/white! Used for debugging Pixelated.Start3D2D.
-- x : number
-- y : number
-- w : number
-- h : number
function Pixelated.DrawTexturedRect(x, y, w, h)Draws a rectangle with shader
-- x : number
-- y : number
-- w : number
-- h : number
-- startU : number? = 0
-- startV : number? = 0
-- endU : number? = 1
-- endV : number? = 1
function Pixelated.DrawTexturedRect(x, y, w, h, startU, startV, endU, endV)Draws a rectangle with shader and with custom UV. Internally use mesh builder.
meow.