From bf6380ee7077b00ad425b242e483482e98854983 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 25 May 2017 13:53:59 -0300 Subject: [PATCH] Removed skybox support, added panorama support. Skybox support may come back eventually, but hope not. --- drivers/gles3/rasterizer_scene_gles3.cpp | 58 +++++----- drivers/gles3/rasterizer_scene_gles3.h | 26 ++--- drivers/gles3/rasterizer_storage_gles3.cpp | 56 +++++----- drivers/gles3/rasterizer_storage_gles3.h | 12 +-- drivers/gles3/shaders/copy.glsl | 43 ++++++-- drivers/gles3/shaders/cubemap_filter.glsl | 35 +++++- scene/register_scene_types.cpp | 4 +- scene/resources/environment.cpp | 70 ++++++------ scene/resources/environment.h | 20 ++-- scene/resources/sky_box.cpp | 119 +++++---------------- scene/resources/sky_box.h | 35 +++--- servers/visual/rasterizer.h | 12 +-- servers/visual/visual_server_raster.h | 10 +- servers/visual_server.h | 14 +-- 14 files changed, 256 insertions(+), 258 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 79c6f7f01fb..5214de6d060 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -798,20 +798,20 @@ void RasterizerSceneGLES3::environment_set_background(RID p_env, VS::Environment env->bg_mode = p_bg; } -void RasterizerSceneGLES3::environment_set_skybox(RID p_env, RID p_skybox) { +void RasterizerSceneGLES3::environment_set_sky(RID p_env, RID p_sky) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->skybox = p_skybox; + env->sky = p_sky; } -void RasterizerSceneGLES3::environment_set_skybox_scale(RID p_env, float p_scale) { +void RasterizerSceneGLES3::environment_set_sky_scale(RID p_env, float p_scale) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->skybox_scale = p_scale; + env->sky_scale = p_scale; } void RasterizerSceneGLES3::environment_set_bg_color(RID p_env, const Color &p_color) { @@ -836,14 +836,14 @@ void RasterizerSceneGLES3::environment_set_canvas_max_layer(RID p_env, int p_max env->canvas_max_layer = p_max_layer; } -void RasterizerSceneGLES3::environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy, float p_skybox_contribution) { +void RasterizerSceneGLES3::environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy, float p_sky_contribution) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->ambient_color = p_color; env->ambient_energy = p_energy; - env->ambient_skybox_contribution = p_skybox_contribution; + env->ambient_sky_contribution = p_sky_contribution; } void RasterizerSceneGLES3::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) { @@ -2120,12 +2120,12 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo } } -void RasterizerSceneGLES3::_draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale) { +void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale) { - if (!p_skybox) + if (!p_sky) return; - RasterizerStorageGLES3::Texture *tex = storage->texture_owner.getornull(p_skybox->cubemap); + RasterizerStorageGLES3::Texture *tex = storage->texture_owner.getornull(p_sky->panorama); ERR_FAIL_COND(!tex); glActiveTexture(GL_TEXTURE0); @@ -2164,7 +2164,7 @@ void RasterizerSceneGLES3::_draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox }; - //skybox uv vectors + //sky uv vectors float vw, vh, zn; p_projection.get_viewport_size(vw, vh); zn = p_projection.get_z_near(); @@ -2181,13 +2181,13 @@ void RasterizerSceneGLES3::_draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox vertices[i * 2 + 1].z = -vertices[i * 2 + 1].z; } - glBindBuffer(GL_ARRAY_BUFFER, state.skybox_verts); + glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * 8, vertices); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - glBindVertexArray(state.skybox_array); + glBindVertexArray(state.sky_array); - storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_CUBEMAP, true); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, true); storage->shaders.copy.bind(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -2195,7 +2195,7 @@ void RasterizerSceneGLES3::_draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox glBindVertexArray(0); glColorMask(1, 1, 1, 1); - storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_CUBEMAP, false); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, false); } void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform) { @@ -2239,7 +2239,7 @@ void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatr state.ubo_data.bg_color[2] = bg_color.b; state.ubo_data.bg_color[3] = bg_color.a; - state.env_radiance_data.ambient_contribution = env->ambient_skybox_contribution; + state.env_radiance_data.ambient_contribution = env->ambient_sky_contribution; state.ubo_data.ambient_occlusion_affect_light = env->ssao_light_affect; } else { state.ubo_data.bg_energy = 1.0; @@ -2683,7 +2683,7 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul ambient_linear.r *= p_env->ambient_energy; ambient_linear.g *= p_env->ambient_energy; ambient_linear.b *= p_env->ambient_energy; - contrib = p_env->ambient_skybox_contribution; + contrib = p_env->ambient_sky_contribution; } reflection_ubo.ambient[0] = ambient_linear.r; @@ -3807,7 +3807,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const Color clear_color(0, 0, 0, 0); - RasterizerStorageGLES3::SkyBox *skybox = NULL; + RasterizerStorageGLES3::Sky *sky = NULL; GLuint env_radiance_tex = 0; if (!env || env->bg_mode == VS::ENV_BG_CLEAR_COLOR) { @@ -3822,12 +3822,12 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const clear_color = env->bg_color.to_linear(); storage->frame.clear_request = false; - } else if (env->bg_mode == VS::ENV_BG_SKYBOX) { + } else if (env->bg_mode == VS::ENV_BG_SKY) { - skybox = storage->skybox_owner.getornull(env->skybox); + sky = storage->sky_owner.getornull(env->sky); - if (skybox) { - env_radiance_tex = skybox->radiance; + if (sky) { + env_radiance_tex = sky->radiance; } storage->frame.clear_request = false; @@ -3878,14 +3878,14 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const glDrawBuffers(1, &gldb); } - if (env && env->bg_mode == VS::ENV_BG_SKYBOX) { + if (env && env->bg_mode == VS::ENV_BG_SKY) { /* if (use_mrt) { - glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo); //switch to alpha fbo for skybox, only diffuse/ambient matters + glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo); //switch to alpha fbo for sky, only diffuse/ambient matters */ - _draw_skybox(skybox, p_cam_projection, p_cam_transform, storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP], env->skybox_scale); + _draw_sky(sky, p_cam_projection, p_cam_transform, storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP], env->sky_scale); } //_render_list_forward(&alpha_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting,true); @@ -4585,14 +4585,14 @@ void RasterizerSceneGLES3::initialize() { { //quad buffers - glGenBuffers(1, &state.skybox_verts); - glBindBuffer(GL_ARRAY_BUFFER, state.skybox_verts); + glGenBuffers(1, &state.sky_verts); + glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts); glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, NULL, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - glGenVertexArrays(1, &state.skybox_array); - glBindVertexArray(state.skybox_array); - glBindBuffer(GL_ARRAY_BUFFER, state.skybox_verts); + glGenVertexArrays(1, &state.sky_array); + glBindVertexArray(state.sky_array); + glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts); glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0); glEnableVertexAttribArray(VS::ARRAY_VERTEX); glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, ((uint8_t *)NULL) + sizeof(Vector3)); diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 33698fc2679..69a7e406045 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -141,8 +141,8 @@ public: GLuint brdf_texture; - GLuint skybox_verts; - GLuint skybox_array; + GLuint sky_verts; + GLuint sky_array; GLuint directional_ubo; @@ -329,16 +329,16 @@ public: VS::EnvironmentBG bg_mode; - RID skybox; - float skybox_scale; + RID sky; + float sky_scale; Color bg_color; float bg_energy; - float skybox_ambient; + float sky_ambient; Color ambient_color; float ambient_energy; - float ambient_skybox_contribution; + float ambient_sky_contribution; int canvas_max_layer; @@ -393,11 +393,11 @@ public: Environment() { bg_mode = VS::ENV_BG_CLEAR_COLOR; - skybox_scale = 1.0; + sky_scale = 1.0; bg_energy = 1.0; - skybox_ambient = 0; + sky_ambient = 0; ambient_energy = 1.0; - ambient_skybox_contribution = 0.0; + ambient_sky_contribution = 0.0; canvas_max_layer = 0; ssr_enabled = false; @@ -455,12 +455,12 @@ public: virtual RID environment_create(); virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg); - virtual void environment_set_skybox(RID p_env, RID p_skybox); - virtual void environment_set_skybox_scale(RID p_env, float p_scale); + virtual void environment_set_sky(RID p_env, RID p_sky); + virtual void environment_set_sky_scale(RID p_env, float p_scale); virtual void environment_set_bg_color(RID p_env, const Color &p_color); virtual void environment_set_bg_energy(RID p_env, float p_energy); 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_skybox_contribution = 0.0); + 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); @@ -700,7 +700,7 @@ public: _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow); - void _draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale); + void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale); 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); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 8749021a124..08ff687510d 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1213,32 +1213,32 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_ return texture_owner.make_rid(ctex); } -RID RasterizerStorageGLES3::skybox_create() { +RID RasterizerStorageGLES3::sky_create() { - SkyBox *skybox = memnew(SkyBox); - skybox->radiance = 0; - return skybox_owner.make_rid(skybox); + Sky *sky = memnew(Sky); + sky->radiance = 0; + return sky_owner.make_rid(sky); } -void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) { +void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size) { - SkyBox *skybox = skybox_owner.getornull(p_skybox); - ERR_FAIL_COND(!skybox); + Sky *sky = sky_owner.getornull(p_sky); + ERR_FAIL_COND(!sky); - if (skybox->cubemap.is_valid()) { - skybox->cubemap = RID(); - glDeleteTextures(1, &skybox->radiance); - skybox->radiance = 0; + if (sky->panorama.is_valid()) { + sky->panorama = RID(); + glDeleteTextures(1, &sky->radiance); + sky->radiance = 0; } - skybox->cubemap = p_cube_map; - if (!skybox->cubemap.is_valid()) + sky->panorama = p_panorama; + if (!sky->panorama.is_valid()) return; //cleared - Texture *texture = texture_owner.getornull(skybox->cubemap); - if (!texture || !(texture->flags & VS::TEXTURE_FLAG_CUBEMAP)) { - skybox->cubemap = RID(); - ERR_FAIL_COND(!texture || !(texture->flags & VS::TEXTURE_FLAG_CUBEMAP)); + Texture *texture = texture_owner.getornull(sky->panorama); + if (!texture) { + sky->panorama = RID(); + ERR_FAIL_COND(!texture); } glBindVertexArray(0); @@ -1263,8 +1263,8 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in } glActiveTexture(GL_TEXTURE1); - glGenTextures(1, &skybox->radiance); - glBindTexture(GL_TEXTURE_2D, skybox->radiance); + glGenTextures(1, &sky->radiance); + glBindTexture(GL_TEXTURE_2D, sky->radiance); GLuint tmp_fb; @@ -1304,11 +1304,12 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in size = p_radiance_size; shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, true); shaders.cubemap_filter.bind(); while (mm_level) { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, skybox->radiance, lod); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sky->radiance, lod); #ifdef DEBUG_ENABLED GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE); @@ -1331,6 +1332,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in mm_level--; } shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, false); //restore ranges glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); @@ -6116,12 +6118,12 @@ bool RasterizerStorageGLES3::free(RID p_rid) { info.texture_mem -= texture->total_data_size; texture_owner.free(p_rid); memdelete(texture); - } else if (skybox_owner.owns(p_rid)) { - // delete the skybox - SkyBox *skybox = skybox_owner.get(p_rid); - skybox_set_texture(p_rid, RID(), 256); - skybox_owner.free(p_rid); - memdelete(skybox); + } else if (sky_owner.owns(p_rid)) { + // delete the sky + Sky *sky = sky_owner.get(p_rid); + sky_set_texture(p_rid, RID(), 256); + sky_owner.free(p_rid); + memdelete(sky); } else if (shader_owner.owns(p_rid)) { @@ -6478,7 +6480,7 @@ void RasterizerStorageGLES3::initialize() { glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind } - //generic quadie for copying without touching skybox + //generic quadie for copying without touching sky { //transform feedback buffers diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 7cae58852d0..26b7cea45e1 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -308,19 +308,19 @@ public: virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); - /* SKYBOX API */ + /* SKY API */ - struct SkyBox : public RID_Data { + struct Sky : public RID_Data { - RID cubemap; + RID panorama; GLuint radiance; int radiance_size; }; - mutable RID_Owner skybox_owner; + mutable RID_Owner sky_owner; - virtual RID skybox_create(); - virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size); + virtual RID sky_create(); + virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size); /* SHADER API */ diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl index a87d62f2d7a..f3c72a4e6f7 100644 --- a/drivers/gles3/shaders/copy.glsl +++ b/drivers/gles3/shaders/copy.glsl @@ -2,14 +2,14 @@ layout(location=0) in highp vec4 vertex_attrib; -#ifdef USE_CUBEMAP +#if defined(USE_CUBEMAP) || defined(USE_PANORAMA) layout(location=4) in vec3 cube_in; #else layout(location=4) in vec2 uv_in; #endif layout(location=5) in vec2 uv2_in; -#ifdef USE_CUBEMAP +#if defined(USE_CUBEMAP) || defined(USE_PANORAMA) out vec3 cube_interp; #else out vec2 uv_interp; @@ -19,7 +19,7 @@ out vec2 uv2_interp; void main() { -#ifdef USE_CUBEMAP +#if defined(USE_CUBEMAP) || defined(USE_PANORAMA) cube_interp = cube_in; #else uv_interp = uv_in; @@ -30,15 +30,40 @@ void main() { [fragment] +#define M_PI 3.14159265359 -#ifdef USE_CUBEMAP + +#if defined(USE_CUBEMAP) || defined(USE_PANORAMA) in vec3 cube_interp; -uniform samplerCube source_cube; //texunit:0 #else in vec2 uv_interp; +#endif + +#ifdef USE_CUBEMAP +uniform samplerCube source_cube; //texunit:0 +#else uniform sampler2D source; //texunit:0 #endif +#ifdef USE_PANORAMA + +vec4 texturePanorama(vec3 normal,sampler2D pano ) { + + vec2 st = vec2( + atan(normal.x, normal.z), + acos(normal.y) + ); + + if(st.x < 0.0) + st.x += M_PI*2.0; + + st/=vec2(M_PI*2.0,M_PI); + + return textureLod(pano,st,0.0); + +} + +#endif float sRGB_gamma_correct(float c){ float a = 0.055; @@ -60,13 +85,19 @@ void main() { //vec4 color = color_interp; -#ifdef USE_CUBEMAP +#ifdef USE_PANORAMA + + vec4 color = texturePanorama( normalize(cube_interp), source ); + +#elif defined(USE_CUBEMAP) vec4 color = texture( source_cube, normalize(cube_interp) ); #else vec4 color = texture( source, uv_interp ); #endif + + #ifdef LINEAR_TO_SRGB //regular Linear -> SRGB conversion vec3 a = vec3(0.055); diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl index 768d20ad22a..2aec6380f5b 100644 --- a/drivers/gles3/shaders/cubemap_filter.glsl +++ b/drivers/gles3/shaders/cubemap_filter.glsl @@ -19,8 +19,12 @@ void main() { precision highp float; precision highp int; - +#ifdef USE_PANORAMA +uniform sampler2D source_panorama; //texunit:0 +#else uniform samplerCube source_cube; //texunit:0 +#endif + uniform int face_id; uniform float roughness; in highp vec2 uv_interp; @@ -165,6 +169,26 @@ vec2 Hammersley(uint i, uint N) { uniform bool z_flip; +#ifdef USE_PANORAMA + +vec4 texturePanorama(vec3 normal,sampler2D pano ) { + + vec2 st = vec2( + atan(normal.x, normal.z), + acos(normal.y) + ); + + if(st.x < 0.0) + st.x += M_PI*2.0; + + st/=vec2(M_PI*2.0,M_PI); + + return textureLod(pano,st,0.0); + +} + +#endif + void main() { #ifdef USE_DUAL_PARABOLOID @@ -188,7 +212,12 @@ void main() { #ifdef USE_DIRECT_WRITE +#ifdef USE_PANORAMA + + frag_color=vec4(texturePanorama(N,source_panorama).rgb,1.0); +#else frag_color=vec4(texture(N,source_cube).rgb,1.0); +#endif #else @@ -204,7 +233,11 @@ void main() { float ndotl = clamp(dot(N, L),0.0,1.0); if (ndotl>0.0) { +#ifdef USE_PANORAMA + sum.rgb += texturePanorama(H,source_panorama).rgb *ndotl; +#else sum.rgb += textureLod(source_cube, H, 0.0).rgb *ndotl; +#endif sum.a += ndotl; } } diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 76ff6edc630..4c359f73ab3 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -561,8 +561,8 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_virtual_class(); - ClassDB::register_virtual_class(); - ClassDB::register_class(); + ClassDB::register_virtual_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 96871cc9445..39943b99db9 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -44,21 +44,21 @@ void Environment::set_background(BGMode p_bg) { _change_notify(); } -void Environment::set_skybox(const Ref &p_skybox) { +void Environment::set_sky(const Ref &p_sky) { - bg_skybox = p_skybox; + bg_sky = p_sky; RID sb_rid; - if (bg_skybox.is_valid()) - sb_rid = bg_skybox->get_rid(); + if (bg_sky.is_valid()) + sb_rid = bg_sky->get_rid(); - VS::get_singleton()->environment_set_skybox(environment, sb_rid); + VS::get_singleton()->environment_set_sky(environment, sb_rid); } -void Environment::set_skybox_scale(float p_scale) { +void Environment::set_sky_scale(float p_scale) { - bg_skybox_scale = p_scale; - VS::get_singleton()->environment_set_skybox_scale(environment, p_scale); + bg_sky_scale = p_scale; + VS::get_singleton()->environment_set_sky_scale(environment, p_scale); } void Environment::set_bg_color(const Color &p_color) { @@ -79,31 +79,31 @@ void Environment::set_canvas_max_layer(int p_max_layer) { void Environment::set_ambient_light_color(const Color &p_color) { ambient_color = p_color; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_skybox_contribution); + VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution); } void Environment::set_ambient_light_energy(float p_energy) { ambient_energy = p_energy; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_skybox_contribution); + VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution); } -void Environment::set_ambient_light_skybox_contribution(float p_energy) { +void Environment::set_ambient_light_sky_contribution(float p_energy) { - ambient_skybox_contribution = p_energy; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_skybox_contribution); + ambient_sky_contribution = p_energy; + VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution); } Environment::BGMode Environment::get_background() const { return bg_mode; } -Ref Environment::get_skybox() const { +Ref Environment::get_sky() const { - return bg_skybox; + return bg_sky; } -float Environment::get_skybox_scale() const { +float Environment::get_sky_scale() const { - return bg_skybox_scale; + return bg_sky_scale; } Color Environment::get_bg_color() const { @@ -126,9 +126,9 @@ float Environment::get_ambient_light_energy() const { return ambient_energy; } -float Environment::get_ambient_light_skybox_contribution() const { +float Environment::get_ambient_light_sky_contribution() const { - return ambient_skybox_contribution; + return ambient_sky_contribution; } void Environment::set_tonemapper(ToneMapper p_tone_mapper) { @@ -266,8 +266,8 @@ Ref Environment::get_adjustment_color_correction() const { void Environment::_validate_property(PropertyInfo &property) const { - if (property.name == "background/skybox" || property.name == "background/skybox_scale" || property.name == "ambient_light/skybox_contribution") { - if (bg_mode != BG_SKYBOX) { + if (property.name == "background/sky" || property.name == "background/sky_scale" || property.name == "ambient_light/sky_contribution") { + if (bg_mode != BG_SKY) { property.usage = PROPERTY_USAGE_NOEDITOR; } } @@ -664,36 +664,36 @@ Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const { void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background); - ClassDB::bind_method(D_METHOD("set_skybox", "skybox:CubeMap"), &Environment::set_skybox); - ClassDB::bind_method(D_METHOD("set_skybox_scale", "scale"), &Environment::set_skybox_scale); + ClassDB::bind_method(D_METHOD("set_sky", "sky:CubeMap"), &Environment::set_sky); + ClassDB::bind_method(D_METHOD("set_sky_scale", "scale"), &Environment::set_sky_scale); ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &Environment::set_bg_color); ClassDB::bind_method(D_METHOD("set_bg_energy", "energy"), &Environment::set_bg_energy); ClassDB::bind_method(D_METHOD("set_canvas_max_layer", "layer"), &Environment::set_canvas_max_layer); ClassDB::bind_method(D_METHOD("set_ambient_light_color", "color"), &Environment::set_ambient_light_color); ClassDB::bind_method(D_METHOD("set_ambient_light_energy", "energy"), &Environment::set_ambient_light_energy); - ClassDB::bind_method(D_METHOD("set_ambient_light_skybox_contribution", "energy"), &Environment::set_ambient_light_skybox_contribution); + ClassDB::bind_method(D_METHOD("set_ambient_light_sky_contribution", "energy"), &Environment::set_ambient_light_sky_contribution); ClassDB::bind_method(D_METHOD("get_background"), &Environment::get_background); - ClassDB::bind_method(D_METHOD("get_skybox:CubeMap"), &Environment::get_skybox); - ClassDB::bind_method(D_METHOD("get_skybox_scale"), &Environment::get_skybox_scale); + ClassDB::bind_method(D_METHOD("get_sky:CubeMap"), &Environment::get_sky); + ClassDB::bind_method(D_METHOD("get_sky_scale"), &Environment::get_sky_scale); ClassDB::bind_method(D_METHOD("get_bg_color"), &Environment::get_bg_color); ClassDB::bind_method(D_METHOD("get_bg_energy"), &Environment::get_bg_energy); ClassDB::bind_method(D_METHOD("get_canvas_max_layer"), &Environment::get_canvas_max_layer); ClassDB::bind_method(D_METHOD("get_ambient_light_color"), &Environment::get_ambient_light_color); ClassDB::bind_method(D_METHOD("get_ambient_light_energy"), &Environment::get_ambient_light_energy); - ClassDB::bind_method(D_METHOD("get_ambient_light_skybox_contribution"), &Environment::get_ambient_light_skybox_contribution); + ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution); ADD_GROUP("Background", "background_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Skybox,Canvas,Keep"), "set_background", "get_background"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_skybox", PROPERTY_HINT_RESOURCE_TYPE, "SkyBox"), "set_skybox", "get_skybox"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_skybox_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_skybox_scale", "get_skybox_scale"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Canvas,Keep"), "set_background", "get_background"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_sky_scale", "get_sky_scale"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_bg_energy", "get_bg_energy"); ADD_PROPERTY(PropertyInfo(Variant::INT, "background_canvas_max_layer", PROPERTY_HINT_RANGE, "-1000,1000,1"), "set_canvas_max_layer", "get_canvas_max_layer"); ADD_GROUP("Ambient Light", "ambient_light_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_light_color"), "set_ambient_light_color", "get_ambient_light_color"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ambient_light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_light_energy", "get_ambient_light_energy"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "ambient_light_skybox_contribution", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ambient_light_skybox_contribution", "get_ambient_light_skybox_contribution"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ambient_light_sky_contribution", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ambient_light_sky_contribution", "get_ambient_light_sky_contribution"); ClassDB::bind_method(D_METHOD("set_ssr_enabled", "enabled"), &Environment::set_ssr_enabled); ClassDB::bind_method(D_METHOD("is_ssr_enabled"), &Environment::is_ssr_enabled); @@ -909,12 +909,12 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction"); - GLOBAL_DEF("rendering/skybox/irradiance_cube_resolution", 256); + GLOBAL_DEF("rendering/sky/irradiance_cube_resolution", 256); BIND_CONSTANT(BG_KEEP); BIND_CONSTANT(BG_CLEAR_COLOR); BIND_CONSTANT(BG_COLOR); - BIND_CONSTANT(BG_SKYBOX); + BIND_CONSTANT(BG_SKY); BIND_CONSTANT(BG_CANVAS); BIND_CONSTANT(BG_MAX); BIND_CONSTANT(GLOW_BLEND_MODE_ADDITIVE); @@ -933,11 +933,11 @@ void Environment::_bind_methods() { Environment::Environment() { bg_mode = BG_CLEAR_COLOR; - bg_skybox_scale = 1.0; + bg_sky_scale = 1.0; bg_energy = 1.0; bg_canvas_max_layer = 0; ambient_energy = 1.0; - ambient_skybox_contribution = 0; + ambient_sky_contribution = 0; tone_mapper = TONE_MAPPER_LINEAR; tonemap_exposure = 1.0; diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 9014a9f5c27..d9141ccd9c0 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -44,7 +44,7 @@ public: BG_CLEAR_COLOR, BG_COLOR, - BG_SKYBOX, + BG_SKY, BG_CANVAS, BG_KEEP, BG_MAX @@ -74,14 +74,14 @@ private: RID environment; BGMode bg_mode; - Ref bg_skybox; - float bg_skybox_scale; + Ref bg_sky; + float bg_sky_scale; Color bg_color; float bg_energy; int bg_canvas_max_layer; Color ambient_color; float ambient_energy; - float ambient_skybox_contribution; + float ambient_sky_contribution; ToneMapper tone_mapper; float tonemap_exposure; @@ -144,24 +144,24 @@ protected: public: void set_background(BGMode p_bg); - void set_skybox(const Ref &p_skybox); - void set_skybox_scale(float p_scale); + void set_sky(const Ref &p_sky); + void set_sky_scale(float p_scale); void set_bg_color(const Color &p_color); void set_bg_energy(float p_energy); void set_canvas_max_layer(int p_max_layer); void set_ambient_light_color(const Color &p_color); void set_ambient_light_energy(float p_energy); - void set_ambient_light_skybox_contribution(float p_energy); + void set_ambient_light_sky_contribution(float p_energy); BGMode get_background() const; - Ref get_skybox() const; - float get_skybox_scale() const; + Ref get_sky() const; + float get_sky_scale() const; Color get_bg_color() const; float get_bg_energy() const; int get_canvas_max_layer() const; Color get_ambient_light_color() const; float get_ambient_light_energy() const; - float get_ambient_light_skybox_contribution() const; + float get_ambient_light_sky_contribution() const; void set_tonemapper(ToneMapper p_tone_mapper); ToneMapper get_tonemapper() const; diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp index 2fd074de0ff..59ade4a7294 100644 --- a/scene/resources/sky_box.cpp +++ b/scene/resources/sky_box.cpp @@ -30,22 +30,22 @@ #include "sky_box.h" #include "io/image_loader.h" -void SkyBox::set_radiance_size(RadianceSize p_size) { +void Sky::set_radiance_size(RadianceSize p_size) { ERR_FAIL_INDEX(p_size, RADIANCE_SIZE_MAX); radiance_size = p_size; _radiance_changed(); } -SkyBox::RadianceSize SkyBox::get_radiance_size() const { +Sky::RadianceSize Sky::get_radiance_size() const { return radiance_size; } -void SkyBox::_bind_methods() { +void Sky::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_radiance_size", "size"), &SkyBox::set_radiance_size); - ClassDB::bind_method(D_METHOD("get_radiance_size"), &SkyBox::get_radiance_size); + 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"); @@ -56,124 +56,59 @@ void SkyBox::_bind_methods() { BIND_CONSTANT(RADIANCE_SIZE_MAX); } -SkyBox::SkyBox() { +Sky::Sky() { radiance_size = RADIANCE_SIZE_512; } ///////////////////////////////////////// -void ImageSkyBox::_radiance_changed() { +void PanoramaSky::_radiance_changed() { - if (cube_map_valid) { + if (panorama.is_valid()) { static const int size[RADIANCE_SIZE_MAX] = { 256, 512, 1024, 2048 }; - VS::get_singleton()->skybox_set_texture(sky_box, cube_map, size[get_radiance_size()]); + VS::get_singleton()->sky_set_texture(sky, panorama->get_rid(), size[get_radiance_size()]); } } -void ImageSkyBox::set_image_path(ImagePath p_image, const String &p_path) { +void PanoramaSky::set_panorama(const Ref &p_panorama) { - ERR_FAIL_INDEX(p_image, IMAGE_PATH_MAX); - image_path[p_image] = p_path; + panorama = p_panorama; - bool all_ok = true; - for (int i = 0; i < IMAGE_PATH_MAX; i++) { - if (image_path[i] == String()) { - all_ok = false; - } - } + if (panorama.is_valid()) { - cube_map_valid = false; - - if (all_ok) { - - Ref images[IMAGE_PATH_MAX]; - int w = 0, h = 0; - Image::Format format; - - for (int i = 0; i < IMAGE_PATH_MAX; i++) { - images[i].instance(); - Error err = ImageLoader::load_image(image_path[i], images[i]); - if (err) { - ERR_PRINTS("Error loading image for skybox: " + image_path[i]); - return; - } - - if (i == 0) { - w = images[0]->get_width(); - h = images[0]->get_height(); - format = images[0]->get_format(); - } else { - if (images[i]->get_width() != w || images[i]->get_height() != h || images[i]->get_format() != format) { - ERR_PRINTS("Image size mismatch (" + itos(images[i]->get_width()) + "," + itos(images[i]->get_height()) + ":" + Image::get_format_name(images[i]->get_format()) + " when it should be " + itos(w) + "," + itos(h) + ":" + Image::get_format_name(format) + "): " + image_path[i]); - return; - } - } - } - - VS::get_singleton()->texture_allocate(cube_map, w, h, format, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_CUBEMAP | VS::TEXTURE_FLAG_MIPMAPS); - for (int i = 0; i < IMAGE_PATH_MAX; i++) { - VS::get_singleton()->texture_set_data(cube_map, images[i], VS::CubeMapSide(i)); - } - - cube_map_valid = true; _radiance_changed(); + + } else { + VS::get_singleton()->sky_set_texture(sky, RID(), 0); } } -String ImageSkyBox::get_image_path(ImagePath p_image) const { +Ref PanoramaSky::get_panorama() const { - ERR_FAIL_INDEX_V(p_image, IMAGE_PATH_MAX, String()); - return image_path[p_image]; + return panorama; } -RID ImageSkyBox::get_rid() const { +RID PanoramaSky::get_rid() const { - return sky_box; + return sky; } -void ImageSkyBox::_bind_methods() { +void PanoramaSky::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_image_path", "image", "path"), &ImageSkyBox::set_image_path); - ClassDB::bind_method(D_METHOD("get_image_path", "image"), &ImageSkyBox::get_image_path); + ClassDB::bind_method(D_METHOD("set_panorama", "texture:Texture"), &PanoramaSky::set_panorama); + ClassDB::bind_method(D_METHOD("get_panorama:Texture"), &PanoramaSky::get_panorama); - List extensions; - ImageLoader::get_recognized_extensions(&extensions); - String hints; - for (List::Element *E = extensions.front(); E; E = E->next()) { - if (hints != String()) { - hints += ","; - } - hints += "*." + E->get(); - } - - ADD_GROUP("Image Path", "image_path_"); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_negative_x", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_NEGATIVE_X); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_positive_x", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_POSITIVE_X); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_negative_y", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_NEGATIVE_Y); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_positive_y", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_POSITIVE_Y); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_negative_z", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_NEGATIVE_Z); - ADD_PROPERTYI(PropertyInfo(Variant::STRING, "image_path_positive_z", PROPERTY_HINT_FILE, hints), "set_image_path", "get_image_path", IMAGE_PATH_POSITIVE_Z); - - BIND_CONSTANT(IMAGE_PATH_NEGATIVE_X); - BIND_CONSTANT(IMAGE_PATH_POSITIVE_X); - BIND_CONSTANT(IMAGE_PATH_NEGATIVE_Y); - BIND_CONSTANT(IMAGE_PATH_POSITIVE_Y); - BIND_CONSTANT(IMAGE_PATH_NEGATIVE_Z); - BIND_CONSTANT(IMAGE_PATH_POSITIVE_Z); - BIND_CONSTANT(IMAGE_PATH_MAX); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_panorama", "get_panorama"); } -ImageSkyBox::ImageSkyBox() { +PanoramaSky::PanoramaSky() { - cube_map = VS::get_singleton()->texture_create(); - sky_box = VS::get_singleton()->skybox_create(); - cube_map_valid = false; + sky = VS::get_singleton()->sky_create(); } -ImageSkyBox::~ImageSkyBox() { +PanoramaSky::~PanoramaSky() { - VS::get_singleton()->free(cube_map); - VS::get_singleton()->free(sky_box); + VS::get_singleton()->free(sky); } diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h index f748ac1e2d4..afbfb3019e4 100644 --- a/scene/resources/sky_box.h +++ b/scene/resources/sky_box.h @@ -27,13 +27,13 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SKYBOX_H -#define SKYBOX_H +#ifndef Sky_H +#define Sky_H #include "scene/resources/texture.h" -class SkyBox : public Resource { - GDCLASS(SkyBox, Resource); +class Sky : public Resource { + GDCLASS(Sky, Resource); public: enum RadianceSize { @@ -54,13 +54,13 @@ protected: public: void set_radiance_size(RadianceSize p_size); RadianceSize get_radiance_size() const; - SkyBox(); + Sky(); }; -VARIANT_ENUM_CAST(SkyBox::RadianceSize) +VARIANT_ENUM_CAST(Sky::RadianceSize) -class ImageSkyBox : public SkyBox { - GDCLASS(ImageSkyBox, SkyBox); +class PanoramaSky : public Sky { + GDCLASS(PanoramaSky, Sky); public: enum ImagePath { @@ -74,26 +74,23 @@ public: }; private: - RID cube_map; - RID sky_box; - bool cube_map_valid; - - String image_path[IMAGE_PATH_MAX]; + RID sky; + Ref panorama; protected: static void _bind_methods(); virtual void _radiance_changed(); public: - void set_image_path(ImagePath p_image, const String &p_path); - String get_image_path(ImagePath p_image) const; + void set_panorama(const Ref &p_panorama); + Ref get_panorama() const; virtual RID get_rid() const; - ImageSkyBox(); - ~ImageSkyBox(); + PanoramaSky(); + ~PanoramaSky(); }; -VARIANT_ENUM_CAST(ImageSkyBox::ImagePath) +VARIANT_ENUM_CAST(PanoramaSky::ImagePath) -#endif // SKYBOX_H +#endif // Sky_H diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 12cf30cfc4c..c51dcd1a3b9 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -52,12 +52,12 @@ public: virtual RID environment_create() = 0; virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 0; - virtual void environment_set_skybox(RID p_env, RID p_skybox) = 0; - virtual void environment_set_skybox_scale(RID p_env, float p_scale) = 0; + virtual void environment_set_sky(RID p_env, RID p_sky) = 0; + virtual void environment_set_sky_scale(RID p_env, float p_scale) = 0; virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0; virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; - virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_skybox_contribution = 0.0) = 0; + virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.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) = 0; 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) = 0; @@ -187,10 +187,10 @@ public: virtual void textures_keep_original(bool p_enable) = 0; - /* SKYBOX API */ + /* SKY API */ - virtual RID skybox_create() = 0; - virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) = 0; + virtual RID sky_create() = 0; + virtual void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) = 0; /* SHADER API */ diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 95806a2e1a0..957af7b9ddc 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -644,10 +644,10 @@ public: BIND1(textures_keep_original, bool) - /* SKYBOX API */ + /* SKY API */ - BIND0R(RID, skybox_create) - BIND3(skybox_set_texture, RID, RID, int) + BIND0R(RID, sky_create) + BIND3(sky_set_texture, RID, RID, int) /* SHADER API */ @@ -932,8 +932,8 @@ public: BIND0R(RID, environment_create) BIND2(environment_set_background, RID, EnvironmentBG) - BIND2(environment_set_skybox, RID, RID) - BIND2(environment_set_skybox_scale, RID, float) + BIND2(environment_set_sky, RID, RID) + BIND2(environment_set_sky_scale, RID, float) BIND2(environment_set_bg_color, RID, const Color &) BIND2(environment_set_bg_energy, RID, float) BIND2(environment_set_canvas_max_layer, RID, int) diff --git a/servers/visual_server.h b/servers/visual_server.h index 92776847322..aa98d47455e 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -141,10 +141,10 @@ public: virtual void textures_keep_original(bool p_enable) = 0; - /* SKYBOX API */ + /* SKY API */ - virtual RID skybox_create() = 0; - virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) = 0; + virtual RID sky_create() = 0; + virtual void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) = 0; /* SHADER API */ @@ -589,19 +589,19 @@ public: ENV_BG_CLEAR_COLOR, ENV_BG_COLOR, - ENV_BG_SKYBOX, + ENV_BG_SKY, ENV_BG_CANVAS, ENV_BG_KEEP, ENV_BG_MAX }; virtual void environment_set_background(RID p_env, EnvironmentBG p_bg) = 0; - virtual void environment_set_skybox(RID p_env, RID p_skybox) = 0; - virtual void environment_set_skybox_scale(RID p_env, float p_scale) = 0; + virtual void environment_set_sky(RID p_env, RID p_sky) = 0; + virtual void environment_set_sky_scale(RID p_env, float p_scale) = 0; virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0; virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; - virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_skybox_contribution = 0.0) = 0; + virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0; //set default SSAO options //set default SSR options