Hello,
I am currently have poor performance in my OpenGL program. I know that many of you will want me to quantify “poor.” My program currently renders a scene with 100 objects at about ~40FPS. If I set this scene up in Blender (using Blender Render) it runs at around >200FPS. I am unsure what type of render method that Blender uses, but my program is using deferred rendering. I believe that my over-usage of renderbuffers is causing the issue. I narrowed this down, because depending on which/how many renderbuffers I disable, performance increases to around ~140FPS. I am unfortunatly unsure of how to pass the information to the lighting shader without the use of renderbuffers. I was wondering if someone could take a look at my shaders to help me along.
I am currently combining other shaders with these, and it eliminates the use of two renderbuffers.
material.vert
#version 330 core
layout (location = 0) in vec3 vertex;
layout (location = 3) in vec2 texcoord;
out vec3 frag_vertex;
out vec2 frag_texcoord;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
void main (void) {
gl_Position = (P * V * M) * vec4(vertex, 1.0);
frag_vertex = vertex;
frag_texcoord = texcoord;
}
material.frag
#version 330 core
in vec3 frag_vertex;
in vec2 frag_texcoord;
layout (location = 0) out vec4 out_texture_diffuse;
layout (location = 1) out vec4 out_texture_normal;
layout (location = 2) out vec4 out_texture_specular;
layout (location = 3) out vec4 out_texture_emissive;
layout (location = 4) out vec4 out_properties;
uniform sampler2D texture_diffuse;
uniform sampler2D texture_normal;
uniform sampler2D texture_specular;
uniform sampler2D texture_emissive;
uniform vec3 diffuse_color;
uniform vec3 specular_color;
uniform float diffuse_intensity;
uniform float specular_intensity;
uniform float specular_hardness;
uniform float translucency;
uniform int has_diffuse_texture;
uniform int has_normal_texture;
uniform int has_specular_texture;
uniform int has_emissive_texture;
void main (void) {
out_texture_diffuse = ((1 - has_diffuse_texture) * vec4(diffuse_color, 1.0)) + (has_diffuse_texture * texture(texture_diffuse, frag_texcoord));
if (out_texture_diffuse.a < 0.1) discard;
out_texture_normal = ((1 - has_normal_texture) * vec4(0.5, 0.5, 1.0, 1.0)) + (has_normal_texture * texture(texture_normal, frag_texcoord));
out_texture_specular = ((1 - has_specular_texture) * vec4(0.0, 0.0, 0.0, 1.0)) + (has_specular_texture * texture(texture_specular, frag_texcoord));
out_texture_emissive = ((1 - has_emissive_texture) * vec4(0.0, 0.0, 0.0, 1.0)) * (has_emissive_texture * texture(texture_emissive, frag_texcoord));
out_texture_specular *= vec4(specular_color, 1.0);
out_properties = vec4(diffuse_intensity, specular_intensity, specular_hardness, translucency);
}
Thank You