diff --git a/src/i18n/en.lua b/src/i18n/en.lua index 57e5413..cf847a6 100644 --- a/src/i18n/en.lua +++ b/src/i18n/en.lua @@ -23,12 +23,18 @@ ENTER TO KEEP]], mouseSensitivity = "TURN SPEED", language = "LANGUAGE", FOV = "FOV", - win = [[ZIMINIAR HAS ARRIVED. THE WORLD WILL NEVER BE THE SAME. - -RICHES TO THE CONJUROR! + win = [[RICHES TO THE CONJUROR! ZIMINIAR IS MANIFEST. + +JARED PROPHESIES THAT WAR WILL SOON ENGULF THE WORLD. + +WE SPEND THE LAST DAYS, TOGETHER, HUDDLED AROUND ZIMINIAR'S ERSTWHILE PRISON. + +IT WON'T BE LONG NOW, BEFORE WE GO TO OUR REWARD. + +TETΓ‰LESTAI ]], phoneRing = "THE PHONE RINGS IMPATIENTLY", phonePickup = "[%s]: PICK UP", phoneRedial = "[%s]: *69", - phoneClue = "THE TIME IS %dP.M. πŸ””πŸ””πŸ””πŸ””πŸ””πŸ””πŸ””", + phoneClue = "πŸ””πŸ””πŸ””πŸ””πŸ””πŸ””πŸ””", } \ No newline at end of file diff --git a/src/level/world.lua b/src/level/world.lua index 09e3912..90284de 100644 --- a/src/level/world.lua +++ b/src/level/world.lua @@ -14,8 +14,6 @@ local contempra local terrain local spike local water -local building -local veil local light = require( "level.light" ) function t.start() @@ -25,8 +23,6 @@ function t.start() depth = true, } - veil = require( "models.veil" ) - building = require( "models.building" ) -- water = require( "models.water" ) sky = require( "models.sky" ) bell = require( "models.bell" ) @@ -49,7 +45,7 @@ local function matte( ) end end -function t.draw( view, proj, player ) +function t.draw( view, proj, x, z ) if isDebugging then end @@ -65,11 +61,9 @@ function t.draw( view, proj, player ) sky.draw( view, proj, light ) terrain.draw( view, proj, light ) - building.draw( view, proj, light ) bell.draw( view, proj, light ) - contempra.draw( view, proj, light ) spike.draw( view, proj, light ) - veil.draw( view, proj ) + contempra.draw( view, proj, light, x, z ) love.graphics.pop() diff --git a/src/models/bell.lua b/src/models/bell.lua index 79db485..3503598 100644 --- a/src/models/bell.lua +++ b/src/models/bell.lua @@ -110,8 +110,8 @@ local bellInstanceMesh do local c, s = math.cos( 2*math.pi / 7 ), -math.sin( 2*math.pi / 7 ) - local x, z = 1, 0 - local r = 40 + local x, z = math.cos(math.pi/7), -math.sin( math.pi/7 ) + local r = 20 for i = 1, 7 do bells[i] = { i / 2, r * x, r * z, (i-1)/6 } x, z = c*x+s*z, c*z-s*x diff --git a/src/models/building.bin b/src/models/building.bin deleted file mode 100644 index 35578f8..0000000 Binary files a/src/models/building.bin and /dev/null differ diff --git a/src/models/building.gltf b/src/models/building.gltf deleted file mode 100644 index c2c47dc..0000000 --- a/src/models/building.gltf +++ /dev/null @@ -1,96 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v4.2.70", - "version":"2.0" - }, - "scene":0, - "scenes":[ - { - "name":"Scene", - "nodes":[ - 0 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"Building", - "translation":[ - 0, - 1, - 0 - ] - } - ], - "meshes":[ - { - "name":"Building", - "primitives":[ - { - "attributes":{ - "POSITION":0, - "NORMAL":1 - }, - "indices":2 - } - ] - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5126, - "count":643, - "max":[ - 10.494050979614258, - 2.4390439987182617, - 10.381834983825684 - ], - "min":[ - -9.749046325683594, - -0.9988071918487549, - -10.38186264038086 - ], - "type":"VEC3" - }, - { - "bufferView":1, - "componentType":5126, - "count":643, - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5123, - "count":999, - "type":"SCALAR" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":7716, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":7716, - "byteOffset":7716, - "target":34962 - }, - { - "buffer":0, - "byteLength":1998, - "byteOffset":15432, - "target":34963 - } - ], - "buffers":[ - { - "byteLength":17432, - "uri":"building.bin" - } - ] -} diff --git a/src/models/building.lua b/src/models/building.lua deleted file mode 100644 index 36eb2bd..0000000 --- a/src/models/building.lua +++ /dev/null @@ -1,94 +0,0 @@ -local dkjson = require( "lib.dkjson" ) -local love = assert( love ) -local shader = require( "shaders.flat" ) -local mat = require( "mat4" ) - -local attributeNames = { - POSITION = "VertexPosition", - NORMAL = "VertexNormal", -} - -local types = { - ["SCALAR"] = 1, - ["VEC3"] = 3, -} - -local componentTypes = { - [5121] = "byte", - [5123] = "unorm16", - [5126] = "float", -} - -local elementComponentTypes = { - [5123] = "uint16", - [5126] = "uint32", -} - -local asset -local buffer -do - local fd = assert( love.filesystem.newFileData( "models/building.gltf" ) ) - asset = dkjson.decode( fd:getString() ) - buffer = love.filesystem.newFileData( "models/building.bin" ) -end - ---load all the bufferViews -local bufferViews = {} -for i, view in pairs( asset.bufferViews ) do - bufferViews[i] = love.data.newByteData( buffer, view.byteOffset, view.byteLength ) -end - -local function attributeFormat( attributeName, accessor ) - return {attributeNames[attributeName], componentTypes[accessor.componentType], types[accessor.type] } -end - -local function lgMesh( primitive ) - assert( not( primitive.mode ) ) --triangles only - - local finalMesh - for name, accIdx in pairs( primitive.attributes ) do - local acc = asset.accessors[accIdx+1] - - local mesh = love.graphics.newMesh( - {attributeFormat(name, acc)}, --vertexformat - acc.count, - "triangles", - "static" - ) - - local bfv = bufferViews[1+acc.bufferView] - mesh:setVertices( bfv ) - - if finalMesh then - finalMesh:attachAttribute( attributeNames[name], mesh ) - else - finalMesh = mesh - end - - end - - - do - local acc = asset.accessors[1+primitive.indices] - local bfv = bufferViews[1+acc.bufferView] - finalMesh:setVertexMap(bfv, elementComponentTypes[acc.componentType] ) - end - return finalMesh -end - -local obj = {} -local mesh = lgMesh( asset.meshes[1].primitives[1] ) -local id = mat.TRS(2,2,2,0,0,0,0,2,0) - -function obj.draw( view, proj, light ) - love.graphics.setMeshCullMode( "none" ) - shader:send( "view", "column", view ) - shader:send( "proj", "column", proj ) - shader:send( "light", light ) - love.graphics.setShader( shader ) - love.graphics.setColor( 0.05,0.05,0.1,1.0 ) - shader:send( "mdl", "column", id ) - love.graphics.draw( mesh ) -end - -return obj \ No newline at end of file diff --git a/src/models/contempra.bin b/src/models/contempra.bin index 059a6d9..7ad9b07 100644 Binary files a/src/models/contempra.bin and b/src/models/contempra.bin differ diff --git a/src/models/contempra.gltf b/src/models/contempra.gltf index 26b60ab..1b2584f 100644 --- a/src/models/contempra.gltf +++ b/src/models/contempra.gltf @@ -11,7 +11,11 @@ "nodes":[ 0, 1, - 2 + 2, + 3, + 4, + 5, + 6 ] } ], @@ -59,6 +63,22 @@ 1, 0 ] + }, + { + "mesh":3, + "name":"Structure" + }, + { + "mesh":4, + "name":"Rings" + }, + { + "mesh":5, + "name":"Ring" + }, + { + "mesh":6, + "name":"Veil" } ], "meshes":[ @@ -97,6 +117,54 @@ "indices":8 } ] + }, + { + "name":"Structure", + "primitives":[ + { + "attributes":{ + "POSITION":9, + "NORMAL":10 + }, + "indices":11 + } + ] + }, + { + "name":"Rings", + "primitives":[ + { + "attributes":{ + "POSITION":12, + "NORMAL":13 + }, + "indices":14 + } + ] + }, + { + "name":"Ring", + "primitives":[ + { + "attributes":{ + "POSITION":15, + "NORMAL":16 + }, + "indices":17 + } + ] + }, + { + "name":"Veil", + "primitives":[ + { + "attributes":{ + "POSITION":18, + "NORMAL":19 + }, + "indices":20 + } + ] } ], "accessors":[ @@ -183,6 +251,118 @@ "componentType":5123, "count":546, "type":"SCALAR" + }, + { + "bufferView":9, + "componentType":5126, + "count":4169, + "max":[ + 10.97492790222168, + 5.941353797912598, + 10.650248527526855 + ], + "min":[ + -9.984618186950684, + 0, + -10.74928092956543 + ], + "type":"VEC3" + }, + { + "bufferView":10, + "componentType":5126, + "count":4169, + "type":"VEC3" + }, + { + "bufferView":11, + "componentType":5123, + "count":6240, + "type":"SCALAR" + }, + { + "bufferView":12, + "componentType":5126, + "count":4704, + "max":[ + 9.912541389465332, + 9.3552885055542, + 9.751956939697266 + ], + "min":[ + -9.272379875183105, + 5.85702657699585, + -9.751955032348633 + ], + "type":"VEC3" + }, + { + "bufferView":13, + "componentType":5126, + "count":4704, + "type":"VEC3" + }, + { + "bufferView":14, + "componentType":5123, + "count":7056, + "type":"SCALAR" + }, + { + "bufferView":15, + "componentType":5126, + "count":84, + "max":[ + 5.228943824768066, + 9.8660249710083, + 5.652868747711182 + ], + "min":[ + -5.799994945526123, + 8.1339750289917, + -5.656285762786865 + ], + "type":"VEC3" + }, + { + "bufferView":16, + "componentType":5126, + "count":84, + "type":"VEC3" + }, + { + "bufferView":17, + "componentType":5123, + "count":126, + "type":"SCALAR" + }, + { + "bufferView":18, + "componentType":5126, + "count":35, + "max":[ + 10, + 3.4767696857452393, + 9.749279022216797 + ], + "min":[ + -9.009689331054688, + 0, + -9.749279975891113 + ], + "type":"VEC3" + }, + { + "bufferView":19, + "componentType":5126, + "count":35, + "type":"VEC3" + }, + { + "bufferView":20, + "componentType":5123, + "count":57, + "type":"SCALAR" } ], "bufferViews":[ @@ -239,11 +419,83 @@ "byteLength":1092, "byteOffset":66792, "target":34963 + }, + { + "buffer":0, + "byteLength":50028, + "byteOffset":67884, + "target":34962 + }, + { + "buffer":0, + "byteLength":50028, + "byteOffset":117912, + "target":34962 + }, + { + "buffer":0, + "byteLength":12480, + "byteOffset":167940, + "target":34963 + }, + { + "buffer":0, + "byteLength":56448, + "byteOffset":180420, + "target":34962 + }, + { + "buffer":0, + "byteLength":56448, + "byteOffset":236868, + "target":34962 + }, + { + "buffer":0, + "byteLength":14112, + "byteOffset":293316, + "target":34963 + }, + { + "buffer":0, + "byteLength":1008, + "byteOffset":307428, + "target":34962 + }, + { + "buffer":0, + "byteLength":1008, + "byteOffset":308436, + "target":34962 + }, + { + "buffer":0, + "byteLength":252, + "byteOffset":309444, + "target":34963 + }, + { + "buffer":0, + "byteLength":420, + "byteOffset":309696, + "target":34962 + }, + { + "buffer":0, + "byteLength":420, + "byteOffset":310116, + "target":34962 + }, + { + "buffer":0, + "byteLength":114, + "byteOffset":310536, + "target":34963 } ], "buffers":[ { - "byteLength":67884, + "byteLength":310652, "uri":"contempra.bin" } ] diff --git a/src/models/contempra.lua b/src/models/contempra.lua index c689885..cb8671a 100644 --- a/src/models/contempra.lua +++ b/src/models/contempra.lua @@ -110,18 +110,41 @@ local colors = setmetatable( Handset = {0.9, 0.1, 0.1 }, Phone = {0.85, 0.1, 0.1 }, Table = {0.30, 0.1, 0.1 }, + Plane = {0.14, 0.1, 0.1 }, + Veil = {1.0, 1.0, 1.0, 1.0 }, }, - {__index = { 0, 0, 0 } } + {__index = function() return { 0.3, 0, 0 } end} ) -function obj.draw( view, proj, light ) +local shaders = { + Veil = require( "shaders.veil" ) +} + +local function veilAlpha( x, z ) + return math.max( 0, math.min( 1.0, 1.0 - (x*x+z*z - 7.0) / 25.0)) +end + +function obj.draw( view, proj, light, x, z ) + if veilAlpha( x, z ) > 0.0 then + love.graphics.setDepthMode( "less", false ) + local s = shaders.Veil + love.graphics.setShader( s ) + s:send( "view", "column", view ) + s:send( "proj", "column", proj ) + love.graphics.setColor( 0, 0, 0, veilAlpha( x, z ) ) + love.graphics.draw( meshes.Veil ) + love.graphics.setBlendMode( "alpha" ) + love.graphics.setDepthMode( "less", true ) + end + shader:send( "view", "column", view ) shader:send( "proj", "column", proj ) shader:send( "light", light ) love.graphics.setShader( shader ) for name, mesh in pairs( meshes ) do - if ( name ~= "Handset" or not obj.pickedUp ) then - love.graphics.setColor( colors[name] ) + love.graphics.setColor( colors[name] ) + if name ~= "Veil" and + ( name ~= "Handset" or not obj.pickedUp ) then shader:send( "mdl", "column", transforms[name] ) love.graphics.draw( mesh ) end diff --git a/src/models/terrain.lua b/src/models/terrain.lua index 69f470e..947cb6b 100644 --- a/src/models/terrain.lua +++ b/src/models/terrain.lua @@ -56,11 +56,17 @@ local shader = love.graphics.newShader[[ uniform sampler2D height; uniform mat4 view; uniform mat4 proj; + + float sigmoid( float x ){ + return 1.0 / ( 1.0 + exp( -x ) ); + } + vec4 position( mat4 _, vec4 pos ){ pos = pos.xzyw; float y = Texel( height, pos.xz / 256.0 ).r - 0.5; uv = 0.25 * (pos.xz + vec2(y, sin( y ) )); - pos.y += y; + float r = dot( pos.xz, pos.xz ); + pos.y = sigmoid( r / 50.0 - 20.0 ) * ( 1.0 + y ) * 0.05 * r / (sqrt( r ) + 1) - 0.01; world = pos.xyz; vec4 eye = view*pos; diff --git a/src/shaders/veil.lua b/src/shaders/veil.lua index 9cdfef7..37c38fb 100644 --- a/src/shaders/veil.lua +++ b/src/shaders/veil.lua @@ -1,21 +1,14 @@ return love.graphics.newShader[[ - #define fog vec4( 0.85, 0.85, 1.0, 1.0 ) - #define blue vec4( 0.6, 0.6, 0.7, 0.0 ) - - varying float d; #ifdef VERTEX uniform mat4 view; uniform mat4 proj; vec4 position( mat4 _, vec4 pos ){ - pos.xyz *= 16.0; - vec4 eye = view*pos; - d = clamp( -eye.z / 16.0 - 0.4, 0.0, 1.0 ); - return proj*eye; + return proj*view*pos; } #endif #ifdef PIXEL vec4 effect( vec4 color, Image _, vec2 __, vec2 ___) { - return mix( blue, fog, d); + return color; } #endif ]] \ No newline at end of file