diff --git a/res/project/game.proj b/res/project/game.proj index 4686656..981cd34 100644 --- a/res/project/game.proj +++ b/res/project/game.proj @@ -33,5 +33,5 @@ "path": "scenes://TestScene.evsc" }, ], - "activeScene": "MainScene" + "activeScene": "TestScene" } diff --git a/res/project/res/scenes/MainScene.evsc b/res/project/res/scenes/MainScene.evsc index abad1fa..f73ebf8 100644 --- a/res/project/res/scenes/MainScene.evsc +++ b/res/project/res/scenes/MainScene.evsc @@ -85,6 +85,11 @@ "type": "ScriptComponent", "script_name": "MainPlayerController", "script_path": "scripts://MainScene/Player.lua" + }, + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" } ], "children": [ @@ -119,6 +124,11 @@ "type": "ScriptComponent", "script_name": "MainChildController", "script_path": "scripts://MainScene/Child.lua" + }, + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" } ] } @@ -195,6 +205,11 @@ "type": "Box", "halfExtents": [1.0, 4.0, 9.0] } + }, + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" } ] }, diff --git a/res/project/res/scenes/TestScene.evsc b/res/project/res/scenes/TestScene.evsc index 9a6054e..a6ed9b2 100644 --- a/res/project/res/scenes/TestScene.evsc +++ b/res/project/res/scenes/TestScene.evsc @@ -98,7 +98,7 @@ "type": "ScriptComponent", "script_name": "MainPlayerController", "script_path": "scripts://TestScene/Player.lua" - } + }, ] }, { @@ -119,6 +119,11 @@ "type": "Sphere", "radius": 1.0 } + }, + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" } ] }, @@ -140,12 +145,22 @@ "type": "Sphere", "radius": 1.0 } + }, + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" } ] }, { "id": "Ball3", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -167,6 +182,11 @@ { "id": "Ball4", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -188,6 +208,11 @@ { "id": "Ball5", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -209,6 +234,11 @@ { "id": "Ball6", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -230,6 +260,11 @@ { "id": "Ball7", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -251,6 +286,11 @@ { "id": "Ball9", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -272,6 +312,11 @@ { "id": "Ball10", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -293,6 +338,11 @@ { "id": "Ball11", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -314,6 +364,11 @@ { "id": "Ball12", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -335,6 +390,11 @@ { "id": "Ball13", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -356,6 +416,11 @@ { "id": "Ball14", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -377,6 +442,11 @@ { "id": "Ball15", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -398,6 +468,11 @@ { "id": "Ball16", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -419,6 +494,11 @@ { "id": "Ball17", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -440,6 +520,11 @@ { "id": "Ball18", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -461,6 +546,11 @@ { "id": "Ball19", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -482,6 +572,11 @@ { "id": "Ball21", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -503,6 +598,11 @@ { "id": "Ball22", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -524,6 +624,11 @@ { "id": "Ball23", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "GreenMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -545,6 +650,11 @@ { "id": "Ball24", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -566,6 +676,11 @@ { "id": "Ball25", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -587,6 +702,11 @@ { "id": "Ball26", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -608,6 +728,11 @@ { "id": "Ball27", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -629,6 +754,11 @@ { "id": "Ball28", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -650,6 +780,11 @@ { "id": "Ball29", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -671,6 +806,11 @@ { "id": "Ball30", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -692,6 +832,11 @@ { "id": "Ball31", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -713,6 +858,11 @@ { "id": "Ball32", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -734,6 +884,11 @@ { "id": "Ball33", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -755,6 +910,11 @@ { "id": "Ball34", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -776,6 +936,11 @@ { "id": "Ball35", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -797,6 +962,11 @@ { "id": "Ball36", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -818,6 +988,11 @@ { "id": "Ball37", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -839,6 +1014,11 @@ { "id": "Ball38", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -860,6 +1040,11 @@ { "id": "Ball39", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -881,6 +1066,11 @@ { "id": "Ball40", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -902,6 +1092,11 @@ { "id": "Ball41", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -923,6 +1118,11 @@ { "id": "Ball42", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -944,6 +1144,11 @@ { "id": "Ball43", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -965,6 +1170,11 @@ { "id": "Ball44", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -986,6 +1196,11 @@ { "id": "Ball45", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1007,6 +1222,11 @@ { "id": "Ball46", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1028,6 +1248,11 @@ { "id": "Ball47", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1049,6 +1274,11 @@ { "id": "Ball48", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1070,6 +1300,11 @@ { "id": "Ball49", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1091,6 +1326,11 @@ { "id": "Ball50", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1112,6 +1352,11 @@ { "id": "Ball51", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1133,6 +1378,11 @@ { "id": "Ball52", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1154,6 +1404,11 @@ { "id": "Ball53", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1175,6 +1430,11 @@ { "id": "Ball54", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1196,6 +1456,11 @@ { "id": "Ball55", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1217,6 +1482,11 @@ { "id": "Ball56", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1238,6 +1508,11 @@ { "id": "Ball57", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1259,6 +1534,11 @@ { "id": "Ball58", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1280,6 +1560,11 @@ { "id": "Ball59", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1301,6 +1586,11 @@ { "id": "Ball60", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], @@ -1322,6 +1612,11 @@ { "id": "Ball61", "components": [ + { + "type": "RenderComponent", + "mesh": "project://Avocado.mesh", + "material": "WhiteMaterial" + }, { "type": "TransformComponent", "position": [0.0, 10.0, -15.0], diff --git a/res/project/res/scripts/MainScene/Camera.lua b/res/project/res/scripts/MainScene/Camera.lua index 0edf53b..8ff3834 100644 --- a/res/project/res/scripts/MainScene/Camera.lua +++ b/res/project/res/scripts/MainScene/Camera.lua @@ -15,6 +15,9 @@ this.on_update = function() if Input.getKeyJustPressed(Input.KeyCode.Enter) then gotoScene('SideScene') end + if Input.getKeyJustPressed(Input.KeyCode.T) then + gotoScene('TestScene') + end local pos = this.position diff --git a/res/project/res/shaders/default.frag b/res/project/res/shaders/default.frag index 482980a..1a80a3a 100644 --- a/res/project/res/shaders/default.frag +++ b/res/project/res/shaders/default.frag @@ -13,7 +13,7 @@ layout(location = 1) in Material material; layout(location = 0) out vec4 outColor; void main() { - //float intensity = ((dot(normalize(normal), normalize(directional_light)) +1)/2.0)+0.05; + float intensity = ((dot(normalize(normal), normalize(directional_light)) +1)/2.0)+0.05; - //outColor = vec4(material.baseColor * intensity, 1.0); + outColor = vec4(material.baseColor * intensity, 1.0); } diff --git a/res/project/res/shaders/default.vert b/res/project/res/shaders/default.vert index 316f40a..21c2b57 100644 --- a/res/project/res/shaders/default.vert +++ b/res/project/res/shaders/default.vert @@ -42,23 +42,19 @@ layout(set = 1, binding = 2) buffer IndexBuffer { } IndexBuffers[]; layout(set = 1, binding = 3) buffer MaterialBuffer { - layout(align = 16) Material material; -} MaterialBuffers[]; + layout(align = 16) Material materials[]; +} MaterialBuffers; layout(location = 0) out vec3 normal; layout(location = 1) out Material material; void main() { - //Mesh mesh = MeshBuffers[PushConstants.meshIndex].mesh; - //material = MaterialBuffers[ mesh.materialBufferIndex ].material; - material = MaterialBuffers[ PushConstants.materialBufferIndex ].material; + material = MaterialBuffers.materials[ PushConstants.materialBufferIndex ]; uint index = IndexBuffers[ PushConstants.indexBufferIndex ].indices[gl_VertexIndex]; - //uint index = IndexBuffers[ mesh.indexBufferIndex ].indices[gl_VertexIndex]; - //Vertex vertex = VertexBuffers[ mesh.vertexBufferIndex ].vertices[ index ]; Vertex vertex = VertexBuffers[ PushConstants.vertexBufferIndex ].vertices[ index ]; normal = vertex.normal.xyz; - gl_Position = Camera.projection * Camera.view * PushConstants.render_matrix * vec4(vertex.position.x, vertex.position.y, vertex.position.z, 1.0); + gl_Position = Camera.projection * Camera.view * PushConstants.render_matrix * vec4(vertex.position.xyz, 1.0); } diff --git a/src/main.c b/src/main.c index dec5ae5..dbb81d4 100644 --- a/src/main.c +++ b/src/main.c @@ -41,6 +41,10 @@ void project_changed_cb() { Game->clearScenes(); + /* evol_unloadmodule(State.renderer_mod); */ + /* State.renderer_mod = evol_loadmodule("renderer"); */ + /* Renderer->setWindow((GenericHandle)State.window); */ + evstring project_dir = NULL; EvConfigLoaderResult project_dir_get_res = ev_configloader_get("project_dir", EV_TYPE_NAME(STRING), &project_dir); @@ -81,7 +85,6 @@ project_changed_cb() evstring_free(path_id); } - // Loading Scenes double scene_count = evjs_get(project_desc.json_data, "scenes.len")->as_num; for(int i = 0; i < (int)scene_count;i++) { @@ -106,10 +109,6 @@ project_changed_cb() evstring_free(project_dir); - evol_unloadmodule(State.renderer_mod); - State.renderer_mod = evol_loadmodule("renderer"); - - Renderer->setWindow((GenericHandle)State.window); } void @@ -173,8 +172,6 @@ load_project() evstring_free(path_id); } - Renderer->setWindow((GenericHandle)State.window); - // Loading Scenes double scene_count = evjs_get(project_desc.json_data, "scenes.len")->as_num; for(int i = 0; i < (int)scene_count;i++) {