Remove the 3d-"batched" rendering
This commit is contained in:
parent
1ea28a8790
commit
f2258f41c4
|
@ -77,9 +77,6 @@ int main(int argc, char *argv[]) {
|
|||
// Load core shaders from SimpleEngine resources
|
||||
se::gfx::shaders::Core3dShader core_shader;
|
||||
|
||||
auto light = std::make_shared<se::gfx::Light>(core_shader, glm::vec3(0.f, 1.f, -10.f), glm::vec3(1.f, 1.f, 1.f));
|
||||
game.add_event(light);
|
||||
|
||||
auto white_texture = se::gfx::Texture::white_texture();
|
||||
// white_texture.shine_damper = 10;
|
||||
//white_texture.reflectivity = 1;
|
||||
|
@ -183,16 +180,20 @@ int main(int argc, char *argv[]) {
|
|||
//entity.add_component<se::ModelComponent>("examples/dev_testing/resources/stall.obj");
|
||||
|
||||
// Backpack model required vertically flipped texture coords.
|
||||
auto& model_comp = entity.add_component<se::ModelComponent>("examples/dev_testing/resources/backpack/backpack.obj");
|
||||
model_comp.model.vertically_flip_tex_coords();
|
||||
/* auto& model_comp = entity.add_component<se::ModelComponent>("examples/dev_testing/resources/backpack/backpack.obj");
|
||||
model_comp.model.vertically_flip_tex_coords(); */
|
||||
|
||||
//entity.add_component<se::ModelComponent>("examples/dev_testing/resources/viper/viper.obj");
|
||||
entity.add_component<se::ModelComponent>("examples/dev_testing/resources/halo/halo.fbx");
|
||||
|
||||
//entity.add_component<se::ModelComponent>("examples/dev_testing/resources/scientist/scientist.fbx");
|
||||
//entity.add_component<se::ModelComponent>("examples/dev_testing/resources/paradigm/paradigm.fbx");
|
||||
//entity.add_component<se::RotatingComponent>();
|
||||
auto& transform_comp = entity.add_component<se::TransformComponent>();
|
||||
transform_comp.translate(15.f, -8.f, 0.f);
|
||||
/* transform_comp.scale(0.1f);
|
||||
transform_comp.rotate_z(-90.f);*/
|
||||
transform_comp.translate(7.f, -4.f, 0.f);
|
||||
transform_comp.scale(0.05f);
|
||||
//transform_comp.rotate_z(-90.f);
|
||||
transform_comp.rotate_y(-90.f);
|
||||
transform_comp.rotate_x(-90.f);
|
||||
|
||||
|
||||
|
@ -208,6 +209,9 @@ int main(int argc, char *argv[]) {
|
|||
auto camera = std::make_shared<se::Camera>(game.get_window(), core_shader, 70, glm::vec3(0, 0, 0));
|
||||
game.add_event(camera);
|
||||
|
||||
auto light = std::make_shared<se::gfx::Light>(core_shader, glm::vec3(-10.f, 0.f, 0.f), glm::vec3(1.f, 1.f, 1.f));
|
||||
game.add_event(light);
|
||||
|
||||
auto fps_counter = std::make_shared<FPSCounterEvent>();
|
||||
game.add_event(fps_counter);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ in vec3 vs_position;
|
|||
in vec3 vs_color;
|
||||
in vec3 vs_normal;
|
||||
in vec2 vs_texcoord;
|
||||
flat in float vs_tex_id; // < 0 is reserved for solid colored objects.
|
||||
|
||||
in mat4 vs_transform;
|
||||
in vec3 vs_to_light;
|
||||
|
@ -29,17 +28,13 @@ void main() {
|
|||
float brightness = max(dot_prod, 0.f);
|
||||
vec3 diffuse = brightness * light_color;
|
||||
|
||||
if (vs_tex_id > -1) {
|
||||
int id = int(vs_tex_id);
|
||||
// Calculate the specular
|
||||
float shine_damper = u_texture_shine[0];
|
||||
float reflectivity = u_texture_reflectivity[0];
|
||||
vec3 final_specular = calculate_specular(unit_normal, shine_damper, reflectivity);
|
||||
|
||||
float shine_damper = u_texture_shine[id];
|
||||
float reflectivity = u_texture_reflectivity[id];
|
||||
vec3 final_specular = calculate_specular(unit_normal, shine_damper, reflectivity);
|
||||
|
||||
fs_color = vec4(diffuse, 1.f) * texture(u_textures[id], vs_texcoord) + vec4(final_specular, 1.f);
|
||||
} else {
|
||||
fs_color = vec4(vs_color, 1.f); // We don't add any reflectivity to solid colored vectors.
|
||||
}
|
||||
// Combine diffuse lighting, specular, and the texture into one color.
|
||||
fs_color = vec4(diffuse, 1.f) * texture(u_textures[0], vs_texcoord) + vec4(final_specular, 1.f);
|
||||
}
|
||||
|
||||
vec3 calculate_specular(vec3 unit_normal, float shine_damper, float reflectivity) {
|
||||
|
|
|
@ -4,13 +4,11 @@ layout (location = 0) in vec3 vertex_position;
|
|||
layout (location = 1) in vec3 vertex_color;
|
||||
layout (location = 2) in vec3 vertex_normal;
|
||||
layout (location = 3) in vec2 vertex_texcoord;
|
||||
layout (location = 4) in float vertex_tex_id;
|
||||
|
||||
out vec3 vs_position;
|
||||
out vec3 vs_color;
|
||||
out vec3 vs_normal;
|
||||
out vec2 vs_texcoord;
|
||||
flat out float vs_tex_id;
|
||||
|
||||
out mat4 vs_transform;
|
||||
out vec3 vs_to_light;
|
||||
|
@ -30,9 +28,6 @@ void main() {
|
|||
vs_texcoord = vertex_texcoord;
|
||||
vs_color = vertex_color;
|
||||
|
||||
vs_tex_id = vertex_tex_id;
|
||||
|
||||
|
||||
gl_Position = projection_matrix * view_matrix * world_pos;
|
||||
|
||||
vs_normal = (transform_matrix * vec4(vertex_normal, 0.f)).xyz;
|
||||
|
|
|
@ -68,17 +68,19 @@ namespace simpleengine::gfx {
|
|||
for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
|
||||
LitVertex vertex;
|
||||
vertex.color = glm::vec3(1.f);
|
||||
vertex.texture_id = 0;
|
||||
vertex.texture_id = 0; // TODO
|
||||
|
||||
simpleengine::Vectorf position(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z);
|
||||
vertex.position = position;
|
||||
|
||||
// Only process normals if they exist.
|
||||
if (mesh->HasNormals()) {
|
||||
glm::vec3 normal(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z);
|
||||
vertex.normal = normal;
|
||||
}
|
||||
|
||||
if (mesh->mTextureCoords[0]) {
|
||||
// Only process texture coords if they exist.
|
||||
if (mesh->HasTextureCoords(0)) {
|
||||
glm::vec2 tex_coord(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y);
|
||||
|
||||
vertex.tex_coord = tex_coord;
|
||||
|
|
Loading…
Reference in New Issue