Skip to content

Instantly share code, notes, and snippets.

@sp4cemonkey
sp4cemonkey / Cube world
Created April 27, 2015 18:10
Cube World Performance Comparison
--# Main
-- Cube World
-- Use this function to perform your initial setup
function setup()
print(math.floor(3/4))
--print(3\4)
@sp4cemonkey
sp4cemonkey / gist:3373a25556dba6984124
Created October 12, 2014 18:51
Terrain heightmap
--# Main
-- Terrain
--[[
I started a project on terrains with the idea of small triangles near the camera, and then bigger triangles further away where less detail was required and driving the terrain from a heightfield.
It got very messy...
So I restarted heavily influenced by:
http://galfar.vevb.net/wp/2013/android-terrain-rendering-vertex-texture-fetch-part-1/
@sp4cemonkey
sp4cemonkey / gist:b6cd5c718a7598717700
Last active August 29, 2015 14:02
Touch Explosion 2d
--# Main
-- Explosion
-- Use this function to perform your initial setup
function setup()
--first generate a spherical mesh radius 1 around the origin
--this uses an isosphere primitive code I made some time ago, but any sphere will do with sufficient vertices
--the parameter to Sphere is how much to subdivide the faces (more vertices, slower performance)
sphere = Primitive:Sphere(3)
--attach the explosion shader to the mesh
@sp4cemonkey
sp4cemonkey / gist:7caadf6d098be9e0d865
Last active August 29, 2015 14:02
Explosion shader
-- Explosion
-- Use this function to perform your initial setup
function setup()
sphere = Primitive:Sphere(4)
sphere.shader = shader(ExplosionShader.vertexShader,ExplosionShader.fragmentShader)
sphere.shader.texture = readImage("Dropbox:explosion")
shader()
size = 0.0
--# Main
-- Skeletal Animation
--helper function for matrix vector maths
function matrixByVector(m, v)
m=m:transpose()
vx = vec4(m[1], m[2], m[3], m[4]):dot(v)
vy = vec4(m[5], m[6], m[7], m[8]):dot(v)
vz = vec4(m[9], m[10], m[11], m[12]):dot(v)
vw = vec4(m[13], m[14], m[15], m[16]):dot(v)
--# Main
-- RayTracer 3Balls
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN)
myMesh = mesh()
--myMesh.shader = shader("Documents:ray")
myMesh.shader = shader(rayShader.vertexShader, rayShader.fragmentShader)
--# Main
-- Particle Effect
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN)
--to get ghost trails
backingMode(RETAINED)
--b=Backup("Particle Fireworks Ver 002")
--# Main
-- Particle Effect
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN)
--to get ghost trails
backingMode(RETAINED)
--b=Backup("Particle Effect Ver 006")
@sp4cemonkey
sp4cemonkey / Grass
Last active December 15, 2015 05:19
-- Grass
-- Use this function to perform your initial setup
function setup()
field = mesh()
--field.shader = shader("Documents:Grass")
field.shader = shader(GrassShader.vertexShader, GrassShader.fragmentShader)
bladeWidth = 0.15
bladeHeight = 1.5
midWeight = 0.4
@sp4cemonkey
sp4cemonkey / LitMesh Class
Last active December 14, 2015 15:59
This is a codea class with an ADS lighting with options for colored, textured and bumpmapped
LitMesh = class()
--[[
LitMesh provides a bumpmappable ADS (ambient/diffuse/specular) lighting enhanced class
for meshes.
usage:
setup()
myObject = LitMesh(isTextured, isBumpMapped)
myObject.litMesh.vertices = some table of vertices