summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp128
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.h5
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp26
-rw-r--r--drivers/gles3/rasterizer_gles3.h4
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp103
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp102
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h6
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp51
-rw-r--r--drivers/gles3/shader_compiler_gles3.h4
-rw-r--r--drivers/gles3/shader_gles3.cpp6
-rw-r--r--drivers/gles3/shader_gles3.h4
-rw-r--r--drivers/gles3/shaders/canvas.glsl27
-rw-r--r--drivers/gles3/shaders/copy.glsl8
-rw-r--r--drivers/gles3/shaders/cubemap_filter.glsl12
-rw-r--r--drivers/gles3/shaders/scene.glsl85
16 files changed, 326 insertions, 249 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 55d16a6c2e..b7b31c66aa 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -327,9 +327,8 @@ void RasterizerCanvasGLES3::_draw_polygon(const int *p_indices, int p_index_coun
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
- // Orphan the buffers to avoid CPU/GPU sync points caused by glBufferSubData
+ // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
#endif
uint32_t buffer_ofs = 0;
@@ -402,6 +401,10 @@ void RasterizerCanvasGLES3::_draw_polygon(const int *p_indices, int p_index_coun
//bind the indices buffer.
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
+#ifndef GLES_OVER_GL
+ // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
+#endif
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
//draw the triangles.
@@ -416,6 +419,7 @@ void RasterizerCanvasGLES3::_draw_polygon(const int *p_indices, int p_index_coun
}
glBindVertexArray(0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void RasterizerCanvasGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
@@ -424,9 +428,8 @@ void RasterizerCanvasGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
- // Orphan the buffers to avoid CPU/GPU sync points caused by glBufferSubData
+ // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
#endif
uint32_t buffer_ofs = 0;
@@ -469,6 +472,80 @@ void RasterizerCanvasGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count
storage->frame.canvas_draw_commands++;
glBindVertexArray(0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+}
+
+void RasterizerCanvasGLES3::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
+
+ glBindVertexArray(data.polygon_buffer_pointer_array);
+ glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
+
+#ifndef GLES_OVER_GL
+ // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
+ glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
+#endif
+
+ uint32_t buffer_ofs = 0;
+
+ //vertex
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_vertices);
+ glEnableVertexAttribArray(VS::ARRAY_VERTEX);
+ glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ buffer_ofs += sizeof(Vector2) * p_vertex_count;
+ //color
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
+#endif
+
+ if (p_singlecolor) {
+ glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ Color m = *p_colors;
+ glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
+ } else if (!p_colors) {
+ glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ } else {
+
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
+ glEnableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ buffer_ofs += sizeof(Color) * p_vertex_count;
+ }
+
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
+#endif
+
+ if (p_uvs) {
+
+ glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
+ glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ buffer_ofs += sizeof(Vector2) * p_vertex_count;
+
+ } else {
+ glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ }
+
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
+#endif
+
+ //bind the indices buffer.
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
+#ifndef GLES_OVER_GL
+ // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
+#endif
+ glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
+
+ //draw the triangles.
+ glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_INT, 0);
+
+ storage->frame.canvas_draw_commands++;
+
+ glBindVertexArray(0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
@@ -824,7 +901,11 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
#ifdef GLES_OVER_GL
if (polygon->antialiased) {
glEnable(GL_LINE_SMOOTH);
- _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
+ if (polygon->antialiasing_use_indices) {
+ _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
+ } else {
+ _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
+ }
glDisable(GL_LINE_SMOOTH);
}
#endif
@@ -931,6 +1012,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
switch (multi_mesh->color_format) {
+ case VS::MULTIMESH_COLOR_MAX:
case VS::MULTIMESH_COLOR_NONE: {
glDisableVertexAttribArray(11);
glVertexAttrib4f(11, 1, 1, 1, 1);
@@ -952,6 +1034,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
switch (multi_mesh->custom_data_format) {
+ case VS::MULTIMESH_CUSTOM_DATA_MAX:
case VS::MULTIMESH_CUSTOM_DATA_NONE: {
glDisableVertexAttribArray(12);
glVertexAttrib4f(12, 1, 1, 1, 1);
@@ -1336,11 +1419,9 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (skeleton) {
- glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
+ glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 4);
glBindTexture(GL_TEXTURE_2D, skeleton->texture);
state.using_skeleton = true;
- state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform);
- state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
} else {
state.using_skeleton = false;
}
@@ -1527,6 +1608,11 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
state.final_transform = ci->final_transform;
state.extra_matrix = Transform2D();
+ if (state.using_skeleton) {
+ state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform);
+ state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
+ }
+
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.extra_matrix);
@@ -1597,7 +1683,6 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
bool light_rebind = state.canvas_shader.bind();
if (light_rebind) {
-
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D());
@@ -1606,6 +1691,10 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
} else {
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0));
}
+ if (state.using_skeleton) {
+ state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform);
+ state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
+ }
}
glBindBufferBase(GL_UNIFORM_BUFFER, 1, static_cast<LightInternal *>(light->light_internal.get_data())->ubo);
@@ -1802,7 +1891,7 @@ void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, cons
while (instance) {
- RasterizerStorageGLES3::CanvasOccluder *cc = storage->canvas_occluder_owner.get(instance->polygon_buffer);
+ RasterizerStorageGLES3::CanvasOccluder *cc = storage->canvas_occluder_owner.getornull(instance->polygon_buffer);
if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
@@ -1810,9 +1899,20 @@ void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::WORLD_MATRIX, instance->xform_cache);
- if (cull != instance->cull_cache) {
- cull = instance->cull_cache;
+ VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
+
+ if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
+ (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
+ transformed_cull_cache =
+ transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
+ }
+
+ if (cull != transformed_cull_cache) {
+
+ cull = transformed_cull_cache;
switch (cull) {
case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h
index 382b1e5640..929867337d 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.h
+++ b/drivers/gles3/rasterizer_canvas_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -132,6 +132,7 @@ public:
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const int *p_bones, const float *p_weights);
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
+ _FORCE_INLINE_ void _draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index ea15a278d6..e06cc55423 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -120,7 +120,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
String output = String() + "GL ERROR: Source: " + debSource + "\tType: " + debType + "\tID: " + itos(id) + "\tSeverity: " + debSev + "\tMessage: " + message;
- ERR_PRINTS(output);
+ ERR_PRINT(output);
}
#endif // GLAD_ENABLED
@@ -186,8 +186,7 @@ void RasterizerGLES3::initialize() {
}
*/
- const GLubyte *renderer = glGetString(GL_RENDERER);
- print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
+ print_line("OpenGL ES 3.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name());
storage->initialize();
canvas->initialize();
scene->initialize();
@@ -340,8 +339,6 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
RasterizerStorageGLES3::RenderTarget *rt = storage->render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
-#if 1
-
Size2 win_size = OS::get_singleton()->get_window_size();
if (rt->external.fbo != 0) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->external.fbo);
@@ -351,21 +348,6 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
glBlitFramebuffer(0, 0, rt->width, rt->height, p_screen_rect.position.x, win_size.height - p_screen_rect.position.y - p_screen_rect.size.height, p_screen_rect.position.x + p_screen_rect.size.width, win_size.height - p_screen_rect.position.y, GL_COLOR_BUFFER_BIT, GL_NEAREST);
-
-#else
- canvas->canvas_begin();
- glDisable(GL_BLEND);
- glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, rt->color);
- //glBindTexture(GL_TEXTURE_2D, rt->effects.mip_maps[0].color);
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
-
- canvas->draw_generic_textured_rect(p_screen_rect, Rect2(0, 0, 1, -1));
- glBindTexture(GL_TEXTURE_2D, 0);
- canvas->canvas_end();
-#endif
}
void RasterizerGLES3::output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h
index 8fa208a1aa..de7c1ab7e1 100644
--- a/drivers/gles3/rasterizer_gles3.h
+++ b/drivers/gles3/rasterizer_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 9815936d1e..27173d317b 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1146,47 +1146,6 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
state.current_depth_draw = p_material->shader->spatial.depth_draw_mode;
}
-#if 0
- //blend mode
- if (state.current_blend_mode!=p_material->shader->spatial.blend_mode) {
-
- switch(p_material->shader->spatial.blend_mode) {
-
- case RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX: {
- glBlendEquation(GL_FUNC_ADD);
- if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- } else {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- } break;
- case RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_ADD: {
-
- glBlendEquation(GL_FUNC_ADD);
- glBlendFunc(p_alpha_pass?GL_SRC_ALPHA:GL_ONE,GL_ONE);
-
- } break;
- case RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_SUB: {
-
- glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- } break;
- case RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MUL: {
- glBlendEquation(GL_FUNC_ADD);
- if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- } else {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- } break;
- }
-
- state.current_blend_mode=p_material->shader->spatial.blend_mode;
-
- }
-#endif
//material parameters
state.scene_shader.set_custom_shader(p_material->shader->custom_code_id);
@@ -1416,6 +1375,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
switch (multi_mesh->color_format) {
+ case VS::MULTIMESH_COLOR_MAX:
case VS::MULTIMESH_COLOR_NONE: {
glDisableVertexAttribArray(11);
glVertexAttrib4f(11, 1, 1, 1, 1);
@@ -1437,6 +1397,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
switch (multi_mesh->custom_data_format) {
+ case VS::MULTIMESH_CUSTOM_DATA_MAX:
case VS::MULTIMESH_CUSTOM_DATA_NONE: {
glDisableVertexAttribArray(12);
glVertexAttrib4f(12, 1, 1, 1, 1);
@@ -1887,17 +1848,17 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
const RID *lights = e->instance->light_instances.ptr();
for (int i = 0; i < lc; i++) {
- LightInstance *li = light_instance_owner.getptr(lights[i]);
- if (li->last_pass != render_pass) //not visible
+ LightInstance *li = light_instance_owner.getornull(lights[i]);
+ if (!li || li->last_pass != render_pass) //not visible
continue;
- if (li->light_ptr->type == VS::LIGHT_OMNI) {
+ if (li && li->light_ptr->type == VS::LIGHT_OMNI) {
if (omni_count < maxobj && e->instance->layer_mask & li->light_ptr->cull_mask) {
omni_indices[omni_count++] = li->light_index;
}
}
- if (li->light_ptr->type == VS::LIGHT_SPOT) {
+ if (li && li->light_ptr->type == VS::LIGHT_SPOT) {
if (spot_count < maxobj && e->instance->layer_mask & li->light_ptr->cull_mask) {
spot_indices[spot_count++] = li->light_index;
}
@@ -2536,14 +2497,14 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C
};
if (!asymmetrical) {
- float vw, vh, zn;
- camera.get_viewport_size(vw, vh);
+ Vector2 vp_he = camera.get_viewport_half_extents();
+ float zn;
zn = p_projection.get_z_near();
for (int i = 0; i < 4; i++) {
Vector3 uv = vertices[i * 2 + 1];
- uv.x = (uv.x * 2.0 - 1.0) * vw;
- uv.y = -(uv.y * 2.0 - 1.0) * vh;
+ uv.x = (uv.x * 2.0 - 1.0) * vp_he.x;
+ uv.y = -(uv.y * 2.0 - 1.0) * vp_he.y;
uv.z = -zn;
vertices[i * 2 + 1] = p_transform.basis.xform(uv).normalized();
vertices[i * 2 + 1].z = -vertices[i * 2 + 1].z;
@@ -3005,16 +2966,6 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
li->light_index = state.spot_light_count;
copymem(&state.spot_array_tmp[li->light_index * state.ubo_light_size], &ubo_data, state.ubo_light_size);
state.spot_light_count++;
-
-#if 0
- if (li->light_ptr->shadow_enabled) {
- CameraMatrix bias;
- bias.set_light_bias();
- Transform modelview=Transform(camera_transform_inverse * li->transform).inverse();
- li->shadow_projection[0] = bias * li->projection * modelview;
- lights_use_shadow=true;
- }
-#endif
} break;
}
@@ -4147,7 +4098,11 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_reflection_atlas);
- if (shadow_atlas && shadow_atlas->size) {
+ bool use_shadows = shadow_atlas && shadow_atlas->size;
+
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_SHADOW, use_shadows);
+
+ if (use_shadows) {
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
@@ -4175,11 +4130,15 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.ubo_data.shadow_dual_paraboloid_render_zfar = 0;
state.ubo_data.opaque_prepass_threshold = 0.99;
- p_cam_projection.get_viewport_size(state.ubo_data.viewport_size[0], state.ubo_data.viewport_size[1]);
-
if (storage->frame.current_rt) {
- state.ubo_data.screen_pixel_size[0] = 1.0 / storage->frame.current_rt->width;
- state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;
+ int viewport_width_pixels = storage->frame.current_rt->width;
+ int viewport_height_pixels = storage->frame.current_rt->height;
+
+ state.ubo_data.viewport_size[0] = viewport_width_pixels;
+ state.ubo_data.viewport_size[1] = viewport_height_pixels;
+
+ state.ubo_data.screen_pixel_size[0] = 1.0 / viewport_width_pixels;
+ state.ubo_data.screen_pixel_size[1] = 1.0 / viewport_height_pixels;
}
_setup_environment(env, p_cam_projection, p_cam_transform, p_reflection_probe.is_valid());
@@ -4521,15 +4480,15 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
if (state.directional_light_count == 0) {
directional_light = NULL;
- _render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, sky, false, false, false, false, shadow_atlas != NULL);
+ _render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, sky, false, false, false, false, use_shadows);
} else {
for (int i = 0; i < state.directional_light_count; i++) {
directional_light = directional_lights[i];
if (i > 0) {
glEnable(GL_BLEND);
}
- _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0);
- _render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, sky, false, false, false, i > 0, shadow_atlas != NULL);
+ _setup_directional_light(i, p_cam_transform.affine_inverse(), use_shadows);
+ _render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, sky, false, false, false, i > 0, use_shadows);
}
}
@@ -4607,12 +4566,12 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
if (state.directional_light_count == 0) {
directional_light = NULL;
- _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, sky, false, true, false, false, shadow_atlas != NULL);
+ _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, sky, false, true, false, false, use_shadows);
} else {
for (int i = 0; i < state.directional_light_count; i++) {
directional_light = directional_lights[i];
- _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0);
- _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, sky, false, true, false, i > 0, shadow_atlas != NULL);
+ _setup_directional_light(i, p_cam_transform.affine_inverse(), use_shadows);
+ _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, sky, false, true, false, i > 0, use_shadows);
}
}
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index a756ce251e..7885d7c1b7 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 4509c9d17e..e5a7fcce07 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1794,13 +1794,21 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10);
- // Need Mipmaps regardless of whether they are set in import by user
+ glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, 0);
+#ifdef GLES_OVER_GL
+ glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, int(Math::floor(Math::log(float(texture->width)) / Math::log(2.0f))));
glGenerateMipmap(texture->target);
+#else
+ glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, 0);
+#endif
+ // Need Mipmaps regardless of whether they are set in import by user
glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
+#ifdef GLES_OVER_GL
glTexParameterf(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+#else
+ glTexParameterf(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+#endif
glTexParameterf(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) {
@@ -1826,7 +1834,7 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glGenFramebuffers(1, &tmp_fb);
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb);
- int size = 64;
+ int size = 32;
bool use_float = config.framebuffer_half_float_supported;
@@ -1846,6 +1854,27 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sky->irradiance, 0);
+ int irradiance_size = GLOBAL_GET("rendering/quality/reflections/irradiance_max_size");
+ int upscale_size = MIN(int(previous_power_of_2(irradiance_size)), p_radiance_size);
+
+ GLuint tmp_fb2;
+ GLuint tmp_tex;
+ {
+ //generate another one for rendering, as can't read and write from a single texarray it seems
+ glGenFramebuffers(1, &tmp_fb2);
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
+ glGenTextures(1, &tmp_tex);
+ glBindTexture(GL_TEXTURE_2D, tmp_tex);
+ glTexImage2D(GL_TEXTURE_2D, 0, internal_format, upscale_size, 2.0 * upscale_size, 0, format, type, NULL);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+#ifdef DEBUG_ENABLED
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
+#endif
+ }
+
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::COMPUTE_IRRADIANCE, true);
@@ -1855,8 +1884,9 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
// level that corresponds to a panorama of 1024x512
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_MIP_LEVEL, MAX(Math::floor(Math::log(float(texture->width)) / Math::log(2.0f)) - 10.0f, 0.0f));
+ // Compute Irradiance for a large texture, specified by radiance size and then pull out a low mipmap corresponding to 32x32
for (int i = 0; i < 2; i++) {
- glViewport(0, i * size, size, size);
+ glViewport(0, i * upscale_size, upscale_size, upscale_size);
glBindVertexArray(resources.quadie_array);
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
@@ -1864,13 +1894,32 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glBindVertexArray(0);
}
+ glGenerateMipmap(GL_TEXTURE_2D);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, tmp_tex);
+ glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::COMPUTE_IRRADIANCE, false);
+ shaders.copy.set_conditional(CopyShaderGLES3::USE_LOD, true);
+ shaders.copy.bind();
+ shaders.copy.set_uniform(CopyShaderGLES3::MIP_LEVEL, MAX(Math::floor(Math::log(float(upscale_size)) / Math::log(2.0f)) - 5.0f, 0.0f)); // Mip level that corresponds to a 32x32 texture
+
+ glViewport(0, 0, size, size * 2.0);
+ glBindVertexArray(resources.quadie_array);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glBindVertexArray(0);
+
+ shaders.copy.set_conditional(CopyShaderGLES3::USE_LOD, false);
+
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(texture->target, texture->tex_id);
glDeleteFramebuffers(1, &tmp_fb);
+ glDeleteFramebuffers(1, &tmp_fb2);
+ glDeleteTextures(1, &tmp_tex);
}
// Now compute radiance
@@ -1925,7 +1974,11 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
+#ifdef GLES_OVER_GL
if (j < 3) {
+#else
+ if (j == 0) {
+#endif
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
@@ -1943,7 +1996,6 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, sky->radiance);
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_ARRAY_INDEX, j - 1); //read from previous to ensure better blur
- shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_RESOLUTION, float(size / 2));
}
for (int i = 0; i < 2; i++) {
@@ -2051,7 +2103,11 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size * 2, 0, format, type, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0);
+#ifdef GLES_OVER_GL
if (lod < 3) {
+#else
+ if (lod == 0) {
+#endif
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
@@ -2069,7 +2125,6 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, sky->radiance);
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_MIP_LEVEL, float(lod - 1)); //read from previous to ensure better blur
- shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::SOURCE_RESOLUTION, float(size));
}
for (int i = 0; i < 2; i++) {
@@ -4438,6 +4493,7 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances
if (multimesh->buffer) {
glDeleteBuffers(1, &multimesh->buffer);
multimesh->data.resize(0);
+ multimesh->buffer = 0;
}
multimesh->size = p_instances;
@@ -4453,20 +4509,20 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances
multimesh->xform_floats = 12;
}
- if (multimesh->color_format == VS::MULTIMESH_COLOR_NONE) {
- multimesh->color_floats = 0;
- } else if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
multimesh->color_floats = 1;
} else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
multimesh->color_floats = 4;
+ } else {
+ multimesh->color_floats = 0;
}
- if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE) {
- multimesh->custom_data_floats = 0;
- } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
multimesh->custom_data_floats = 1;
} else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
multimesh->custom_data_floats = 4;
+ } else {
+ multimesh->custom_data_floats = 0;
}
int format_floats = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
@@ -4662,6 +4718,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_color(RID p_multimesh, int p
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE);
+ ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_MAX);
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
@@ -4695,6 +4752,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_custom_data(RID p_multimesh,
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE);
+ ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX);
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
@@ -4783,6 +4841,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_color(RID p_multimesh, int
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color());
+ ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_MAX, Color());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
@@ -4816,6 +4875,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_custom_data(RID p_multimesh
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color());
+ ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX, Color());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
@@ -7084,7 +7144,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
int max_samples = 0;
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
if (msaa > max_samples) {
- WARN_PRINTS("MSAA must be <= GL_MAX_SAMPLES, falling-back to GL_MAX_SAMPLES = " + itos(max_samples));
+ WARN_PRINT("MSAA must be <= GL_MAX_SAMPLES, falling-back to GL_MAX_SAMPLES = " + itos(max_samples));
msaa = max_samples;
}
@@ -8078,6 +8138,16 @@ int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) {
}
}
+String RasterizerStorageGLES3::get_video_adapter_name() const {
+
+ return (const char *)glGetString(GL_RENDERER);
+}
+
+String RasterizerStorageGLES3::get_video_adapter_vendor() const {
+
+ return (const char *)glGetString(GL_VENDOR);
+}
+
void RasterizerStorageGLES3::initialize() {
RasterizerStorageGLES3::system_fbo = 0;
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 350b259b2b..bd853852fe 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1467,6 +1467,8 @@ public:
virtual int get_captured_render_info(VS::RenderInfo p_info);
virtual int get_render_info(VS::RenderInfo p_info);
+ virtual String get_video_adapter_name() const;
+ virtual String get_video_adapter_vendor() const;
RasterizerStorageGLES3();
};
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 7499962da3..4e4d896bd7 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -166,7 +166,7 @@ static String _opstr(SL::Operator p_op) {
static String _mkid(const String &p_id) {
- String id = "m_" + p_id;
+ String id = "m_" + p_id.replace("__", "_dus_");
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
@@ -400,7 +400,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
for (int i = 0; i < max_uniforms; i++) {
r_gen_code.uniforms += uniform_defines[i];
}
-#if 1
+
// add up
int offset = 0;
for (int i = 0; i < uniform_sizes.size(); i++) {
@@ -420,45 +420,6 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
if (r_gen_code.uniform_total_size % 16 != 0) { //UBO sizes must be multiples of 16
r_gen_code.uniform_total_size += r_gen_code.uniform_total_size % 16;
}
-#else
- // add up
- for (int i = 0; i < uniform_sizes.size(); i++) {
-
- if (i > 0) {
-
- int align = uniform_sizes[i - 1] % uniform_alignments[i];
- if (align != 0) {
- uniform_sizes[i - 1] += uniform_alignments[i] - align;
- }
-
- uniform_sizes[i] = uniform_sizes[i] + uniform_sizes[i - 1];
- }
- }
- //offset
- r_gen_code.uniform_offsets.resize(uniform_sizes.size());
- for (int i = 0; i < uniform_sizes.size(); i++) {
-
- if (i > 0)
- r_gen_code.uniform_offsets[i] = uniform_sizes[i - 1];
- else
- r_gen_code.uniform_offsets[i] = 0;
- }
- /*
- for(Map<StringName,SL::ShaderNode::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) {
-
- if (SL::is_sampler_type(E->get().type)) {
- continue;
- }
-
- }
-
-*/
- if (uniform_sizes.size()) {
- r_gen_code.uniform_total_size = uniform_sizes[uniform_sizes.size() - 1];
- } else {
- r_gen_code.uniform_total_size = 0;
- }
-#endif
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
@@ -913,7 +874,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv";
- actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "gl_PointSize";
+ actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size";
actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
@@ -970,7 +931,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
- actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize";
+ actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID";
//builtins
diff --git a/drivers/gles3/shader_compiler_gles3.h b/drivers/gles3/shader_compiler_gles3.h
index 79f5c50f88..08e08241d1 100644
--- a/drivers/gles3/shader_compiler_gles3.h
+++ b/drivers/gles3/shader_compiler_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index ac911993be..69f42c4d6d 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -161,7 +161,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
line++;
}
- ERR_PRINTS(p_error);
+ ERR_PRINT(p_error);
}
ShaderGLES3::Version *ShaderGLES3::get_current_version() {
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index d8d49868f4..2bfe72fbc0 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 7255b0425c..07ee9cd010 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -55,7 +55,7 @@ out highp vec2 pixel_size_interp;
#endif
#ifdef USE_SKELETON
-uniform mediump sampler2D skeleton_texture; // texunit:-1
+uniform mediump sampler2D skeleton_texture; // texunit:-4
uniform highp mat4 skeleton_transform;
uniform highp mat4 skeleton_transform_inverse;
#endif
@@ -150,6 +150,7 @@ void main() {
#define extra_matrix extra_matrix_instance
+ float point_size = 1.0;
//for compatibility with the fragment shader we need to use uv here
vec2 uv = uv_interp;
{
@@ -160,6 +161,7 @@ VERTEX_SHADER_CODE
/* clang-format on */
}
+ gl_PointSize = point_size;
uv_interp = uv;
#ifdef USE_NINEPATCH
@@ -395,26 +397,29 @@ float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, flo
draw_center--;
}
- if (np_repeat == 0) { //stretch
- //convert to ratio
+ // np_repeat is passed as uniform using NinePatchRect::AxisStretchMode enum.
+ if (np_repeat == 0) { // Stretch.
+ // Convert to ratio.
float ratio = (pixel - screen_margin_begin) / (draw_size - screen_margin_begin - screen_margin_end);
- //scale to source texture
+ // Scale to source texture.
return (margin_begin + ratio * (tex_size - margin_begin - margin_end)) * tex_pixel_size;
- } else if (np_repeat == 1) { //tile
- //convert to ratio
+ } else if (np_repeat == 1) { // Tile.
+ // Convert to offset.
float ofs = mod((pixel - screen_margin_begin), tex_size - margin_begin - margin_end);
- //scale to source texture
+ // Scale to source texture.
return (margin_begin + ofs) * tex_pixel_size;
- } else if (np_repeat == 2) { //tile fit
- //convert to ratio
+ } else if (np_repeat == 2) { // Tile Fit.
+ // Calculate scale.
float src_area = draw_size - screen_margin_begin - screen_margin_end;
float dst_area = tex_size - margin_begin - margin_end;
float scale = max(1.0, floor(src_area / max(dst_area, 0.0000001) + 0.5));
-
- //convert to ratio
+ // Convert to ratio.
float ratio = (pixel - screen_margin_begin) / src_area;
ratio = mod(ratio * scale, 1.0);
+ // Scale to source texture.
return (margin_begin + ratio * dst_area) * tex_pixel_size;
+ } else { // Shouldn't happen, but silences compiler warning.
+ return 0.0;
}
}
}
diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl
index 1952e201aa..a3cdb3a543 100644
--- a/drivers/gles3/shaders/copy.glsl
+++ b/drivers/gles3/shaders/copy.glsl
@@ -104,6 +104,10 @@ uniform sampler2D CbCr; //texunit:1
/* clang-format on */
+#ifdef USE_LOD
+uniform float mip_level;
+#endif
+
#if defined(USE_TEXTURE3D) || defined(USE_TEXTURE2DARRAY)
uniform float layer;
#endif
@@ -190,8 +194,12 @@ void main() {
color.gb = textureLod(CbCr, uv_interp, 0.0).rg - vec2(0.5, 0.5);
color.a = 1.0;
#else
+#ifdef USE_LOD
+ vec4 color = textureLod(source, uv_interp, mip_level);
+#else
vec4 color = textureLod(source, uv_interp, 0.0);
#endif
+#endif
#ifdef LINEAR_TO_SRGB
// regular Linear -> SRGB conversion
diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl
index f94ac8c81c..e1872eb433 100644
--- a/drivers/gles3/shaders/cubemap_filter.glsl
+++ b/drivers/gles3/shaders/cubemap_filter.glsl
@@ -23,6 +23,7 @@ precision highp int;
#ifdef USE_SOURCE_PANORAMA
uniform sampler2D source_panorama; //texunit:0
+uniform float source_resolution;
#endif
#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
@@ -44,7 +45,6 @@ uniform samplerCube source_cube; //texunit:0
uniform int face_id;
uniform float roughness;
-uniform float source_resolution;
in highp vec2 uv_interp;
@@ -183,12 +183,12 @@ vec2 Hammersley(uint i, uint N) {
#ifdef LOW_QUALITY
#define SAMPLE_COUNT 64u
-#define SAMPLE_DELTA 0.05
+#define SAMPLE_DELTA 0.1
#else
#define SAMPLE_COUNT 512u
-#define SAMPLE_DELTA 0.01
+#define SAMPLE_DELTA 0.03
#endif
@@ -309,7 +309,7 @@ void main() {
}
st /= vec2(M_PI * 2.0, M_PI);
- irradiance += texture(source_panorama, st, source_mip_level).rgb * cos(theta) * sin(theta);
+ irradiance += textureLod(source_panorama, st, source_mip_level).rgb * cos(theta) * sin(theta);
num_samples++;
}
}
@@ -332,6 +332,7 @@ void main() {
if (ndotl > 0.0) {
+#ifdef USE_SOURCE_PANORAMA
float D = DistributionGGX(N, H, roughness);
float ndoth = max(dot(N, H), 0.0);
float hdotv = max(dot(H, V), 0.0);
@@ -342,17 +343,14 @@ void main() {
float mipLevel = roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel);
-#ifdef USE_SOURCE_PANORAMA
sum.rgb += texturePanorama(L, source_panorama, mipLevel).rgb * ndotl;
#endif
#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
-
sum.rgb += textureDualParaboloidArray(L).rgb * ndotl;
#endif
#ifdef USE_SOURCE_DUAL_PARABOLOID
-
sum.rgb += textureDualParaboloid(L).rgb * ndotl;
#endif
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index e1b0e9f595..a45ac2eb8a 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -213,12 +213,10 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float roughness, in
//normalized blinn always unless disabled
vec3 H = normalize(V + L);
float cNdotH = max(dot(N, H), 0.0);
- float cVdotH = max(dot(V, H), 0.0);
- float cLdotH = max(dot(L, H), 0.0);
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
- float blinn = pow(cNdotH, shininess);
+ float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
- specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
+ specular_brdf_NL = blinn;
#endif
specular += specular_brdf_NL * light_color * (1.0 / M_PI);
@@ -434,6 +432,8 @@ void main() {
}
#endif
+ float point_size = 1.0;
+
highp mat4 modelview = camera_inverse_matrix * world_matrix;
{
/* clang-format off */
@@ -443,6 +443,8 @@ VERTEX_SHADER_CODE
/* clang-format on */
}
+ gl_PointSize = point_size;
+
// using local coordinates (default)
#if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED)
@@ -895,18 +897,22 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
bias += incr * 2.0;
vec3 uv_depth = (source.xyz / source.w) * 0.5 + 0.5;
- float depth = texture(depth_buffer, uv_depth.xy).r;
-
- if (depth < uv_depth.z) {
- if (depth > (bias.z / bias.w) * 0.5 + 0.5) {
- return min(pow(ratio, 4.0), 1.0);
- } else {
- return 1.0;
+ if (uv_depth.x > 0.0 && uv_depth.x < 1.0 && uv_depth.y > 0.0 && uv_depth.y < 1.0) {
+ float depth = texture(depth_buffer, uv_depth.xy).r;
+
+ if (depth < uv_depth.z) {
+ if (depth > (bias.z / bias.w) * 0.5 + 0.5) {
+ return min(pow(ratio, 4.0), 1.0);
+ } else {
+ return 1.0;
+ }
}
- }
- ratio += ratio_incr;
- steps -= 1.0;
+ ratio += ratio_incr;
+ steps -= 1.0;
+ } else {
+ return 1.0;
+ }
}
return 1.0;
@@ -1094,9 +1100,9 @@ LIGHT_SHADER_CODE
//normalized blinn
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
- float blinn = pow(cNdotH, shininess);
+ float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
- float intensity = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
+ float intensity = blinn;
specular_light += light_color * intensity * specular_blob_intensity * attenuation;
@@ -1218,44 +1224,21 @@ in highp float dp_clip;
#endif
-#if 0
-// need to save texture depth for this
-vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 pos, float distance) {
-
- float scale = 8.25 * (1.0 - translucency) / subsurface_scatter_width;
- float d = scale * distance;
-
- /**
- * Armed with the thickness, we can now calculate the color by means of the
- * precalculated transmittance profile.
- * (It can be precomputed into a texture, for maximum performance):
- */
- float dd = -d * d;
- vec3 profile =
- vec3(0.233, 0.455, 0.649) * exp(dd / 0.0064) +
- vec3(0.1, 0.336, 0.344) * exp(dd / 0.0484) +
- vec3(0.118, 0.198, 0.0) * exp(dd / 0.187) +
- vec3(0.113, 0.007, 0.007) * exp(dd / 0.567) +
- vec3(0.358, 0.004, 0.0) * exp(dd / 1.99) +
- vec3(0.078, 0.0, 0.0) * exp(dd / 7.41);
-
- /**
- * Using the profile, we finally approximate the transmitted lighting from
- * the back of the object:
- */
- return profile * clamp(0.3 + dot(light_vec, normal),0.0,1.0);
-}
-#endif
-
void light_process_omni(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent, vec3 albedo, vec3 transmission, float roughness, float metallic, float specular, float rim, float rim_tint, float clearcoat, float clearcoat_gloss, float anisotropy, float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light, inout float alpha) {
vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz - vertex;
float light_length = length(light_rel_vec);
float normalized_distance = light_length * omni_lights[idx].light_pos_inv_radius.w;
- float omni_attenuation = pow(max(1.0 - normalized_distance, 0.0), omni_lights[idx].light_direction_attenuation.w);
+ float omni_attenuation;
+ if (normalized_distance < 1.0) {
+ omni_attenuation = pow(1.0 - normalized_distance, omni_lights[idx].light_direction_attenuation.w);
+ } else {
+ omni_attenuation = 0.0;
+ }
vec3 light_attenuation = vec3(omni_attenuation);
#if !defined(SHADOWS_DISABLED)
+#ifdef USE_SHADOW
if (omni_lights[idx].light_params.w > 0.5) {
// there is a shadowmap
@@ -1300,6 +1283,7 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
#endif
light_attenuation *= mix(omni_lights[idx].shadow_color_contact.rgb, vec3(1.0), shadow);
}
+#endif //USE_SHADOW
#endif //SHADOWS_DISABLED
light_compute(normal, normalize(light_rel_vec), eye_vec, binormal, tangent, omni_lights[idx].light_color_energy.rgb, light_attenuation, albedo, transmission, omni_lights[idx].light_params.z * p_blob_intensity, roughness, metallic, specular, rim * omni_attenuation, rim_tint, clearcoat, clearcoat_gloss, anisotropy, diffuse_light, specular_light, alpha);
}
@@ -1309,7 +1293,12 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz - vertex;
float light_length = length(light_rel_vec);
float normalized_distance = light_length * spot_lights[idx].light_pos_inv_radius.w;
- float spot_attenuation = pow(max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w);
+ float spot_attenuation;
+ if (normalized_distance < 1.0) {
+ spot_attenuation = pow(1.0 - normalized_distance, spot_lights[idx].light_direction_attenuation.w);
+ } else {
+ spot_attenuation = 0.0;
+ }
vec3 spot_dir = spot_lights[idx].light_direction_attenuation.xyz;
float spot_cutoff = spot_lights[idx].light_params.y;
float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_cutoff);
@@ -1318,6 +1307,7 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
vec3 light_attenuation = vec3(spot_attenuation);
#if !defined(SHADOWS_DISABLED)
+#ifdef USE_SHADOW
if (spot_lights[idx].light_params.w > 0.5) {
//there is a shadowmap
highp vec4 splane = (spot_lights[idx].shadow_matrix * vec4(vertex, 1.0));
@@ -1334,6 +1324,7 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
#endif
light_attenuation *= mix(spot_lights[idx].shadow_color_contact.rgb, vec3(1.0), shadow);
}
+#endif //USE_SHADOW
#endif //SHADOWS_DISABLED
light_compute(normal, normalize(light_rel_vec), eye_vec, binormal, tangent, spot_lights[idx].light_color_energy.rgb, light_attenuation, albedo, transmission, spot_lights[idx].light_params.z * p_blob_intensity, roughness, metallic, specular, rim * spot_attenuation, rim_tint, clearcoat, clearcoat_gloss, anisotropy, diffuse_light, specular_light, alpha);