diff --git a/assets/model/monitor_graphics.fbx b/assets/model/monitor_graphics.fbx deleted file mode 100644 index 02f60fa..0000000 Binary files a/assets/model/monitor_graphics.fbx and /dev/null differ diff --git a/assets/model/pump_switch_1.fbx b/assets/model/pump_switch_1.fbx deleted file mode 100644 index 6f50f7c..0000000 Binary files a/assets/model/pump_switch_1.fbx and /dev/null differ diff --git a/assets/model/pump_switch_2.fbx b/assets/model/pump_switch_2.fbx deleted file mode 100644 index c05e9d2..0000000 Binary files a/assets/model/pump_switch_2.fbx and /dev/null differ diff --git a/assets/model/pump_switch_3.fbx b/assets/model/pump_switch_3.fbx deleted file mode 100644 index 3830445..0000000 Binary files a/assets/model/pump_switch_3.fbx and /dev/null differ diff --git a/assets/model/reactor_core_interface_cell.scad b/assets/model/reactor_core_interface_cell.scad deleted file mode 100644 index 317d259..0000000 --- a/assets/model/reactor_core_interface_cell.scad +++ /dev/null @@ -1,3 +0,0 @@ - -linear_extrude(0.0001) -square([1, 1], center = true); diff --git a/assets/model/reactor_core_interface_circle.scad b/assets/model/reactor_core_interface_circle.scad deleted file mode 100644 index 4bdc405..0000000 --- a/assets/model/reactor_core_interface_circle.scad +++ /dev/null @@ -1,10 +0,0 @@ - -$fn = 256; - -linear_extrude(0.0001) -translate([0.5, 0.5]) -difference() -{ - circle(d = 0.81); - circle(d = 0.8); -} diff --git a/assets/model/resistor_bank_switch.fbx b/assets/model/resistor_bank_switch.fbx deleted file mode 100644 index 2120830..0000000 Binary files a/assets/model/resistor_bank_switch.fbx and /dev/null differ diff --git a/assets/model/synchroscope_dial.fbx b/assets/model/synchroscope_dial.fbx deleted file mode 100644 index 5ca4a9d..0000000 Binary files a/assets/model/synchroscope_dial.fbx and /dev/null differ diff --git a/assets/model/turbine_breaker_switch.fbx b/assets/model/turbine_breaker_switch.fbx deleted file mode 100644 index e21ae15..0000000 Binary files a/assets/model/turbine_breaker_switch.fbx and /dev/null differ diff --git a/assets/model/turbine_valve_bypass_switch.fbx b/assets/model/turbine_valve_bypass_switch.fbx deleted file mode 100644 index 0ae2dc9..0000000 Binary files a/assets/model/turbine_valve_bypass_switch.fbx and /dev/null differ diff --git a/assets/model/turbine_valve_inlet_switch.fbx b/assets/model/turbine_valve_inlet_switch.fbx deleted file mode 100644 index 17e4251..0000000 Binary files a/assets/model/turbine_valve_inlet_switch.fbx and /dev/null differ diff --git a/assets/scene.bin b/assets/scene.bin deleted file mode 100644 index 252c405..0000000 Binary files a/assets/scene.bin and /dev/null differ diff --git a/assets/scene.fbx b/assets/scene.fbx deleted file mode 100644 index 461edc4..0000000 Binary files a/assets/scene.fbx and /dev/null differ diff --git a/assets/shader/light.fsh b/assets/shader/light.fsh new file mode 100644 index 0000000..7d36ad3 --- /dev/null +++ b/assets/shader/light.fsh @@ -0,0 +1,13 @@ + +#version 460 core + +in vec4 frag_pos; +out vec4 frag_colour; + +void main() +{ + float distance = length(frag_pos); + frag_colour = vec4(vec3(distance / 50.0f), 1); + gl_FragDepth = distance / 50.0f; +} + diff --git a/assets/shader/light.gsh b/assets/shader/light.gsh new file mode 100644 index 0000000..6c57360 --- /dev/null +++ b/assets/shader/light.gsh @@ -0,0 +1,28 @@ + +#version 460 core + +layout (triangles) in; +layout (triangle_strip, max_vertices=18) out; + +uniform mat4 shadow_mats[6]; + +out vec4 frag_pos; + +void main() +{ + for(int i = 0; i < 6; i++) + { + gl_Layer = i; + + for(int j = 0; j < 3; j++) + { + frag_pos = gl_in[j].gl_Position; + gl_Position = shadow_mats[i] * frag_pos; + + EmitVertex(); + } + + EndPrimitive(); + } +} + diff --git a/assets/shader/light.vsh b/assets/shader/light.vsh new file mode 100644 index 0000000..991ba7f --- /dev/null +++ b/assets/shader/light.vsh @@ -0,0 +1,13 @@ + +#version 460 core + +layout (location = 2) in vec4 aPos; + +uniform mat4 model; +uniform mat4 camera; + +void main() +{ + gl_Position = camera * model * aPos; +} + diff --git a/assets/test.bin b/assets/test.bin deleted file mode 100644 index abd0636..0000000 Binary files a/assets/test.bin and /dev/null differ diff --git a/assets/test.fbx b/assets/test.fbx deleted file mode 100644 index 2075ae9..0000000 Binary files a/assets/test.fbx and /dev/null differ diff --git a/assets/test.glb b/assets/test.glb deleted file mode 100644 index 9a42769..0000000 --- a/assets/test.glb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f83c9f4a59566dcb497c60c7470a92979eb610d09171f8f4471d5b284230d19c -size 29164 diff --git a/assets/test.gltf b/assets/test.gltf deleted file mode 100644 index 09cb0bd..0000000 --- a/assets/test.gltf +++ /dev/null @@ -1,382 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v4.0.44", - "version":"2.0" - }, - "scene":0, - "scenes":[ - { - "extras":{ - "SimpleBake_Props":{}, - "bake_to_vertex_color_props":{} - }, - "name":"Scene", - "nodes":[ - 0, - 1, - 2, - 3 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"Cylinder", - "translation":[ - 0, - 0, - 0.5 - ] - }, - { - "mesh":1, - "name":"Cylinder.001", - "translation":[ - 1, - 0, - 0.5 - ] - }, - { - "mesh":2, - "name":"Cylinder.002", - "translation":[ - 3, - 0, - 0.5 - ] - }, - { - "mesh":3, - "name":"Cylinder.003", - "translation":[ - 2, - 0, - 0.5 - ] - } - ], - "materials":[ - { - "doubleSided":true, - "name":"Material.006", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.75 - } - }, - { - "doubleSided":true, - "name":"Material.005", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.5 - } - }, - { - "doubleSided":true, - "name":"Material.003", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.125 - } - }, - { - "doubleSided":true, - "name":"Material.004", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.25 - } - } - ], - "meshes":[ - { - "name":"Cylinder", - "primitives":[ - { - "attributes":{ - "POSITION":0, - "NORMAL":1, - "TEXCOORD_0":2 - }, - "indices":3, - "material":0 - } - ] - }, - { - "name":"Cylinder.001", - "primitives":[ - { - "attributes":{ - "POSITION":4, - "NORMAL":5, - "TEXCOORD_0":6 - }, - "indices":3, - "material":1 - } - ] - }, - { - "name":"Cylinder.002", - "primitives":[ - { - "attributes":{ - "POSITION":7, - "NORMAL":8, - "TEXCOORD_0":9 - }, - "indices":3, - "material":2 - } - ] - }, - { - "name":"Cylinder.003", - "primitives":[ - { - "attributes":{ - "POSITION":10, - "NORMAL":11, - "TEXCOORD_0":12 - }, - "indices":3, - "material":3 - } - ] - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5126, - "count":192, - "max":[ - 0.20000000298023224, - 0.20000000298023224, - 0.5 - ], - "min":[ - -0.20000000298023224, - -0.20000000298023224, - -0.5 - ], - "type":"VEC3" - }, - { - "bufferView":1, - "componentType":5126, - "count":192, - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5126, - "count":192, - "type":"VEC2" - }, - { - "bufferView":3, - "componentType":5123, - "count":372, - "type":"SCALAR" - }, - { - "bufferView":4, - "componentType":5126, - "count":192, - "max":[ - 0.20000000298023224, - 0.20000000298023224, - 0.5 - ], - "min":[ - -0.20000000298023224, - -0.20000000298023224, - -0.5 - ], - "type":"VEC3" - }, - { - "bufferView":5, - "componentType":5126, - "count":192, - "type":"VEC3" - }, - { - "bufferView":6, - "componentType":5126, - "count":192, - "type":"VEC2" - }, - { - "bufferView":7, - "componentType":5126, - "count":192, - "max":[ - 0.20000000298023224, - 0.20000000298023224, - 0.5 - ], - "min":[ - -0.20000000298023224, - -0.20000000298023224, - -0.5 - ], - "type":"VEC3" - }, - { - "bufferView":8, - "componentType":5126, - "count":192, - "type":"VEC3" - }, - { - "bufferView":9, - "componentType":5126, - "count":192, - "type":"VEC2" - }, - { - "bufferView":10, - "componentType":5126, - "count":192, - "max":[ - 0.20000000298023224, - 0.20000000298023224, - 0.5 - ], - "min":[ - -0.20000000298023224, - -0.20000000298023224, - -0.5 - ], - "type":"VEC3" - }, - { - "bufferView":11, - "componentType":5126, - "count":192, - "type":"VEC3" - }, - { - "bufferView":12, - "componentType":5126, - "count":192, - "type":"VEC2" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":2304, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":2304, - "target":34962 - }, - { - "buffer":0, - "byteLength":1536, - "byteOffset":4608, - "target":34962 - }, - { - "buffer":0, - "byteLength":744, - "byteOffset":6144, - "target":34963 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":6888, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":9192, - "target":34962 - }, - { - "buffer":0, - "byteLength":1536, - "byteOffset":11496, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":13032, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":15336, - "target":34962 - }, - { - "buffer":0, - "byteLength":1536, - "byteOffset":17640, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":19176, - "target":34962 - }, - { - "buffer":0, - "byteLength":2304, - "byteOffset":21480, - "target":34962 - }, - { - "buffer":0, - "byteLength":1536, - "byteOffset":23784, - "target":34962 - } - ], - "buffers":[ - { - "byteLength":25320, - "uri":"test.bin" - } - ] -} diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index d98c282..5612fe1 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -13,6 +13,7 @@ using namespace Sim::Graphics; Shader Shader::MAIN; Shader Shader::BLUR; +Shader Shader::LIGHT; static int load_shader(const char* src, int type) { @@ -39,6 +40,12 @@ static std::string read_shader(const char* path) return ss.str(); } +static std::string read_shader(const char* base, const char* file) +{ + std::string path = std::string(base) + "/" + std::string(file); + return read_shader(path.c_str()); +} + Shader::Shader() { @@ -60,18 +67,29 @@ Shader::~Shader() void Shader::load(const char* path, const char* file_vsh, const char* file_fsh) { - std::string path_vsh = std::string(path) + "/" + std::string(file_vsh); - std::string path_fsh = std::string(path) + "/" + std::string(file_fsh); - std::string shader_vsh = read_shader(path_vsh.c_str()); - std::string shader_fsh = read_shader(path_fsh.c_str()); + load(path, file_vsh, nullptr, file_fsh); +} + +void Shader::load(const char* path, const char* file_vsh, const char* file_gsh, const char* file_fsh) +{ + std::string shader_vsh = file_vsh ? read_shader(path, file_vsh) : ""; + std::string shader_gsh = file_gsh ? read_shader(path, file_gsh) : ""; + std::string shader_fsh = file_fsh ? read_shader(path, file_fsh) : ""; int success; - int vsh_id = load_shader(shader_vsh.c_str(), GL_VERTEX_SHADER); - int fsh_id = load_shader(shader_fsh.c_str(), GL_FRAGMENT_SHADER); + int vsh_id = file_vsh ? load_shader(shader_vsh.c_str(), GL_VERTEX_SHADER) : 0; + int gsh_id = file_gsh ? load_shader(shader_gsh.c_str(), GL_GEOMETRY_SHADER) : 0; + int fsh_id = file_fsh ? load_shader(shader_fsh.c_str(), GL_FRAGMENT_SHADER) : 0; + prog_id = glCreateProgram(); - glAttachShader(prog_id, vsh_id); - glAttachShader(prog_id, fsh_id); + if(file_vsh) + glAttachShader(prog_id, vsh_id); + if(file_gsh) + glAttachShader(prog_id, gsh_id); + if(file_fsh) + glAttachShader(prog_id, fsh_id); + glLinkProgram(prog_id); glGetProgramiv(prog_id, GL_LINK_STATUS, &success); @@ -85,8 +103,13 @@ void Shader::load(const char* path, const char* file_vsh, const char* file_fsh) } glUseProgram(prog_id); - glDeleteShader(vsh_id); - glDeleteShader(fsh_id); + + if(file_vsh) + glDeleteShader(vsh_id); + if(file_gsh) + glDeleteShader(gsh_id); + if(file_fsh) + glDeleteShader(fsh_id); } void Shader::use() diff --git a/src/graphics/shader.hpp b/src/graphics/shader.hpp index af12c7e..ef53da4 100644 --- a/src/graphics/shader.hpp +++ b/src/graphics/shader.hpp @@ -16,12 +16,14 @@ public: static Shader MAIN; static Shader BLUR; + static Shader LIGHT; Shader(); Shader(const Shader& o) = delete; Shader(Shader&& o); ~Shader(); + void load(const char* path, const char* file_vsh, const char* file_gsh, const char* file_fsh); void load(const char* path, const char* file_vsh, const char* file_fsh); void use(); diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index b6b5912..8bb27b2 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -119,6 +119,7 @@ void Window::create() Font::init(); UI::init(); + Shader::LIGHT.load("../assets/shader", "light.vsh", "light.gsh", "light.fsh"); Shader::MAIN.load("../assets/shader", "main.vsh", "main.fsh"); glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -255,7 +256,7 @@ void Window::render() projection_matrix = mat_projection; glClearColor(0, 0, 0, 1.0f); - glClear(GL_DEPTH_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glFrontFace(GL_CW); render_scene();