summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp7
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp17
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp9
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp78
-rw-r--r--drivers/gles3/shader_gles3.h4
-rw-r--r--drivers/gles3/shaders/copy.glsl4
7 files changed, 77 insertions, 46 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index f4faed8736..edffe852a2 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -200,6 +200,8 @@ void RasterizerCanvasGLES3::canvas_end() {
glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
glColorMask(1, 1, 1, 1);
+ glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+
state.using_texture_rect = false;
state.using_ninepatch = false;
}
@@ -1154,10 +1156,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
- if (storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0) {
- ERR_EXPLAIN("Can't use screen texture copying in a render target configured without copy buffers");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0, "Can't use screen texture copying in a render target configured without copy buffers.");
glDisable(GL_BLEND);
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 30ca07aa28..1472954ebc 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1008,8 +1008,7 @@ RID RasterizerSceneGLES3::light_instance_create(RID p_light) {
if (!light_instance->light_ptr) {
memdelete(light_instance);
- ERR_EXPLAIN("Condition ' !light_instance->light_ptr ' is true.");
- ERR_FAIL_V(RID());
+ ERR_FAIL_V_MSG(RID(), "Condition ' !light_instance->light_ptr ' is true.");
}
light_instance->self = light_instance_owner.make_rid(light_instance);
@@ -1121,13 +1120,23 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
if (state.current_depth_draw != p_material->shader->spatial.depth_draw_mode) {
switch (p_material->shader->spatial.depth_draw_mode) {
- case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS:
+ case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS: {
+ glDepthMask(GL_TRUE);
+ // If some transparent objects write to depth, we need to re-copy depth texture when we need it
+ if (p_alpha_pass && !state.used_depth_prepass) {
+ state.prepared_depth_texture = false;
+ }
+ } break;
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_OPAQUE: {
glDepthMask(!p_alpha_pass);
} break;
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALWAYS: {
glDepthMask(GL_TRUE);
+ // If some transparent objects write to depth, we need to re-copy depth texture when we need it
+ if (p_alpha_pass) {
+ state.prepared_depth_texture = false;
+ }
} break;
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_NEVER: {
glDepthMask(GL_FALSE);
@@ -4616,6 +4625,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
return;
}
+ if (env && (env->dof_blur_far_enabled || env->dof_blur_near_enabled) && storage->frame.current_rt && storage->frame.current_rt->buffers.active)
+ _prepare_depth_texture();
_post_process(env, p_cam_projection);
// Needed only for debugging
/* if (shadow_atlas && storage->frame.current_rt) {
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index b5e64b6162..3d09adcfeb 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -527,8 +527,8 @@ public:
fog_transmit_enabled(true),
fog_transmit_curve(1),
fog_height_enabled(false),
- fog_height_min(0),
- fog_height_max(100),
+ fog_height_min(10),
+ fog_height_max(0),
fog_height_curve(1) {
}
};
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index e0ca388da9..5f4acbc2de 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -2247,7 +2247,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn
pi.type = Variant::INT;
if (u.hint == ShaderLanguage::ShaderNode::Uniform::HINT_RANGE) {
pi.hint = PROPERTY_HINT_RANGE;
- pi.hint_string = rtos(u.hint_range[0]) + "," + rtos(u.hint_range[1]);
+ pi.hint_string = rtos(u.hint_range[0]) + "," + rtos(u.hint_range[1]) + "," + rtos(u.hint_range[2]);
}
} break;
@@ -2522,8 +2522,8 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
int v = value;
GLuint *gui = (GLuint *)data;
- gui[0] = v & 1 ? GL_TRUE : GL_FALSE;
- gui[1] = v & 2 ? GL_TRUE : GL_FALSE;
+ gui[0] = (v & 1) ? GL_TRUE : GL_FALSE;
+ gui[1] = (v & 2) ? GL_TRUE : GL_FALSE;
} break;
case ShaderLanguage::TYPE_BVEC3: {
@@ -3191,8 +3191,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
//must have index and bones, both.
{
uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS;
- ERR_EXPLAIN("Array must have both bones and weights in format or none.");
- ERR_FAIL_COND((p_format & bones_weight) && (p_format & bones_weight) != bones_weight);
+ ERR_FAIL_COND_MSG((p_format & bones_weight) && (p_format & bones_weight) != bones_weight, "Array must have both bones and weights in format or none.");
}
//bool has_morph = p_blend_shapes.size();
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index f826bdf5a2..0121d88f4d 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -555,7 +555,12 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
case SL::Node::TYPE_VARIABLE_DECLARATION: {
SL::VariableDeclarationNode *vdnode = (SL::VariableDeclarationNode *)p_node;
- String declaration = _prestr(vdnode->precision) + _typestr(vdnode->datatype);
+ String declaration;
+ if (vdnode->is_const) {
+ declaration += "const ";
+ }
+ declaration += _prestr(vdnode->precision);
+ declaration += _typestr(vdnode->datatype);
for (int i = 0; i < vdnode->declarations.size(); i++) {
if (i > 0) {
declaration += ",";
@@ -609,29 +614,34 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::Node::TYPE_ARRAY_DECLARATION: {
- SL::ArrayDeclarationNode *vdnode = (SL::ArrayDeclarationNode *)p_node;
+ SL::ArrayDeclarationNode *adnode = (SL::ArrayDeclarationNode *)p_node;
- String declaration = _prestr(vdnode->precision) + _typestr(vdnode->datatype);
- for (int i = 0; i < vdnode->declarations.size(); i++) {
+ String declaration;
+ if (adnode->is_const) {
+ declaration += "const ";
+ }
+ declaration += _prestr(adnode->precision);
+ declaration += _typestr(adnode->datatype);
+ for (int i = 0; i < adnode->declarations.size(); i++) {
if (i > 0) {
declaration += ",";
} else {
declaration += " ";
}
- declaration += _mkid(vdnode->declarations[i].name);
+ declaration += _mkid(adnode->declarations[i].name);
declaration += "[";
- declaration += itos(vdnode->declarations[i].size);
+ declaration += itos(adnode->declarations[i].size);
declaration += "]";
- int sz = vdnode->declarations[i].initializer.size();
+ int sz = adnode->declarations[i].initializer.size();
if (sz > 0) {
declaration += "=";
- declaration += _typestr(vdnode->datatype);
+ declaration += _typestr(adnode->datatype);
declaration += "[";
declaration += itos(sz);
declaration += "]";
declaration += "(";
for (int j = 0; j < sz; j++) {
- declaration += _dump_node_code(vdnode->declarations[i].initializer[j], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ declaration += _dump_node_code(adnode->declarations[i].initializer[j], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
if (j != sz - 1) {
declaration += ", ";
}
@@ -643,43 +653,43 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += declaration;
} break;
case SL::Node::TYPE_ARRAY: {
- SL::ArrayNode *vnode = (SL::ArrayNode *)p_node;
+ SL::ArrayNode *anode = (SL::ArrayNode *)p_node;
- if (p_assigning && p_actions.write_flag_pointers.has(vnode->name)) {
- *p_actions.write_flag_pointers[vnode->name] = true;
+ if (p_assigning && p_actions.write_flag_pointers.has(anode->name)) {
+ *p_actions.write_flag_pointers[anode->name] = true;
}
- if (p_default_actions.usage_defines.has(vnode->name) && !used_name_defines.has(vnode->name)) {
- String define = p_default_actions.usage_defines[vnode->name];
+ if (p_default_actions.usage_defines.has(anode->name) && !used_name_defines.has(anode->name)) {
+ String define = p_default_actions.usage_defines[anode->name];
if (define.begins_with("@")) {
define = p_default_actions.usage_defines[define.substr(1, define.length())];
}
r_gen_code.defines.push_back(define.utf8());
- used_name_defines.insert(vnode->name);
+ used_name_defines.insert(anode->name);
}
- if (p_actions.usage_flag_pointers.has(vnode->name) && !used_flag_pointers.has(vnode->name)) {
- *p_actions.usage_flag_pointers[vnode->name] = true;
- used_flag_pointers.insert(vnode->name);
+ if (p_actions.usage_flag_pointers.has(anode->name) && !used_flag_pointers.has(anode->name)) {
+ *p_actions.usage_flag_pointers[anode->name] = true;
+ used_flag_pointers.insert(anode->name);
}
- if (p_default_actions.renames.has(vnode->name))
- code = p_default_actions.renames[vnode->name];
+ if (p_default_actions.renames.has(anode->name))
+ code = p_default_actions.renames[anode->name];
else
- code = _mkid(vnode->name);
+ code = _mkid(anode->name);
- if (vnode->call_expression != NULL) {
+ if (anode->call_expression != NULL) {
code += ".";
- code += _dump_node_code(vnode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += _dump_node_code(anode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
}
- if (vnode->index_expression != NULL) {
+ if (anode->index_expression != NULL) {
code += "[";
- code += _dump_node_code(vnode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += _dump_node_code(anode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "]";
}
- if (vnode->name == time_name) {
+ if (anode->name == time_name) {
if (current_func_name == vertex_name) {
r_gen_code.uses_vertex_time = true;
}
@@ -762,11 +772,13 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::OP_SELECT_IF: {
+ code += "(";
code += _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "?";
code += _dump_node_code(onode->arguments[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += ":";
code += _dump_node_code(onode->arguments[2], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += ")";
} break;
@@ -789,6 +801,20 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += _mktab(p_level) + "else\n";
code += _dump_node_code(cfnode->blocks[1], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
}
+ } else if (cfnode->flow_op == SL::FLOW_OP_SWITCH) {
+ code += _mktab(p_level) + "switch (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
+ code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
+ } else if (cfnode->flow_op == SL::FLOW_OP_CASE) {
+ code += _mktab(p_level) + "case " + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ":\n";
+ code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
+ } else if (cfnode->flow_op == SL::FLOW_OP_DEFAULT) {
+ code += _mktab(p_level) + "default:\n";
+ code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
+ } else if (cfnode->flow_op == SL::FLOW_OP_DO) {
+ code += _mktab(p_level) + "do";
+ code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += _mktab(p_level) + "while (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ");";
+
} else if (cfnode->flow_op == SL::FLOW_OP_WHILE) {
code += _mktab(p_level) + "while (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index be2c34ba07..d8d49868f4 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -45,10 +45,6 @@
#include <stdio.h>
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
class ShaderGLES3 {
protected:
struct Enum {
diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl
index 232b9ce7c0..1952e201aa 100644
--- a/drivers/gles3/shaders/copy.glsl
+++ b/drivers/gles3/shaders/copy.glsl
@@ -165,11 +165,11 @@ void main() {
#elif defined(USE_ASYM_PANO)
// When an asymmetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result.
- // Note that we're ignoring the x-offset for IPD, with Z sufficiently in the distance it becomes neglectible, as a result we could probably just set cube_normal.z to -1.
+ // Asymmetrical projection means the center of projection is no longer in the center of the screen but shifted.
// The Matrix[2][0] (= asym_proj.x) and Matrix[2][1] (= asym_proj.z) values are what provide the right shift in the image.
vec3 cube_normal;
- cube_normal.z = -1000000.0;
+ cube_normal.z = -1.0;
cube_normal.x = (cube_normal.z * (-uv_interp.x - asym_proj.x)) / asym_proj.y;
cube_normal.y = (cube_normal.z * (-uv_interp.y - asym_proj.z)) / asym_proj.a;
cube_normal = mat3(sky_transform) * mat3(pano_transform) * cube_normal;