Fixed model with texture and texture-less objects having texture-less objects renderer 'black' due to having hasTexture incorrectly set for shader

This commit is contained in:
2020-05-11 23:05:34 -05:00
parent f72a8d4c35
commit fa2873bb8f
2 changed files with 5 additions and 2 deletions

View File

@@ -43,7 +43,6 @@ class IMICFPS
shader.uniform_transform("projection", camera.projection_matrix)
shader.uniform_transform("view", camera.view_matrix)
shader.uniform_transform("model", entity.model_matrix)
shader.uniform_boolean("hasTexture", entity.model.has_texture?)
shader.uniform_vec3("cameraPosition", camera.position)
gl_error?
@@ -167,8 +166,12 @@ class IMICFPS
offset = 0
model.objects.each do |object|
shader.uniform_boolean("hasTexture", object.has_texture?)
if object.has_texture?
glBindTexture(GL_TEXTURE_2D, object.materials.find { |mat| mat.texture_id }.texture_id)
else
glBindTexture(GL_TEXTURE_2D, 0)
end
glDrawArrays(GL_TRIANGLES, offset, object.faces.count * 3)

View File

@@ -30,7 +30,7 @@ class IMICFPS
end
# Try searching shared textures folder
unless File.exist?(path)
if path && !File.exist?(path)
path = "#{IMICFPS.assets_path}/base/shared/textures/#{path.split("/").last}"
end