Several changes to better run in mobile.

This commit is contained in:
Juan Linietsky 2017-07-22 14:07:38 -03:00
parent 492999a33b
commit 772485cdb3
24 changed files with 508 additions and 171 deletions

View file

@ -30,8 +30,8 @@
#include "rasterizer_gles3.h"
#include "gl_context/context_gl.h"
#include "project_settings.h"
#include "os/os.h"
#include "project_settings.h"
#include <string.h>
RasterizerStorage *RasterizerGLES3::get_storage() {
@ -186,6 +186,9 @@ void RasterizerGLES3::initialize() {
GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello");
*/
const GLubyte *renderer = glGetString(GL_RENDERER);
print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
storage->initialize();
canvas->initialize();
scene->initialize();
@ -336,6 +339,10 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
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();

View file

@ -521,13 +521,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_size
glBindTexture(GL_TEXTURE_2D, reflection_atlas->color);
int mmsize = reflection_atlas->size;
for (int i = 0; i < 6; i++) {
glTexImage2D(GL_TEXTURE_2D, i, internal_format, mmsize, mmsize, 0,
format, type, NULL);
mmsize >>= 1;
}
glTexStorage2DCustom(GL_TEXTURE_2D, 6, internal_format, mmsize, mmsize, format, type);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -537,8 +531,6 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_size
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
mmsize = reflection_atlas->size;
for (int i = 0; i < 6; i++) {
glGenFramebuffers(1, &reflection_atlas->fbo[i]);
glBindFramebuffer(GL_FRAMEBUFFER, reflection_atlas->fbo[i]);
@ -1962,6 +1954,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS, true);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_FORWARD_LIGHTING, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_DIRECTIONAL_SHADOW, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM4, false);
@ -1972,6 +1965,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, false);
//state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS,true);
} else {
@ -1979,7 +1973,10 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, e->instance->gi_probe_instances.size() > 0);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_FORWARD_LIGHTING, !p_directional_add);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, (e->sort_key & SORT_KEY_VERTEX_LIT_FLAG));
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_DIRECTIONAL_SHADOW, false);
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM4, false);
@ -1988,6 +1985,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, shadow_filter_mode == SHADOW_FILTER_PCF5);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, use_radiance_map);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, state.used_contact_shadows);
if (p_directional_add || (directional_light && (e->sort_key & SORT_KEY_NO_DIRECTIONAL_FLAG) == 0)) {
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, true);
@ -2136,6 +2134,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, false);
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, false);
}
void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow) {
@ -2281,6 +2281,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
e->sort_key |= SORT_KEY_UNSHADED_FLAG;
}
if (!shadow && (m->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
e->sort_key |= SORT_KEY_VERTEX_LIT_FLAG;
}
}
void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy) {
@ -2912,7 +2917,19 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
glBindBufferBase(GL_UNIFORM_BUFFER, 6, state.reflection_array_ubo);
}
void RasterizerSceneGLES3::_copy_screen() {
void RasterizerSceneGLES3::_copy_screen(bool p_invalidate_color, bool p_invalidate_depth) {
#ifndef GLES_OVER_GL
if (p_invalidate_color) {
GLenum attachments[2] = {
GL_COLOR_ATTACHMENT0,
GL_DEPTH_STENCIL_ATTACHMENT
};
glInvalidateFramebuffer(GL_FRAMEBUFFER, p_invalidate_depth ? 2 : 1, attachments);
}
#endif
glBindVertexArray(storage->resources.quadie_array);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -3080,7 +3097,7 @@ void RasterizerSceneGLES3::_blur_effect_buffer() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //previous level, since mipmaps[0] starts one level bigger
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[i].fbo);
_copy_screen();
_copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_HORIZONTAL, false);
//vertical pass
@ -3091,7 +3108,7 @@ void RasterizerSceneGLES3::_blur_effect_buffer() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[1].color);
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger
_copy_screen();
_copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_VERTICAL, false);
}
}
@ -3139,7 +3156,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.ssao.depth_mipmap_fbos[i]); //copy to front first
glViewport(0, 0, ss[0], ss[1]);
_copy_screen();
_copy_screen(true);
}
ss[0] = storage->frame.current_rt->width;
ss[1] = storage->frame.current_rt->height;
@ -3191,7 +3208,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
Color white(1, 1, 1, 1);
glClearBufferfv(GL_COLOR, 0, white.components); // specular
_copy_screen();
_copy_screen(true);
//do the batm, i mean blur
@ -3212,7 +3229,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
if (i == 0) {
glClearBufferfv(GL_COLOR, 0, white.components); // specular
}
_copy_screen();
_copy_screen(true);
}
}
@ -3229,7 +3246,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.ssao.blur_red[0]); //previous level, since mipmaps[0] starts one level bigger
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); // copy to base level
_copy_screen();
_copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::SSAO_MERGE, false);
} else {
@ -3278,14 +3295,14 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
_copy_screen();
_copy_screen(true);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::DIR, Vector2(0, 1));
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); // copy to base level
_copy_screen();
_copy_screen(true);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //restore filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -3337,7 +3354,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[0].fbo);
glViewport(0, 0, ssr_w, ssr_h);
_copy_screen();
_copy_screen(true);
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
}
@ -3368,7 +3385,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE); //use additive to accumulate one over the other
_copy_screen();
_copy_screen(true);
glDisable(GL_BLEND); //end additive
@ -3392,7 +3409,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
_copy_screen();
_copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::SIMPLE_COPY, false);
}
@ -3413,13 +3430,16 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
//copy specular to front buffer
//copy diffuse to effect buffer
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
if (storage->frame.current_rt->buffers.active) {
//transfer to effect buffer if using buffers, also resolve MSAA
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
if (!env || storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
//no environment or transparent render, simply return and convert to SRGB
@ -3431,7 +3451,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]);
storage->shaders.copy.bind();
_copy_screen();
_copy_screen(true);
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB, false);
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false); //compute luminance
@ -3487,7 +3507,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
_copy_screen();
_copy_screen(true);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
@ -3574,7 +3594,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->buffers.diffuse);
}
_copy_screen();
_copy_screen(true);
if (composite_from != storage->frame.current_rt->buffers.diffuse) {
@ -3614,7 +3634,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindFramebuffer(GL_FRAMEBUFFER, exposure_shrink[0].fbo);
glViewport(0, 0, exposure_shrink_size, exposure_shrink_size);
_copy_screen();
_copy_screen(true);
//second step, shrink to 2x2 pixels
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_BEGIN, false);
@ -3658,7 +3678,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.exposure_shader.set_uniform(ExposureShaderGLES3::MAX_LUMINANCE, env->auto_exposure_max);
state.exposure_shader.set_uniform(ExposureShaderGLES3::MIN_LUMINANCE, env->auto_exposure_min);
_copy_screen();
_copy_screen(true);
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_FORCE_SET, false);
state.exposure_shader.set_conditional(ExposureShaderGLES3::EXPOSURE_END, false);
@ -3729,7 +3749,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //previous level, since mipmaps[0] starts one level bigger
}
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[i].fbo);
_copy_screen();
_copy_screen(true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_GAUSSIAN_HORIZONTAL, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_FIRST_PASS, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GLOW_USE_AUTO_EXPOSURE, false);
@ -3837,7 +3857,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.tonemap_shader.set_uniform(TonemapShaderGLES3::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation));
}
_copy_screen();
_copy_screen(true, true);
//turn off everything used
state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_AUTO_EXPOSURE, false);
@ -3913,7 +3933,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.used_contact_shadows = true;
if (storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { //detect with state.used_contact_shadows too
if (!storage->config.no_depth_prepass && storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { //detect with state.used_contact_shadows too
//pre z pass
glDisable(GL_BLEND);
@ -3927,7 +3947,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glColorMask(0, 0, 0, 0);
glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
render_list.clear();
_fill_render_list(p_cull_result, p_cull_count, true);
@ -3953,6 +3973,9 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
fb_cleared = true;
render_pass++;
state.using_contact_shadows = true;
} else {
state.using_contact_shadows = false;
}
_setup_lights(p_light_cull_result, p_light_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_shadow_atlas);
@ -4034,8 +4057,13 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
} else {
current_fbo = storage->frame.current_rt->buffers.fbo;
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
if (storage->frame.current_rt->buffers.active) {
current_fbo = storage->frame.current_rt->buffers.fbo;
} else {
current_fbo = storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo;
}
glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_MULTIPLE_RENDER_TARGETS, false);
Vector<GLenum> draw_buffers;
@ -4045,8 +4073,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
}
if (!fb_cleared) {
glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0);
}
Color clear_color(0, 0, 0, 0);
@ -4111,7 +4138,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
storage->shaders.copy.bind();
_copy_screen();
_copy_screen(true, true);
//turn off everything used
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, false);
@ -4178,7 +4205,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
_render_mrts(env, p_cam_projection);
} else {
//FIXME: check that this is possible to use
if (storage->frame.current_rt && state.used_screen_texture) {
if (storage->frame.current_rt && storage->frame.current_rt->buffers.active && state.used_screen_texture) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
@ -4192,7 +4219,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
}
}
if (storage->frame.current_rt && state.used_screen_texture) {
if (storage->frame.current_rt && state.used_screen_texture && storage->frame.current_rt->buffers.active) {
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 7);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
}
@ -4273,6 +4300,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
//disable all stuff
}
void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {
@ -4297,6 +4326,8 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
float bias = 0;
float normal_bias = 0;
state.using_contact_shadows = false;
CameraMatrix light_projection;
Transform light_transform;

View file

@ -187,6 +187,7 @@ public:
bool cull_front;
bool used_sss;
bool used_screen_texture;
bool using_contact_shadows;
VS::ViewportDebugDraw debug_draw;
} state;
@ -645,8 +646,9 @@ public:
#define SORT_KEY_UNSHADED_FLAG (uint64_t(1) << 59)
#define SORT_KEY_NO_DIRECTIONAL_FLAG (uint64_t(1) << 58)
#define SORT_KEY_GI_PROBES_FLAG (uint64_t(1) << 57)
SORT_KEY_SHADING_SHIFT = 57,
SORT_KEY_SHADING_MASK = 7,
#define SORT_KEY_VERTEX_LIT_FLAG (uint64_t(1) << 56)
SORT_KEY_SHADING_SHIFT = 56,
SORT_KEY_SHADING_MASK = 15,
SORT_KEY_MATERIAL_INDEX_SHIFT = 40,
SORT_KEY_GEOMETRY_INDEX_SHIFT = 20,
SORT_KEY_GEOMETRY_TYPE_SHIFT = 15,
@ -795,7 +797,7 @@ public:
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);
void _copy_screen();
void _copy_screen(bool p_invalidate_color = false, bool p_invalidate_depth = false);
void _copy_to_front_buffer(Environment *env);
void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug

View file

@ -99,6 +99,21 @@
#define _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
#define _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
void glTexStorage2DCustom(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type) {
#ifdef GLES_OVER_GL
for (int i = 0; i < levels; i++) {
glTexImage2D(target, i, internalformat, width, height, 0, format, type, NULL);
width = MAX(1, (width / 2));
height = MAX(1, (height / 2));
}
#else
glTexStorage2D(target, levels, internalformat, width, height);
#endif
}
GLuint RasterizerStorageGLES3::system_fbo = 0;
Ref<Image> RasterizerStorageGLES3::_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) {
@ -1412,18 +1427,10 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
GLenum format = GL_RGBA;
GLenum type = use_float ? GL_HALF_FLOAT : GL_UNSIGNED_INT_2_10_10_10_REV;
while (mm_level) {
glTexImage2D(GL_TEXTURE_2D, lod, internal_format, size, size * 2, 0, format, type, NULL);
lod++;
mm_level--;
if (size > 1)
size >>= 1;
}
glTexStorage2DCustom(GL_TEXTURE_2D, mipmaps, internal_format, size, size * 2.0, format, type);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, lod - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmaps - 1);
lod = 0;
mm_level = mipmaps;
@ -1593,6 +1600,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
p_shader->spatial.unshaded = false;
p_shader->spatial.ontop = false;
p_shader->spatial.uses_sss = false;
p_shader->spatial.uses_vertex_lighting = false;
p_shader->spatial.uses_screen_texture = false;
p_shader->spatial.uses_vertex = false;
p_shader->spatial.writes_modelview_or_projection = false;
@ -1614,6 +1622,8 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded;
shaders.actions_scene.render_mode_flags["ontop"] = &p_shader->spatial.ontop;
shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
shaders.actions_scene.usage_flag_pointers["ALPHA"] = &p_shader->spatial.uses_alpha;
shaders.actions_scene.usage_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
@ -5818,17 +5828,20 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->fbo = 0;
}
if (rt->buffers.fbo) {
if (rt->buffers.active) {
glDeleteFramebuffers(1, &rt->buffers.fbo);
glDeleteRenderbuffers(1, &rt->buffers.depth);
glDeleteRenderbuffers(1, &rt->buffers.diffuse);
glDeleteRenderbuffers(1, &rt->buffers.specular);
glDeleteRenderbuffers(1, &rt->buffers.normal_rough);
glDeleteRenderbuffers(1, &rt->buffers.sss);
glDeleteFramebuffers(1, &rt->buffers.effect_fbo);
glDeleteTextures(1, &rt->buffers.effect);
if (rt->buffers.effects_active) {
glDeleteRenderbuffers(1, &rt->buffers.specular);
glDeleteRenderbuffers(1, &rt->buffers.normal_rough);
glDeleteRenderbuffers(1, &rt->buffers.sss);
glDeleteFramebuffers(1, &rt->buffers.effect_fbo);
glDeleteTextures(1, &rt->buffers.effect);
}
rt->buffers.fbo = 0;
rt->buffers.effects_active = false;
rt->buffers.active = false;
}
if (rt->depth) {
@ -5866,13 +5879,15 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
tex->active = false;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
glDeleteFramebuffers(1, &rt->effects.mip_maps[i].sizes[j].fbo);
}
if (rt->effects.mip_maps[i].color) {
for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
glDeleteFramebuffers(1, &rt->effects.mip_maps[i].sizes[j].fbo);
}
glDeleteTextures(1, &rt->effects.mip_maps[i].color);
rt->effects.mip_maps[i].sizes.clear();
rt->effects.mip_maps[i].levels = 0;
glDeleteTextures(1, &rt->effects.mip_maps[i].color);
rt->effects.mip_maps[i].sizes.clear();
rt->effects.mip_maps[i].levels = 0;
}
}
/*
@ -5899,10 +5914,20 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
if (!hdr || rt->flags[RENDER_TARGET_NO_3D]) {
color_internal_format = GL_RGBA8;
color_format = GL_RGBA;
color_type = GL_UNSIGNED_BYTE;
image_format = Image::FORMAT_RGBA8;
if (rt->flags[RENDER_TARGET_NO_3D_EFFECTS] && !rt->flags[RENDER_TARGET_TRANSPARENT]) {
//if this is not used, linear colorspace looks pretty bad
//this is the default mode used for mobile
color_internal_format = GL_RGB10_A2;
color_format = GL_RGBA;
color_type = GL_UNSIGNED_INT_2_10_10_10_REV;
image_format = Image::FORMAT_RGBA8;
} else {
color_internal_format = GL_RGBA8;
color_format = GL_RGBA;
color_type = GL_UNSIGNED_BYTE;
image_format = Image::FORMAT_RGBA8;
}
} else {
color_internal_format = GL_RGBA16F;
color_format = GL_RGBA;
@ -5967,7 +5992,9 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
/* BACK FBO */
if (!rt->flags[RENDER_TARGET_NO_3D]) {
if (!rt->flags[RENDER_TARGET_NO_3D] && (!rt->flags[RENDER_TARGET_NO_3D_EFFECTS] || rt->msaa != VS::VIEWPORT_MSAA_DISABLED)) {
rt->buffers.active = true;
static const int msaa_value[] = { 0, 2, 4, 8, 16 };
int msaa = msaa_value[rt->msaa];
@ -5997,6 +6024,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
if (!rt->flags[RENDER_TARGET_NO_3D_EFFECTS]) {
rt->buffers.effects_active = true;
glGenRenderbuffers(1, &rt->buffers.specular);
glBindRenderbuffer(GL_RENDERBUFFER, rt->buffers.specular);
@ -6140,7 +6168,12 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
_render_target_clear(rt);
ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
}
} else {
rt->buffers.effects_active = false;
}
} else {
rt->buffers.active = false;
rt->buffers.effects_active = true;
}
if (!rt->flags[RENDER_TARGET_NO_SAMPLING]) {
@ -6164,8 +6197,6 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
while (true) {
RenderTarget::Effects::MipMaps::Size mm;
glTexImage2D(GL_TEXTURE_2D, level, color_internal_format, w, h, 0, color_format, color_type, NULL);
mm.width = w;
mm.height = h;
rt->effects.mip_maps[i].sizes.push_back(mm);
@ -6179,8 +6210,13 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
level++;
}
glTexStorage2DCustom(GL_TEXTURE_2D, level + 1, color_internal_format, rt->width, rt->height, color_format, color_type);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
glDisable(GL_SCISSOR_TEST);
glColorMask(1, 1, 1, 1);
glDepthMask(GL_TRUE);
for (int j = 0; j < rt->effects.mip_maps[i].sizes.size(); j++) {
@ -6189,6 +6225,11 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
glGenFramebuffers(1, &mm.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->effects.mip_maps[i].color, j);
bool used_depth = false;
if (j == 0 && i == 0 && rt->buffers.active == false && !rt->flags[RENDER_TARGET_NO_3D]) { //will use this one for rendering 3D
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
used_depth = true;
}
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
@ -6197,7 +6238,12 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
}
float zero[4] = { 1, 0, 1, 0 };
glViewport(0, 0, rt->effects.mip_maps[i].sizes[j].width, rt->effects.mip_maps[i].sizes[j].height);
glClearBufferfv(GL_COLOR, 0, zero);
if (used_depth) {
glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0);
}
}
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
@ -6838,7 +6884,6 @@ void RasterizerStorageGLES3::initialize() {
int max_extensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max_extensions);
print_line("GLES3: max extensions: " + itos(max_extensions));
for (int i = 0; i < max_extensions; i++) {
const GLubyte *s = glGetStringi(GL_EXTENSIONS, i);
if (!s)
@ -6864,7 +6909,6 @@ void RasterizerStorageGLES3::initialize() {
config.hdr_supported = false;
#endif
print_line("hdr supported: " + itos(config.hdr_supported));
config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc");
config.srgb_decode_supported = config.extensions.has("GL_EXT_texture_sRGB_decode");
@ -6997,6 +7041,8 @@ void RasterizerStorageGLES3::initialize() {
}
shaders.cubemap_filter.init();
bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx.mobile");
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, !ggx_hq);
shaders.particles.init();
#ifdef GLES_OVER_GL
@ -7010,6 +7056,28 @@ void RasterizerStorageGLES3::initialize() {
config.keep_original_textures = false;
config.generate_wireframes = false;
config.use_texture_array_environment = GLOBAL_GET("rendering/quality/reflections/texture_array_reflections");
config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading");
GLOBAL_DEF("rendering/quality/depth_prepass/disable", false);
String renderer = (const char *)glGetString(GL_RENDERER);
config.no_depth_prepass = !bool(GLOBAL_GET("rendering/quality/depth_prepass/enable"));
if (!config.no_depth_prepass) {
String vendors = GLOBAL_GET("rendering/quality/depth_prepass/disable_for_vendors");
Vector<String> vendor_match = vendors.split(",");
for (int i = 0; i < vendor_match.size(); i++) {
String v = vendor_match[i].strip_edges();
if (v == String())
continue;
if (renderer.findn(v) != -1) {
config.no_depth_prepass = true;
}
}
}
}
void RasterizerStorageGLES3::finalize() {

View file

@ -48,6 +48,8 @@ class RasterizerSceneGLES3;
#define _DECODE_EXT 0x8A49
#define _SKIP_DECODE_EXT 0x8A4A
void glTexStorage2DCustom(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type);
class RasterizerStorageGLES3 : public RasterizerStorage {
public:
RasterizerCanvasGLES3 *canvas;
@ -91,6 +93,9 @@ public:
Set<String> extensions;
bool keep_original_textures;
bool no_depth_prepass;
bool force_vertex_shading;
} config;
mutable struct Shaders {
@ -444,6 +449,7 @@ public:
bool uses_sss;
bool uses_screen_texture;
bool writes_modelview_or_projection;
bool uses_vertex_lighting;
} spatial;
@ -1193,6 +1199,9 @@ public:
GLuint depth;
struct Buffers {
bool active;
bool effects_active;
GLuint fbo;
GLuint depth;
GLuint specular;
@ -1282,6 +1291,8 @@ public:
flags[RENDER_TARGET_NO_3D] = false;
flags[RENDER_TARGET_NO_SAMPLING] = false;
flags[RENDER_TARGET_HDR] = true;
buffers.active = false;
buffers.effects_active = false;
last_exposure_tick = 0;
}

View file

@ -208,6 +208,7 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
Vector<const char *> strings;
#ifdef GLES_OVER_GL
strings.push_back("#version 330\n");
strings.push_back("#define GLES_OVER_GL\n");
#else
strings.push_back("#version 300 es\n");
#endif

View file

@ -49,6 +49,9 @@ void main() {
#define M_PI 3.14159265359
#if !defined(USE_GLES_OVER_GL)
precision mediump float;
#endif
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
in vec3 cube_interp;
@ -87,14 +90,6 @@ vec4 texturePanorama(vec3 normal,sampler2D pano ) {
#endif
float sRGB_gamma_correct(float c){
float a = 0.055;
if(c < 0.0031308)
return 12.92*c;
else
return (1.0+a)*pow(c, 1.0/2.4) - a;
}
uniform float stuff;
uniform vec2 pixel_size;
@ -131,7 +126,7 @@ void main() {
vec4 color = texture( source_cube, normalize(cube_interp) );
#else
vec4 color = texture( source, uv_interp );
vec4 color = textureLod( source, uv_interp,0.0 );
#endif

View file

@ -204,7 +204,7 @@ vec4 textureDualParaboloidArray(vec3 normal) {
vec3 norm = normalize(normal);
norm.xy/=1.0+abs(norm.z);
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
if (norm.z<0) {
if (norm.z<0.0) {
norm.y=0.5-norm.y+0.5;
}
return textureLod(source_dual_paraboloid_array, vec3(norm.xy, float(source_array_index) ), 0.0);

View file

@ -25,6 +25,9 @@ void main() {
[fragment]
#if !defined(GLES_OVER_GL)
precision mediump float;
#endif
in vec2 uv_interp;
uniform sampler2D source_color; //texunit:0

View file

@ -178,7 +178,7 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_FORCE)
if (true) {
if (false) {
vec3 force = vec3(0.0);
for(int i=0;i<attractor_count;i++) {
@ -187,7 +187,7 @@ VERTEX_SHADER_CODE
float dist = length(rel_vec);
if (attractors[i].radius < dist)
continue;
if (attractors[i].eat_radius>0 && attractors[i].eat_radius > dist) {
if (attractors[i].eat_radius>0.0 && attractors[i].eat_radius > dist) {
out_velocity_active.a=0.0;
}

View file

@ -15,6 +15,9 @@ void main() {
[fragment]
#if !defined(GLES_OVER_GL)
precision mediump float;
#endif
in vec2 uv_interp;
uniform sampler2D source_specular; //texunit:0

View file

@ -64,44 +64,45 @@ layout(std140) uniform SceneData { //ubo:0
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
highp vec4 ambient_light_color;
highp vec4 bg_color;
mediump vec4 ambient_light_color;
mediump vec4 bg_color;
vec4 fog_color_enabled;
vec4 fog_sun_color_amount;
mediump vec4 fog_color_enabled;
mediump vec4 fog_sun_color_amount;
float ambient_energy;
float bg_energy;
mediump float ambient_energy;
mediump float bg_energy;
float z_offset;
float z_slope_scale;
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
mediump float z_offset;
mediump float z_slope_scale;
highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side;
highp vec2 screen_pixel_size;
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;
highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size;
float time;
float z_far;
float reflection_multiplier;
float subsurface_scatter_width;
float ambient_occlusion_affect_light;
highp float time;
highp float z_far;
mediump float reflection_multiplier;
mediump float subsurface_scatter_width;
mediump float ambient_occlusion_affect_light;
bool fog_depth_enabled;
float fog_depth_begin;
float fog_depth_curve;
highp float fog_depth_begin;
highp float fog_depth_curve;
bool fog_transmit_enabled;
float fog_transmit_curve;
highp float fog_transmit_curve;
bool fog_height_enabled;
float fog_height_min;
float fog_height_max;
float fog_height_curve;
highp float fog_height_min;
highp float fog_height_max;
highp float fog_height_curve;
};
uniform highp mat4 world_transform;
#ifdef USE_LIGHT_DIRECTIONAL
layout(std140) uniform DirectionalLightData { //ubo:3
@ -121,6 +122,90 @@ layout(std140) uniform DirectionalLightData { //ubo:3
#endif
#ifdef USE_VERTEX_LIGHTING
//omni and spot
struct LightData {
highp vec4 light_pos_inv_radius;
mediump vec4 light_direction_attenuation;
mediump vec4 light_color_energy;
mediump vec4 light_params; //cone attenuation, angle, specular, shadow enabled,
mediump vec4 light_clamp;
mediump vec4 shadow_color_contact;
highp mat4 shadow_matrix;
};
layout(std140) uniform OmniLightData { //ubo:4
LightData omni_lights[MAX_LIGHT_DATA_STRUCTS];
};
layout(std140) uniform SpotLightData { //ubo:5
LightData spot_lights[MAX_LIGHT_DATA_STRUCTS];
};
#ifdef USE_FORWARD_LIGHTING
uniform int omni_light_indices[MAX_FORWARD_LIGHTS];
uniform int omni_light_count;
uniform int spot_light_indices[MAX_FORWARD_LIGHTS];
uniform int spot_light_count;
#endif
out vec4 diffuse_light_interp;
out vec4 specular_light_interp;
void light_compute(vec3 N, vec3 L,vec3 V, vec3 light_color,float roughness,inout vec3 diffuse, inout vec3 specular) {
float dotNL = max(dot(N,L), 0.0 );
diffuse += dotNL * light_color;
if (roughness > 0.0) {
vec3 H = normalize(V + L);
float dotNH = max(dot(N,H), 0.0 );
float intensity = pow( dotNH, (1.0-roughness) * 256.0);
specular += light_color * intensity;
}
}
void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal, float roughness,inout vec3 diffuse, inout vec3 specular) {
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;
vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.0), omni_lights[idx].light_direction_attenuation.w ));
light_compute(normal,normalize(light_rel_vec),eye_vec,omni_lights[idx].light_color_energy.rgb * light_attenuation,roughness,diffuse,specular);
}
void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, float roughness, inout vec3 diffuse, inout vec3 specular) {
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;
vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w ));
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);
float spot_rim = (1.0 - scos) / (1.0 - spot_cutoff);
light_attenuation *= 1.0 - pow( max(spot_rim,0.001), spot_lights[idx].light_params.x);
light_compute(normal,normalize(light_rel_vec),eye_vec,spot_lights[idx].light_color_energy.rgb*light_attenuation,roughness,diffuse,specular);
}
#endif
/* Varyings */
@ -288,6 +373,8 @@ void main() {
#endif
#endif
float roughness=0.0;
//defines that make writing custom shaders easier
#define projection_matrix local_projection
#define world_transform world_matrix
@ -376,6 +463,54 @@ VERTEX_SHADER_CODE
#endif
position_interp=gl_Position;
#ifdef USE_VERTEX_LIGHTING
diffuse_light_interp=vec4(0.0);
specular_light_interp=vec4(0.0);
#ifdef USE_FORWARD_LIGHTING
for(int i=0;i<omni_light_count;i++) {
light_process_omni(omni_light_indices[i],vertex_interp,-normalize( vertex_interp ),normal_interp,roughness,diffuse_light_interp.rgb,specular_light_interp.rgb);
}
for(int i=0;i<spot_light_count;i++) {
light_process_spot(spot_light_indices[i],vertex_interp,-normalize( vertex_interp ),normal_interp,roughness,diffuse_light_interp.rgb,specular_light_interp.rgb);
}
#endif
#ifdef USE_LIGHT_DIRECTIONAL
vec3 directional_diffuse = vec3(0.0);
vec3 directional_specular = vec3(0.0);
light_compute(normal_interp,-light_direction_attenuation.xyz,-normalize( vertex_interp ),normal_interp,roughness,directional_diffuse,directional_specular);
float diff_avg = dot(diffuse_light_interp.rgb,vec3(0.33333));
float diff_dir_avg = dot(directional_diffuse,vec3(0.33333));
if (diff_avg>0.0) {
diffuse_light_interp.a=diff_dir_avg/(diff_avg+diff_dir_avg);
} else {
diffuse_light_interp.a=1.0;
}
diffuse_light_interp.rgb+=directional_diffuse;
float spec_avg = dot(specular_light_interp.rgb,vec3(0.33333));
float spec_dir_avg = dot(directional_specular,vec3(0.33333));
if (spec_avg>0.0) {
specular_light_interp.a=spec_dir_avg/(spec_avg+spec_dir_avg);
} else {
specular_light_interp.a=1.0;
}
specular_light_interp.rgb+=directional_specular;
#endif //USE_LIGHT_DIRECTIONAL
#endif // USE_VERTEX_LIGHTING
}
@ -455,7 +590,7 @@ vec3 textureDualParaboloid(sampler2DArray p_tex, vec3 p_vec,float p_roughness) {
// we need to lie the derivatives (normg) and assume that DP side is always the same
// to get proper texure filtering
vec2 normg=norm.xy;
if (norm.z>0) {
if (norm.z>0.0) {
norm.y=0.5-norm.y+0.5;
}
@ -479,7 +614,7 @@ vec3 textureDualParaboloid(sampler2D p_tex, vec3 p_vec,float p_roughness) {
vec3 norm = normalize(p_vec);
norm.xy/=1.0+abs(norm.z);
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
if (norm.z>0) {
if (norm.z>0.0) {
norm.y=0.5-norm.y+0.5;
}
return textureLod(p_tex, norm.xy, p_roughness * RADIANCE_MAX_LOD).xyz;
@ -511,39 +646,39 @@ layout(std140) uniform SceneData {
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
highp vec4 ambient_light_color;
highp vec4 bg_color;
mediump vec4 ambient_light_color;
mediump vec4 bg_color;
vec4 fog_color_enabled;
vec4 fog_sun_color_amount;
mediump vec4 fog_color_enabled;
mediump vec4 fog_sun_color_amount;
float ambient_energy;
float bg_energy;
mediump float ambient_energy;
mediump float bg_energy;
float z_offset;
float z_slope_scale;
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
mediump float z_offset;
mediump float z_slope_scale;
highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side;
highp vec2 screen_pixel_size;
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;
highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size;
float time;
float z_far;
float reflection_multiplier;
float subsurface_scatter_width;
float ambient_occlusion_affect_light;
highp float time;
highp float z_far;
mediump float reflection_multiplier;
mediump float subsurface_scatter_width;
mediump float ambient_occlusion_affect_light;
bool fog_depth_enabled;
float fog_depth_begin;
float fog_depth_curve;
highp float fog_depth_begin;
highp float fog_depth_curve;
bool fog_transmit_enabled;
float fog_transmit_curve;
highp float fog_transmit_curve;
bool fog_height_enabled;
float fog_height_min;
float fog_height_max;
float fog_height_curve;
highp float fog_height_min;
highp float fog_height_max;
highp float fog_height_curve;
};
//directional light data
@ -570,6 +705,10 @@ uniform highp sampler2DShadow directional_shadow; //texunit:-4
#endif
#ifdef USE_VERTEX_LIGHTING
in vec4 diffuse_light_interp;
in vec4 specular_light_interp;
#endif
//omni and spot
struct LightData {
@ -655,6 +794,8 @@ layout(location=0) out vec4 frag_color;
in highp vec4 position_interp;
uniform highp sampler2D depth_buffer; //texunit:-8
#ifdef USE_CONTACT_SHADOWS
float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
if (abs(dir.z)>0.99)
@ -715,6 +856,8 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
return 1.0;
}
#endif
// GGX Specular
// Source: http://www.filmicworlds.com/images/ggx-opt/optimized-ggx.hlsl
float G1V(float dotNV, float k)
@ -1010,13 +1153,16 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
splane.xy = clamp_rect.xy+splane.xy*clamp_rect.zw;
float shadow = sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,clamp_rect);
#ifdef USE_CONTACT_SHADOWS
if (shadow>0.01 && omni_lights[idx].shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,normalize(light_rel_vec),min(light_length,omni_lights[idx].shadow_color_contact.a));
shadow=min(shadow,contact_shadow);
}
#endif
light_attenuation*=mix(omni_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
@ -1043,13 +1189,14 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
float shadow = sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,spot_lights[idx].light_clamp);
#ifdef USE_CONTACT_SHADOWS
if (shadow>0.01 && spot_lights[idx].shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,normalize(light_rel_vec),min(light_length,spot_lights[idx].shadow_color_contact.a));
shadow=min(shadow,contact_shadow);
}
#endif
light_attenuation*=mix(spot_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
@ -1097,7 +1244,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta
vec3 norm = normalize(local_ref_vec);
norm.xy/=1.0+abs(norm.z);
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
if (norm.z>0) {
if (norm.z>0.0) {
norm.y=0.5-norm.y+0.5;
}
@ -1460,9 +1607,18 @@ FRAGMENT_SHADER_CODE
//apply energy conservation
#ifdef USE_VERTEX_LIGHTING
vec3 specular_light = specular_light_interp.rgb;
vec3 diffuse_light = diffuse_light_interp.rgb;
#else
vec3 specular_light = vec3(0.0,0.0,0.0);
vec3 ambient_light;
vec3 diffuse_light = vec3(0.0,0.0,0.0);
#endif
vec3 ambient_light;
vec3 env_reflection_light = vec3(0.0,0.0,0.0);
vec3 eye_vec = -normalize( vertex_interp );
@ -1515,7 +1671,7 @@ FRAGMENT_SHADER_CODE
specular_blob_intensity*=specular * 2.0;
#endif
#ifdef USE_LIGHT_DIRECTIONAL
#if defined(USE_LIGHT_DIRECTIONAL)
vec3 light_attenuation=vec3(1.0);
@ -1640,13 +1796,14 @@ FRAGMENT_SHADER_CODE
}
#endif
#ifdef USE_CONTACT_SHADOWS
if (shadow>0.01 && shadow_color_contact.a>0.0) {
float contact_shadow = contact_shadow_compute(vertex,-light_direction_attenuation.xyz,shadow_color_contact.a);
shadow=min(shadow,contact_shadow);
}
#endif
light_attenuation=mix(shadow_color_contact.rgb,vec3(1.0),shadow);
@ -1654,7 +1811,13 @@ FRAGMENT_SHADER_CODE
#endif //LIGHT_DIRECTIONAL_SHADOW
#ifdef USE_VERTEX_LIGHTING
diffuse_light*=mix(vec3(1.0),light_attenuation,diffuse_light_interp.a);
specular_light*=mix(vec3(1.0),light_attenuation,specular_light_interp.a);
#else
light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
#endif
#endif //#USE_LIGHT_DIRECTIONAL
@ -1664,12 +1827,11 @@ FRAGMENT_SHADER_CODE
#endif
#ifdef USE_FORWARD_LIGHTING
highp vec4 reflection_accum = vec4(0.0,0.0,0.0,0.0);
highp vec4 ambient_accum = vec4(0.0,0.0,0.0,0.0);
for(int i=0;i<reflection_count;i++) {
reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,env_reflection_light,reflection_accum,ambient_accum);
}
@ -1684,6 +1846,13 @@ FRAGMENT_SHADER_CODE
ambient_light+=ambient_accum.rgb/ambient_accum.a;
}
#ifdef USE_VERTEX_LIGHTING
diffuse_light*=albedo;
#else
for(int i=0;i<omni_light_count;i++) {
light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
@ -1692,15 +1861,13 @@ FRAGMENT_SHADER_CODE
light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
#endif //USE_VERTEX_LIGHTING
#endif
#ifdef RENDER_DEPTH
//nothing happens, so a tree-ssa optimizer will result in no fragment shader :)
#else
@ -1713,13 +1880,11 @@ FRAGMENT_SHADER_CODE
#endif
//energu conservation
diffuse_light=mix(diffuse_light,vec3(0.0),metallic);
ambient_light=mix(ambient_light,vec3(0.0),metallic);
{
#if defined(DIFFUSE_TOON)
@ -1744,7 +1909,7 @@ FRAGMENT_SHADER_CODE
if (fog_color_enabled.a > 0.5) {
float fog_amount=0;
float fog_amount=0.0;

View file

@ -18,6 +18,10 @@ void main() {
[fragment]
#if !defined(GLES_OVER_GL)
precision mediump float;
#endif
in vec2 uv_interp;

View file

@ -1260,6 +1260,7 @@ bool Main::start() {
String stretch_mode = GLOBAL_DEF("display/window/stretch/mode", "disabled");
String stretch_aspect = GLOBAL_DEF("display/window/stretch/aspect", "ignore");
Size2i stretch_size = Size2(GLOBAL_DEF("display/window/size/width", 0), GLOBAL_DEF("display/window/size/height", 0));
int stretch_shrink = GLOBAL_DEF("display/window/stretch/shrink", 1);
SceneTree::StretchMode sml_sm = SceneTree::STRETCH_MODE_DISABLED;
if (stretch_mode == "2d")
@ -1275,7 +1276,7 @@ bool Main::start() {
else if (stretch_aspect == "keep_height")
sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_HEIGHT;
sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size);
sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size, stretch_shrink);
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
@ -1302,6 +1303,8 @@ bool Main::start() {
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
GLOBAL_DEF("display/window/stretch/aspect", "ignore");
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height"));
GLOBAL_DEF("display/window/stretch/shrink", 1);
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink", PropertyInfo(Variant::STRING, "display/window/stretch/shrink", PROPERTY_HINT_RANGE, "1,8,1"));
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
}

View file

@ -2830,7 +2830,11 @@ public:
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
r_features->push_back("etc");
int api = p_preset->get("graphics/api");
if (api == 0)
r_features->push_back("etc");
else
r_features->push_back("etc2");
}
virtual void get_export_options(List<ExportOption> *r_options) {

View file

@ -1153,7 +1153,7 @@ void SceneTree::_update_root_rect() {
if (stretch_mode == STRETCH_MODE_DISABLED) {
root->set_size(last_screen_size);
root->set_size((last_screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(Point2(), last_screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
@ -1231,15 +1231,15 @@ void SceneTree::_update_root_rect() {
switch (stretch_mode) {
case STRETCH_MODE_2D: {
root->set_size(screen_size);
root->set_size((screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(true);
root->set_size_override(true, viewport_size);
root->set_size_override(true, (viewport_size / stretch_shrink).floor());
} break;
case STRETCH_MODE_VIEWPORT: {
root->set_size(viewport_size);
root->set_size((viewport_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
@ -1248,11 +1248,12 @@ void SceneTree::_update_root_rect() {
}
}
void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize) {
void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink) {
stretch_mode = p_mode;
stretch_aspect = p_aspect;
stretch_min = p_minsize;
stretch_shrink = p_shrink;
_update_root_rect();
}
@ -2207,7 +2208,7 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame);
ClassDB::bind_method(D_METHOD("quit"), &SceneTree::quit);
ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize"), &SceneTree::set_screen_stretch);
ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize", "shrink"), &SceneTree::set_screen_stretch, DEFVAL(1));
ClassDB::bind_method(D_METHOD("queue_delete", "obj"), &SceneTree::queue_delete);
@ -2395,6 +2396,7 @@ SceneTree::SceneTree() {
stretch_mode = STRETCH_MODE_DISABLED;
stretch_aspect = STRETCH_ASPECT_IGNORE;
stretch_shrink = 1;
last_screen_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
_update_root_rect();

View file

@ -149,6 +149,7 @@ private:
StretchMode stretch_mode;
StretchAspect stretch_aspect;
Size2i stretch_min;
int stretch_shrink;
void _update_root_rect();
@ -420,7 +421,7 @@ public:
void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
bool has_group(const StringName &p_identifier) const;
void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize);
void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink = 1);
//void change_scene(const String& p_path);
//Node *get_loaded_scene();

View file

@ -338,7 +338,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
cpos.y += ch->v_align;
ERR_FAIL_COND_V(ch->texture_idx < -1 || ch->texture_idx >= fb->textures.size(), 0);
if (ch->texture_idx != -1)
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), fb->textures[ch->texture_idx].texture->get_rid(), ch->rect, p_modulate);
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), fb->textures[ch->texture_idx].texture->get_rid(), ch->rect, p_modulate, false, RID(), false);
advance = ch->advance;
used_fallback = true;
break;
@ -360,7 +360,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
cpos.y += c->v_align;
ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
if (c->texture_idx != -1)
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate);
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate, false, RID(), false);
advance = c->advance;
//textures[c->texture_idx].texture->draw(p_canvas_item,Vector2());
}

View file

@ -334,6 +334,9 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_ONTOP]) {
code += ",ontop";
}
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
code += ",vertex_lighting";
}
if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
code += ",world_vertex_coords";
@ -444,6 +447,11 @@ void SpatialMaterial::_update_shader() {
code += "\tPOINT_SIZE=point_size;\n";
}
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
code += "\tROUGHNESS=roughness;\n";
}
if (!flags[FLAG_UV1_USE_TRIPLANAR]) {
code += "\tUV=UV*uv1_scale.xy+uv1_offset.xy;\n";
}
@ -1450,6 +1458,7 @@ void SpatialMaterial::_bind_methods() {
ADD_GROUP("Flags", "flags_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_vertex_lighting"), "set_flag", "get_flag", FLAG_USE_VERTEX_LIGHTING);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_on_top"), "set_flag", "get_flag", FLAG_ONTOP);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE);
@ -1605,6 +1614,7 @@ void SpatialMaterial::_bind_methods() {
BIND_CONSTANT(CULL_DISABLED);
BIND_CONSTANT(FLAG_UNSHADED);
BIND_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
BIND_CONSTANT(FLAG_ONTOP);
BIND_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
BIND_CONSTANT(FLAG_SRGB_VERTEX_COLOR)

View file

@ -155,6 +155,7 @@ public:
enum Flags {
FLAG_UNSHADED,
FLAG_USE_VERTEX_LIGHTING,
FLAG_ONTOP,
FLAG_ALBEDO_FROM_VERTEX_COLOR,
FLAG_SRGB_VERTEX_COLOR,

View file

@ -47,8 +47,11 @@ void Sky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radiance_size", "size"), &Sky::set_radiance_size);
ClassDB::bind_method(D_METHOD("get_radiance_size"), &Sky::get_radiance_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "32,64,128,256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
BIND_CONSTANT(RADIANCE_SIZE_32);
BIND_CONSTANT(RADIANCE_SIZE_64);
BIND_CONSTANT(RADIANCE_SIZE_128);
BIND_CONSTANT(RADIANCE_SIZE_256);
BIND_CONSTANT(RADIANCE_SIZE_512);
BIND_CONSTANT(RADIANCE_SIZE_1024);
@ -66,7 +69,7 @@ void PanoramaSky::_radiance_changed() {
if (panorama.is_valid()) {
static const int size[RADIANCE_SIZE_MAX] = {
256, 512, 1024, 2048
32, 64, 128, 256, 512, 1024, 2048
};
VS::get_singleton()->sky_set_texture(sky, panorama->get_rid(), size[get_radiance_size()]);
}
@ -120,7 +123,7 @@ void ProceduralSky::_radiance_changed() {
return; //do nothing yet
static const int size[RADIANCE_SIZE_MAX] = {
256, 512, 1024, 2048
32, 64, 128, 256, 512, 1024, 2048
};
VS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]);
}
@ -132,7 +135,7 @@ void ProceduralSky::_update_sky() {
PoolVector<uint8_t> imgdata;
static const int size[TEXTURE_SIZE_MAX] = {
1024, 2048, 4096
256, 512, 1024, 2048, 4096
};
int w = size[texture_size];
@ -465,7 +468,14 @@ void ProceduralSky::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sun_energy", "get_sun_energy");
ADD_GROUP("Texture", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "1024,2048,4096"), "set_texture_size", "get_texture_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size");
BIND_CONSTANT(TEXTURE_SIZE_256);
BIND_CONSTANT(TEXTURE_SIZE_512);
BIND_CONSTANT(TEXTURE_SIZE_1024);
BIND_CONSTANT(TEXTURE_SIZE_2048);
BIND_CONSTANT(TEXTURE_SIZE_4096);
BIND_CONSTANT(TEXTURE_SIZE_MAX);
}
ProceduralSky::ProceduralSky() {

View file

@ -37,6 +37,9 @@ class Sky : public Resource {
public:
enum RadianceSize {
RADIANCE_SIZE_32,
RADIANCE_SIZE_64,
RADIANCE_SIZE_128,
RADIANCE_SIZE_256,
RADIANCE_SIZE_512,
RADIANCE_SIZE_1024,
@ -85,6 +88,8 @@ class ProceduralSky : public Sky {
public:
enum TextureSize {
TEXTURE_SIZE_256,
TEXTURE_SIZE_512,
TEXTURE_SIZE_1024,
TEXTURE_SIZE_2048,
TEXTURE_SIZE_4096,

View file

@ -66,6 +66,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_ID"] = ShaderLanguage::TYPE_INT;
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_CUSTOM"] = ShaderLanguage::TYPE_VEC4;
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
//builtins
shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
@ -147,6 +148,8 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_vertex_transform");
shader_modes[VS::SHADER_SPATIAL].modes.insert("world_vertex_coords");
shader_modes[VS::SHADER_SPATIAL].modes.insert("vertex_lighting");
/************ CANVAS ITEM **************************/
shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["SRC_VERTEX"] = ShaderLanguage::TYPE_VEC2;

View file

@ -1592,6 +1592,14 @@ VisualServer::VisualServer() {
GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections", true);
GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections.mobile", false);
GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx", true);
GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx.mobile", false);
GLOBAL_DEF("rendering/quality/shading/force_vertex_shading", false);
GLOBAL_DEF("rendering/quality/shading/force_vertex_shading.mobile", true);
GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno");
}
VisualServer::~VisualServer() {