mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 13:09:40 +00:00
Merge remote-tracking branch 'scrawl/graphics'
This commit is contained in:
commit
d839a4c6c2
14 changed files with 88 additions and 138 deletions
|
@ -62,6 +62,13 @@ void OMW::Engine::setAnimationVerbose(bool animverbose)
|
|||
{
|
||||
}
|
||||
|
||||
bool OMW::Engine::frameStarted (const Ogre::FrameEvent& evt)
|
||||
{
|
||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
MWBase::Environment::get().getWorld()->frameStarted(evt.timeSinceLastFrame);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace OMW
|
|||
void executeLocalScripts();
|
||||
|
||||
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);
|
||||
virtual bool frameStarted (const Ogre::FrameEvent& evt);
|
||||
|
||||
/// Load settings from various files, returns the path to the user settings file
|
||||
std::string loadSettings (Settings::Manager & settings);
|
||||
|
|
|
@ -314,6 +314,7 @@ namespace MWBase
|
|||
/// \todo this does not belong here
|
||||
virtual void playVideo(const std::string& name, bool allowSkipping) = 0;
|
||||
virtual void stopVideo() = 0;
|
||||
virtual void frameStarted (float dt) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
// Set default mipmap level (NB some APIs ignore this)
|
||||
// Mipmap generation is currently disabled because it causes issues on Intel/AMD
|
||||
//TextureManager::getSingleton().setDefaultNumMipmaps(Settings::Manager::getInt("num mipmaps", "General"));
|
||||
TextureManager::getSingleton().setDefaultNumMipmaps(0);
|
||||
|
||||
// Set default texture filtering options
|
||||
TextureFilterOptions tfo;
|
||||
|
@ -128,7 +129,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
sh::Factory::getInstance ().setShadersEnabled (Settings::Manager::getBool("shaders", "Objects"));
|
||||
|
||||
sh::Factory::getInstance ().setGlobalSetting ("fog", "true");
|
||||
sh::Factory::getInstance ().setGlobalSetting ("lighting", "true");
|
||||
sh::Factory::getInstance ().setGlobalSetting ("num_lights", Settings::Manager::getString ("num lights", "Objects"));
|
||||
sh::Factory::getInstance ().setGlobalSetting ("terrain_num_lights", Settings::Manager::getString ("num lights", "Terrain"));
|
||||
sh::Factory::getInstance ().setGlobalSetting ("simple_water", Settings::Manager::getBool("shader", "Water") ? "false" : "true");
|
||||
|
@ -329,8 +329,6 @@ void RenderingManager::update (float duration, bool paused)
|
|||
float *_playerPos = data.getPosition().pos;
|
||||
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
|
||||
|
||||
Ogre::Vector3 cam = mRendering.getCamera()->getRealPosition();
|
||||
|
||||
Ogre::Vector3 orig, dest;
|
||||
mPlayer->setCameraDistance();
|
||||
if (!mPlayer->getPosition(orig, dest)) {
|
||||
|
@ -353,6 +351,8 @@ void RenderingManager::update (float duration, bool paused)
|
|||
|
||||
Ogre::ControllerManager::getSingleton().setTimeFactor(paused ? 0.f : 1.f);
|
||||
|
||||
Ogre::Vector3 cam = mRendering.getCamera()->getRealPosition();
|
||||
|
||||
applyFog(world->isUnderwater (world->getPlayer().getPlayer().getCell(), cam));
|
||||
|
||||
if(paused)
|
||||
|
@ -939,4 +939,9 @@ void RenderingManager::updateWaterRippleEmitterPtr (const MWWorld::Ptr& old, con
|
|||
mWater->updateEmitterPtr(old, ptr);
|
||||
}
|
||||
|
||||
void RenderingManager::frameStarted(float dt)
|
||||
{
|
||||
mWater->frameStarted(dt);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -196,6 +196,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
|
||||
void playVideo(const std::string& name, bool allowSkipping);
|
||||
void stopVideo();
|
||||
void frameStarted(float dt);
|
||||
|
||||
protected:
|
||||
virtual void windowResized(Ogre::RenderWindow* rw);
|
||||
|
|
|
@ -191,7 +191,8 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend) :
|
|||
mWaterTimer(0.f),
|
||||
mReflection(NULL),
|
||||
mRefraction(NULL),
|
||||
mSimulation(NULL)
|
||||
mSimulation(NULL),
|
||||
mPlayer(0,0)
|
||||
{
|
||||
mSimulation = new RippleSimulation(mSceneMgr);
|
||||
|
||||
|
@ -371,7 +372,12 @@ void Water::update(float dt, Ogre::Vector3 player)
|
|||
|
||||
mRendering->getSkyManager ()->setGlareEnabled (!mIsUnderwater);
|
||||
|
||||
mSimulation->update(dt, Ogre::Vector2(player.x, player.y));
|
||||
mPlayer = Ogre::Vector2(player.x, player.y);
|
||||
}
|
||||
|
||||
void Water::frameStarted(float dt)
|
||||
{
|
||||
mSimulation->update(dt, mPlayer);
|
||||
|
||||
if (mReflection)
|
||||
mReflection->update();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <OgreRenderTargetListener.h>
|
||||
#include <OgreMaterial.h>
|
||||
#include <OgreTexture.h>
|
||||
#include <OgreVector2.h>
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
@ -98,7 +99,7 @@ namespace MWRender {
|
|||
};
|
||||
|
||||
/// Water rendering
|
||||
class Water : public Ogre::RenderTargetListener, public Ogre::RenderQueueListener, public sh::MaterialInstanceListener
|
||||
class Water : public sh::MaterialInstanceListener
|
||||
{
|
||||
static const int CELL_SIZE = 8192;
|
||||
Ogre::Camera *mCamera;
|
||||
|
@ -139,6 +140,8 @@ namespace MWRender {
|
|||
Refraction* mRefraction;
|
||||
RippleSimulation* mSimulation;
|
||||
|
||||
Ogre::Vector2 mPlayer;
|
||||
|
||||
public:
|
||||
Water (Ogre::Camera *camera, RenderingManager* rend);
|
||||
~Water();
|
||||
|
@ -147,6 +150,7 @@ namespace MWRender {
|
|||
|
||||
void toggle();
|
||||
void update(float dt, Ogre::Vector3 player);
|
||||
void frameStarted(float dt);
|
||||
|
||||
/// adds an emitter, position will be tracked automatically using its scene node
|
||||
void addEmitter (const MWWorld::Ptr& ptr, float scale = 1.f, float force = 1.f);
|
||||
|
|
|
@ -1467,4 +1467,9 @@ namespace MWWorld
|
|||
{
|
||||
mRendering->stopVideo();
|
||||
}
|
||||
|
||||
void World::frameStarted (float dt)
|
||||
{
|
||||
mRendering->frameStarted(dt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,6 +356,7 @@ namespace MWWorld
|
|||
/// \todo this does not belong here
|
||||
virtual void playVideo(const std::string& name, bool allowSkipping);
|
||||
virtual void stopVideo();
|
||||
virtual void frameStarted (float dt);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -694,21 +694,24 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
|
|||
sh::MaterialInstance* instance = sh::Factory::getInstance ().createMaterialInstance (matname, "openmw_objects_base");
|
||||
if(vertMode == 0 || !vertexColour)
|
||||
{
|
||||
instance->setProperty("ambient", sh::makeProperty(new sh::Vector4(ambient.x, ambient.y, ambient.z, alpha)));
|
||||
instance->setProperty("ambient", sh::makeProperty(new sh::Vector4(ambient.x, ambient.y, ambient.z, 1)));
|
||||
instance->setProperty("diffuse", sh::makeProperty(new sh::Vector4(diffuse.x, diffuse.y, diffuse.z, alpha)));
|
||||
instance->setProperty("emissive", sh::makeProperty(new sh::Vector4(emissive.x, emissive.y, emissive.z, alpha)));
|
||||
instance->setProperty("emissive", sh::makeProperty(new sh::Vector4(emissive.x, emissive.y, emissive.z, 1)));
|
||||
instance->setProperty("vertmode", sh::makeProperty(new sh::StringValue("0")));
|
||||
}
|
||||
else if(vertMode == 1)
|
||||
{
|
||||
instance->setProperty("ambient", sh::makeProperty(new sh::Vector4(ambient.x, ambient.y, ambient.z, alpha)));
|
||||
instance->setProperty("ambient", sh::makeProperty(new sh::Vector4(ambient.x, ambient.y, ambient.z, 1)));
|
||||
instance->setProperty("diffuse", sh::makeProperty(new sh::Vector4(diffuse.x, diffuse.y, diffuse.z, alpha)));
|
||||
instance->setProperty("emissive", sh::makeProperty(new sh::StringValue("vertexcolour")));
|
||||
instance->setProperty("vertmode", sh::makeProperty(new sh::StringValue("1")));
|
||||
}
|
||||
else if(vertMode == 2)
|
||||
{
|
||||
instance->setProperty("ambient", sh::makeProperty(new sh::StringValue("vertexcolour")));
|
||||
instance->setProperty("diffuse", sh::makeProperty(new sh::StringValue("vertexcolour")));
|
||||
instance->setProperty("emissive", sh::makeProperty(new sh::Vector4(emissive.x, emissive.y, emissive.z, alpha)));
|
||||
instance->setProperty("emissive", sh::makeProperty(new sh::Vector4(emissive.x, emissive.y, emissive.z, 1)));
|
||||
instance->setProperty("vertmode", sh::makeProperty(new sh::StringValue("2")));
|
||||
}
|
||||
else
|
||||
std::cerr<< "Unhandled vertex mode: "<<vertMode <<std::endl;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
material openmw_objects_base
|
||||
{
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.4 0.4 0.4 32
|
||||
specular 0 0 0 0
|
||||
ambient 1.0 1.0 1.0
|
||||
emissive 0.0 0.0 0.0
|
||||
has_vertex_colour false
|
||||
vertmode 0
|
||||
diffuseMap black.png
|
||||
|
||||
is_transparent false // real transparency, alpha rejection doesn't count here
|
||||
|
@ -19,7 +19,7 @@ material openmw_objects_base
|
|||
|
||||
shader_properties
|
||||
{
|
||||
has_vertex_colour $has_vertex_colour
|
||||
vertexcolor_mode $vertmode
|
||||
is_transparent $is_transparent
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,6 @@ material openmw_objects_base
|
|||
alpha_rejection $alpha_rejection
|
||||
depth_write $depth_write
|
||||
|
||||
ffp_vertex_colour_ambient $has_vertex_colour
|
||||
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $diffuseMap
|
||||
|
@ -58,10 +55,5 @@ material openmw_objects_base
|
|||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
|
||||
texture_unit causticMap
|
||||
{
|
||||
direct_texture water_nm.png
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
#define LIGHTING @shGlobalSettingBool(lighting)
|
||||
|
||||
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)
|
||||
#define SHADOWS_PSSM @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
|
@ -18,8 +17,7 @@
|
|||
|
||||
#define UNDERWATER @shGlobalSettingBool(render_refraction)
|
||||
|
||||
|
||||
#define HAS_VERTEXCOLOR @shPropertyBool(has_vertex_colour)
|
||||
#define VERTEXCOLOR_MODE @shPropertyString(vertexcolor_mode)
|
||||
|
||||
#define VERTEX_LIGHTING 1
|
||||
|
||||
|
@ -48,16 +46,10 @@
|
|||
shOutput(float, depthPassthrough)
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
shOutput(float3, normalPassthrough)
|
||||
shOutput(float3, objSpacePositionPassthrough)
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
#if VERTEXCOLOR_MODE != 0
|
||||
shColourInput(float4)
|
||||
#if !VERTEX_LIGHTING
|
||||
shOutput(float4, colourPassthrough)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
|
@ -66,11 +58,15 @@
|
|||
shUniform(float4, lightDiffuse[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightDiffuse, light_diffuse_colour_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAttenuation[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightAttenuation, light_attenuation_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
#if !HAS_VERTEXCOLOUR
|
||||
#if VERTEXCOLOR_MODE != 2
|
||||
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE != 2
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE != 1
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -90,16 +86,13 @@
|
|||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shOutput(float3, lightResult)
|
||||
shOutput(float4, lightResult)
|
||||
shOutput(float3, directionalResult)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
#if LIGHTING
|
||||
normalPassthrough = normal.xyz;
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEPTH
|
||||
|
||||
|
@ -124,13 +117,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
objSpacePositionPassthrough = shInputPosition.xyz;
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR && !VERTEX_LIGHTING
|
||||
colourPassthrough = colour;
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
lightSpacePos0 = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
|
@ -146,28 +133,43 @@
|
|||
#if VERTEX_LIGHTING
|
||||
float3 lightDir;
|
||||
float d;
|
||||
lightResult = float3(0,0,0);
|
||||
lightResult = float4(0,0,0,1);
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
lightDir = lightPosition[@shIterator].xyz - (shInputPosition.xyz * lightPosition[@shIterator].w);
|
||||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
lightResult += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
|
||||
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += colour.xyz * lightDiffuse[@shIterator].xyz
|
||||
* (1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(normalize(normal.xyz), normalize(lightDir)), 0);
|
||||
#else
|
||||
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
|
||||
* (1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(normalize(normal.xyz), normalize(lightDir)), 0);
|
||||
#endif
|
||||
|
||||
#if @shIterator == 0
|
||||
directionalResult = lightResult;
|
||||
directionalResult = lightResult.xyz;
|
||||
#endif
|
||||
|
||||
@shEndForeach
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
// ambient vertex colour tracking, FFP behaviour
|
||||
lightResult += lightAmbient.xyz * colour.xyz + materialEmissive.xyz;
|
||||
|
||||
#else
|
||||
lightResult += lightAmbient.xyz * materialAmbient.xyz + materialEmissive.xyz;
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += lightAmbient.xyz * colour.xyz + materialEmissive.xyz;
|
||||
lightResult.a *= colour.a;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 1
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + colour.xyz;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 0
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + materialEmissive.xyz;
|
||||
#endif
|
||||
|
||||
#if VERTEXCOLOR_MODE != 2
|
||||
lightResult.a *= materialDiffuse.a;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -189,35 +191,13 @@
|
|||
shInput(float, depthPassthrough)
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
shInput(float3, normalPassthrough)
|
||||
shInput(float3, objSpacePositionPassthrough)
|
||||
#if !HAS_VERTEXCOLOR
|
||||
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||
#endif
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
#if !VERTEX_LIGHTING
|
||||
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightPosObjSpace@shIterator) @shAutoConstant(lightPosObjSpace@shIterator, light_position_object_space, @shIterator)
|
||||
shUniform(float4, lightAttenuation@shIterator) @shAutoConstant(lightAttenuation@shIterator, light_attenuation, @shIterator)
|
||||
shUniform(float4, lightDiffuse@shIterator) @shAutoConstant(lightDiffuse@shIterator, light_diffuse_colour, @shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
shUniform(float3, fogColour) @shAutoConstant(fogColour, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR && !VERTEX_LIGHTING
|
||||
shInput(float4, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shInput(float4, lightSpacePos0)
|
||||
shSampler2D(shadowMap0)
|
||||
|
@ -247,20 +227,14 @@
|
|||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shInput(float3, lightResult)
|
||||
shInput(float4, lightResult)
|
||||
shInput(float3, directionalResult)
|
||||
#endif
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = shSample(diffuseMap, UV);
|
||||
|
||||
#if LIGHTING
|
||||
float3 normal = normalize(normalPassthrough);
|
||||
float3 lightDir;
|
||||
float3 diffuse = float3(0,0,0);
|
||||
float d;
|
||||
|
||||
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
|
@ -289,45 +263,10 @@
|
|||
float3 waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,0,1), waterLevel);
|
||||
#endif
|
||||
|
||||
#if !VERTEX_LIGHTING
|
||||
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
|
||||
/// \todo use the array auto params for lights, and use a real for-loop with auto param "light_count" iterations
|
||||
lightDir = lightPosObjSpace@shIterator.xyz - (objSpacePositionPassthrough.xyz * lightPosObjSpace@shIterator.w);
|
||||
d = length(lightDir);
|
||||
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
#if @shIterator == 0
|
||||
|
||||
#if (SHADOWS || SHADOWS_PSSM)
|
||||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0) * shadow;
|
||||
|
||||
#else
|
||||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
||||
#endif
|
||||
|
||||
@shEndForeach
|
||||
|
||||
lightResult = (ambient + diffuse + materialEmissive.xyz);
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shOutputColour(0).xyz *= (lightResult - directionalResult * (1.0-shadow));
|
||||
shOutputColour(0) *= (lightResult - float4(directionalResult * (1.0-shadow),0));
|
||||
#else
|
||||
shOutputColour(0).xyz *= (lightResult);
|
||||
#endif
|
||||
|
||||
#endif // IF LIGHTING
|
||||
|
||||
#if HAS_VERTEXCOLOR && !LIGHTING
|
||||
shOutputColour(0).xyz *= colourPassthrough.xyz;
|
||||
shOutputColour(0) *= lightResult;
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
|
||||
#define LIGHTING @shGlobalSettingBool(lighting)
|
||||
|
||||
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)
|
||||
#define SHADOWS_PSSM @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
|
@ -32,9 +30,7 @@
|
|||
|
||||
@shAllocatePassthrough(2, UV)
|
||||
|
||||
#if LIGHTING
|
||||
@shAllocatePassthrough(3, worldPos)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
@shAllocatePassthrough(4, lightSpacePos0)
|
||||
|
@ -123,9 +119,7 @@
|
|||
|
||||
@shPassthroughAssign(UV, uv0);
|
||||
|
||||
#if LIGHTING
|
||||
@shPassthroughAssign(worldPos, worldPos.xyz);
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
|
@ -176,16 +170,12 @@
|
|||
|
||||
@shPassthroughFragmentInputs
|
||||
|
||||
|
||||
#if LIGHTING
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
@shForeach(@shGlobalSettingString(terrain_num_lights))
|
||||
shUniform(float4, lightPosObjSpace@shIterator) @shAutoConstant(lightPosObjSpace@shIterator, light_position, @shIterator)
|
||||
shUniform(float4, lightAttenuation@shIterator) @shAutoConstant(lightAttenuation@shIterator, light_attenuation, @shIterator)
|
||||
shUniform(float4, lightDiffuse@shIterator) @shAutoConstant(lightDiffuse@shIterator, light_diffuse_colour, @shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
|
||||
#if SHADOWS
|
||||
shSampler2D(shadowMap0)
|
||||
|
@ -222,12 +212,10 @@
|
|||
|
||||
float2 UV = @shPassthroughReceive(UV);
|
||||
|
||||
#if LIGHTING
|
||||
float3 worldPos = @shPassthroughReceive(worldPos);
|
||||
|
||||
float3 normal = shSample(normalMap, UV).rgb * 2 - 1;
|
||||
normal = normalize(normal);
|
||||
#endif
|
||||
|
||||
|
||||
#if UNDERWATER
|
||||
|
@ -268,7 +256,6 @@
|
|||
|
||||
// Lighting
|
||||
|
||||
#if LIGHTING
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos0 = @shPassthroughReceive(lightSpacePos0);
|
||||
|
@ -322,9 +309,7 @@
|
|||
|
||||
@shEndForeach
|
||||
|
||||
shOutputColour(0).xyz *= (lightAmbient.xyz + diffuse);
|
||||
#endif
|
||||
|
||||
shOutputColour(0).xyz *= (lightAmbient.xyz + diffuse);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ material Water
|
|||
|
||||
texture_unit normalMap
|
||||
{
|
||||
direct_texture water_nm.png
|
||||
texture water_nm.png 5
|
||||
}
|
||||
|
||||
texture_unit rippleNormalMap
|
||||
|
|
Loading…
Reference in a new issue