aboutsummaryrefslogtreecommitdiff
path: root/src/client/sky.cpp
diff options
context:
space:
mode:
authornumzero <numzer0@yandex.ru>2020-11-22 18:25:41 +0300
committerlhofhansl <larsh@apache.org>2020-11-26 12:49:10 -0800
commitcdcf7dca7c9afb329d49f2016964f77ac379ed67 (patch)
treee4ca73d6130a55ce1445ef7da373fb7e830b1e98 /src/client/sky.cpp
parentbe59668f4743bb3bf85b37a188ffc1759601c152 (diff)
downloadminetest-cdcf7dca7c9afb329d49f2016964f77ac379ed67.tar.gz
minetest-cdcf7dca7c9afb329d49f2016964f77ac379ed67.tar.bz2
minetest-cdcf7dca7c9afb329d49f2016964f77ac379ed67.zip
Sky: support GLES2
IrrLicht built-in shader is broken, have to write my own
Diffstat (limited to 'src/client/sky.cpp')
-rw-r--r--src/client/sky.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/client/sky.cpp b/src/client/sky.cpp
index dda59dd11..3fc5a95b4 100644
--- a/src/client/sky.cpp
+++ b/src/client/sky.cpp
@@ -51,7 +51,7 @@ static video::SMaterial baseMaterial() {
return mat;
};
-Sky::Sky(s32 id, ITextureSource *tsrc) :
+Sky::Sky(s32 id, ITextureSource *tsrc, IShaderSource *ssrc) :
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
RenderingEngine::get_scene_manager(), id)
{
@@ -59,10 +59,12 @@ Sky::Sky(s32 id, ITextureSource *tsrc) :
m_box.MaxEdge.set(0, 0, 0);
m_box.MinEdge.set(0, 0, 0);
+ m_enable_shaders = g_settings->getBool("enable_shaders");
+
// Create materials
m_materials[0] = baseMaterial();
- m_materials[0].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+ m_materials[0].MaterialType = ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA, 0)).material;
m_materials[0].Lighting = true;
m_materials[0].ColorMaterial = video::ECM_NONE;
@@ -694,12 +696,11 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day)
float tod = wicked_time_of_day < 0.5f ? wicked_time_of_day : (1.0f - wicked_time_of_day);
float starbrightness = (0.25f - fabsf(tod)) * 20.0f;
- int alpha = clamp<int>(starbrightness * m_star_params.starcolor.getAlpha(), 0, 255);
- if (!alpha) // Stars are only drawn when not fully transparent
+ m_star_color = m_star_params.starcolor;
+ m_star_color.a = clamp(starbrightness * m_star_color.a, 0.0f, 1.0f);
+ if (m_star_color.a <= 0.0f) // Stars are only drawn when not fully transparent
return;
-
- m_materials[0].DiffuseColor = video::SColor(alpha, 0, 0, 0);
- m_materials[0].EmissiveColor = m_star_params.starcolor;
+ m_materials[0].DiffuseColor = m_materials[0].EmissiveColor = m_star_color.toSColor();
auto sky_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f));
auto world_matrix = driver->getTransform(video::ETS_WORLD);
driver->setTransform(video::ETS_WORLD, world_matrix * sky_rotation);