actorid
scrawl 13 years ago
parent cd6e9986b6
commit b8384162b6

@ -105,6 +105,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
Settings::Manager::setBool("enabled", "Shadows", false); Settings::Manager::setBool("enabled", "Shadows", false);
sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false");
sh::Factory::getInstance ().setGlobalSetting ("fog", "true");
sh::Factory::getInstance ().setGlobalSetting ("lighting", "true");
applyCompositors(); applyCompositors();

@ -28,15 +28,16 @@ namespace MWRender
mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend) mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend)
{ {
mTerrainGlobals = OGRE_NEW TerrainGlobalOptions(); mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
TerrainMaterialGeneratorPtr matGen; TerrainMaterialGeneratorPtr matGen;
TerrainMaterialGeneratorB* matGenP = new TerrainMaterialGeneratorB(); TerrainMaterial* matGenP = new TerrainMaterial();
matGen.bind(matGenP); matGen.bind(matGenP);
mTerrainGlobals->setDefaultMaterialGenerator(matGen); mTerrainGlobals->setDefaultMaterialGenerator(matGen);
TerrainMaterialGenerator::Profile* const activeProfile = TerrainMaterialGenerator::Profile* const activeProfile =
mTerrainGlobals->getDefaultMaterialGenerator() mTerrainGlobals->getDefaultMaterialGenerator()
->getActiveProfile(); ->getActiveProfile();
mActiveProfile = static_cast<TerrainMaterialGeneratorB::SM2Profile*>(activeProfile); mActiveProfile = static_cast<TerrainMaterial::Profile*>(activeProfile);
//The pixel error should be as high as possible without it being noticed //The pixel error should be as high as possible without it being noticed
//as it governs how fast mesh quality decreases. //as it governs how fast mesh quality decreases.
@ -52,6 +53,7 @@ namespace MWRender
//this seemed the distance where it wasn't too noticeable //this seemed the distance where it wasn't too noticeable
mTerrainGlobals->setCompositeMapDistance(mWorldSize*2); mTerrainGlobals->setCompositeMapDistance(mWorldSize*2);
/*
mActiveProfile->setLightmapEnabled(false); mActiveProfile->setLightmapEnabled(false);
mActiveProfile->setLayerSpecularMappingEnabled(false); mActiveProfile->setLayerSpecularMappingEnabled(false);
mActiveProfile->setLayerNormalMappingEnabled(false); mActiveProfile->setLayerNormalMappingEnabled(false);
@ -71,6 +73,7 @@ namespace MWRender
//composite maps lead to a drastic increase in loading time so are //composite maps lead to a drastic increase in loading time so are
//disabled //disabled
mActiveProfile->setCompositeMapEnabled(false); mActiveProfile->setCompositeMapEnabled(false);
*/
mTerrainGroup.setOrigin(Vector3(mWorldSize/2, mTerrainGroup.setOrigin(Vector3(mWorldSize/2,
0, 0,
@ -181,7 +184,7 @@ namespace MWRender
if ( land->landData->usingColours ) if ( land->landData->usingColours )
{ {
// disable or enable global colour map (depends on available vertex colours) // disable or enable global colour map (depends on available vertex colours)
mActiveProfile->setGlobalColourMapEnabled(true); //mActiveProfile->setGlobalColourMapEnabled(true);
TexturePtr vertex = getVertexColours(land, TexturePtr vertex = getVertexColours(land,
cellX, cellY, cellX, cellY,
x*(mLandSize-1), x*(mLandSize-1),
@ -191,7 +194,10 @@ namespace MWRender
//this is a hack to get around the fact that Ogre seems to //this is a hack to get around the fact that Ogre seems to
//corrupt the global colour map leading to rendering errors //corrupt the global colour map leading to rendering errors
MaterialPtr mat = terrain->getMaterial(); MaterialPtr mat = terrain->getMaterial();
mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); /// \todo
//mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() );
//mat = terrain->_getCompositeMapMaterial(); //mat = terrain->_getCompositeMapMaterial();
//mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); //mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() );
} }

@ -46,7 +46,7 @@ namespace MWRender{
RenderingManager* mRendering; RenderingManager* mRendering;
Ogre::TerrainMaterialGeneratorB::SM2Profile* mActiveProfile; TerrainMaterial::Profile* mActiveProfile;
/** /**
* The length in verticies of a single terrain block. * The length in verticies of a single terrain block.

File diff suppressed because it is too large Load Diff

@ -26,246 +26,50 @@ THE SOFTWARE.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
*/ */
#ifndef __Ogre_TerrainMaterialGeneratorB_H__ #ifndef MWRENDER_TERRAINMATERIAL_H
#define __Ogre_TerrainMaterialGeneratorB_H__ #define MWRENDER_TERRAINMATERIAL_H
#include "OgreTerrainPrerequisites.h" #include "OgreTerrainPrerequisites.h"
#include "OgreTerrainMaterialGenerator.h" #include "OgreTerrainMaterialGenerator.h"
#include "OgreGpuProgramParams.h" #include "OgreGpuProgramParams.h"
namespace Ogre namespace MWRender
{ {
class PSSMShadowCameraSetup;
/** \addtogroup Optional Components class TerrainMaterial : public Ogre::TerrainMaterialGenerator
* @{
*/
/** \addtogroup Terrain
* Some details on the terrain component
* @{
*/
/** A TerrainMaterialGenerator which can cope with normal mapped, specular mapped
terrain.
@note Requires the Cg plugin to render correctly
*/
class TerrainMaterialGeneratorB : public TerrainMaterialGenerator
{ {
public: public:
TerrainMaterialGeneratorB();
~TerrainMaterialGeneratorB();
/** Shader model 2 profile target. class Profile : public Ogre::TerrainMaterialGenerator::Profile
*/
class SM2Profile : public TerrainMaterialGenerator::Profile
{ {
public:
SM2Profile(TerrainMaterialGenerator* parent, const String& name, const String& desc);
~SM2Profile();
bool isVertexCompressionSupported() const {return false;}
MaterialPtr generate(const Terrain* terrain);
MaterialPtr generateForCompositeMap(const Terrain* terrain);
uint8 getMaxLayers(const Terrain* terrain) const;
void updateParams(const MaterialPtr& mat, const Terrain* terrain);
void updateParamsForCompositeMap(const MaterialPtr& mat, const Terrain* terrain);
void requestOptions(Terrain* terrain);
void setShadowFar(float far);
void setShadowFadeStart(float fadestart);
/** Whether to support normal mapping per layer in the shader (default true).
*/
bool isLayerNormalMappingEnabled() const { return mLayerNormalMappingEnabled; }
/** Whether to support normal mapping per layer in the shader (default true).
*/
void setLayerNormalMappingEnabled(bool enabled);
/** Whether to support parallax mapping per layer in the shader (default true).
*/
bool isLayerParallaxMappingEnabled() const { return mLayerParallaxMappingEnabled; }
/** Whether to support parallax mapping per layer in the shader (default true).
*/
void setLayerParallaxMappingEnabled(bool enabled);
/** Whether to support specular mapping per layer in the shader (default true).
*/
bool isLayerSpecularMappingEnabled() const { return mLayerSpecularMappingEnabled; }
/** Whether to support specular mapping per layer in the shader (default true).
*/
void setLayerSpecularMappingEnabled(bool enabled);
/** Whether to support a global colour map over the terrain in the shader,
if it's present (default true).
*/
bool isGlobalColourMapEnabled() const { return mGlobalColourMapEnabled; }
/** Whether to support a global colour map over the terrain in the shader,
if it's present (default true).
*/
void setGlobalColourMapEnabled(bool enabled);
/** Whether to support a light map over the terrain in the shader,
if it's present (default true).
*/
bool isLightmapEnabled() const { return mLightmapEnabled; }
/** Whether to support a light map over the terrain in the shader,
if it's present (default true).
*/
void setLightmapEnabled(bool enabled);
/** Whether to use the composite map to provide a lower LOD technique
in the distance (default true).
*/
bool isCompositeMapEnabled() const { return mCompositeMapEnabled; }
/** Whether to use the composite map to provide a lower LOD technique
in the distance (default true).
*/
void setCompositeMapEnabled(bool enabled);
/** Whether to support dynamic texture shadows received from other
objects, on the terrain (default true).
*/
bool getReceiveDynamicShadowsEnabled() const { return mReceiveDynamicShadows; }
/** Whether to support dynamic texture shadows received from other
objects, on the terrain (default true).
*/
void setReceiveDynamicShadowsEnabled(bool enabled);
/** Whether to use PSSM support dynamic texture shadows, and if so the
settings to use (default 0).
*/
void setReceiveDynamicShadowsPSSM(PSSMShadowCameraSetup* pssmSettings);
/** Whether to use PSSM support dynamic texture shadows, and if so the
settings to use (default 0).
*/
PSSMShadowCameraSetup* getReceiveDynamicShadowsPSSM() const { return mPSSM; }
/** Whether to use depth shadows (default false).
*/
void setReceiveDynamicShadowsDepth(bool enabled);
/** Whether to use depth shadows (default false).
*/
bool getReceiveDynamicShadowsDepth() const { return mDepthShadows; }
/** Whether to use shadows on low LOD material rendering (when using composite map) (default false).
*/
void setReceiveDynamicShadowsLowLod(bool enabled);
/** Whether to use shadows on low LOD material rendering (when using composite map) (default false).
*/
bool getReceiveDynamicShadowsLowLod() const { return mLowLodShadows; }
int getNumberOfLightsSupported() const;
/// Internal
bool _isSM3Available() const { return mSM3Available; }
protected: protected:
Ogre::TerrainMaterialGenerator* mParent;
enum TechniqueType Ogre::String mName;
{ Ogre::String mDesc;
HIGH_LOD,
LOW_LOD,
RENDER_COMPOSITE_MAP
};
void addTechnique(const MaterialPtr& mat, const Terrain* terrain, TechniqueType tt);
/// Interface definition for helper class to generate shaders
class ShaderHelper : public TerrainAlloc
{
public: public:
ShaderHelper() : mShadowSamplerStartHi(0), mShadowSamplerStartLo(0) {} Profile(Ogre::TerrainMaterialGenerator* parent, const Ogre::String& name, const Ogre::String& desc);
virtual ~ShaderHelper() {} virtual ~Profile();
virtual HighLevelGpuProgramPtr generateVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
virtual HighLevelGpuProgramPtr generateFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
virtual void updateParams(const SM2Profile* prof, const MaterialPtr& mat, const Terrain* terrain, bool compositeMap);
protected:
virtual String getVertexProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
virtual String getFragmentProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
virtual HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
virtual HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
virtual void generateVertexProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
virtual void generateFragmentProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
virtual void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
virtual void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
virtual void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
virtual void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
virtual void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
virtual void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
virtual void defaultVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
virtual void defaultFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
virtual void updateVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
virtual void updateFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
static String getChannel(uint idx);
size_t mShadowSamplerStartHi; virtual bool isVertexCompressionSupported() const { return false; }
size_t mShadowSamplerStartLo;
}; virtual Ogre::MaterialPtr generate(const Ogre::Terrain* terrain);
/// Utility class to help with generating shaders for Cg / HLSL. virtual Ogre::MaterialPtr generateForCompositeMap(const Ogre::Terrain* terrain);
class ShaderHelperCg : public ShaderHelper
{
protected:
HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
uint generateVpDynamicShadowsParams(uint texCoordStart, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateVpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateFpDynamicShadowsHelpers(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateFpDynamicShadowsParams(uint* texCoord, uint* sampler, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
void generateFpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
};
class ShaderHelperHLSL : public ShaderHelperCg virtual Ogre::uint8 getMaxLayers(const Ogre::Terrain* terrain) const;
{
protected:
HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
};
/// Utility class to help with generating shaders for GLSL. virtual void updateParams(const Ogre::MaterialPtr& mat, const Ogre::Terrain* terrain);
class ShaderHelperGLSL : public ShaderHelper
{
protected:
HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
};
ShaderHelper* mShaderGen; virtual void updateParamsForCompositeMap(const Ogre::MaterialPtr& mat, const Ogre::Terrain* terrain);
bool mLayerNormalMappingEnabled;
bool mLayerParallaxMappingEnabled;
bool mLayerSpecularMappingEnabled;
bool mGlobalColourMapEnabled;
bool mLightmapEnabled;
bool mCompositeMapEnabled;
bool mReceiveDynamicShadows;
PSSMShadowCameraSetup* mPSSM;
bool mDepthShadows;
bool mLowLodShadows;
bool mSM3Available;
float mShadowFar;
float mShadowFadeStart;
bool isShadowingEnabled(TechniqueType tt, const Terrain* terrain) const; virtual void requestOptions(Ogre::Terrain* terrain);
}; };
TerrainMaterial();
}; };
/** @} */
/** @} */
} }
#endif #endif

2
extern/shiny vendored

@ -1 +1 @@
Subproject commit 7485a15c26f129084a1c264fa1a98dc2de86f298 Subproject commit ca0549ae6db7aa9efb125335942c61fb3f583a8d

@ -6,9 +6,6 @@ material openmw_objects_base
emissive 0.0 0.0 0.0 emissive 0.0 0.0 0.0
has_vertex_colour false has_vertex_colour false
diffuseMap black.png diffuseMap black.png
fog true
mrt_output true
lighting true
is_transparent false // real transparency, alpha rejection doesn't count here is_transparent false // real transparency, alpha rejection doesn't count here
scene_blend default scene_blend default
@ -25,9 +22,6 @@ material openmw_objects_base
shader_properties shader_properties
{ {
fog $fog
mrt_output $mrt_output
lighting $lighting
has_vertex_colour $has_vertex_colour has_vertex_colour $has_vertex_colour
is_transparent $is_transparent is_transparent $is_transparent
} }

@ -3,9 +3,9 @@
#include "shadows.h" #include "shadows.h"
#define FOG @shPropertyBool(fog) #define FOG @shGlobalSettingBool(fog)
#define MRT @shPropertyNotBool(is_transparent) && @shPropertyBool(mrt_output) && @shGlobalSettingBool(mrt_output) #define MRT @shPropertyNotBool(is_transparent) && @shGlobalSettingBool(mrt_output)
#define LIGHTING @shPropertyBool(lighting) #define LIGHTING @shGlobalSettingBool(lighting)
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm) #define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows) #define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)

@ -1,15 +1,16 @@
configuration water_reflection configuration water_reflection
{ {
fog false fog false
receives_shadows false shadows false
shadows_pssm false
mrt_output false mrt_output false
} }
configuration local_map configuration local_map
{ {
fog false fog false
receives_shadows false
simple_water true
mrt_output false mrt_output false
lighting false lighting false
shadows false
shadows_pssm false
} }

@ -0,0 +1,57 @@
#include "core.h"
#define FOG @shPropertyBool(fog)
#define MRT @shGlobalSettingBool(mrt_output)
@shAllocatePassthrough(1, depth)
#ifdef SH_VERTEX_SHADER
SH_BEGIN_PROGRAM
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
shUniform(float4x4, viewProjMatrix) @shAutoConstant(viewProjMatrix, viewproj_matrix)
shInput(float2, uv0)
@shPassthroughVertexOutputs
SH_START_PROGRAM
{
float4 worldPos = shMatrixMult(worldMatrix, shInputPosition);
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
@shPassthroughAssign(depth, shOutputPosition.z);
}
#else
SH_BEGIN_PROGRAM
@shPassthroughFragmentInputs
#if MRT
shDeclareMrtOutput(1)
#endif
SH_START_PROGRAM
{
float depth = @shPassthroughReceive(depth);
#if MRT
//shOutputColour(1) = float4(1,1,1,1);
#endif
}
#endif

@ -0,0 +1,15 @@
shader_set terrain_vertex
{
source terrain.shader
type vertex
profiles_cg vs_2_0 arbvp1
profiles_hlsl vs_2_0
}
shader_set terrain_fragment
{
source terrain.shader
type fragment
profiles_cg ps_2_x ps_2_0 ps arbfp1
profiles_hlsl ps_2_0
}
Loading…
Cancel
Save