diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index dd0351721..4fa125c9b 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -229,7 +229,7 @@ void LocalMap::render(const float x, const float y, vp->setVisibilityMask(RV_Map); // use fallback techniques without shadows and without mrt - vp->setMaterialScheme("Fallback"); + vp->setMaterialScheme("simple"); rtt->update(); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 94fb3d6d9..666161052 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -336,7 +336,7 @@ void Water::applyRTT() vp->setBackgroundColour(ColourValue(0.8f, 0.9f, 1.0f)); vp->setShadowsEnabled(false); // use fallback techniques without shadows and without mrt (currently not implemented for sky and terrain) - //vp->setMaterialScheme("Fallback"); + vp->setMaterialScheme("simple"); rtt->addListener(this); rtt->setActive(true); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index eb1714b61..164b51daf 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -260,8 +262,8 @@ void NIFLoader::createMaterial(const String &name, NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName); if (result.first) { - instance->setProperty("alpha_rejection_func", sh::makeProperty(new sh::StringValue("greater_equal"))); - instance->setProperty("alpha_rejection_value", sh::makeProperty(new sh::IntValue(result.second))); + instance->setProperty("alpha_rejection", + sh::makeProperty(new sh::StringValue("greater_equal " + boost::lexical_cast(result.second)))); } else { @@ -272,81 +274,34 @@ void NIFLoader::createMaterial(const String &name, } else warn("Unhandled alpha setting for texture " + texName); - } -/* - if (!texName.empty()) - { - Pass *pass = material->getTechnique(0)->getPass(0); - /*TextureUnitState *txt =*/ - /* - pass->createTextureUnitState(texName); - - pass->setVertexColourTracking(TVC_DIFFUSE); -*/ - // As of yet UNTESTED code from Chris: - /*pass->setTextureFiltering(Ogre::TFO_ANISOTROPIC); - pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL); - pass->setDepthCheckEnabled(true); + // As of yet UNTESTED code from Chris: + /*pass->setTextureFiltering(Ogre::TFO_ANISOTROPIC); + pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL); + pass->setDepthCheckEnabled(true); - // Add transparency if NiAlphaProperty was present - if (alphaFlags != -1) + // Add transparency if NiAlphaProperty was present + if (alphaFlags != -1) + { + std::cout << "Alpha flags set!" << endl; + if ((alphaFlags&1)) { - std::cout << "Alpha flags set!" << endl; - if ((alphaFlags&1)) - { - pass->setDepthWriteEnabled(false); - pass->setSceneBlending(getBlendFactor((alphaFlags>>1)&0xf), - getBlendFactor((alphaFlags>>5)&0xf)); - } - else - pass->setDepthWriteEnabled(true); - - if ((alphaFlags>>9)&1) - pass->setAlphaRejectSettings(getTestMode((alphaFlags>>10)&0x7), - alphaTest); - - pass->setTransparentSortingEnabled(!((alphaFlags>>13)&1)); + pass->setDepthWriteEnabled(false); + pass->setSceneBlending(getBlendFactor((alphaFlags>>1)&0xf), + getBlendFactor((alphaFlags>>5)&0xf)); } else - pass->setDepthWriteEnabled(true); */ + pass->setDepthWriteEnabled(true); -/* - // Add transparency if NiAlphaProperty was present - if (alphaFlags != -1) - { - // The 237 alpha flags are by far the most common. Check - // NiAlphaProperty in nif/property.h if you need to decode - // other values. 237 basically means normal transparencly. - if (alphaFlags == 237) - { - NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName); - if (result.first) - { - pass->setAlphaRejectFunction(CMPF_GREATER_EQUAL); - pass->setAlphaRejectValue(result.second); - } - else - { - // Enable transparency - pass->setSceneBlending(SBT_TRANSPARENT_ALPHA); + if ((alphaFlags>>9)&1) + pass->setAlphaRejectSettings(getTestMode((alphaFlags>>10)&0x7), + alphaTest); - //pass->setDepthCheckEnabled(false); - pass->setDepthWriteEnabled(false); - //std::cout << "alpha 237; material: " << name << " texName: " << texName << std::endl; - } - } - else - warn("Unhandled alpha setting for texture " + texName); - } - else - { - material->getTechnique(0)->setShadowCasterMaterial("depth_shadow_caster_noalpha"); - } + pass->setTransparentSortingEnabled(!((alphaFlags>>13)&1)); } - */ - + else + pass->setDepthWriteEnabled(true); */ } // Takes a name and adds a unique part to it. This is just used to diff --git a/extern/shiny b/extern/shiny index 3a1b8e2ae..8af2cce2d 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit 3a1b8e2aefa746ef0922e78f4be3ff736ce92fc3 +Subproject commit 8af2cce2db40aa67edcba78c534a268e595696c8 diff --git a/files/materials/core.h b/files/materials/core.h index fe0172cd9..0ee95057f 100644 --- a/files/materials/core.h +++ b/files/materials/core.h @@ -52,7 +52,7 @@ #endif #if SH_GLSL == 1 - @shGlslVersion(130) + @version 130 #define float2 vec2 #define float3 vec3 diff --git a/files/materials/objects.mat b/files/materials/objects.mat index 3fcc12d62..fc23b947a 100644 --- a/files/materials/objects.mat +++ b/files/materials/objects.mat @@ -7,30 +7,35 @@ material openmw_objects_base has_vertex_colour false diffuseMap black.png fog true + mrt_output true + lighting true is_transparent false // real transparency, alpha rejection doesn't count here scene_blend default - alpha_rejection_value default - alpha_rejection_func default + alpha_rejection default pass { vertex_program openmw_objects_vertex fragment_program openmw_objects_fragment + shader_properties + { + fog $fog + mrt_output $mrt_output + lighting $lighting + has_vertex_colour $has_vertex_colour + is_transparent $is_transparent + } + diffuse $diffuse specular $specular ambient $ambient emissive $emissive - fog $fog + scene_blend $scene_blend + alpha_rejection $alpha_rejection ffp_vertex_colour_ambient $has_vertex_colour - has_vertex_colour $has_vertex_colour - - is_transparent $is_transparent - scene_blend $scene_blend - alpha_rejection_value $alpha_rejection_value - alpha_rejection_func $alpha_rejection_func texture_unit diffuseMap { diff --git a/files/materials/objects.shader b/files/materials/objects.shader index 9a78bb455..3697e33e5 100644 --- a/files/materials/objects.shader +++ b/files/materials/objects.shader @@ -2,13 +2,10 @@ #define FOG @shPropertyBool(fog) -#define MRT @shPropertyNotBool(is_transparent) +#define MRT @shPropertyNotBool(is_transparent) && @shPropertyBool(mrt_output) +#define LIGHTING @shPropertyBool(lighting) -#if MRT -#define NEED_DEPTH -#endif - -#if FOG +#if FOG || MRT #define NEED_DEPTH #endif @@ -48,7 +45,9 @@ SH_BEGIN_PROGRAM shSampler2D(diffuseMap) shInput(float2, UV) +#if MRT shDeclareMrtOutput(1) +#endif shInput(float4, normalPassthrough) #ifdef NEED_DEPTH @@ -79,7 +78,9 @@ shOutputColor(0).xyz = shLerp (shOutputColor(0).xyz, fogColor, fogValue); #endif +#if MRT shOutputColor(1) = float4(depthPassthrough / far,1,1,1); +#endif } #endif