Removed skybox support, added panorama support. Skybox support may come back eventually, but hope not.
This commit is contained in:
parent
7592c2380d
commit
bf6380ee70
14 changed files with 256 additions and 258 deletions
|
@ -798,20 +798,20 @@ void RasterizerSceneGLES3::environment_set_background(RID p_env, VS::Environment
|
||||||
env->bg_mode = p_bg;
|
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);
|
Environment *env = environment_owner.getornull(p_env);
|
||||||
ERR_FAIL_COND(!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);
|
Environment *env = environment_owner.getornull(p_env);
|
||||||
ERR_FAIL_COND(!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) {
|
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;
|
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);
|
Environment *env = environment_owner.getornull(p_env);
|
||||||
ERR_FAIL_COND(!env);
|
ERR_FAIL_COND(!env);
|
||||||
|
|
||||||
env->ambient_color = p_color;
|
env->ambient_color = p_color;
|
||||||
env->ambient_energy = p_energy;
|
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) {
|
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;
|
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);
|
ERR_FAIL_COND(!tex);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
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;
|
float vw, vh, zn;
|
||||||
p_projection.get_viewport_size(vw, vh);
|
p_projection.get_viewport_size(vw, vh);
|
||||||
zn = p_projection.get_z_near();
|
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;
|
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);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * 8, vertices);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
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();
|
storage->shaders.copy.bind();
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
@ -2195,7 +2195,7 @@ void RasterizerSceneGLES3::_draw_skybox(RasterizerStorageGLES3::SkyBox *p_skybox
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glColorMask(1, 1, 1, 1);
|
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) {
|
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[2] = bg_color.b;
|
||||||
state.ubo_data.bg_color[3] = bg_color.a;
|
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;
|
state.ubo_data.ambient_occlusion_affect_light = env->ssao_light_affect;
|
||||||
} else {
|
} else {
|
||||||
state.ubo_data.bg_energy = 1.0;
|
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.r *= p_env->ambient_energy;
|
||||||
ambient_linear.g *= p_env->ambient_energy;
|
ambient_linear.g *= p_env->ambient_energy;
|
||||||
ambient_linear.b *= 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;
|
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);
|
Color clear_color(0, 0, 0, 0);
|
||||||
|
|
||||||
RasterizerStorageGLES3::SkyBox *skybox = NULL;
|
RasterizerStorageGLES3::Sky *sky = NULL;
|
||||||
GLuint env_radiance_tex = 0;
|
GLuint env_radiance_tex = 0;
|
||||||
|
|
||||||
if (!env || env->bg_mode == VS::ENV_BG_CLEAR_COLOR) {
|
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();
|
clear_color = env->bg_color.to_linear();
|
||||||
storage->frame.clear_request = false;
|
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) {
|
if (sky) {
|
||||||
env_radiance_tex = skybox->radiance;
|
env_radiance_tex = sky->radiance;
|
||||||
}
|
}
|
||||||
storage->frame.clear_request = false;
|
storage->frame.clear_request = false;
|
||||||
|
|
||||||
|
@ -3878,14 +3878,14 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||||
glDrawBuffers(1, &gldb);
|
glDrawBuffers(1, &gldb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env && env->bg_mode == VS::ENV_BG_SKYBOX) {
|
if (env && env->bg_mode == VS::ENV_BG_SKY) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (use_mrt) {
|
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);
|
//_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
|
//quad buffers
|
||||||
|
|
||||||
glGenBuffers(1, &state.skybox_verts);
|
glGenBuffers(1, &state.sky_verts);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, state.skybox_verts);
|
glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, NULL, GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, NULL, GL_DYNAMIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
||||||
|
|
||||||
glGenVertexArrays(1, &state.skybox_array);
|
glGenVertexArrays(1, &state.sky_array);
|
||||||
glBindVertexArray(state.skybox_array);
|
glBindVertexArray(state.sky_array);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, state.skybox_verts);
|
glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts);
|
||||||
glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0);
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0);
|
||||||
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
||||||
glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, ((uint8_t *)NULL) + sizeof(Vector3));
|
glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, ((uint8_t *)NULL) + sizeof(Vector3));
|
||||||
|
|
|
@ -141,8 +141,8 @@ public:
|
||||||
|
|
||||||
GLuint brdf_texture;
|
GLuint brdf_texture;
|
||||||
|
|
||||||
GLuint skybox_verts;
|
GLuint sky_verts;
|
||||||
GLuint skybox_array;
|
GLuint sky_array;
|
||||||
|
|
||||||
GLuint directional_ubo;
|
GLuint directional_ubo;
|
||||||
|
|
||||||
|
@ -329,16 +329,16 @@ public:
|
||||||
|
|
||||||
VS::EnvironmentBG bg_mode;
|
VS::EnvironmentBG bg_mode;
|
||||||
|
|
||||||
RID skybox;
|
RID sky;
|
||||||
float skybox_scale;
|
float sky_scale;
|
||||||
|
|
||||||
Color bg_color;
|
Color bg_color;
|
||||||
float bg_energy;
|
float bg_energy;
|
||||||
float skybox_ambient;
|
float sky_ambient;
|
||||||
|
|
||||||
Color ambient_color;
|
Color ambient_color;
|
||||||
float ambient_energy;
|
float ambient_energy;
|
||||||
float ambient_skybox_contribution;
|
float ambient_sky_contribution;
|
||||||
|
|
||||||
int canvas_max_layer;
|
int canvas_max_layer;
|
||||||
|
|
||||||
|
@ -393,11 +393,11 @@ public:
|
||||||
|
|
||||||
Environment() {
|
Environment() {
|
||||||
bg_mode = VS::ENV_BG_CLEAR_COLOR;
|
bg_mode = VS::ENV_BG_CLEAR_COLOR;
|
||||||
skybox_scale = 1.0;
|
sky_scale = 1.0;
|
||||||
bg_energy = 1.0;
|
bg_energy = 1.0;
|
||||||
skybox_ambient = 0;
|
sky_ambient = 0;
|
||||||
ambient_energy = 1.0;
|
ambient_energy = 1.0;
|
||||||
ambient_skybox_contribution = 0.0;
|
ambient_sky_contribution = 0.0;
|
||||||
canvas_max_layer = 0;
|
canvas_max_layer = 0;
|
||||||
|
|
||||||
ssr_enabled = false;
|
ssr_enabled = false;
|
||||||
|
@ -455,12 +455,12 @@ public:
|
||||||
virtual RID environment_create();
|
virtual RID environment_create();
|
||||||
|
|
||||||
virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg);
|
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_sky(RID p_env, RID p_sky);
|
||||||
virtual void environment_set_skybox_scale(RID p_env, float p_scale);
|
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_color(RID p_env, const Color &p_color);
|
||||||
virtual void environment_set_bg_energy(RID p_env, float p_energy);
|
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_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_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
|
||||||
virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality);
|
virtual void environment_set_dof_blur_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);
|
_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_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
|
||||||
void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transformm, bool p_use_shadows);
|
void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transformm, bool p_use_shadows);
|
||||||
|
|
|
@ -1213,32 +1213,32 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_
|
||||||
return texture_owner.make_rid(ctex);
|
return texture_owner.make_rid(ctex);
|
||||||
}
|
}
|
||||||
|
|
||||||
RID RasterizerStorageGLES3::skybox_create() {
|
RID RasterizerStorageGLES3::sky_create() {
|
||||||
|
|
||||||
SkyBox *skybox = memnew(SkyBox);
|
Sky *sky = memnew(Sky);
|
||||||
skybox->radiance = 0;
|
sky->radiance = 0;
|
||||||
return skybox_owner.make_rid(skybox);
|
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);
|
Sky *sky = sky_owner.getornull(p_sky);
|
||||||
ERR_FAIL_COND(!skybox);
|
ERR_FAIL_COND(!sky);
|
||||||
|
|
||||||
if (skybox->cubemap.is_valid()) {
|
if (sky->panorama.is_valid()) {
|
||||||
skybox->cubemap = RID();
|
sky->panorama = RID();
|
||||||
glDeleteTextures(1, &skybox->radiance);
|
glDeleteTextures(1, &sky->radiance);
|
||||||
skybox->radiance = 0;
|
sky->radiance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
skybox->cubemap = p_cube_map;
|
sky->panorama = p_panorama;
|
||||||
if (!skybox->cubemap.is_valid())
|
if (!sky->panorama.is_valid())
|
||||||
return; //cleared
|
return; //cleared
|
||||||
|
|
||||||
Texture *texture = texture_owner.getornull(skybox->cubemap);
|
Texture *texture = texture_owner.getornull(sky->panorama);
|
||||||
if (!texture || !(texture->flags & VS::TEXTURE_FLAG_CUBEMAP)) {
|
if (!texture) {
|
||||||
skybox->cubemap = RID();
|
sky->panorama = RID();
|
||||||
ERR_FAIL_COND(!texture || !(texture->flags & VS::TEXTURE_FLAG_CUBEMAP));
|
ERR_FAIL_COND(!texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
@ -1263,8 +1263,8 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glGenTextures(1, &skybox->radiance);
|
glGenTextures(1, &sky->radiance);
|
||||||
glBindTexture(GL_TEXTURE_2D, skybox->radiance);
|
glBindTexture(GL_TEXTURE_2D, sky->radiance);
|
||||||
|
|
||||||
GLuint tmp_fb;
|
GLuint tmp_fb;
|
||||||
|
|
||||||
|
@ -1304,11 +1304,12 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in
|
||||||
size = p_radiance_size;
|
size = p_radiance_size;
|
||||||
|
|
||||||
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
|
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
|
||||||
|
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, true);
|
||||||
shaders.cubemap_filter.bind();
|
shaders.cubemap_filter.bind();
|
||||||
|
|
||||||
while (mm_level) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE);
|
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--;
|
mm_level--;
|
||||||
}
|
}
|
||||||
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
|
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, false);
|
||||||
|
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_PANORAMA, false);
|
||||||
|
|
||||||
//restore ranges
|
//restore ranges
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
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;
|
info.texture_mem -= texture->total_data_size;
|
||||||
texture_owner.free(p_rid);
|
texture_owner.free(p_rid);
|
||||||
memdelete(texture);
|
memdelete(texture);
|
||||||
} else if (skybox_owner.owns(p_rid)) {
|
} else if (sky_owner.owns(p_rid)) {
|
||||||
// delete the skybox
|
// delete the sky
|
||||||
SkyBox *skybox = skybox_owner.get(p_rid);
|
Sky *sky = sky_owner.get(p_rid);
|
||||||
skybox_set_texture(p_rid, RID(), 256);
|
sky_set_texture(p_rid, RID(), 256);
|
||||||
skybox_owner.free(p_rid);
|
sky_owner.free(p_rid);
|
||||||
memdelete(skybox);
|
memdelete(sky);
|
||||||
|
|
||||||
} else if (shader_owner.owns(p_rid)) {
|
} else if (shader_owner.owns(p_rid)) {
|
||||||
|
|
||||||
|
@ -6478,7 +6480,7 @@ void RasterizerStorageGLES3::initialize() {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
||||||
}
|
}
|
||||||
|
|
||||||
//generic quadie for copying without touching skybox
|
//generic quadie for copying without touching sky
|
||||||
|
|
||||||
{
|
{
|
||||||
//transform feedback buffers
|
//transform feedback buffers
|
||||||
|
|
|
@ -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_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);
|
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;
|
GLuint radiance;
|
||||||
int radiance_size;
|
int radiance_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
mutable RID_Owner<SkyBox> skybox_owner;
|
mutable RID_Owner<Sky> sky_owner;
|
||||||
|
|
||||||
virtual RID skybox_create();
|
virtual RID sky_create();
|
||||||
virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size);
|
virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
|
|
||||||
layout(location=0) in highp vec4 vertex_attrib;
|
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;
|
layout(location=4) in vec3 cube_in;
|
||||||
#else
|
#else
|
||||||
layout(location=4) in vec2 uv_in;
|
layout(location=4) in vec2 uv_in;
|
||||||
#endif
|
#endif
|
||||||
layout(location=5) in vec2 uv2_in;
|
layout(location=5) in vec2 uv2_in;
|
||||||
|
|
||||||
#ifdef USE_CUBEMAP
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
||||||
out vec3 cube_interp;
|
out vec3 cube_interp;
|
||||||
#else
|
#else
|
||||||
out vec2 uv_interp;
|
out vec2 uv_interp;
|
||||||
|
@ -19,7 +19,7 @@ out vec2 uv2_interp;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
#ifdef USE_CUBEMAP
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
||||||
cube_interp = cube_in;
|
cube_interp = cube_in;
|
||||||
#else
|
#else
|
||||||
uv_interp = uv_in;
|
uv_interp = uv_in;
|
||||||
|
@ -30,15 +30,40 @@ void main() {
|
||||||
|
|
||||||
[fragment]
|
[fragment]
|
||||||
|
|
||||||
|
#define M_PI 3.14159265359
|
||||||
|
|
||||||
#ifdef USE_CUBEMAP
|
|
||||||
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
||||||
in vec3 cube_interp;
|
in vec3 cube_interp;
|
||||||
uniform samplerCube source_cube; //texunit:0
|
|
||||||
#else
|
#else
|
||||||
in vec2 uv_interp;
|
in vec2 uv_interp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CUBEMAP
|
||||||
|
uniform samplerCube source_cube; //texunit:0
|
||||||
|
#else
|
||||||
uniform sampler2D source; //texunit:0
|
uniform sampler2D source; //texunit:0
|
||||||
#endif
|
#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 sRGB_gamma_correct(float c){
|
||||||
float a = 0.055;
|
float a = 0.055;
|
||||||
|
@ -60,13 +85,19 @@ void main() {
|
||||||
|
|
||||||
//vec4 color = color_interp;
|
//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) );
|
vec4 color = texture( source_cube, normalize(cube_interp) );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
vec4 color = texture( source, uv_interp );
|
vec4 color = texture( source, uv_interp );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef LINEAR_TO_SRGB
|
#ifdef LINEAR_TO_SRGB
|
||||||
//regular Linear -> SRGB conversion
|
//regular Linear -> SRGB conversion
|
||||||
vec3 a = vec3(0.055);
|
vec3 a = vec3(0.055);
|
||||||
|
|
|
@ -19,8 +19,12 @@ void main() {
|
||||||
precision highp float;
|
precision highp float;
|
||||||
precision highp int;
|
precision highp int;
|
||||||
|
|
||||||
|
#ifdef USE_PANORAMA
|
||||||
|
uniform sampler2D source_panorama; //texunit:0
|
||||||
|
#else
|
||||||
uniform samplerCube source_cube; //texunit:0
|
uniform samplerCube source_cube; //texunit:0
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform int face_id;
|
uniform int face_id;
|
||||||
uniform float roughness;
|
uniform float roughness;
|
||||||
in highp vec2 uv_interp;
|
in highp vec2 uv_interp;
|
||||||
|
@ -165,6 +169,26 @@ vec2 Hammersley(uint i, uint N) {
|
||||||
|
|
||||||
uniform bool z_flip;
|
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() {
|
void main() {
|
||||||
|
|
||||||
#ifdef USE_DUAL_PARABOLOID
|
#ifdef USE_DUAL_PARABOLOID
|
||||||
|
@ -188,7 +212,12 @@ void main() {
|
||||||
|
|
||||||
#ifdef USE_DIRECT_WRITE
|
#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);
|
frag_color=vec4(texture(N,source_cube).rgb,1.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -204,7 +233,11 @@ void main() {
|
||||||
float ndotl = clamp(dot(N, L),0.0,1.0);
|
float ndotl = clamp(dot(N, L),0.0,1.0);
|
||||||
|
|
||||||
if (ndotl>0.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;
|
sum.rgb += textureLod(source_cube, H, 0.0).rgb *ndotl;
|
||||||
|
#endif
|
||||||
sum.a += ndotl;
|
sum.a += ndotl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,8 +561,8 @@ void register_scene_types() {
|
||||||
ClassDB::register_class<Environment>();
|
ClassDB::register_class<Environment>();
|
||||||
ClassDB::register_class<World2D>();
|
ClassDB::register_class<World2D>();
|
||||||
ClassDB::register_virtual_class<Texture>();
|
ClassDB::register_virtual_class<Texture>();
|
||||||
ClassDB::register_virtual_class<SkyBox>();
|
ClassDB::register_virtual_class<Sky>();
|
||||||
ClassDB::register_class<ImageSkyBox>();
|
ClassDB::register_class<PanoramaSky>();
|
||||||
ClassDB::register_class<StreamTexture>();
|
ClassDB::register_class<StreamTexture>();
|
||||||
ClassDB::register_class<ImageTexture>();
|
ClassDB::register_class<ImageTexture>();
|
||||||
ClassDB::register_class<AtlasTexture>();
|
ClassDB::register_class<AtlasTexture>();
|
||||||
|
|
|
@ -44,21 +44,21 @@ void Environment::set_background(BGMode p_bg) {
|
||||||
_change_notify();
|
_change_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::set_skybox(const Ref<SkyBox> &p_skybox) {
|
void Environment::set_sky(const Ref<Sky> &p_sky) {
|
||||||
|
|
||||||
bg_skybox = p_skybox;
|
bg_sky = p_sky;
|
||||||
|
|
||||||
RID sb_rid;
|
RID sb_rid;
|
||||||
if (bg_skybox.is_valid())
|
if (bg_sky.is_valid())
|
||||||
sb_rid = bg_skybox->get_rid();
|
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;
|
bg_sky_scale = p_scale;
|
||||||
VS::get_singleton()->environment_set_skybox_scale(environment, p_scale);
|
VS::get_singleton()->environment_set_sky_scale(environment, p_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::set_bg_color(const Color &p_color) {
|
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) {
|
void Environment::set_ambient_light_color(const Color &p_color) {
|
||||||
|
|
||||||
ambient_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) {
|
void Environment::set_ambient_light_energy(float p_energy) {
|
||||||
|
|
||||||
ambient_energy = 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;
|
ambient_sky_contribution = 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment::BGMode Environment::get_background() const {
|
Environment::BGMode Environment::get_background() const {
|
||||||
|
|
||||||
return bg_mode;
|
return bg_mode;
|
||||||
}
|
}
|
||||||
Ref<SkyBox> Environment::get_skybox() const {
|
Ref<Sky> 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 {
|
Color Environment::get_bg_color() const {
|
||||||
|
@ -126,9 +126,9 @@ float Environment::get_ambient_light_energy() const {
|
||||||
|
|
||||||
return ambient_energy;
|
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) {
|
void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
|
||||||
|
@ -266,8 +266,8 @@ Ref<Texture> Environment::get_adjustment_color_correction() const {
|
||||||
|
|
||||||
void Environment::_validate_property(PropertyInfo &property) 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 (property.name == "background/sky" || property.name == "background/sky_scale" || property.name == "ambient_light/sky_contribution") {
|
||||||
if (bg_mode != BG_SKYBOX) {
|
if (bg_mode != BG_SKY) {
|
||||||
property.usage = PROPERTY_USAGE_NOEDITOR;
|
property.usage = PROPERTY_USAGE_NOEDITOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -664,36 +664,36 @@ Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const {
|
||||||
void Environment::_bind_methods() {
|
void Environment::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background);
|
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_sky", "sky:CubeMap"), &Environment::set_sky);
|
||||||
ClassDB::bind_method(D_METHOD("set_skybox_scale", "scale"), &Environment::set_skybox_scale);
|
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_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_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_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_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_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_background"), &Environment::get_background);
|
||||||
ClassDB::bind_method(D_METHOD("get_skybox:CubeMap"), &Environment::get_skybox);
|
ClassDB::bind_method(D_METHOD("get_sky:CubeMap"), &Environment::get_sky);
|
||||||
ClassDB::bind_method(D_METHOD("get_skybox_scale"), &Environment::get_skybox_scale);
|
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_color"), &Environment::get_bg_color);
|
||||||
ClassDB::bind_method(D_METHOD("get_bg_energy"), &Environment::get_bg_energy);
|
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_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_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_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_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::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,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::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
|
||||||
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::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::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::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_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_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::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_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("set_ssr_enabled", "enabled"), &Environment::set_ssr_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("is_ssr_enabled"), &Environment::is_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::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");
|
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_KEEP);
|
||||||
BIND_CONSTANT(BG_CLEAR_COLOR);
|
BIND_CONSTANT(BG_CLEAR_COLOR);
|
||||||
BIND_CONSTANT(BG_COLOR);
|
BIND_CONSTANT(BG_COLOR);
|
||||||
BIND_CONSTANT(BG_SKYBOX);
|
BIND_CONSTANT(BG_SKY);
|
||||||
BIND_CONSTANT(BG_CANVAS);
|
BIND_CONSTANT(BG_CANVAS);
|
||||||
BIND_CONSTANT(BG_MAX);
|
BIND_CONSTANT(BG_MAX);
|
||||||
BIND_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
|
BIND_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
|
||||||
|
@ -933,11 +933,11 @@ void Environment::_bind_methods() {
|
||||||
Environment::Environment() {
|
Environment::Environment() {
|
||||||
|
|
||||||
bg_mode = BG_CLEAR_COLOR;
|
bg_mode = BG_CLEAR_COLOR;
|
||||||
bg_skybox_scale = 1.0;
|
bg_sky_scale = 1.0;
|
||||||
bg_energy = 1.0;
|
bg_energy = 1.0;
|
||||||
bg_canvas_max_layer = 0;
|
bg_canvas_max_layer = 0;
|
||||||
ambient_energy = 1.0;
|
ambient_energy = 1.0;
|
||||||
ambient_skybox_contribution = 0;
|
ambient_sky_contribution = 0;
|
||||||
|
|
||||||
tone_mapper = TONE_MAPPER_LINEAR;
|
tone_mapper = TONE_MAPPER_LINEAR;
|
||||||
tonemap_exposure = 1.0;
|
tonemap_exposure = 1.0;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
|
|
||||||
BG_CLEAR_COLOR,
|
BG_CLEAR_COLOR,
|
||||||
BG_COLOR,
|
BG_COLOR,
|
||||||
BG_SKYBOX,
|
BG_SKY,
|
||||||
BG_CANVAS,
|
BG_CANVAS,
|
||||||
BG_KEEP,
|
BG_KEEP,
|
||||||
BG_MAX
|
BG_MAX
|
||||||
|
@ -74,14 +74,14 @@ private:
|
||||||
RID environment;
|
RID environment;
|
||||||
|
|
||||||
BGMode bg_mode;
|
BGMode bg_mode;
|
||||||
Ref<SkyBox> bg_skybox;
|
Ref<Sky> bg_sky;
|
||||||
float bg_skybox_scale;
|
float bg_sky_scale;
|
||||||
Color bg_color;
|
Color bg_color;
|
||||||
float bg_energy;
|
float bg_energy;
|
||||||
int bg_canvas_max_layer;
|
int bg_canvas_max_layer;
|
||||||
Color ambient_color;
|
Color ambient_color;
|
||||||
float ambient_energy;
|
float ambient_energy;
|
||||||
float ambient_skybox_contribution;
|
float ambient_sky_contribution;
|
||||||
|
|
||||||
ToneMapper tone_mapper;
|
ToneMapper tone_mapper;
|
||||||
float tonemap_exposure;
|
float tonemap_exposure;
|
||||||
|
@ -144,24 +144,24 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_background(BGMode p_bg);
|
void set_background(BGMode p_bg);
|
||||||
void set_skybox(const Ref<SkyBox> &p_skybox);
|
void set_sky(const Ref<Sky> &p_sky);
|
||||||
void set_skybox_scale(float p_scale);
|
void set_sky_scale(float p_scale);
|
||||||
void set_bg_color(const Color &p_color);
|
void set_bg_color(const Color &p_color);
|
||||||
void set_bg_energy(float p_energy);
|
void set_bg_energy(float p_energy);
|
||||||
void set_canvas_max_layer(int p_max_layer);
|
void set_canvas_max_layer(int p_max_layer);
|
||||||
void set_ambient_light_color(const Color &p_color);
|
void set_ambient_light_color(const Color &p_color);
|
||||||
void set_ambient_light_energy(float p_energy);
|
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;
|
BGMode get_background() const;
|
||||||
Ref<SkyBox> get_skybox() const;
|
Ref<Sky> get_sky() const;
|
||||||
float get_skybox_scale() const;
|
float get_sky_scale() const;
|
||||||
Color get_bg_color() const;
|
Color get_bg_color() const;
|
||||||
float get_bg_energy() const;
|
float get_bg_energy() const;
|
||||||
int get_canvas_max_layer() const;
|
int get_canvas_max_layer() const;
|
||||||
Color get_ambient_light_color() const;
|
Color get_ambient_light_color() const;
|
||||||
float get_ambient_light_energy() 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);
|
void set_tonemapper(ToneMapper p_tone_mapper);
|
||||||
ToneMapper get_tonemapper() const;
|
ToneMapper get_tonemapper() const;
|
||||||
|
|
|
@ -30,22 +30,22 @@
|
||||||
#include "sky_box.h"
|
#include "sky_box.h"
|
||||||
#include "io/image_loader.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);
|
ERR_FAIL_INDEX(p_size, RADIANCE_SIZE_MAX);
|
||||||
|
|
||||||
radiance_size = p_size;
|
radiance_size = p_size;
|
||||||
_radiance_changed();
|
_radiance_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyBox::RadianceSize SkyBox::get_radiance_size() const {
|
Sky::RadianceSize Sky::get_radiance_size() const {
|
||||||
|
|
||||||
return radiance_size;
|
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("set_radiance_size", "size"), &Sky::set_radiance_size);
|
||||||
ClassDB::bind_method(D_METHOD("get_radiance_size"), &SkyBox::get_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, "256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
|
||||||
|
|
||||||
|
@ -56,124 +56,59 @@ void SkyBox::_bind_methods() {
|
||||||
BIND_CONSTANT(RADIANCE_SIZE_MAX);
|
BIND_CONSTANT(RADIANCE_SIZE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyBox::SkyBox() {
|
Sky::Sky() {
|
||||||
radiance_size = RADIANCE_SIZE_512;
|
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] = {
|
static const int size[RADIANCE_SIZE_MAX] = {
|
||||||
256, 512, 1024, 2048
|
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<Texture> &p_panorama) {
|
||||||
|
|
||||||
ERR_FAIL_INDEX(p_image, IMAGE_PATH_MAX);
|
panorama = p_panorama;
|
||||||
image_path[p_image] = p_path;
|
|
||||||
|
|
||||||
bool all_ok = true;
|
if (panorama.is_valid()) {
|
||||||
for (int i = 0; i < IMAGE_PATH_MAX; i++) {
|
|
||||||
if (image_path[i] == String()) {
|
|
||||||
all_ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cube_map_valid = false;
|
|
||||||
|
|
||||||
if (all_ok) {
|
|
||||||
|
|
||||||
Ref<Image> 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();
|
_radiance_changed();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
VS::get_singleton()->sky_set_texture(sky, RID(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String ImageSkyBox::get_image_path(ImagePath p_image) const {
|
Ref<Texture> PanoramaSky::get_panorama() const {
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_image, IMAGE_PATH_MAX, String());
|
return panorama;
|
||||||
return image_path[p_image];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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("set_panorama", "texture:Texture"), &PanoramaSky::set_panorama);
|
||||||
ClassDB::bind_method(D_METHOD("get_image_path", "image"), &ImageSkyBox::get_image_path);
|
ClassDB::bind_method(D_METHOD("get_panorama:Texture"), &PanoramaSky::get_panorama);
|
||||||
|
|
||||||
List<String> extensions;
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_panorama", "get_panorama");
|
||||||
ImageLoader::get_recognized_extensions(&extensions);
|
|
||||||
String hints;
|
|
||||||
for (List<String>::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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSkyBox::ImageSkyBox() {
|
PanoramaSky::PanoramaSky() {
|
||||||
|
|
||||||
cube_map = VS::get_singleton()->texture_create();
|
sky = VS::get_singleton()->sky_create();
|
||||||
sky_box = VS::get_singleton()->skybox_create();
|
|
||||||
cube_map_valid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSkyBox::~ImageSkyBox() {
|
PanoramaSky::~PanoramaSky() {
|
||||||
|
|
||||||
VS::get_singleton()->free(cube_map);
|
VS::get_singleton()->free(sky);
|
||||||
VS::get_singleton()->free(sky_box);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
#ifndef SKYBOX_H
|
#ifndef Sky_H
|
||||||
#define SKYBOX_H
|
#define Sky_H
|
||||||
|
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
class SkyBox : public Resource {
|
class Sky : public Resource {
|
||||||
GDCLASS(SkyBox, Resource);
|
GDCLASS(Sky, Resource);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum RadianceSize {
|
enum RadianceSize {
|
||||||
|
@ -54,13 +54,13 @@ protected:
|
||||||
public:
|
public:
|
||||||
void set_radiance_size(RadianceSize p_size);
|
void set_radiance_size(RadianceSize p_size);
|
||||||
RadianceSize get_radiance_size() const;
|
RadianceSize get_radiance_size() const;
|
||||||
SkyBox();
|
Sky();
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(SkyBox::RadianceSize)
|
VARIANT_ENUM_CAST(Sky::RadianceSize)
|
||||||
|
|
||||||
class ImageSkyBox : public SkyBox {
|
class PanoramaSky : public Sky {
|
||||||
GDCLASS(ImageSkyBox, SkyBox);
|
GDCLASS(PanoramaSky, Sky);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ImagePath {
|
enum ImagePath {
|
||||||
|
@ -74,26 +74,23 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RID cube_map;
|
RID sky;
|
||||||
RID sky_box;
|
Ref<Texture> panorama;
|
||||||
bool cube_map_valid;
|
|
||||||
|
|
||||||
String image_path[IMAGE_PATH_MAX];
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
virtual void _radiance_changed();
|
virtual void _radiance_changed();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_image_path(ImagePath p_image, const String &p_path);
|
void set_panorama(const Ref<Texture> &p_panorama);
|
||||||
String get_image_path(ImagePath p_image) const;
|
Ref<Texture> get_panorama() const;
|
||||||
|
|
||||||
virtual RID get_rid() const;
|
virtual RID get_rid() const;
|
||||||
|
|
||||||
ImageSkyBox();
|
PanoramaSky();
|
||||||
~ImageSkyBox();
|
~PanoramaSky();
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(ImageSkyBox::ImagePath)
|
VARIANT_ENUM_CAST(PanoramaSky::ImagePath)
|
||||||
|
|
||||||
#endif // SKYBOX_H
|
#endif // Sky_H
|
||||||
|
|
|
@ -52,12 +52,12 @@ public:
|
||||||
virtual RID environment_create() = 0;
|
virtual RID environment_create() = 0;
|
||||||
|
|
||||||
virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 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_sky(RID p_env, RID p_sky) = 0;
|
||||||
virtual void environment_set_skybox_scale(RID p_env, float p_scale) = 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_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_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_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_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;
|
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;
|
virtual void textures_keep_original(bool p_enable) = 0;
|
||||||
|
|
||||||
/* SKYBOX API */
|
/* SKY API */
|
||||||
|
|
||||||
virtual RID skybox_create() = 0;
|
virtual RID sky_create() = 0;
|
||||||
virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) = 0;
|
virtual void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) = 0;
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
||||||
|
|
|
@ -644,10 +644,10 @@ public:
|
||||||
|
|
||||||
BIND1(textures_keep_original, bool)
|
BIND1(textures_keep_original, bool)
|
||||||
|
|
||||||
/* SKYBOX API */
|
/* SKY API */
|
||||||
|
|
||||||
BIND0R(RID, skybox_create)
|
BIND0R(RID, sky_create)
|
||||||
BIND3(skybox_set_texture, RID, RID, int)
|
BIND3(sky_set_texture, RID, RID, int)
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
||||||
|
@ -932,8 +932,8 @@ public:
|
||||||
BIND0R(RID, environment_create)
|
BIND0R(RID, environment_create)
|
||||||
|
|
||||||
BIND2(environment_set_background, RID, EnvironmentBG)
|
BIND2(environment_set_background, RID, EnvironmentBG)
|
||||||
BIND2(environment_set_skybox, RID, RID)
|
BIND2(environment_set_sky, RID, RID)
|
||||||
BIND2(environment_set_skybox_scale, RID, float)
|
BIND2(environment_set_sky_scale, RID, float)
|
||||||
BIND2(environment_set_bg_color, RID, const Color &)
|
BIND2(environment_set_bg_color, RID, const Color &)
|
||||||
BIND2(environment_set_bg_energy, RID, float)
|
BIND2(environment_set_bg_energy, RID, float)
|
||||||
BIND2(environment_set_canvas_max_layer, RID, int)
|
BIND2(environment_set_canvas_max_layer, RID, int)
|
||||||
|
|
|
@ -141,10 +141,10 @@ public:
|
||||||
|
|
||||||
virtual void textures_keep_original(bool p_enable) = 0;
|
virtual void textures_keep_original(bool p_enable) = 0;
|
||||||
|
|
||||||
/* SKYBOX API */
|
/* SKY API */
|
||||||
|
|
||||||
virtual RID skybox_create() = 0;
|
virtual RID sky_create() = 0;
|
||||||
virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) = 0;
|
virtual void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) = 0;
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
||||||
|
@ -589,19 +589,19 @@ public:
|
||||||
|
|
||||||
ENV_BG_CLEAR_COLOR,
|
ENV_BG_CLEAR_COLOR,
|
||||||
ENV_BG_COLOR,
|
ENV_BG_COLOR,
|
||||||
ENV_BG_SKYBOX,
|
ENV_BG_SKY,
|
||||||
ENV_BG_CANVAS,
|
ENV_BG_CANVAS,
|
||||||
ENV_BG_KEEP,
|
ENV_BG_KEEP,
|
||||||
ENV_BG_MAX
|
ENV_BG_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void environment_set_background(RID p_env, EnvironmentBG p_bg) = 0;
|
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_sky(RID p_env, RID p_sky) = 0;
|
||||||
virtual void environment_set_skybox_scale(RID p_env, float p_scale) = 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_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_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_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 SSAO options
|
||||||
//set default SSR options
|
//set default SSR options
|
||||||
|
|
Loading…
Reference in a new issue