mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-14 16:36:44 +00:00
much better looking moons
This commit is contained in:
parent
e354203c21
commit
877cb2aca7
2 changed files with 21 additions and 8 deletions
|
@ -162,14 +162,20 @@ Moon::Moon( const String& textureName,
|
||||||
" in float2 uv : TEXCOORD0, \n"
|
" in float2 uv : TEXCOORD0, \n"
|
||||||
" out float4 oColor : COLOR, \n"
|
" out float4 oColor : COLOR, \n"
|
||||||
" uniform sampler2D texture : TEXUNIT0, \n"
|
" uniform sampler2D texture : TEXUNIT0, \n"
|
||||||
|
" uniform float4 skyColour, \n"
|
||||||
" uniform float4 diffuse, \n"
|
" uniform float4 diffuse, \n"
|
||||||
" uniform float4 emissive \n"
|
" uniform float4 emissive \n"
|
||||||
") \n"
|
") \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" float4 tex = tex2D(texture, uv); \n"
|
" float4 tex = tex2D(texture, uv); \n"
|
||||||
" oColor = float4(emissive.xyz,1) * tex2D(texture, uv) * float4(1,1,1,diffuse.a); \n"
|
" oColor = float4(emissive.xyz,1) * tex; \n"
|
||||||
" float bump = pow((1-diffuse.a),4); \n"
|
// use a circle for the alpha (compute UV distance to center)
|
||||||
" oColor.rgb += float3(bump, bump, bump)*0.5; \n"
|
// looks a bit bad because its not filtered on the edges,
|
||||||
|
// but it's cheaper than a seperate alpha texture.
|
||||||
|
" float sqrUVdist = pow(uv.x-0.5,2) + pow(uv.y-0.5, 2); \n"
|
||||||
|
" oColor.a = diffuse.a * (sqrUVdist >= 0.24 ? 0 : 1); \n"
|
||||||
|
" oColor.rgb += (1-tex.a) * oColor.a * skyColour.rgb; \n"//fill dark side of moon with skycolour
|
||||||
|
" oColor.rgb += (1-diffuse.a) * skyColour.rgb; \n"//fade bump
|
||||||
"}";
|
"}";
|
||||||
fshader->setSource(outStream2.str());
|
fshader->setSource(outStream2.str());
|
||||||
fshader->load();
|
fshader->load();
|
||||||
|
@ -187,15 +193,19 @@ void Moon::setType(const Moon::Type& type)
|
||||||
mType = type;
|
mType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Moon::setSkyColour(const Ogre::ColourValue& colour)
|
||||||
|
{
|
||||||
|
mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("skyColour", colour);
|
||||||
|
}
|
||||||
|
|
||||||
/// \todo the moon phase rendering is not correct - the dark part of the moon does not occlude the stars
|
|
||||||
void Moon::setPhase(const Moon::Phase& phase)
|
void Moon::setPhase(const Moon::Phase& phase)
|
||||||
{
|
{
|
||||||
|
// Colour texture
|
||||||
Ogre::String textureName = "textures\\tx_";
|
Ogre::String textureName = "textures\\tx_";
|
||||||
|
|
||||||
if (mType == Moon::Type_Secunda) textureName += "secunda_";
|
if (mType == Moon::Type_Secunda) textureName += "secunda_";
|
||||||
else textureName += "masser_";
|
else textureName += "masser_";
|
||||||
|
|
||||||
if (phase == Moon::Phase_New) textureName += "new";
|
if (phase == Moon::Phase_New) textureName += "new";
|
||||||
else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax";
|
else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax";
|
||||||
else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax";
|
else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax";
|
||||||
|
@ -204,9 +214,9 @@ void Moon::setPhase(const Moon::Phase& phase)
|
||||||
else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan";
|
else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan";
|
||||||
else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan";
|
else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan";
|
||||||
else if (phase == Moon::Phase_Full) textureName += "full";
|
else if (phase == Moon::Phase_Full) textureName += "full";
|
||||||
|
|
||||||
textureName += ".dds";
|
textureName += ".dds";
|
||||||
|
|
||||||
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
|
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
|
||||||
|
|
||||||
mPhase = phase;
|
mPhase = phase;
|
||||||
|
@ -650,6 +660,8 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
||||||
if (mSkyColour != weather.mSkyColor)
|
if (mSkyColour != weather.mSkyColor)
|
||||||
{
|
{
|
||||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
|
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
|
||||||
|
mMasser->setSkyColour(weather.mSkyColor);
|
||||||
|
mSecunda->setSkyColour(weather.mSkyColor);
|
||||||
mSkyColour = weather.mSkyColor;
|
mSkyColour = weather.mSkyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ namespace MWRender
|
||||||
|
|
||||||
void setPhase(const Phase& phase);
|
void setPhase(const Phase& phase);
|
||||||
void setType(const Type& type);
|
void setType(const Type& type);
|
||||||
|
void setSkyColour(const Ogre::ColourValue& colour);
|
||||||
|
|
||||||
Phase getPhase() const;
|
Phase getPhase() const;
|
||||||
unsigned int getPhaseInt() const;
|
unsigned int getPhaseInt() const;
|
||||||
|
|
Loading…
Reference in a new issue