reworked building and veil

This commit is contained in:
wan-may 2025-03-20 20:38:51 -03:00
parent b1e4ea12c1
commit 5a5a31430c
11 changed files with 304 additions and 220 deletions

View File

@ -23,12 +23,18 @@ ENTER TO KEEP]],
mouseSensitivity = "TURN SPEED", mouseSensitivity = "TURN SPEED",
language = "LANGUAGE", language = "LANGUAGE",
FOV = "FOV", FOV = "FOV",
win = [[ZIMINIAR HAS ARRIVED. THE WORLD WILL NEVER BE THE SAME. win = [[RICHES TO THE CONJUROR! ZIMINIAR IS MANIFEST.
RICHES TO THE CONJUROR! 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", phoneRing = "THE PHONE RINGS IMPATIENTLY",
phonePickup = "[%s]: PICK UP", phonePickup = "[%s]: PICK UP",
phoneRedial = "[%s]: *69", phoneRedial = "[%s]: *69",
phoneClue = "THE TIME IS %dP.M. 🔔🔔🔔🔔🔔🔔🔔", phoneClue = "🔔🔔🔔🔔🔔🔔🔔",
} }

View File

@ -14,8 +14,6 @@ local contempra
local terrain local terrain
local spike local spike
local water local water
local building
local veil
local light = require( "level.light" ) local light = require( "level.light" )
function t.start() function t.start()
@ -25,8 +23,6 @@ function t.start()
depth = true, depth = true,
} }
veil = require( "models.veil" )
building = require( "models.building" )
-- water = require( "models.water" ) -- water = require( "models.water" )
sky = require( "models.sky" ) sky = require( "models.sky" )
bell = require( "models.bell" ) bell = require( "models.bell" )
@ -49,7 +45,7 @@ local function matte( )
end end
end end
function t.draw( view, proj, player ) function t.draw( view, proj, x, z )
if isDebugging then if isDebugging then
end end
@ -65,11 +61,9 @@ function t.draw( view, proj, player )
sky.draw( view, proj, light ) sky.draw( view, proj, light )
terrain.draw( view, proj, light ) terrain.draw( view, proj, light )
building.draw( view, proj, light )
bell.draw( view, proj, light ) bell.draw( view, proj, light )
contempra.draw( view, proj, light )
spike.draw( view, proj, light ) spike.draw( view, proj, light )
veil.draw( view, proj ) contempra.draw( view, proj, light, x, z )
love.graphics.pop() love.graphics.pop()

View File

@ -110,8 +110,8 @@ local bellInstanceMesh
do do
local c, s = math.cos( 2*math.pi / 7 ), -math.sin( 2*math.pi / 7 ) local c, s = math.cos( 2*math.pi / 7 ), -math.sin( 2*math.pi / 7 )
local x, z = 1, 0 local x, z = math.cos(math.pi/7), -math.sin( math.pi/7 )
local r = 40 local r = 20
for i = 1, 7 do for i = 1, 7 do
bells[i] = { i / 2, r * x, r * z, (i-1)/6 } bells[i] = { i / 2, r * x, r * z, (i-1)/6 }
x, z = c*x+s*z, c*z-s*x x, z = c*x+s*z, c*z-s*x

Binary file not shown.

View File

@ -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"
}
]
}

View File

@ -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

Binary file not shown.

View File

@ -11,7 +11,11 @@
"nodes":[ "nodes":[
0, 0,
1, 1,
2 2,
3,
4,
5,
6
] ]
} }
], ],
@ -59,6 +63,22 @@
1, 1,
0 0
] ]
},
{
"mesh":3,
"name":"Structure"
},
{
"mesh":4,
"name":"Rings"
},
{
"mesh":5,
"name":"Ring"
},
{
"mesh":6,
"name":"Veil"
} }
], ],
"meshes":[ "meshes":[
@ -97,6 +117,54 @@
"indices":8 "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":[ "accessors":[
@ -183,6 +251,118 @@
"componentType":5123, "componentType":5123,
"count":546, "count":546,
"type":"SCALAR" "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":[ "bufferViews":[
@ -239,11 +419,83 @@
"byteLength":1092, "byteLength":1092,
"byteOffset":66792, "byteOffset":66792,
"target":34963 "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":[ "buffers":[
{ {
"byteLength":67884, "byteLength":310652,
"uri":"contempra.bin" "uri":"contempra.bin"
} }
] ]

View File

@ -110,18 +110,41 @@ local colors = setmetatable(
Handset = {0.9, 0.1, 0.1 }, Handset = {0.9, 0.1, 0.1 },
Phone = {0.85, 0.1, 0.1 }, Phone = {0.85, 0.1, 0.1 },
Table = {0.30, 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( "view", "column", view )
shader:send( "proj", "column", proj ) shader:send( "proj", "column", proj )
shader:send( "light", light ) shader:send( "light", light )
love.graphics.setShader( shader ) love.graphics.setShader( shader )
for name, mesh in pairs( meshes ) do 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] ) shader:send( "mdl", "column", transforms[name] )
love.graphics.draw( mesh ) love.graphics.draw( mesh )
end end

View File

@ -56,11 +56,17 @@ local shader = love.graphics.newShader[[
uniform sampler2D height; uniform sampler2D height;
uniform mat4 view; uniform mat4 view;
uniform mat4 proj; uniform mat4 proj;
float sigmoid( float x ){
return 1.0 / ( 1.0 + exp( -x ) );
}
vec4 position( mat4 _, vec4 pos ){ vec4 position( mat4 _, vec4 pos ){
pos = pos.xzyw; pos = pos.xzyw;
float y = Texel( height, pos.xz / 256.0 ).r - 0.5; float y = Texel( height, pos.xz / 256.0 ).r - 0.5;
uv = 0.25 * (pos.xz + vec2(y, sin( y ) )); 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; world = pos.xyz;
vec4 eye = view*pos; vec4 eye = view*pos;

View File

@ -1,21 +1,14 @@
return love.graphics.newShader[[ 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 #ifdef VERTEX
uniform mat4 view; uniform mat4 view;
uniform mat4 proj; uniform mat4 proj;
vec4 position( mat4 _, vec4 pos ){ vec4 position( mat4 _, vec4 pos ){
pos.xyz *= 16.0; return proj*view*pos;
vec4 eye = view*pos;
d = clamp( -eye.z / 16.0 - 0.4, 0.0, 1.0 );
return proj*eye;
} }
#endif #endif
#ifdef PIXEL #ifdef PIXEL
vec4 effect( vec4 color, Image _, vec2 __, vec2 ___) { vec4 effect( vec4 color, Image _, vec2 __, vec2 ___) {
return mix( blue, fog, d); return color;
} }
#endif #endif
]] ]]