summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp28
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h6
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp52
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h8
-rw-r--r--drivers/gles3/shader_gles3.cpp8
-rw-r--r--drivers/gles3/shader_gles3.h8
6 files changed, 57 insertions, 53 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 30a77c4b39..30c0d65ff3 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2180,38 +2180,38 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
}
}
-void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *m, bool p_shadow) {
+void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow) {
- bool has_base_alpha = (m->shader->spatial.uses_alpha && !m->shader->spatial.uses_alpha_scissor) || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded;
- bool has_blend_alpha = m->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || m->shader->spatial.ontop;
+ bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.unshaded;
+ bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || p_material->shader->spatial.ontop;
bool has_alpha = has_base_alpha || has_blend_alpha;
bool shadow = false;
bool mirror = p_instance->mirror;
- if (m->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_FRONT) {
+ if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_FRONT) {
mirror = !mirror;
}
- if (m->shader->spatial.uses_sss) {
+ if (p_material->shader->spatial.uses_sss) {
state.used_sss = true;
}
- if (m->shader->spatial.uses_screen_texture) {
+ if (p_material->shader->spatial.uses_screen_texture) {
state.used_screen_texture = true;
}
if (p_shadow) {
- if (has_blend_alpha || (has_base_alpha && m->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
+ if (has_blend_alpha || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
- if (!m->shader->spatial.uses_alpha_scissor && !m->shader->spatial.writes_modelview_or_projection && !m->shader->spatial.uses_vertex && !m->shader->spatial.uses_discard && m->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
+ if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//shader does not use discard and does not write a vertex position, use generic material
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED)
- m = storage->material_owner.getptr(default_material_twosided);
+ p_material = storage->material_owner.getptr(default_material_twosided);
else
- m = storage->material_owner.getptr(default_material);
+ p_material = storage->material_owner.getptr(default_material);
}
has_alpha = false;
@@ -2223,7 +2223,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
return;
e->geometry = p_geometry;
- e->material = m;
+ e->material = p_material;
e->instance = p_instance;
e->owner = p_owner;
e->sort_key = 0;
@@ -2250,7 +2250,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT;
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_DEPTH_LAYER_SHIFT;
- if (!has_blend_alpha && has_alpha && m->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
+ if (!has_blend_alpha && has_alpha && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//if nothing exists, add this element as opaque too
RenderList::Element *oe = render_list.add_element();
@@ -2277,12 +2277,12 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
//e->light_type=0xFF; // no lights!
- if (shadow || m->shader->spatial.unshaded || state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
+ if (shadow || p_material->shader->spatial.unshaded || state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
e->sort_key |= SORT_KEY_UNSHADED_FLAG;
}
- if (!shadow && (m->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
+ if (!shadow && (p_material->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
e->sort_key |= SORT_KEY_VERTEX_LIT_FLAG;
}
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 0cdaef44a9..e1d96f23dd 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -523,8 +523,8 @@ public:
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer);
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0);
- virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
- virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
+ virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality);
+ virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality);
virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale);
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture);
@@ -795,7 +795,7 @@ public:
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy);
void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
- void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transformm, bool p_use_shadows);
+ void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transform, bool p_use_shadows);
void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_shadow_atlas);
void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index a8e4bc0d4b..ea6ac569f0 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -5468,58 +5468,58 @@ RID RasterizerStorageGLES3::particles_get_draw_pass_mesh(RID p_particles, int p_
return particles->draw_passes[p_pass];
}
-void RasterizerStorageGLES3::_particles_process(Particles *particles, float p_delta) {
+void RasterizerStorageGLES3::_particles_process(Particles *p_particles, float p_delta) {
- float new_phase = Math::fmod((float)particles->phase + (p_delta / particles->lifetime) * particles->speed_scale, (float)1.0);
+ float new_phase = Math::fmod((float)p_particles->phase + (p_delta / p_particles->lifetime) * p_particles->speed_scale, (float)1.0);
- if (particles->clear) {
- particles->cycle_number = 0;
- particles->random_seed = Math::rand();
- } else if (new_phase < particles->phase) {
- if (particles->one_shot) {
- particles->emitting = false;
+ if (p_particles->clear) {
+ p_particles->cycle_number = 0;
+ p_particles->random_seed = Math::rand();
+ } else if (new_phase < p_particles->phase) {
+ if (p_particles->one_shot) {
+ p_particles->emitting = false;
shaders.particles.set_uniform(ParticlesShaderGLES3::EMITTING, false);
}
- particles->cycle_number++;
+ p_particles->cycle_number++;
}
shaders.particles.set_uniform(ParticlesShaderGLES3::SYSTEM_PHASE, new_phase);
- shaders.particles.set_uniform(ParticlesShaderGLES3::PREV_SYSTEM_PHASE, particles->phase);
- particles->phase = new_phase;
+ shaders.particles.set_uniform(ParticlesShaderGLES3::PREV_SYSTEM_PHASE, p_particles->phase);
+ p_particles->phase = new_phase;
- shaders.particles.set_uniform(ParticlesShaderGLES3::DELTA, p_delta * particles->speed_scale);
- shaders.particles.set_uniform(ParticlesShaderGLES3::CLEAR, particles->clear);
- glUniform1ui(shaders.particles.get_uniform_location(ParticlesShaderGLES3::RANDOM_SEED), particles->random_seed);
+ shaders.particles.set_uniform(ParticlesShaderGLES3::DELTA, p_delta * p_particles->speed_scale);
+ shaders.particles.set_uniform(ParticlesShaderGLES3::CLEAR, p_particles->clear);
+ glUniform1ui(shaders.particles.get_uniform_location(ParticlesShaderGLES3::RANDOM_SEED), p_particles->random_seed);
- if (particles->use_local_coords)
+ if (p_particles->use_local_coords)
shaders.particles.set_uniform(ParticlesShaderGLES3::EMISSION_TRANSFORM, Transform());
else
- shaders.particles.set_uniform(ParticlesShaderGLES3::EMISSION_TRANSFORM, particles->emission_transform);
+ shaders.particles.set_uniform(ParticlesShaderGLES3::EMISSION_TRANSFORM, p_particles->emission_transform);
- glUniform1ui(shaders.particles.get_uniform(ParticlesShaderGLES3::CYCLE), particles->cycle_number);
+ glUniform1ui(shaders.particles.get_uniform(ParticlesShaderGLES3::CYCLE), p_particles->cycle_number);
- particles->clear = false;
+ p_particles->clear = false;
- glBindVertexArray(particles->particle_vaos[0]);
+ glBindVertexArray(p_particles->particle_vaos[0]);
- glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, particles->particle_buffers[1]);
+ glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, p_particles->particle_buffers[1]);
// GLint size = 0;
// glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
glBeginTransformFeedback(GL_POINTS);
- glDrawArrays(GL_POINTS, 0, particles->amount);
+ glDrawArrays(GL_POINTS, 0, p_particles->amount);
glEndTransformFeedback();
- SWAP(particles->particle_buffers[0], particles->particle_buffers[1]);
- SWAP(particles->particle_vaos[0], particles->particle_vaos[1]);
+ SWAP(p_particles->particle_buffers[0], p_particles->particle_buffers[1]);
+ SWAP(p_particles->particle_vaos[0], p_particles->particle_vaos[1]);
glBindVertexArray(0);
/* //debug particles :D
- glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[0]);
+ glBindBuffer(GL_ARRAY_BUFFER, p_particles->particle_buffers[0]);
- float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, particles->amount * 16 * 6, GL_MAP_READ_BIT);
- for (int i = 0; i < particles->amount; i++) {
+ float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, p_particles->amount * 16 * 6, GL_MAP_READ_BIT);
+ for (int i = 0; i < p_particles->amount; i++) {
int ofs = i * 24;
print_line(itos(i) + ":");
print_line("\tColor: " + Color(data[ofs + 0], data[ofs + 1], data[ofs + 2], data[ofs + 3]));
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 5a272f43fb..3c7ea000ba 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -314,7 +314,7 @@ public:
mutable RID_Owner<Texture> texture_owner;
- Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_type, bool &r_compressed, bool &srgb);
+ Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &srgb);
virtual RID texture_create();
virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT);
@@ -528,8 +528,8 @@ public:
mutable SelfList<Material>::List _material_dirty_list;
void _material_make_dirty(Material *p_material) const;
- void _material_add_geometry(RID p_material, Geometry *p_instantiable);
- void _material_remove_geometry(RID p_material, Geometry *p_instantiable);
+ void _material_add_geometry(RID p_material, Geometry *p_geometry);
+ void _material_remove_geometry(RID p_material, Geometry *p_geometry);
mutable RID_Owner<Material> material_owner;
@@ -1168,7 +1168,7 @@ public:
virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order);
- virtual void particles_set_draw_passes(RID p_particles, int p_count);
+ virtual void particles_set_draw_passes(RID p_particles, int p_passes);
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh);
virtual void particles_request_process(RID p_particles);
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index 77e257dfc8..20956ad644 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -102,11 +102,11 @@ void ShaderGLES3::bind_uniforms() {
uniforms_dirty = false;
}
-GLint ShaderGLES3::get_uniform_location(int p_idx) const {
+GLint ShaderGLES3::get_uniform_location(int p_index) const {
ERR_FAIL_COND_V(!version, -1);
- return version->uniform_location[p_idx];
+ return version->uniform_location[p_index];
}
bool ShaderGLES3::bind() {
@@ -273,9 +273,11 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
//vertex precision is high
strings.push_back("precision highp float;\n");
strings.push_back("precision highp int;\n");
+#ifndef GLES_OVER_GL
strings.push_back("precision highp sampler2D;\n");
strings.push_back("precision highp samplerCube;\n");
strings.push_back("precision highp sampler2DArray;\n");
+#endif
#if 0
if (cc) {
@@ -374,9 +376,11 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
//fragment precision is medium
strings.push_back("precision highp float;\n");
strings.push_back("precision highp int;\n");
+#ifndef GLES_OVER_GL
strings.push_back("precision highp sampler2D;\n");
strings.push_back("precision highp samplerCube;\n");
strings.push_back("precision highp sampler2DArray;\n");
+#endif
#if 0
if (cc) {
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index 5a34010a98..6a399a74cc 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -306,7 +306,7 @@ public:
};
GLint get_uniform_location(const String &p_name) const;
- GLint get_uniform_location(int p_uniform) const;
+ GLint get_uniform_location(int p_index) const;
static _FORCE_INLINE_ ShaderGLES3 *get_active() { return active; };
bool bind();
@@ -318,9 +318,9 @@ public:
void clear_caches();
uint32_t create_custom_shader();
- void set_custom_shader_code(uint32_t p_id, const String &p_vertex, const String &p_vertex_globals, const String &p_fragment, const String &p_p_light, const String &p_fragment_globals, const String &p_uniforms, const Vector<StringName> &p_texture_uniforms, const Vector<CharString> &p_custom_defines);
- void set_custom_shader(uint32_t p_id);
- void free_custom_shader(uint32_t p_id);
+ void set_custom_shader_code(uint32_t p_code_id, const String &p_vertex, const String &p_vertex_globals, const String &p_fragment, const String &p_light, const String &p_fragment_globals, const String &p_uniforms, const Vector<StringName> &p_texture_uniforms, const Vector<CharString> &p_custom_defines);
+ void set_custom_shader(uint32_t p_code_id);
+ void free_custom_shader(uint32_t p_code_id);
void set_uniform_default(int p_idx, const Variant &p_value) {