From c3fee7ba6cdefd285255b9e1198bc1fdf585b1ac Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Sun, 15 Sep 2019 19:58:38 +1000 Subject: Add shader based background mode --- drivers/dummy/rasterizer_dummy.h | 1 + drivers/gles2/rasterizer_scene_gles2.cpp | 7 +++++++ drivers/gles2/rasterizer_scene_gles2.h | 3 +++ drivers/gles2/rasterizer_storage_gles2.cpp | 2 ++ 4 files changed, 13 insertions(+) (limited to 'drivers') diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 4dc634aefa..c78b82792b 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -67,6 +67,7 @@ public: void environment_set_sky(RID p_env, RID p_sky) {} void environment_set_sky_custom_fov(RID p_env, float p_scale) {} void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {} + void environment_set_bg_material(RID p_env, RID p_material) {} void environment_set_bg_color(RID p_env, const Color &p_color) {} void environment_set_bg_energy(RID p_env, float p_energy) {} void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {} diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index c433886545..068b9f5538 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -718,6 +718,13 @@ void RasterizerSceneGLES2::environment_set_sky_orientation(RID p_env, const Basi env->sky_orientation = p_orientation; } +void RasterizerSceneGLES2::environment_set_bg_material(RID p_env, RID p_material) { + Environment *env = environment_owner.getornull(p_env); + ERR_FAIL_COND(!env); + + env->bg_material = p_material; +} + void RasterizerSceneGLES2::environment_set_bg_color(RID p_env, const Color &p_color) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 174cdd8e2e..fda46072a5 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -242,6 +242,8 @@ public: float sky_custom_fov; Basis sky_orientation; + RID bg_material; + Color bg_color; float bg_energy; float sky_ambient; @@ -357,6 +359,7 @@ public: virtual void environment_set_sky(RID p_env, RID p_sky); virtual void environment_set_sky_custom_fov(RID p_env, float p_scale); virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation); + virtual void environment_set_bg_material(RID p_env, RID p_material); 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); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 0f5452effc..f76c7da8e1 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -1427,6 +1427,8 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) mode = VS::SHADER_CANVAS_ITEM; else if (mode_string == "particles") mode = VS::SHADER_PARTICLES; + else if (mode_string == "sky") + mode = VS::SHADER_SKY; else mode = VS::SHADER_SPATIAL; -- cgit v1.2.3 From 61a74739ca2d201e7e057d85aa99ae68f0500c33 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Thu, 19 Mar 2020 17:32:19 -0700 Subject: Working sky shader implementation --- drivers/dummy/rasterizer_dummy.h | 7 ++++++- drivers/gles2/rasterizer_scene_gles2.cpp | 7 ------- drivers/gles2/rasterizer_scene_gles2.h | 3 --- 3 files changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index c78b82792b..b446828128 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -58,6 +58,7 @@ public: void sky_set_mode(RID p_sky, VS::SkyMode p_samples) {} void sky_set_texture(RID p_sky, RID p_panorama) {} void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {} + void sky_set_material(RID p_sky, RID p_material) {} /* ENVIRONMENT API */ @@ -67,7 +68,6 @@ public: void environment_set_sky(RID p_env, RID p_sky) {} void environment_set_sky_custom_fov(RID p_env, float p_scale) {} void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {} - void environment_set_bg_material(RID p_env, RID p_material) {} void environment_set_bg_color(RID p_env, const Color &p_color) {} void environment_set_bg_energy(RID p_env, float p_energy) {} void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {} @@ -314,6 +314,11 @@ public: void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {} #endif + /* SKY API */ + + RID sky_create() { return RID(); } + void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {} + /* SHADER API */ RID shader_create() { return RID(); } diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 068b9f5538..c433886545 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -718,13 +718,6 @@ void RasterizerSceneGLES2::environment_set_sky_orientation(RID p_env, const Basi env->sky_orientation = p_orientation; } -void RasterizerSceneGLES2::environment_set_bg_material(RID p_env, RID p_material) { - Environment *env = environment_owner.getornull(p_env); - ERR_FAIL_COND(!env); - - env->bg_material = p_material; -} - void RasterizerSceneGLES2::environment_set_bg_color(RID p_env, const Color &p_color) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index fda46072a5..174cdd8e2e 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -242,8 +242,6 @@ public: float sky_custom_fov; Basis sky_orientation; - RID bg_material; - Color bg_color; float bg_energy; float sky_ambient; @@ -359,7 +357,6 @@ public: virtual void environment_set_sky(RID p_env, RID p_sky); virtual void environment_set_sky_custom_fov(RID p_env, float p_scale); virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation); - virtual void environment_set_bg_material(RID p_env, RID p_material); 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); -- cgit v1.2.3