diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 0b9dc091e..454ed8820 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -187,6 +187,8 @@ Moon::Moon( const String& textureName, { setVisibility(1.0); + mMaterial->setProperty("alphatexture", sh::makeProperty(new sh::StringValue(textureName + "_alpha"))); + mPhase = Moon::Phase_Full; } @@ -215,9 +217,15 @@ void Moon::setPhase(const Moon::Phase& phase) textureName += ".dds"; if (mType == Moon::Type_Secunda) + { sh::Factory::getInstance ().setTextureAlias ("secunda_texture", textureName); + sh::Factory::getInstance ().setTextureAlias ("secunda_texture_alpha", "textures\\tx_mooncircle_full_s.dds"); + } else + { sh::Factory::getInstance ().setTextureAlias ("masser_texture", textureName); + sh::Factory::getInstance ().setTextureAlias ("masser_texture_alpha", "textures\\tx_mooncircle_full_m.dds"); + } mPhase = phase; } diff --git a/files/materials/moon.shader b/files/materials/moon.shader index eb7243d3f..0e1a4ffc8 100644 --- a/files/materials/moon.shader +++ b/files/materials/moon.shader @@ -38,16 +38,14 @@ shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix) SH_START_PROGRAM { - - float4 tex = shSample(diffuseMap, UV); - - shOutputColour(0) = float4(materialEmissive.xyz, 1) * tex; - - shOutputColour(0).a = shSample(alphaMap, UV).a * materialDiffuse.a; - - shOutputColour(0).rgb += (1.0-tex.a) * shOutputColour(0).a * atmosphereColour.rgb; //fill dark side of moon with atmosphereColour - shOutputColour(0).rgb += (1.0-materialDiffuse.a) * atmosphereColour.rgb; //fade bump + float4 phaseTex = shSample(diffuseMap, UV); + float4 fullCircleTex = shSample(alphaMap, UV); + + shOutputColour(0).a = max(phaseTex.a, fullCircleTex.a) * materialDiffuse.a; + shOutputColour(0).xyz = fullCircleTex.xyz * atmosphereColour.xyz; + shOutputColour(0).xyz = shLerp(shOutputColour(0).xyz, phaseTex.xyz, phaseTex.a); + shOutputColour(0).xyz *= materialEmissive.xyz; } #endif diff --git a/files/materials/sky.mat b/files/materials/sky.mat index ccf2a8053..c2e8ddeb0 100644 --- a/files/materials/sky.mat +++ b/files/materials/sky.mat @@ -50,7 +50,7 @@ material openmw_moon texture_unit alphaMap { - direct_texture textures\tx_secunda_full.dds + texture_alias $alphatexture } } }