forked from teamnwah/openmw-tes3coop
Merge remote branch 'scrawl/shadersystem' into shadersystem
Attention: We have submodules again. Don't forget to update! Conflicts: components/files/configurationmanager.cppactorid
commit
2c5d3d8df9
@ -0,0 +1,3 @@
|
||||
[submodule "extern/shiny"]
|
||||
path = extern/shiny
|
||||
url = git@github.com:scrawl/shiny.git
|
@ -1,309 +0,0 @@
|
||||
#include "shaderhelper.hpp"
|
||||
#include "renderingmanager.hpp"
|
||||
#include "shadows.hpp"
|
||||
|
||||
#include <OgreHighLevelGpuProgramManager.h>
|
||||
#include <OgreHighLevelGpuProgram.h>
|
||||
#include <OgreGpuProgramParams.h>
|
||||
#include <OgreShadowCameraSetupPSSM.h>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace MWRender;
|
||||
|
||||
ShaderHelper::ShaderHelper(RenderingManager* rend)
|
||||
{
|
||||
mRendering = rend;
|
||||
applyShaders();
|
||||
}
|
||||
|
||||
void ShaderHelper::applyShaders()
|
||||
{
|
||||
if (!Settings::Manager::getBool("shaders", "Objects")) return;
|
||||
|
||||
bool mrt = RenderingManager::useMRT();
|
||||
bool shadows = Settings::Manager::getBool("enabled", "Shadows");
|
||||
bool split = Settings::Manager::getBool("split", "Shadows");
|
||||
|
||||
// shader for normal rendering
|
||||
createShader(mrt, shadows, split, "main");
|
||||
|
||||
// fallback shader without mrt and without shadows
|
||||
// (useful for reflection and for minimap)
|
||||
createShader(false, false, false, "main_fallback");
|
||||
}
|
||||
|
||||
void ShaderHelper::createShader(const bool mrt, const bool shadows, const bool split, const std::string& name)
|
||||
{
|
||||
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
||||
|
||||
const int numsplits = 3;
|
||||
|
||||
// the number of lights to support.
|
||||
// when rendering an object, OGRE automatically picks the lights that are
|
||||
// closest to the object being rendered. unfortunately this mechanism does
|
||||
// not work perfectly for objects batched together (they will all use the same
|
||||
// lights). to work around this, we are simply pushing the maximum number
|
||||
// of lights here in order to minimize disappearing lights.
|
||||
int num_lights = Settings::Manager::getInt("num lights", "Objects");
|
||||
|
||||
{
|
||||
// vertex
|
||||
HighLevelGpuProgramPtr vertex;
|
||||
if (!mgr.getByName(name+"_vp").isNull())
|
||||
mgr.remove(name+"_vp");
|
||||
|
||||
vertex = mgr.createProgram(name+"_vp", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
"cg", GPT_VERTEX_PROGRAM);
|
||||
vertex->setParameter("profiles", "vs_4_0 vs_2_x vp40 arbvp1");
|
||||
vertex->setParameter("entry_point", "main_vp");
|
||||
StringUtil::StrStreamType outStream;
|
||||
outStream <<
|
||||
"void main_vp( \n"
|
||||
" float4 position : POSITION, \n"
|
||||
" float4 normal : NORMAL, \n"
|
||||
" float4 colour : COLOR, \n"
|
||||
" in float2 uv : TEXCOORD0, \n"
|
||||
" out float2 oUV : TEXCOORD0, \n"
|
||||
" out float4 oPosition : POSITION, \n"
|
||||
" out float4 oPositionObjSpace : TEXCOORD1, \n"
|
||||
" out float4 oNormal : TEXCOORD2, \n"
|
||||
" out float oDepth : TEXCOORD3, \n"
|
||||
" out float4 oVertexColour : TEXCOORD4, \n";
|
||||
if (shadows && !split) outStream <<
|
||||
" out float4 oLightSpacePos0 : TEXCOORD5, \n"
|
||||
" uniform float4x4 worldMatrix, \n"
|
||||
" uniform float4x4 texViewProjMatrix0, \n";
|
||||
else
|
||||
{
|
||||
for (int i=0; i<numsplits; ++i)
|
||||
{
|
||||
outStream <<
|
||||
" out float4 oLightSpacePos"<<i<<" : TEXCOORD"<<i+5<<", \n"
|
||||
" uniform float4x4 texViewProjMatrix"<<i<<", \n";
|
||||
}
|
||||
outStream <<
|
||||
" uniform float4x4 worldMatrix, \n";
|
||||
}
|
||||
outStream <<
|
||||
" uniform float4x4 worldViewProj \n"
|
||||
") \n"
|
||||
"{ \n"
|
||||
" oVertexColour = colour; \n"
|
||||
" oUV = uv; \n"
|
||||
" oNormal = normal; \n"
|
||||
" oPosition = mul( worldViewProj, position ); \n"
|
||||
" oDepth = oPosition.z; \n"
|
||||
" oPositionObjSpace = position; \n";
|
||||
if (shadows && !split) outStream <<
|
||||
" oLightSpacePos0 = mul(texViewProjMatrix0, mul(worldMatrix, position)); \n";
|
||||
else
|
||||
{
|
||||
outStream <<
|
||||
" float4 wPos = mul(worldMatrix, position); \n";
|
||||
for (int i=0; i<numsplits; ++i)
|
||||
{
|
||||
outStream <<
|
||||
" oLightSpacePos"<<i<<" = mul(texViewProjMatrix"<<i<<", wPos); \n";
|
||||
}
|
||||
}
|
||||
outStream <<
|
||||
"}";
|
||||
vertex->setSource(outStream.str());
|
||||
vertex->load();
|
||||
vertex->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
||||
if (shadows)
|
||||
{
|
||||
vertex->getDefaultParameters()->setNamedAutoConstant("worldMatrix", GpuProgramParameters::ACT_WORLD_MATRIX);
|
||||
if (!split)
|
||||
vertex->getDefaultParameters()->setNamedAutoConstant("texViewProjMatrix0", GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX, 0);
|
||||
else
|
||||
{
|
||||
for (int i=0; i<numsplits; ++i)
|
||||
{
|
||||
vertex->getDefaultParameters()->setNamedAutoConstant("texViewProjMatrix"+StringConverter::toString(i), GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// fragment
|
||||
HighLevelGpuProgramPtr fragment;
|
||||
if (!mgr.getByName(name+"_fp").isNull())
|
||||
mgr.remove(name+"_fp");
|
||||
|
||||
fragment = mgr.createProgram(name+"_fp", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
"cg", GPT_FRAGMENT_PROGRAM);
|
||||
fragment->setParameter("profiles", "ps_4_0 ps_2_x fp40 arbfp1");
|
||||
fragment->setParameter("entry_point", "main_fp");
|
||||
StringUtil::StrStreamType outStream;
|
||||
|
||||
if (shadows) outStream <<
|
||||
"float depthShadow(sampler2D shadowMap, float4 shadowMapPos, float2 offset) \n"
|
||||
"{ \n"
|
||||
" shadowMapPos /= shadowMapPos.w; \n"
|
||||
" float3 o = float3(offset.xy, -offset.x) * 0.3f; \n"
|
||||
" float c = (shadowMapPos.z <= tex2D(shadowMap, shadowMapPos.xy - o.xy).r) ? 1 : 0; // top left \n"
|
||||
" c += (shadowMapPos.z <= tex2D(shadowMap, shadowMapPos.xy + o.xy).r) ? 1 : 0; // bottom right \n"
|
||||
" c += (shadowMapPos.z <= tex2D(shadowMap, shadowMapPos.xy + o.zy).r) ? 1 : 0; // bottom left \n"
|
||||
" c += (shadowMapPos.z <= tex2D(shadowMap, shadowMapPos.xy - o.zy).r) ? 1 : 0; // top right \n"
|
||||
" return c / 4; \n"
|
||||
"} \n";
|
||||
|
||||
outStream <<
|
||||
"void main_fp( \n"
|
||||
" in float2 uv : TEXCOORD0, \n"
|
||||
" out float4 oColor : COLOR, \n"
|
||||
" uniform sampler2D texture : register(s0), \n"
|
||||
" float4 positionObjSpace : TEXCOORD1, \n"
|
||||
" float4 normal : TEXCOORD2, \n"
|
||||
" float iDepth : TEXCOORD3, \n"
|
||||
" float4 vertexColour : TEXCOORD4, \n"
|
||||
" uniform float4 fogColour, \n"
|
||||
" uniform float4 fogParams, \n";
|
||||
|
||||
if (shadows) outStream <<
|
||||
" uniform float4 shadowFar_fadeStart, \n";
|
||||
|
||||
if (shadows && !split) outStream <<
|
||||
" uniform sampler2D shadowMap : register(s1), \n"
|
||||
" float4 lightSpacePos0 : TEXCOORD5, \n"
|
||||
" uniform float4 invShadowmapSize0, \n";
|
||||
else
|
||||
{
|
||||
outStream <<
|
||||
" uniform float4 pssmSplitPoints, \n";
|
||||
for (int i=0; i<numsplits; ++i)
|
||||
{
|
||||
outStream <<
|
||||
" uniform sampler2D shadowMap"<<i<<" : register(s"<<i+1<<"), \n"
|
||||
" float4 lightSpacePos"<<i<<" : TEXCOORD"<<i+5<<", \n"
|
||||
" uniform float4 invShadowmapSize"<<i<<", \n";
|
||||
}
|
||||
}
|
||||
|
||||
if (mrt) outStream <<
|
||||
" out float4 oColor1 : COLOR1, \n"
|
||||
" uniform float far, \n";
|
||||
|
||||
for (int i=0; i<num_lights; ++i)
|
||||
{
|
||||
outStream <<
|
||||
" uniform float4 lightDiffuse"<<i<<", \n"
|
||||
" uniform float4 lightPositionObjSpace"<<i<<", \n"
|
||||
" uniform float4 lightAttenuation"<<i<<", \n";
|
||||
}
|
||||
outStream <<
|
||||
" uniform float4 lightAmbient, \n"
|
||||
" uniform float4 ambient, \n"
|
||||
" uniform float4 diffuse, \n"
|
||||
" uniform float4 emissive \n"
|
||||
") \n"
|
||||
"{ \n"
|
||||
" float4 tex = tex2D(texture, uv); \n"
|
||||
" float d; \n"
|
||||
" float attn; \n"
|
||||
" float3 lightDir; \n"
|
||||
" float3 lightColour = float3(0, 0, 0); \n";
|
||||
|
||||
for (int i=0; i<num_lights; ++i)
|
||||
{
|
||||
outStream <<
|
||||
" lightDir = lightPositionObjSpace"<<i<<".xyz - (positionObjSpace.xyz * lightPositionObjSpace"<<i<<".w); \n"
|
||||
|
||||
// pre-multiply light color with attenuation factor
|
||||
" d = length( lightDir ); \n"
|
||||
" attn = ( 1.0 / (( lightAttenuation"<<i<<".y ) + ( lightAttenuation"<<i<<".z * d ) + ( lightAttenuation"<<i<<".w * d * d ))); \n"
|
||||
" lightDiffuse"<<i<<" *= attn; \n";
|
||||
|
||||
if (i == 0 && shadows)
|
||||
{
|
||||
outStream <<
|
||||
" float shadow; \n";
|
||||
if (!split) outStream <<
|
||||
" shadow = depthShadow(shadowMap, lightSpacePos0, invShadowmapSize0.xy); \n";
|
||||
else
|
||||
{
|
||||
for (int j=0; j<numsplits; ++j)
|
||||
{
|
||||
std::string channel;
|
||||
if (j==0) channel = "x";
|
||||
else if (j==1) channel = "y";
|
||||
else if (j==2) channel = "z";
|
||||
|
||||
if (j==0)
|
||||
outStream << " if (iDepth <= pssmSplitPoints." << channel << ") \n";
|
||||
else if (j < numsplits - 1)
|
||||
outStream << " else if (iDepth <= pssmSplitPoints." << channel << ") \n";
|
||||
else
|
||||
outStream << " else \n";
|
||||
|
||||
outStream <<
|
||||
" { \n"
|
||||
" shadow = depthShadow(shadowMap" << j << ", lightSpacePos" << j << ", invShadowmapSize" << j << ".xy); \n"
|
||||
" } \n";
|
||||
}
|
||||
}
|
||||
outStream <<
|
||||
" float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y; \n"
|
||||
" float fade = 1-((iDepth - shadowFar_fadeStart.y) / fadeRange); \n"
|
||||
" shadow = (iDepth > shadowFar_fadeStart.x) ? 1 : ((iDepth > shadowFar_fadeStart.y) ? 1-((1-shadow)*fade) : shadow); \n"
|
||||
" lightColour.xyz += shadow * lit(dot(normalize(lightDir), normalize(normal)), 0, 0).y * lightDiffuse"<<i<<".xyz;\n";
|
||||
}
|
||||
else outStream <<
|
||||
" lightColour.xyz += lit(dot(normalize(lightDir), normalize(normal)), 0, 0).y * lightDiffuse"<<i<<".xyz;\n";
|
||||
}
|
||||
|
||||
outStream <<
|
||||
" float3 lightingFinal = lightColour.xyz * diffuse.xyz + ambient.xyz * lightAmbient.xyz + emissive.xyz; \n"
|
||||
" float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); \n"
|
||||
" oColor.xyz = saturate(lerp(lightingFinal * tex.xyz * vertexColour.xyz, fogColour.xyz, fogValue)); \n" // saturate output to prevent negative output colors - TODO: replace this once there is HDR-rendering
|
||||
" oColor.a = tex.a * diffuse.a * vertexColour.a; \n";
|
||||
|
||||
if (mrt) outStream <<
|
||||
" oColor1 = float4(iDepth / far, 0, 0, (oColor.a == 1)); \n"; // only write to MRT if alpha is 1
|
||||
|
||||
outStream <<
|
||||
"}";
|
||||
fragment->setSource(outStream.str());
|
||||
fragment->load();
|
||||
|
||||
for (int i=0; i<num_lights; ++i)
|
||||
{
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("lightPositionObjSpace"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_POSITION_OBJECT_SPACE, i);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("lightDiffuse"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR, i);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("lightAttenuation"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_ATTENUATION, i);
|
||||
}
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("ambient", GpuProgramParameters::ACT_SURFACE_AMBIENT_COLOUR);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("lightAmbient", GpuProgramParameters::ACT_AMBIENT_LIGHT_COLOUR);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("fogColour", GpuProgramParameters::ACT_FOG_COLOUR);
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("fogParams", GpuProgramParameters::ACT_FOG_PARAMS);
|
||||
|
||||
if (shadows)
|
||||
{
|
||||
fragment->getDefaultParameters()->setNamedConstant("shadowFar_fadeStart", Vector4(mRendering->getShadows()->getShadowFar(), mRendering->getShadows()->getFadeStart()*mRendering->getShadows()->getShadowFar(), 0, 0));
|
||||
for (int i=0; i < (split ? numsplits : 1); ++i)
|
||||
{
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("invShadowmapSize" + StringConverter::toString(i), GpuProgramParameters::ACT_INVERSE_TEXTURE_SIZE, i+1);
|
||||
}
|
||||
if (split)
|
||||
{
|
||||
Vector4 splitPoints;
|
||||
const PSSMShadowCameraSetup::SplitPointList& splitPointList = mRendering->getShadows()->getPSSMSetup()->getSplitPoints();
|
||||
// Populate from split point 1, not 0, since split 0 isn't useful (usually 0)
|
||||
for (int i = 1; i < numsplits; ++i)
|
||||
{
|
||||
splitPoints[i-1] = splitPointList[i];
|
||||
}
|
||||
fragment->getDefaultParameters()->setNamedConstant("pssmSplitPoints", splitPoints);
|
||||
}
|
||||
}
|
||||
|
||||
if (mrt)
|
||||
fragment->getDefaultParameters()->setNamedAutoConstant("far", GpuProgramParameters::ACT_FAR_CLIP_DISTANCE);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#ifndef GAME_SHADERHELPER_H
|
||||
#define GAME_SHADERHELPER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class RenderingManager;
|
||||
|
||||
///
|
||||
/// \brief manages the main shader
|
||||
///
|
||||
class ShaderHelper
|
||||
{
|
||||
public:
|
||||
ShaderHelper(RenderingManager* rend);
|
||||
|
||||
void applyShaders();
|
||||
///< apply new settings
|
||||
|
||||
private:
|
||||
RenderingManager* mRendering;
|
||||
|
||||
void createShader(const bool mrt, const bool shadows, const bool split, const std::string& name);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
Subproject commit 41245d1361bc0242e5d2c2313caffb711207e5fc
|
@ -1,16 +1,50 @@
|
||||
project(resources)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/caustic_0.png "${OpenMW_BINARY_DIR}/resources/water/caustic_0.png" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/underwater.cg "${OpenMW_BINARY_DIR}/resources/water/underwater.cg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/perlinvolume.dds "${OpenMW_BINARY_DIR}/resources/water/perlinvolume.dds" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.compositor "${OpenMW_BINARY_DIR}/resources/water/water.compositor" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.material "${OpenMW_BINARY_DIR}/resources/water/water.material" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/WaterNormal2.tga "${OpenMW_BINARY_DIR}/resources/water/WaterNormal2.tga" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.cg "${OpenMW_BINARY_DIR}/resources/water/water.cg" COPYONLY)
|
||||
set(WATER_FILES
|
||||
underwater_dome.mesh
|
||||
water_nm.png
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gbuffer/gbuffer.cg "${OpenMW_BINARY_DIR}/resources/gbuffer/gbuffer.cg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gbuffer/gbuffer.material "${OpenMW_BINARY_DIR}/resources/gbuffer/gbuffer.material" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gbuffer/gbuffer.compositor "${OpenMW_BINARY_DIR}/resources/gbuffer/gbuffer.compositor" COPYONLY)
|
||||
set(GBUFFER_FILES
|
||||
gbuffer.compositor
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/shadows/depthshadowcaster.material "${OpenMW_BINARY_DIR}/resources/shadows/depthshadowcaster.material" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/shadows/depthshadowcaster.cg "${OpenMW_BINARY_DIR}/resources/shadows/depthshadowcaster.cg" COPYONLY)
|
||||
set(MATERIAL_FILES
|
||||
atmosphere.shader
|
||||
atmosphere.shaderset
|
||||
clouds.shader
|
||||
clouds.shaderset
|
||||
core.h
|
||||
moon.shader
|
||||
moon.shaderset
|
||||
objects.mat
|
||||
objects.shader
|
||||
objects.shaderset
|
||||
openmw.configuration
|
||||
quad2.shader
|
||||
quad.mat
|
||||
quad.shader
|
||||
quad.shaderset
|
||||
shadowcaster.mat
|
||||
shadowcaster.shader
|
||||
shadowcaster.shaderset
|
||||
shadows.h
|
||||
sky.mat
|
||||
stars.shader
|
||||
stars.shaderset
|
||||
sun.shader
|
||||
sun.shaderset
|
||||
terrain.shader
|
||||
terrain.shaderset
|
||||
underwater.h
|
||||
water.mat
|
||||
water.shader
|
||||
water.shaderset
|
||||
|
||||
)
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR}/water "${OpenMW_BINARY_DIR}/resources/water/" "${WATER_FILES}")
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR}/gbuffer "${OpenMW_BINARY_DIR}/resources/gbuffer/" "${GBUFFER_FILES}")
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR}/materials "${OpenMW_BINARY_DIR}/resources/materials/" "${MATERIAL_FILES}")
|
||||
|
@ -1,18 +0,0 @@
|
||||
void RenderScene_vs(in float4 position : POSITION
|
||||
,in float2 uv :TEXCOORD0
|
||||
,uniform float4x4 wvp
|
||||
,out float4 oPosition : POSITION
|
||||
,out float2 oUV :TEXCOORD0)
|
||||
{
|
||||
oPosition = mul(wvp, position);
|
||||
oUV = uv;
|
||||
}
|
||||
|
||||
void RenderScene_ps(in float4 position : POSITION
|
||||
,in float2 uv :TEXCOORD0
|
||||
,uniform sampler2D tex1 : TEXUNIT0
|
||||
,out float4 oColor : COLOR)
|
||||
{
|
||||
float4 scene =tex2D(tex1, uv);
|
||||
oColor= scene;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
vertex_program RenderGBuffer_vs cg
|
||||
{
|
||||
source gbuffer.cg
|
||||
profiles vs_4_0 vs_1_1 arbvp1
|
||||
entry_point RenderScene_vs
|
||||
default_params
|
||||
{
|
||||
param_named_auto wvp worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
fragment_program RenderGBuffer_ps cg
|
||||
{
|
||||
source gbuffer.cg
|
||||
entry_point RenderScene_ps
|
||||
profiles ps_4_0 ps_2_x arbfp1
|
||||
default_params
|
||||
{
|
||||
}
|
||||
}
|
||||
material RenderScene
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_program_ref RenderGBuffer_vs
|
||||
{
|
||||
}
|
||||
|
||||
fragment_program_ref RenderGBuffer_ps
|
||||
{
|
||||
}
|
||||
|
||||
texture_unit tex1
|
||||
{
|
||||
//scenebuffer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material RenderSceneNoDepth
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_write off
|
||||
vertex_program_ref RenderGBuffer_vs
|
||||
{
|
||||
}
|
||||
|
||||
fragment_program_ref RenderGBuffer_ps
|
||||
{
|
||||
}
|
||||
|
||||
texture_unit tex1
|
||||
{
|
||||
//scenebuffer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#include "core.h"
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
|
||||
shColourInput(float4)
|
||||
shOutput(float4, colourPassthrough)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
colourPassthrough = colour;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float4, colourPassthrough)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4, atmosphereColour) @shSharedParameter(atmosphereColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = colourPassthrough * atmosphereColour;
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set atmosphere_vertex
|
||||
{
|
||||
source atmosphere.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set atmosphere_fragment
|
||||
{
|
||||
source atmosphere.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#include "core.h"
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shColourInput(float4)
|
||||
shOutput(float4, colourPassthrough)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
colourPassthrough = colour;
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float2, UV)
|
||||
shInput(float4, colourPassthrough)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
|
||||
shSampler2D(diffuseMap1)
|
||||
shSampler2D(diffuseMap2)
|
||||
|
||||
shUniform(float, cloudBlendFactor) @shSharedParameter(cloudBlendFactor)
|
||||
shUniform(float, cloudAnimationTimer) @shSharedParameter(cloudAnimationTimer)
|
||||
shUniform(float, cloudOpacity) @shSharedParameter(cloudOpacity)
|
||||
shUniform(float3, cloudColour) @shSharedParameter(cloudColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
// Scroll in y direction
|
||||
float2 scrolledUV = UV + float2(0,1) * cloudAnimationTimer * 0.003;
|
||||
|
||||
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
|
||||
|
||||
shOutputColour(0) = colourPassthrough * float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity);
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set clouds_vertex
|
||||
{
|
||||
source clouds.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set clouds_fragment
|
||||
{
|
||||
source clouds.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
#if SH_HLSL == 1 || SH_CG == 1
|
||||
|
||||
#define shTexture2D sampler2D
|
||||
#define shSample(tex, coord) tex2D(tex, coord)
|
||||
#define shLerp(a, b, t) lerp(a, b, t)
|
||||
#define shSaturate(a) saturate(a)
|
||||
|
||||
#define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name)
|
||||
|
||||
#define shMatrixMult(m, v) mul(m, v)
|
||||
|
||||
#define shUniform(type, name) , uniform type name
|
||||
|
||||
#define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
||||
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
||||
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
||||
|
||||
#define shNormalInput(type) , in type normal : NORMAL
|
||||
|
||||
#define shColourInput(type) , in type colour : COLOR
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define shOutputPosition oPosition
|
||||
#define shInputPosition iPosition
|
||||
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
void main( \
|
||||
float4 iPosition : POSITION \
|
||||
, out float4 oPosition : POSITION
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
) \
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shOutputColour(num) oColor##num
|
||||
|
||||
#define shDeclareMrtOutput(num) , out float4 oColor##num : COLOR##num
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
void main( \
|
||||
out float4 oColor0 : COLOR
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
) \
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if SH_GLSL == 1
|
||||
|
||||
@version 120
|
||||
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4/
|
||||
#define shTexture2D sampler2D
|
||||
#define shSample(tex, coord) texture2D(tex, coord)
|
||||
#define shLerp(a, b, t) mix(a, b, t)
|
||||
#define shSaturate(a) clamp(a, 0.0, 1.0)
|
||||
|
||||
#define shUniform(type, name) uniform type name;
|
||||
|
||||
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
|
||||
|
||||
#define shMatrixMult(m, v) (m * v)
|
||||
|
||||
#define shOutputPosition gl_Position
|
||||
|
||||
#define float4x4 mat4
|
||||
|
||||
// GLSL 1.3
|
||||
#if 0
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shInputPosition vertex
|
||||
|
||||
#define shOutputColour(num) oColor##num
|
||||
|
||||
|
||||
|
||||
#define shInput(type, name) in type name;
|
||||
#define shOutput(type, name) out type name;
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shNormalInput(type) in type normal;
|
||||
#define shColourInput(type) in type colour;
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
in float4 shInputPosition;
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shDeclareMrtOutput(num) out vec4 oColor##num;
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
out float4 oColor0;
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// GLSL 1.2
|
||||
|
||||
#if 1
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shInputPosition gl_Vertex
|
||||
|
||||
#define shOutputColour(num) gl_FragData[num]
|
||||
|
||||
#define shVertexInput(type, name) attribute type name;
|
||||
#define shInput(type, name) varying type name;
|
||||
#define shOutput(type, name) varying type name;
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shNormalInput(type) attribute type normal;
|
||||
#define shColourInput(type) attribute type colour;
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define SH_BEGIN_PROGRAM
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shDeclareMrtOutput(num)
|
||||
|
||||
#define SH_BEGIN_PROGRAM
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,52 @@
|
||||
#include "core.h"
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
shUniform(float4, atmosphereColour) @shSharedParameter(atmosphereColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
||||
float4 tex = shSample(diffuseMap, UV);
|
||||
|
||||
shOutputColour(0) = float4(materialEmissive.xyz, 1) * tex;
|
||||
|
||||
// use a circle for the alpha (compute UV distance to center)
|
||||
// looks a bit bad because it's not filtered on the edges,
|
||||
// but cheaper than a seperate alpha texture.
|
||||
float sqrUVdist = pow(UV.x-0.5,2) + pow(UV.y-0.5, 2);
|
||||
shOutputColour(0).a = materialDiffuse.a * (sqrUVdist >= 0.24 ? 0 : 1);
|
||||
shOutputColour(0).rgb += (1-tex.a) * shOutputColour(0).a * atmosphereColour.rgb; //fill dark side of moon with atmosphereColour
|
||||
shOutputColour(0).rgb += (1-materialDiffuse.a) * atmosphereColour.rgb; //fade bump
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set moon_vertex
|
||||
{
|
||||
source moon.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set moon_fragment
|
||||
{
|
||||
source moon.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
material openmw_objects_base
|
||||
{
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.4 0.4 0.4 32
|
||||
ambient 1.0 1.0 1.0
|
||||
emissive 0.0 0.0 0.0
|
||||
has_vertex_colour false
|
||||
diffuseMap black.png
|
||||
|
||||
is_transparent false // real transparency, alpha rejection doesn't count here
|
||||
scene_blend default
|
||||
depth_write default
|
||||
alpha_rejection default
|
||||
|
||||
pass
|
||||
{
|
||||
vertex_program openmw_objects_vertex
|
||||
fragment_program openmw_objects_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
has_vertex_colour $has_vertex_colour
|
||||
is_transparent $is_transparent
|
||||
}
|
||||
|
||||
diffuse $diffuse
|
||||
specular $specular
|
||||
ambient $ambient
|
||||
emissive $emissive
|
||||
scene_blend $scene_blend
|
||||
alpha_rejection $alpha_rejection
|
||||
depth_write $depth_write
|
||||
|
||||
ffp_vertex_colour_ambient $has_vertex_colour
|
||||
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $diffuseMap
|
||||
create_in_ffp true
|
||||
}
|
||||
|
||||
texture_unit shadowMap0
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap1
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap2
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
|
||||
texture_unit causticMap
|
||||
{
|
||||
direct_texture water_nm.png
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,299 @@
|
||||
#include "core.h"
|
||||
|
||||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
#define MRT @shPropertyNotBool(is_transparent) && @shGlobalSettingBool(mrt_output)
|
||||
#define LIGHTING @shGlobalSettingBool(lighting)
|
||||
|
||||
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
#endif
|
||||
|
||||
#if FOG || MRT || SHADOWS_PSSM
|
||||
#define NEED_DEPTH
|
||||
#endif
|
||||
|
||||
|
||||
#define UNDERWATER @shGlobalSettingBool(underwater_effects) && LIGHTING
|
||||
|
||||
|
||||
#define HAS_VERTEXCOLOR @shPropertyBool(has_vertex_colour)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
// ------------------------------------- VERTEX ---------------------------------------
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shNormalInput(float4)
|
||||
#ifdef NEED_DEPTH
|
||||
shOutput(float, depthPassthrough)
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
shOutput(float3, normalPassthrough)
|
||||
shOutput(float3, objSpacePositionPassthrough)
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
shColourInput(float4)
|
||||
shOutput(float4, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shOutput(float4, lightSpacePos0)
|
||||
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shOutput(float4, lightSpacePos@shIterator)
|
||||
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||
@shEndForeach
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
#if LIGHTING
|
||||
normalPassthrough = normal.xyz;
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEPTH
|
||||
depthPassthrough = shOutputPosition.z;
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
objSpacePositionPassthrough = shInputPosition.xyz;
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
colourPassthrough = colour;
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
lightSpacePos0 = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float4 wPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
@shForeach(3)
|
||||
lightSpacePos@shIterator = shMatrixMult(texViewProjMatrix@shIterator, wPos);
|
||||
@shEndForeach
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// ----------------------------------- FRAGMENT ------------------------------------------
|
||||
|
||||
#if UNDERWATER
|
||||
#include "underwater.h"
|
||||
#endif
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEPTH
|
||||
shInput(float, depthPassthrough)
|
||||
#endif
|
||||
|
||||
#if MRT
|
||||
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
shInput(float3, normalPassthrough)
|
||||
shInput(float3, objSpacePositionPassthrough)
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
//shUniform(float, passIteration) @shAutoConstant(passIteration, pass_iteration_number)
|
||||
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
@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
|
||||
|
||||
#if FOG
|
||||
shUniform(float3, fogColour) @shAutoConstant(fogColour, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
shInput(float4, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shInput(float4, lightSpacePos0)
|
||||
shSampler2D(shadowMap0)
|
||||
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, 1)
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shInput(float4, lightSpacePos@shIterator)
|
||||
shSampler2D(shadowMap@shIterator)
|
||||
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(1))
|
||||
@shEndForeach
|
||||
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||
#endif
|
||||
|
||||
#if UNDERWATER
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
shUniform(float, waterLevel) @shSharedParameter(waterLevel)
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
|
||||
shUniform(float4, lightDirectionWS0) @shAutoConstant(lightDirectionWS0, light_position, 0)
|
||||
|
||||
shSampler2D(causticMap)
|
||||
|
||||
shUniform(float, waterTimer) @shSharedParameter(waterTimer)
|
||||
shUniform(float2, waterSunFade_sunHeight) @shSharedParameter(waterSunFade_sunHeight)
|
||||
shUniform(float, waterEnabled) @shSharedParameter(waterEnabled)
|
||||
|
||||
shUniform(float3, windDir_windSpeed) @shSharedParameter(windDir_windSpeed)
|
||||
#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;
|
||||
float3 ambient = materialAmbient.xyz * lightAmbient.xyz;
|
||||
|
||||
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float shadow = pssmDepthShadow (lightSpacePos0, invShadowmapSize0, shadowMap0, lightSpacePos1, invShadowmapSize1, shadowMap1, lightSpacePos2, invShadowmapSize2, shadowMap2, depthPassthrough, pssmSplitPoints);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
|
||||
float fade = 1-((depthPassthrough - shadowFar_fadeStart.y) / fadeRange);
|
||||
shadow = (depthPassthrough > shadowFar_fadeStart.x) ? 1 : ((depthPassthrough > shadowFar_fadeStart.y) ? 1-((1-shadow)*fade) : shadow);
|
||||
#endif
|
||||
|
||||
#if !SHADOWS && !SHADOWS_PSSM
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
float3 caustics = float3(1,1,1);
|
||||
#if UNDERWATER
|
||||
float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePositionPassthrough,1)).xyz;
|
||||
float3 waterEyePos = float3(1,1,1);
|
||||
if (worldPos.y < waterLevel && waterEnabled == 1)
|
||||
{
|
||||
// NOTE: this calculation would be wrong for non-uniform scaling
|
||||
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
||||
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel);
|
||||
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@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 * caustics;
|
||||
|
||||
#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) * caustics;
|
||||
|
||||
#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
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
ambient *= colourPassthrough.xyz;
|
||||
#endif
|
||||
|
||||
shOutputColour(0).xyz *= (ambient + diffuse + materialEmissive.xyz);
|
||||
#endif
|
||||
|
||||
|
||||
#if HAS_VERTEXCOLOR && !LIGHTING
|
||||
shOutputColour(0).xyz *= colourPassthrough.xyz;
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||
|
||||
#if UNDERWATER
|
||||
// regular fog only if fragment is above water
|
||||
if (worldPos.y > waterLevel)
|
||||
#endif
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||
#endif
|
||||
|
||||
// prevent negative colour output (for example with negative lights)
|
||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
||||
|
||||
#if UNDERWATER
|
||||
float fogAmount = (cameraPos.y > waterLevel)
|
||||
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
||||
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
||||
|
||||
float3 eyeVec = normalize(cameraPos.xyz-worldPos);
|
||||
|
||||
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
||||
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
||||
float3 waterSunColour = float3(0.0,1.0,0.85)*waterSunGradient * 0.5;
|
||||
|
||||
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
||||
|
||||
|
||||
float darkness = VISIBILITY*2.0;
|
||||
darkness = clamp((waterEyePos.y - waterLevel + darkness)/darkness,0.2,1.0);
|
||||
watercolour *= darkness;
|
||||
|
||||
float isUnderwater = (worldPos.y < waterLevel) ? 1.0 : 0.0;
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater * waterEnabled);
|
||||
#endif
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(depthPassthrough / far,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set openmw_objects_vertex
|
||||
{
|
||||
source objects.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set openmw_objects_fragment
|
||||
{
|
||||
source objects.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
configuration water_reflection
|
||||
{
|
||||
fog false
|
||||
shadows false
|
||||
shadows_pssm false
|
||||
mrt_output false
|
||||
}
|
||||
|
||||
configuration local_map
|
||||
{
|
||||
fog false
|
||||
mrt_output false
|
||||
lighting false
|
||||
shadows false
|
||||
shadows_pssm false
|
||||
simple_water true
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
material quad
|
||||
{
|
||||
depth_write on
|
||||
|
||||
pass
|
||||
{
|
||||
vertex_program quad_vertex
|
||||
fragment_program quad_fragment
|
||||
|
||||
depth_write $depth_write
|
||||
|
||||
texture_unit SceneBuffer
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material quad_noDepthWrite
|
||||
{
|
||||
parent quad
|
||||
depth_write off
|
||||
}
|
||||
|
||||
material openmw_viewport_init
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_program viewport_init_vertex
|
||||
fragment_program viewport_init_fragment
|
||||
|
||||
depth_write off
|
||||
depth_check off
|
||||
scene_blend add
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float2, UV)
|
||||
shSampler2D(SceneBuffer)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = shSample(SceneBuffer, UV);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,31 @@
|
||||
shader_set quad_vertex
|
||||
{
|
||||
source quad.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set quad_fragment
|
||||
{
|
||||
source quad.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
||||
|
||||
shader_set viewport_init_vertex
|
||||
{
|
||||
source quad2.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set viewport_init_fragment
|
||||
{
|
||||
source quad2.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float3, viewportBackground) @shSharedParameter(viewportBackground)
|
||||
shDeclareMrtOutput(1)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = float4(viewportBackground, 1);
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,35 @@
|
||||
material openmw_shadowcaster_default
|
||||
{
|
||||
create_configuration Default
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
fog_override true
|
||||
|
||||
vertex_program openmw_shadowcaster_vertex
|
||||
fragment_program openmw_shadowcaster_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
shadow_transparency true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_shadowcaster_noalpha
|
||||
{
|
||||
create_configuration Default
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
fog_override true
|
||||
|
||||
vertex_program openmw_shadowcaster_vertex
|
||||
fragment_program openmw_shadowcaster_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
shadow_transparency false
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
#include "core.h"
|
||||
|
||||
#define ALPHA @shPropertyBool(shadow_transparency)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if ALPHA
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
#endif
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shOutput(float2, depth)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
// this is the view space position
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
|
||||
// depth info for the fragment.
|
||||
depth.x = shOutputPosition.z;
|
||||
depth.y = shOutputPosition.w;
|
||||
|
||||
// clamp z to zero. seem to do the trick. :-/
|
||||
shOutputPosition.z = max(shOutputPosition.z, 0);
|
||||
|
||||
#if ALPHA
|
||||
UV = uv0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if ALPHA
|
||||
shInput(float2, UV)
|
||||
shSampler2D(texture1)
|
||||
#endif
|
||||
shInput(float2, depth)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float finalDepth = depth.x / depth.y;
|
||||
|
||||
|
||||
#if ALPHA
|
||||
// use alpha channel of the first texture
|
||||
float alpha = shSample(texture1, UV).a;
|
||||
|
||||
// discard if alpha is less than 0.5
|
||||
if (alpha < 1.0)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
shOutputColour(0) = float4(finalDepth, finalDepth, finalDepth, 1);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set openmw_shadowcaster_vertex
|
||||
{
|
||||
source shadowcaster.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set openmw_shadowcaster_fragment
|
||||
{
|
||||
source shadowcaster.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
|
||||
float depthShadowPCF (shTexture2D shadowMap, float4 shadowMapPos, float2 offset)
|
||||
{
|
||||
shadowMapPos /= shadowMapPos.w;
|
||||
float3 o = float3(offset.xy, -offset.x) * 0.3;
|
||||
//float3 o = float3(0,0,0);
|
||||
float c = (shadowMapPos.z <= shSample(shadowMap, shadowMapPos.xy - o.xy).r) ? 1 : 0; // top left
|
||||
c += (shadowMapPos.z <= shSample(shadowMap, shadowMapPos.xy + o.xy).r) ? 1 : 0; // bottom right
|
||||
c += (shadowMapPos.z <= shSample(shadowMap, shadowMapPos.xy + o.zy).r) ? 1 : 0; // bottom left
|
||||
c += (shadowMapPos.z <= shSample(shadowMap, shadowMapPos.xy - o.zy).r) ? 1 : 0; // top right
|
||||
return c / 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float pssmDepthShadow (
|
||||
|
||||
|
||||
float4 lightSpacePos0,
|
||||
float2 invShadowmapSize0,
|
||||
shTexture2D shadowMap0,
|
||||
|
||||
float4 lightSpacePos1,
|
||||
float2 invShadowmapSize1,
|
||||
shTexture2D shadowMap1,
|
||||
|
||||
float4 lightSpacePos2,
|
||||
float2 invShadowmapSize2,
|
||||
shTexture2D shadowMap2,
|
||||
|
||||
float depth,
|
||||
float3 pssmSplitPoints)
|
||||
|
||||
{
|
||||
float shadow;
|
||||
|
||||
if (depth < pssmSplitPoints.x)
|
||||
shadow = depthShadowPCF(shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
else if (depth < pssmSplitPoints.y)
|
||||
shadow = depthShadowPCF(shadowMap1, lightSpacePos1, invShadowmapSize1);
|
||||
else
|
||||
shadow = depthShadowPCF(shadowMap2, lightSpacePos2, invShadowmapSize2);
|
||||
|
||||
return shadow;
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
material openmw_moon
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program moon_vertex
|
||||
fragment_program moon_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
depth_write off
|
||||
depth_check off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
texture_alias $texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_clouds
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program clouds_vertex
|
||||
fragment_program clouds_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
|
||||
// second diffuse map is used for weather transitions
|
||||
texture_unit diffuseMap1
|
||||
{
|
||||
texture_alias cloud_texture_1
|
||||
}
|
||||
|
||||
texture_unit diffuseMap2
|
||||
{
|
||||
texture_alias cloud_texture_2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_atmosphere
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program atmosphere_vertex
|
||||
fragment_program atmosphere_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_stars
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program stars_vertex
|
||||
fragment_program stars_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
depth_check off
|
||||
depth_write off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used for both sun and sun glare
|
||||
material openmw_sun
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program sun_vertex
|
||||
fragment_program sun_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
depth_check off
|
||||
depth_write off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $texture
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#include "core.h"
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shOutput(float, fade)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
|
||||
fade = (shInputPosition.z > 50) ? 1 : 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
|
||||
shInput(float2, UV)
|
||||
shInput(float, fade)
|
||||
|
||||
shSampler2D(diffuseMap)
|
||||
shUniform(float, nightFade) @shSharedParameter(nightFade)
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = shSample(diffuseMap, UV) * float4(1,1,1, nightFade * fade);
|
||||
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set stars_vertex
|
||||
{
|
||||
source stars.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set stars_fragment
|
||||
{
|
||||
source stars.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
#include "core.h"
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
//shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = float4(1,1,1,materialDiffuse.a) * shSample(diffuseMap, UV);
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set sun_vertex
|
||||
{
|
||||
source sun.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set sun_fragment
|
||||
{
|
||||
source sun.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,377 @@
|
||||
#include "core.h"
|
||||
|
||||
#define IS_FIRST_PASS 1
|
||||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
#define LIGHTING @shGlobalSettingBool(lighting)
|
||||
|
||||
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
#endif
|
||||
|
||||
#define COLOUR_MAP @shPropertyBool(colour_map)
|
||||
|
||||
#define NUM_LAYERS @shPropertyString(num_layers)
|
||||
|
||||
#if MRT || FOG || SHADOWS_PSSM
|
||||
#define NEED_DEPTH 1
|
||||
#endif
|
||||
|
||||
#define UNDERWATER @shGlobalSettingBool(underwater_effects) && LIGHTING
|
||||
|
||||
|
||||
#if NEED_DEPTH
|
||||
@shAllocatePassthrough(1, depth)
|
||||
#endif
|
||||
|
||||
@shAllocatePassthrough(2, UV)
|
||||
|
||||
#if LIGHTING
|
||||
@shAllocatePassthrough(3, objSpacePosition)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
@shAllocatePassthrough(4, lightSpacePos0)
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
@shAllocatePassthrough(4, lightSpacePos@shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
// ------------------------------------- VERTEX ---------------------------------------
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
shUniform(float4x4, viewProjMatrix) @shAutoConstant(viewProjMatrix, viewproj_matrix)
|
||||
|
||||
shUniform(float2, lodMorph) @shAutoConstant(lodMorph, custom, 1001)
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
shVertexInput(float2, delta) // lodDelta, lodThreshold
|
||||
|
||||
#if SHADOWS
|
||||
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
|
||||
@shPassthroughVertexOutputs
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
||||
|
||||
float4 worldPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
|
||||
// determine whether to apply the LOD morph to this vertex
|
||||
// we store the deltas against all vertices so we only want to apply
|
||||
// the morph to the ones which would disappear. The target LOD which is
|
||||
// being morphed to is stored in lodMorph.y, and the LOD at which
|
||||
// the vertex should be morphed is stored in uv.w. If we subtract
|
||||
// the former from the latter, and arrange to only morph if the
|
||||
// result is negative (it will only be -1 in fact, since after that
|
||||
// the vertex will never be indexed), we will achieve our aim.
|
||||
// sign(vertexLOD - targetLOD) == -1 is to morph
|
||||
float toMorph = -min(0, sign(delta.y - lodMorph.y));
|
||||
|
||||
// morph
|
||||
// this assumes XZ terrain alignment
|
||||
worldPos.y += delta.x * toMorph * lodMorph.x;
|
||||
|
||||
|
||||
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
|
||||
|
||||
#if NEED_DEPTH
|
||||
@shPassthroughAssign(depth, shOutputPosition.z);
|
||||
#endif
|
||||
|
||||
@shPassthroughAssign(UV, uv0);
|
||||
|
||||
#if LIGHTING
|
||||
@shPassthroughAssign(objSpacePosition, shInputPosition.xyz);
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
@shPassthroughAssign(lightSpacePos0, lightSpacePos);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float4 wPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
|
||||
float4 lightSpacePos;
|
||||
@shForeach(3)
|
||||
lightSpacePos = shMatrixMult(texViewProjMatrix@shIterator, wPos);
|
||||
@shPassthroughAssign(lightSpacePos@shIterator, lightSpacePos);
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// ----------------------------------- FRAGMENT ------------------------------------------
|
||||
|
||||
#if UNDERWATER
|
||||
#include "underwater.h"
|
||||
#endif
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
|
||||
|
||||
#if COLOUR_MAP
|
||||
shSampler2D(colourMap)
|
||||
#endif
|
||||
|
||||
shSampler2D(normalMap) // global normal map
|
||||
|
||||
|
||||
@shForeach(@shPropertyString(num_blendmaps))
|
||||
shSampler2D(blendMap@shIterator)
|
||||
@shEndForeach
|
||||
|
||||
@shForeach(@shPropertyString(num_layers))
|
||||
shSampler2D(diffuseMap@shIterator)
|
||||
@shEndForeach
|
||||
|
||||
#if FOG
|
||||
shUniform(float3, fogColour) @shAutoConstant(fogColour, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
@shPassthroughFragmentInputs
|
||||
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||
#endif
|
||||
|
||||
|
||||
#if LIGHTING
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
@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
|
||||
|
||||
|
||||
#if SHADOWS
|
||||
shSampler2D(shadowMap0)
|
||||
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, @shPropertyString(shadowtexture_offset))
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shSampler2D(shadowMap@shIterator)
|
||||
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(@shPropertyString(shadowtexture_offset)))
|
||||
@shEndForeach
|
||||
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||
#endif
|
||||
|
||||
|
||||
#if UNDERWATER
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
shUniform(float, waterLevel) @shSharedParameter(waterLevel)
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
|
||||
shUniform(float4, lightDirectionWS0) @shAutoConstant(lightDirectionWS0, light_position, 0)
|
||||
|
||||
shSampler2D(causticMap)
|
||||
|
||||
shUniform(float, waterTimer) @shSharedParameter(waterTimer)
|
||||
shUniform(float2, waterSunFade_sunHeight) @shSharedParameter(waterSunFade_sunHeight)
|
||||
|
||||
shUniform(float3, windDir_windSpeed) @shSharedParameter(windDir_windSpeed)
|
||||
#endif
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
||||
#if NEED_DEPTH
|
||||
float depth = @shPassthroughReceive(depth);
|
||||
#endif
|
||||
|
||||
float2 UV = @shPassthroughReceive(UV);
|
||||
|
||||
#if LIGHTING
|
||||
float3 objSpacePosition = @shPassthroughReceive(objSpacePosition);
|
||||
|
||||
float3 normal = shSample(normalMap, UV).rgb * 2 - 1;
|
||||
normal = normalize(normal);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
float3 caustics = float3(1,1,1);
|
||||
#if UNDERWATER
|
||||
|
||||
float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePosition,1)).xyz;
|
||||
float3 waterEyePos = float3(1,1,1);
|
||||
if (worldPos.y < waterLevel)
|
||||
{
|
||||
// NOTE: this calculation would be wrong for non-uniform scaling
|
||||
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
||||
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel);
|
||||
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Layer calculations
|
||||
@shForeach(@shPropertyString(num_blendmaps))
|
||||
float4 blendValues@shIterator = shSample(blendMap@shIterator, UV);
|
||||
@shEndForeach
|
||||
|
||||
float3 albedo = float3(0,0,0);
|
||||
@shForeach(@shPropertyString(num_layers))
|
||||
|
||||
|
||||
#if IS_FIRST_PASS == 1 && @shIterator == 0
|
||||
// first layer of first pass doesn't need a blend map
|
||||
albedo = shSample(diffuseMap0, UV * 10).rgb;
|
||||
#else
|
||||
albedo = shLerp(albedo, shSample(diffuseMap@shIterator, UV * 10).rgb, blendValues@shPropertyString(blendmap_component_@shIterator));
|
||||
|
||||
#endif
|
||||
@shEndForeach
|
||||
|
||||
shOutputColour(0) = float4(1,1,1,1);
|
||||
|
||||
#if COLOUR_MAP
|
||||
shOutputColour(0).rgb *= shSample(colourMap, UV).rgb;
|
||||
#endif
|
||||
|
||||
shOutputColour(0).rgb *= albedo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Lighting
|
||||
|
||||
#if LIGHTING
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos0 = @shPassthroughReceive(lightSpacePos0);
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
float4 lightSpacePos@shIterator = @shPassthroughReceive(lightSpacePos@shIterator);
|
||||
@shEndForeach
|
||||
|
||||
float shadow = pssmDepthShadow (lightSpacePos0, invShadowmapSize0, shadowMap0, lightSpacePos1, invShadowmapSize1, shadowMap1, lightSpacePos2, invShadowmapSize2, shadowMap2, depth, pssmSplitPoints);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
|
||||
float fade = 1-((depth - shadowFar_fadeStart.y) / fadeRange);
|
||||
shadow = (depth > shadowFar_fadeStart.x) ? 1 : ((depth > shadowFar_fadeStart.y) ? 1-((1-shadow)*fade) : shadow);
|
||||
#endif
|
||||
|
||||
#if !SHADOWS && !SHADOWS_PSSM
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
float3 lightDir;
|
||||
float3 diffuse = float3(0,0,0);
|
||||
float d;
|
||||
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
|
||||
lightDir = lightPosObjSpace@shIterator.xyz - (objSpacePosition.xyz * lightPosObjSpace@shIterator.w);
|
||||
d = length(lightDir);
|
||||
|
||||
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
#if @shIterator == 0
|
||||
|
||||
#if (SHADOWS || SHADOWS_PSSM)
|
||||
diffuse += lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0) * shadow * caustics;
|
||||
|
||||
#else
|
||||
diffuse += lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0) * caustics;
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
diffuse += lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
||||
#endif
|
||||
|
||||
@shEndForeach
|
||||
|
||||
shOutputColour(0).xyz *= (lightAmbient.xyz + diffuse);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depth - fogParams.y) * fogParams.w);
|
||||
|
||||
#if UNDERWATER
|
||||
// regular fog only if fragment is above water
|
||||
if (worldPos.y > waterLevel)
|
||||
#endif
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||
#endif
|
||||
|
||||
// prevent negative colour output (for example with negative lights)
|
||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
||||
|
||||
#if UNDERWATER
|
||||
float fogAmount = (cameraPos.y > waterLevel)
|
||||
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
||||
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
||||
|
||||
float3 eyeVec = normalize(cameraPos.xyz-worldPos);
|
||||
|
||||
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
||||
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
||||
float3 waterSunColour = float3(0.0,1.0,0.85)*waterSunGradient * 0.5;
|
||||
|
||||
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
||||
|
||||
|
||||
float darkness = VISIBILITY*2.0;
|
||||
darkness = clamp((waterEyePos.y - waterLevel + darkness)/darkness,0.2,1.0);
|
||||
watercolour *= darkness;
|
||||
|
||||
float isUnderwater = (worldPos.y < waterLevel) ? 1.0 : 0.0;
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater);
|
||||
#endif
|
||||
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(depth / far,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set terrain_vertex
|
||||
{
|
||||
source terrain.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set terrain_fragment
|
||||
{
|
||||
source terrain.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
#define VISIBILITY 1500.0 // how far you can look through water
|
||||
|
||||
#define BIG_WAVES_X 0.3 // strength of big waves
|
||||
#define BIG_WAVES_Y 0.3
|
||||
|
||||
#define MID_WAVES_X 0.3 // strength of middle sized waves
|
||||
#define MID_WAVES_Y 0.15
|
||||
|
||||
#define SMALL_WAVES_X 0.15 // strength of small waves
|
||||
#define SMALL_WAVES_Y 0.1
|
||||
|
||||
#define WAVE_CHOPPYNESS 0.15 // wave choppyness
|
||||
#define WAVE_SCALE 0.01 // overall wave scale
|
||||
|
||||
#define ABBERATION 0.001 // chromatic abberation amount
|
||||
|
||||
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
||||
|
||||
float3 intercept(float3 lineP,
|
||||
float3 lineN,
|
||||
float3 planeN,
|
||||
float planeD)
|
||||
{
|
||||
|
||||
float distance = (planeD - dot(planeN, lineP)) / dot(lineN, planeN);
|
||||
return lineP + lineN * distance;
|
||||
}
|
||||
|
||||
float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
|
||||
{
|
||||
float2 nCoord = float2(0.0);
|
||||
bend *= WAVE_CHOPPYNESS;
|
||||
nCoord = coords * (WAVE_SCALE * 0.05) + windDir * timer * (windSpeed*0.04);
|
||||
float3 normal0 = 2.0 * shSample(tex, nCoord + float2(-timer*0.015,-timer*0.05)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 0.1) + windDir * timer * (windSpeed*0.08)-normal0.xy*bend;
|
||||
float3 normal1 = 2.0 * shSample(tex, nCoord + float2(+timer*0.020,+timer*0.015)).rgb - 1.0;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.25) + windDir * timer * (windSpeed*0.07)-normal1.xy*bend;
|
||||
float3 normal2 = 2.0 * shSample(tex, nCoord + float2(-timer*0.04,-timer*0.03)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 0.5) + windDir * timer * (windSpeed*0.09)-normal2.xy*bend;
|
||||
float3 normal3 = 2.0 * shSample(tex, nCoord + float2(+timer*0.03,+timer*0.04)).rgb - 1.0;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE* 1.0) + windDir * timer * (windSpeed*0.4)-normal3.xy*bend;
|
||||
float3 normal4 = 2.0 * shSample(tex, nCoord + float2(-timer*0.2,+timer*0.1)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 2.0) + windDir * timer * (windSpeed*0.7)-normal4.xy*bend;
|
||||
float3 normal5 = 2.0 * shSample(tex, nCoord + float2(+timer*0.1,-timer*0.06)).rgb - 1.0;
|
||||
|
||||
|
||||
float3 normal = normalize(normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y);
|
||||
return normal;
|
||||
}
|
||||
|
||||
float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
|
||||
{
|
||||
bend *= WAVE_CHOPPYNESS;
|
||||
float3 col = float3(0.0);
|
||||
float2 nCoord = float2(0.0); //normal coords
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.025) + windDir * timer * (windSpeed*0.03);
|
||||
col += shSample(tex,nCoord + float2(-timer*0.005,-timer*0.01)).rgb*0.20;
|
||||
nCoord = coords * (WAVE_SCALE * 0.1) + windDir * timer * (windSpeed*0.05)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.01,+timer*0.005)).rgb*0.20;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.2) + windDir * timer * (windSpeed*0.1)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(-timer*0.02,-timer*0.03)).rgb*0.20;
|
||||
nCoord = coords * (WAVE_SCALE * 0.5) + windDir * timer * (windSpeed*0.2)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.03,+timer*0.02)).rgb*0.15;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE* 0.8) + windDir * timer * (windSpeed*1.0)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex, nCoord + float2(-timer*0.06,+timer*0.08)).rgb*0.15;
|
||||
nCoord = coords * (WAVE_SCALE * 1.0) + windDir * timer * (windSpeed*1.3)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.08,-timer*0.06)).rgb*0.10;
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, float3 worldNormal, float3 lightDirectionWS0, float waterLevel, float waterTimer, float3 windDir_windSpeed)
|
||||
{
|
||||
float waterDepth = shSaturate((waterEyePos.y - worldPos.y) / 50.0);
|
||||
|
||||
float3 causticPos = intercept(worldPos.xyz, lightDirectionWS0.xyz, float3(0,1,0), waterLevel);
|
||||
|
||||
///\ todo clean this up
|
||||
float causticdepth = length(causticPos-worldPos.xyz);
|
||||
causticdepth = 1.0-shSaturate(causticdepth / VISIBILITY);
|
||||
causticdepth = shSaturate(causticdepth);
|
||||
|
||||
// NOTE: the original shader calculated a tangent space basis here,
|
||||
// but using only the world normal is cheaper and i couldn't see a visual difference
|
||||
// also, if this effect gets moved to screen-space some day, it's unlikely to have tangent information
|
||||
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xzy * 2 - 1;
|
||||
|
||||
//float fresnel = pow(clamp(dot(LV,causticnorm),0.0,1.0),2.0);
|
||||
|
||||
float NdotL = max(dot(worldNormal.xyz, lightDirectionWS0.xyz),0.0);
|
||||
|
||||
float causticR = 1.0-perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
|
||||
/// \todo sunFade
|
||||
|
||||
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
|
||||
float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
|
||||
float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
|
||||
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*causticdepth;
|
||||
|
||||
caustics *= 3;
|
||||
|
||||
// shore transition
|
||||
caustics = shLerp (float3(1,1,1), caustics, waterDepth);
|
||||
|
||||
return caustics;
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
material Water
|
||||
{
|
||||
pass
|
||||
{
|
||||
emissive 0.6 0.7 1.0
|
||||
ambient 0 0 0
|
||||
diffuse 0 0 0 1
|
||||
specular 0 0 0 32
|
||||
|
||||
vertex_program water_vertex
|
||||
fragment_program water_fragment
|
||||
|
||||
cull_hardware none
|
||||
|
||||
texture_unit reflectionMap
|
||||
{
|
||||
texture_alias WaterReflection
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit refractionMap
|
||||
{
|
||||
texture_alias WaterRefraction
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit depthMap
|
||||
{
|
||||
texture_alias SceneDepth
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit normalMap
|
||||
{
|
||||
direct_texture water_nm.png
|
||||
}
|
||||
|
||||
|
||||
// for simple_water
|
||||
texture_unit animatedTexture
|
||||
{
|
||||
create_in_ffp true
|
||||
scale 0.1 0.1
|
||||
alpha_op_ex source1 src_manual src_current 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
material Underwater_Dome
|
||||
{
|
||||
parent openmw_objects_base
|
||||
|
||||
depth_write off
|
||||
}
|
@ -0,0 +1,307 @@
|
||||
#include "core.h"
|
||||
|
||||
|
||||
#define SIMPLE_WATER @shGlobalSettingBool(simple_water)
|
||||
|
||||
|
||||
#if SIMPLE_WATER
|
||||
// --------------------------------------- SIMPLE WATER ---------------------------------------------------
|
||||
|
||||
|
||||
#define MRT @shGlobalSettingBool(mrt_output)
|
||||
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shOutput(float, depth)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
depth = shOutputPosition.z;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(animatedTexture)
|
||||
shInput(float2, UV)
|
||||
shInput(float, depth)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
|
||||
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0).xyz = shSample(animatedTexture, UV * 15).xyz * float3(0.6, 0.7, 1.0);
|
||||
shOutputColour(0).w = 0.7;
|
||||
|
||||
float fogValue = shSaturate((depth - fogParams.y) * fogParams.w);
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
|
||||
|
||||
#if MRT
|
||||
shOutputColour(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
// Inspired by Blender GLSL Water by martinsh ( http://devlog-martinsh.blogspot.de/2012/07/waterundewater-shader-wip.html )
|
||||
|
||||
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
shOutput(float3, screenCoordsPassthrough)
|
||||
shOutput(float4, position)
|
||||
shOutput(float, depthPassthrough)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
|
||||
|
||||
#if !SH_GLSL
|
||||
float4x4 scalemat = float4x4( 0.5, 0, 0, 0.5,
|
||||
0, -0.5, 0, 0.5,
|
||||
0, 0, 0.5, 0.5,
|
||||
0, 0, 0, 1 );
|
||||
#else
|
||||
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 0.5, 0.0,
|
||||
0.5, 0.5, 0.5, 1.0);
|
||||
#endif
|
||||
|
||||
float4 texcoordProj = shMatrixMult(scalemat, shOutputPosition);
|
||||
screenCoordsPassthrough = float3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
|
||||
|
||||
position = shInputPosition;
|
||||
|
||||
depthPassthrough = shOutputPosition.z;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// tweakables ----------------------------------------------------
|
||||
|
||||
#define VISIBILITY 1500.0 // how far you can look through water
|
||||
|
||||
#define BIG_WAVES_X 0.3 // strength of big waves
|
||||
#define BIG_WAVES_Y 0.3
|
||||
|
||||
#define MID_WAVES_X 0.3 // strength of middle sized waves
|
||||
#define MID_WAVES_Y 0.15
|
||||
|
||||
#define SMALL_WAVES_X 0.15 // strength of small waves
|
||||
#define SMALL_WAVES_Y 0.1
|
||||
|
||||
#define WAVE_CHOPPYNESS 0.15 // wave choppyness
|
||||
#define WAVE_SCALE 75 // overall wave scale
|
||||
|
||||
#define ABBERATION 0.001 // chromatic abberation amount
|
||||
#define BUMP 1.5 // overall water surface bumpiness
|
||||
#define REFL_BUMP 0.08 // reflection distortion amount
|
||||
#define REFR_BUMP 0.06 // refraction distortion amount
|
||||
|
||||
#define SCATTER_AMOUNT 3.0 // amount of sunlight scattering
|
||||
#define SCATTER_COLOUR float3(0.0,1.0,0.95) // colour of sunlight scattering
|
||||
|
||||
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
||||
|
||||
#define SPEC_HARDNESS 256 // specular highlights hardness
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
float fresnel_dielectric(float3 Incoming, float3 Normal, float eta)
|
||||
{
|
||||
/* compute fresnel reflectance without explicitly computing
|
||||
the refracted direction */
|
||||
float c = abs(dot(Incoming, Normal));
|
||||
float g = eta * eta - 1.0 + c * c;
|
||||
float result;
|
||||
|
||||
if(g > 0.0) {
|
||||
g = sqrt(g);
|
||||
float A =(g - c)/(g + c);
|
||||
float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0);
|
||||
result = 0.5 * A * A *(1.0 + B * B);
|
||||
}
|
||||
else
|
||||
result = 1.0; /* TIR (no refracted component) */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float2, UV)
|
||||
shInput(float3, screenCoordsPassthrough)
|
||||
shInput(float4, position)
|
||||
shInput(float, depthPassthrough)
|
||||
|
||||
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||
|
||||
shSampler2D(reflectionMap)
|
||||
shSampler2D(refractionMap)
|
||||
shSampler2D(depthMap)
|
||||
shSampler2D(normalMap)
|
||||
|
||||
shUniform(float3, windDir_windSpeed) @shSharedParameter(windDir_windSpeed)
|
||||
#define WIND_SPEED windDir_windSpeed.z
|
||||
#define WIND_DIR windDir_windSpeed.xy
|
||||
|
||||
shUniform(float, waterTimer) @shSharedParameter(waterTimer)
|
||||
shUniform(float2, waterSunFade_sunHeight) @shSharedParameter(waterSunFade_sunHeight)
|
||||
|
||||
shUniform(float4, sunPosition) @shAutoConstant(sunPosition, light_position, 0)
|
||||
shUniform(float4, sunSpecular) @shAutoConstant(sunSpecular, light_specular_colour, 0)
|
||||
|
||||
|
||||
|
||||
shUniform(float, renderTargetFlipping) @shAutoConstant(renderTargetFlipping, render_target_flipping)
|
||||
|
||||
|
||||
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position_object_space)
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
||||
float2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
|
||||
screenCoords.y = (1-shSaturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
||||
|
||||
float depth = shSample(depthMap, screenCoords).x * far - depthPassthrough;
|
||||
float shoreFade = shSaturate(depth / 50.0);
|
||||
|
||||
float2 nCoord = float2(0.0);
|
||||
|
||||
nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04);
|
||||
float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 0.1) + WIND_DIR * waterTimer * (WIND_SPEED*0.08)-(normal0.xy/normal0.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal1 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.020,+waterTimer*0.015)).rgb - 1.0;
|
||||
|
||||
nCoord = UV * (WAVE_SCALE * 0.25) + WIND_DIR * waterTimer * (WIND_SPEED*0.07)-(normal1.xy/normal1.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal2 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.04,-waterTimer*0.03)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 0.5) + WIND_DIR * waterTimer * (WIND_SPEED*0.09)-(normal2.xy/normal2.z)*WAVE_CHOPPYNESS;
|
||||
float3 normal3 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.03,+waterTimer*0.04)).rgb - 1.0;
|
||||
|
||||
nCoord = UV * (WAVE_SCALE* 1.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.4)-(normal3.xy/normal3.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal4 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.02,+waterTimer*0.1)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 2.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.7)-(normal4.xy/normal4.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal5 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.1,-waterTimer*0.06)).rgb - 1.0;
|
||||
|
||||
|
||||
|
||||
float3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y).xzy;
|
||||
|
||||
normal = normalize(float3(normal.x * BUMP, normal.y, normal.z * BUMP));
|
||||
|
||||
// normal for sunlight scattering
|
||||
float3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
|
||||
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1).xzy;
|
||||
lNormal = normalize(float3(lNormal.x * BUMP, lNormal.y, lNormal.z * BUMP));
|
||||
|
||||
|
||||
float3 lVec = normalize(sunPosition.xyz);
|
||||
float3 vVec = normalize(position.xyz - cameraPos.xyz);
|
||||
|
||||
|
||||
float isUnderwater = (cameraPos.y > 0) ? 0.0 : 1.0;
|
||||
|
||||
// sunlight scattering
|
||||
float3 pNormal = float3(0,1,0);
|
||||
vec3 lR = reflect(lVec, lNormal);
|
||||
vec3 llR = reflect(lVec, pNormal);
|
||||
|
||||
float s = shSaturate(dot(lR, vVec)*2.0-1.2);
|
||||
float lightScatter = shSaturate(dot(-lVec,lNormal)*0.7+0.3) * s * SCATTER_AMOUNT * waterSunFade_sunHeight.x * shSaturate(1.0-exp(-waterSunFade_sunHeight.y));
|
||||
float3 scatterColour = shLerp(vec3(SCATTER_COLOUR)*vec3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||
|
||||
// fresnel
|
||||
float ior = (cameraPos.y>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
|
||||
float fresnel = fresnel_dielectric(-vVec, normal, ior);
|
||||
|
||||
fresnel = shSaturate(fresnel);
|
||||
|
||||
// reflection
|
||||
float3 reflection = shSample(reflectionMap, screenCoords+(normal.xz*REFL_BUMP)).rgb;
|
||||
|
||||
// refraction
|
||||
float3 R = reflect(vVec, normal);
|
||||
|
||||
float3 refraction = float3(0,0,0);
|
||||
refraction.r = shSample(refractionMap, (screenCoords-(shoreFade * normal.xz*REFR_BUMP))*1.0).r;
|
||||
refraction.g = shSample(refractionMap, (screenCoords-(shoreFade * normal.xz*REFR_BUMP))*1.0-(R.xy*ABBERATION)).g;
|
||||
refraction.b = shSample(refractionMap, (screenCoords-(shoreFade * normal.xz*REFR_BUMP))*1.0-(R.xy*ABBERATION*2.0)).b;
|
||||
|
||||
// brighten up the refraction underwater
|
||||
refraction = (cameraPos.y < 0) ? shSaturate(refraction * 1.5) : refraction;
|
||||
|
||||
// specular
|
||||
float specular = pow(max(dot(R, lVec), 0.0),SPEC_HARDNESS);
|
||||
|
||||
shOutputColour(0).xyz = shLerp( shLerp(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * sunSpecular.xyz;
|
||||
|
||||
// smooth transition to shore (above water only)
|
||||
shOutputColour(0).xyz = shLerp(shOutputColour(0).xyz, refraction, (1-shoreFade) * (1-isUnderwater));
|
||||
|
||||
// fog
|
||||
if (isUnderwater == 1)
|
||||
{
|
||||
float waterSunGradient = dot(-vVec, -lVec);
|
||||
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
||||
float3 waterSunColour = float3(0.0,1.0,0.85)*waterSunGradient * 0.5;
|
||||
|
||||
float waterGradient = dot(-vVec, float3(0.0,-1.0,0.0));
|
||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
||||
watercolour = mix(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||
|
||||
float darkness = VISIBILITY*2.0;
|
||||
darkness = clamp((cameraPos.y+darkness)/darkness,0.2,1.0);
|
||||
|
||||
|
||||
float fog = shSaturate(length(cameraPos.xyz-position.xyz) / VISIBILITY);
|
||||
shOutputColour(0).xyz = shLerp(shOutputColour(0).xyz, watercolour * darkness, shSaturate(fog / waterext));
|
||||
}
|
||||
else
|
||||
{
|
||||
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
shader_set water_vertex
|
||||
{
|
||||
source water.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set water_fragment
|
||||
{
|
||||
source water.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,68 +1,72 @@
|
||||
# Minimal MyGUI build system for OpenMW
|
||||
|
||||
# Copy resource files into the build directory
|
||||
set(SDIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(DDIR ${OpenMW_BINARY_DIR}/resources/mygui)
|
||||
|
||||
configure_file("${SDIR}/bigbars.png" "${DDIR}/bigbars.png" COPYONLY)
|
||||
configure_file("${SDIR}/black.png" "${DDIR}/black.png" COPYONLY)
|
||||
configure_file("${SDIR}/core.skin" "${DDIR}/core.skin" COPYONLY)
|
||||
configure_file("${SDIR}/core.xml" "${DDIR}/core.xml" COPYONLY)
|
||||
configure_file("${SDIR}/mwgui.png" "${DDIR}/mwgui.png" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_resources.xml" "${DDIR}/openmw_resources.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_settings.xml" "${DDIR}/openmw_settings.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_box.skin.xml" "${DDIR}/openmw_box.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_button.skin.xml" "${DDIR}/openmw_button.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_list.skin.xml" "${DDIR}/openmw_list.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_edit.skin.xml" "${DDIR}/openmw_edit.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_console.layout" "${DDIR}/openmw_console.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_console.skin.xml" "${DDIR}/openmw_console.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw.font.xml" "${DDIR}/openmw.font.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_hud_box.skin.xml" "${DDIR}/openmw_hud_box.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_hud_energybar.skin.xml" "${DDIR}/openmw_hud_energybar.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_hud.layout" "${DDIR}/openmw_hud.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_text_input.layout" "${DDIR}/openmw_text_input.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_infobox.layout" "${DDIR}/openmw_infobox.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_race.layout" "${DDIR}/openmw_chargen_race.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_class.layout" "${DDIR}/openmw_chargen_class.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_generate_class_result.layout" "${DDIR}/openmw_chargen_generate_class_result.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_create_class.layout" "${DDIR}/openmw_chargen_create_class.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_select_specialization.layout" "${DDIR}/openmw_chargen_select_specialization.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_select_attribute.layout" "${DDIR}/openmw_chargen_select_attribute.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_select_skill.layout" "${DDIR}/openmw_chargen_select_skill.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_class_description.layout" "${DDIR}/openmw_chargen_class_description.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_birth.layout" "${DDIR}/openmw_chargen_birth.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_chargen_review.layout" "${DDIR}/openmw_chargen_review.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_dialogue_window.layout" "${DDIR}/openmw_dialogue_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_dialogue_window_skin.xml" "${DDIR}/openmw_dialogue_window_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_inventory_window.layout" "${DDIR}/openmw_inventory_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_container_window.layout" "${DDIR}/openmw_container_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_mainmenu.layout" "${DDIR}/openmw_mainmenu.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_mainmenu_skin.xml" "${DDIR}/openmw_mainmenu_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_map_window.layout" "${DDIR}/openmw_map_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_map_window_skin.xml" "${DDIR}/openmw_map_window_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw.pointer.xml" "${DDIR}/openmw.pointer.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_progress.skin.xml" "${DDIR}/openmw_progress.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_stats_window.layout" "${DDIR}/openmw_stats_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_text.skin.xml" "${DDIR}/openmw_text.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_windows.skin.xml" "${DDIR}/openmw_windows.skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_messagebox.layout" "${DDIR}/openmw_messagebox.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_interactive_messagebox.layout" "${DDIR}/openmw_interactive_messagebox.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_journal.layout" "${DDIR}/openmw_journal.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_journal_skin.xml" "${DDIR}/openmw_journal_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_tooltips.layout" "${DDIR}/openmw_tooltips.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_scroll.layout" "${DDIR}/openmw_scroll.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_scroll_skin.xml" "${DDIR}/openmw_scroll_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_book.layout" "${DDIR}/openmw_book.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_count_window.layout" "${DDIR}/openmw_count_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_trade_window.layout" "${DDIR}/openmw_trade_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_settings_window.layout" "${DDIR}/openmw_settings_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_confirmation_dialog.layout" "${DDIR}/openmw_confirmation_dialog.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_alchemy_window.layout" "${DDIR}/openmw_alchemy_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_spell_window.layout" "${DDIR}/openmw_spell_window.layout" COPYONLY)
|
||||
configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY)
|
||||
configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY)
|
||||
configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY)
|
||||
configure_file("${SDIR}/Obliviontt.zip" "${DDIR}/Obliviontt.zip" COPYONLY)
|
||||
configure_file("${SDIR}/VeraMono.ttf" "${DDIR}/VeraMono.ttf" COPYONLY)
|
||||
set(MYGUI_FILES
|
||||
atlas1.cfg
|
||||
bigbars.png
|
||||
black.png
|
||||
core.skin
|
||||
core.xml
|
||||
EBGaramond-Regular.ttf
|
||||
mwgui.png
|
||||
Obliviontt.zip
|
||||
openmw_alchemy_window.layout
|
||||
openmw_book.layout
|
||||
openmw_box.skin.xml
|
||||
openmw_button.skin.xml
|
||||
openmw_chargen_birth.layout
|
||||
openmw_chargen_class_description.layout
|
||||
openmw_chargen_class.layout
|
||||
openmw_chargen_create_class.layout
|
||||
openmw_chargen_generate_class_result.layout
|
||||
openmw_chargen_race.layout
|
||||
openmw_chargen_review.layout
|
||||
openmw_chargen_select_attribute.layout
|
||||
openmw_chargen_select_skill.layout
|
||||
openmw_chargen_select_specialization.layout
|
||||
openmw_confirmation_dialog.layout
|
||||
openmw_console.layout
|
||||
openmw_console.skin.xml
|
||||
openmw_container_window.layout
|
||||
openmw_count_window.layout
|
||||
openmw_dialogue_window.layout
|
||||
openmw_dialogue_window_skin.xml
|
||||
openmw_edit.skin.xml
|
||||
openmw.font.xml
|
||||
openmw_hud_box.skin.xml
|
||||
openmw_hud_energybar.skin.xml
|
||||
openmw_hud.layout
|
||||
openmw_infobox.layout
|
||||
openmw_interactive_messagebox.layout
|
||||
openmw_inventory_window.layout
|
||||
openmw_journal.layout
|
||||
openmw_journal_skin.xml
|
||||
openmw_layers.xml
|
||||
openmw_list.skin.xml
|
||||
openmw_mainmenu.layout
|
||||
openmw_mainmenu_skin.xml
|
||||
openmw_map_window.layout
|
||||
openmw_map_window_skin.xml
|
||||
openmw_messagebox.layout
|
||||
openmw.pointer.xml
|
||||
openmw_progress.skin.xml
|
||||
openmw_resources.xml
|
||||
openmw_scroll.layout
|
||||
openmw_scroll_skin.xml
|
||||
openmw_settings_window.layout
|
||||
openmw_settings.xml
|
||||
openmw_spell_window.layout
|
||||
openmw_stats_window.layout
|
||||
openmw_text_input.layout
|
||||
openmw_text.skin.xml
|
||||
openmw_tooltips.layout
|
||||
openmw_trade_window.layout
|
||||
openmw_windows.skin.xml
|
||||
smallbars.png
|
||||
VeraMono.ttf
|
||||
)
|
||||
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR} ${DDIR} "${MYGUI_FILES}")
|
||||
|
@ -1,11 +0,0 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=${OGRE_PLUGIN_DIR_REL}
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_GL${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_ParticleFX${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_OctreeSceneManager${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_CgProgramManager${DEBUG_SUFFIX}
|
||||
|
@ -1,12 +0,0 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=${OGRE_PLUGIN_DIR}
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_GL${DEBUG_SUFFIX}.1.8.0
|
||||
Plugin=Plugin_ParticleFX${DEBUG_SUFFIX}.1.8.0
|
||||
Plugin=Plugin_OctreeSceneManager${DEBUG_SUFFIX}.1.8.0
|
||||
Plugin=Plugin_CgProgramManager${DEBUG_SUFFIX}.1.8.0
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=.\
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_Direct3D9${DEBUG_SUFFIX}
|
||||
Plugin=RenderSystem_GL${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_ParticleFX${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_OctreeSceneManager${DEBUG_SUFFIX}
|
||||
Plugin=Plugin_CgProgramManager${DEBUG_SUFFIX}
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
void main_vp(
|
||||
float4 position : POSITION,
|
||||
float2 uv : TEXCOORD0,
|
||||
|
||||
out float4 oPosition : POSITION,
|
||||
out float2 oDepth : TEXCOORD0,
|
||||
out float2 oUv : TEXCOORD1,
|
||||
|
||||
uniform float4x4 wvpMat)
|
||||
{
|
||||
// this is the view space position
|
||||
oPosition = mul(wvpMat, position);
|
||||
|
||||
// depth info for the fragment.
|
||||
oDepth.x = oPosition.z;
|
||||
oDepth.y = oPosition.w;
|
||||
|
||||
// clamp z to zero. seem to do the trick. :-/
|
||||
oPosition.z = max(oPosition.z, 0);
|
||||
|
||||
oUv = uv;
|
||||
}
|
||||
|
||||
void main_fp(
|
||||
float2 depth : TEXCOORD0,
|
||||
float2 uv : TEXCOORD1,
|
||||
uniform sampler2D texture1 : register(s0),
|
||||
|
||||
out float4 oColour : COLOR)
|
||||
{
|
||||
float finalDepth = depth.x / depth.y;
|
||||
|
||||
// use alpha channel of the first texture
|
||||
float alpha = tex2D(texture1, uv).a;
|
||||
|
||||
// discard if alpha is less than 0.5
|
||||
clip((alpha >= 0.5) ? 1 : -1);
|
||||
|
||||
oColour = float4(finalDepth, finalDepth, finalDepth, 1);
|
||||
}
|
||||
|
||||
void main_fp_noalpha(
|
||||
float2 depth : TEXCOORD0,
|
||||
float2 uv : TEXCOORD1,
|
||||
|
||||
out float4 oColour : COLOR)
|
||||
{
|
||||
float finalDepth = depth.x / depth.y;
|
||||
|
||||
oColour = float4(finalDepth, finalDepth, finalDepth, 1);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
vertex_program depth_shadow_caster_vs cg
|
||||
{
|
||||
source depthshadowcaster.cg
|
||||
profiles vs_1_1 arbvp1
|
||||
entry_point main_vp
|
||||
|
||||
default_params
|
||||
{
|
||||
param_named_auto wvpMat worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
fragment_program depth_shadow_caster_ps cg
|
||||
{
|
||||
source depthshadowcaster.cg
|
||||
profiles ps_2_0 arbfp1
|
||||
entry_point main_fp
|
||||
|
||||
default_params
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
fragment_program depth_shadow_caster_ps_noalpha cg
|
||||
{
|
||||
source depthshadowcaster.cg
|
||||
profiles ps_2_0 arbfp1
|
||||
entry_point main_fp_noalpha
|
||||
|
||||
default_params
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
material depth_shadow_caster
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
// force-disable fog (relevant for DirectX profiles below SM3 that always apply fixed function fog)
|
||||
fog_override true
|
||||
|
||||
vertex_program_ref depth_shadow_caster_vs
|
||||
{
|
||||
}
|
||||
|
||||
fragment_program_ref depth_shadow_caster_ps
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material depth_shadow_caster_noalpha
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
// force-disable fog (relevant for DirectX profiles below SM3 that always apply fixed function fog)
|
||||
fog_override true
|
||||
|
||||
vertex_program_ref depth_shadow_caster_vs
|
||||
{
|
||||
}
|
||||
|
||||
fragment_program_ref depth_shadow_caster_ps_noalpha
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 192 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
@ -1,61 +0,0 @@
|
||||
void main_vp
|
||||
(
|
||||
in float4 inPos : POSITION,
|
||||
|
||||
out float4 pos : POSITION,
|
||||
out float2 uv0 : TEXCOORD0,
|
||||
out float4 noiseCoord : TEXCOORD1,
|
||||
|
||||
uniform float4x4 worldViewProj,
|
||||
uniform float timeVal,
|
||||
uniform float scale
|
||||
)
|
||||
{
|
||||
// Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
|
||||
pos = mul(worldViewProj, inPos);
|
||||
|
||||
// The input positions adjusted by texel offsets, so clean up inaccuracies
|
||||
inPos.xy = sign(inPos.xy);
|
||||
|
||||
// Convert to image-space
|
||||
uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
|
||||
noiseCoord = (pos + timeVal) * scale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float4 main_fp_nomrt (float2 iTexCoord : TEXCOORD0,
|
||||
float3 noiseCoord : TEXCOORD1,
|
||||
uniform sampler2D RT : register(s0),
|
||||
uniform sampler2D NormalMap : register(s1),
|
||||
uniform sampler2D CausticMap : register(s2)) : COLOR
|
||||
{
|
||||
float4 normal = tex2D(NormalMap, noiseCoord) * 2 - 1;
|
||||
|
||||
float4 col = tex2D(RT, iTexCoord + normal.xy * 0.015) +
|
||||
(tex2D(CausticMap, noiseCoord) / 5);
|
||||
col.xyz = lerp(col.xyz, float3(0.15, 0.40, 0.40), 0.4);
|
||||
return col;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float4 main_fp (float2 iTexCoord : TEXCOORD0,
|
||||
float3 noiseCoord : TEXCOORD1,
|
||||
uniform float far,
|
||||
uniform sampler2D RT : register(s0),
|
||||
uniform sampler2D NormalMap : register(s1),
|
||||
uniform sampler2D CausticMap : register(s2),
|
||||
uniform sampler2D DepthMap : register(s3)) : COLOR
|
||||
{
|
||||
float4 normal = tex2D(NormalMap, noiseCoord) * 2 - 1;
|
||||
|
||||
float depth = tex2D(DepthMap, iTexCoord + normal.xy * 0.015).r * far;
|
||||
depth = saturate(depth / 2000.f);
|
||||
|
||||
float4 color = tex2D(RT, iTexCoord + normal.xy * 0.015) +
|
||||
(tex2D(CausticMap, noiseCoord) / 5);
|
||||
color.xyz = lerp(color.xyz, float3(0.15, 0.40, 0.40), 0.4);
|
||||
|
||||
return lerp(color, float4(0.15, 0.40, 0.40, 1), depth);
|
||||
}
|
Binary file not shown.
@ -1,121 +0,0 @@
|
||||
void main_vp
|
||||
(
|
||||
in float4 iPos : POSITION
|
||||
, in float2 iUv : TEXCOORD0
|
||||
|
||||
, out float4 oPos : POSITION
|
||||
, out float3 oScreenCoords : TEXCOORD0
|
||||
, out float2 oUv : TEXCOORD1
|
||||
, out float oDepth : TEXCOORD2
|
||||
, out float4 oEyeVector : TEXCOORD3
|
||||
|
||||
, uniform float4x4 wvpMat
|
||||
, uniform float4 camPosObjSpace
|
||||
)
|
||||
{
|
||||
oPos = mul(wvpMat, iPos);
|
||||
|
||||
oUv = iUv * 10; // uv scale
|
||||
oDepth = oPos.z;
|
||||
|
||||
float4x4 scalemat = float4x4( 0.5, 0, 0, 0.5,
|
||||
0, -0.5, 0, 0.5,
|
||||
0, 0, 0.5, 0.5,
|
||||
0, 0, 0, 1 );
|
||||
float4 texcoordProj = mul(scalemat, oPos);
|
||||
oScreenCoords = float3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
|
||||
|
||||
oEyeVector = camPosObjSpace - iPos;
|
||||
}
|
||||
|
||||
void main_fp
|
||||
(
|
||||
out float4 oColor : COLOR
|
||||
|
||||
, in float3 iScreenCoords : TEXCOORD0
|
||||
, in float2 iUv : TEXCOORD1
|
||||
, in float iDepth : TEXCOORD2
|
||||
, in float4 iEyeVector : TEXCOORD3
|
||||
, uniform float renderTargetFlipping
|
||||
, uniform float4 lightPosObjSpace0
|
||||
, uniform float4 lightSpecularColour0
|
||||
|
||||
, uniform sampler2D reflectionMap : register(s0)
|
||||
, uniform sampler2D refractionMap : register(s1)
|
||||
, uniform sampler2D depthMap : register(s2)
|
||||
, uniform sampler2D normalMap : register(s3)
|
||||
, uniform float time
|
||||
, uniform float far
|
||||
, uniform float4 fogParams
|
||||
, uniform float4 fogColour
|
||||
, uniform float isUnderwater
|
||||
)
|
||||
{
|
||||
|
||||
float2 screenCoords = iScreenCoords.xy / iScreenCoords.z;
|
||||
screenCoords.y = (1-saturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
||||
|
||||
// No need for transparency since we are using a refraction map
|
||||
oColor.a = 1;
|
||||
|
||||
// Sample screen-space depth map and subtract pixel depth to get the real water depth
|
||||
float depthTex = tex2D(depthMap, screenCoords).r;
|
||||
float depth1 = depthTex * far - iDepth;
|
||||
depth1 = saturate(depth1 / 500.f);
|
||||
|
||||
// Simple wave effect. to be replaced by something better
|
||||
float2 uv1 = iUv + time * float2(0.5, 0);
|
||||
float2 uv2 = iUv + time * float2(0, 0.5);
|
||||
float2 uv3 = iUv + time * float2(-0.5, 0);
|
||||
float2 uv4 = iUv + time * float2(0, -0.5);
|
||||
float4 normal = tex2D(normalMap, uv1) + tex2D(normalMap, uv2) + tex2D(normalMap, uv3) + tex2D(normalMap, uv4);
|
||||
normal = normal / 4.f;
|
||||
normal = 2*normal - 1;
|
||||
|
||||
float2 screenCoords_reflect = screenCoords + normal.yx * 0.05;
|
||||
float2 screenCoords_refract = screenCoords + normal.yx * 0.05 * depth1;
|
||||
|
||||
// Sample depth again with the refracted coordinates
|
||||
depthTex = tex2D(depthMap, screenCoords_refract).r;
|
||||
float depth2 = (depthTex * far - iDepth) / 500.f;
|
||||
depth2 = (depthTex == 0 ? 1 : depth2);
|
||||
// if depth2 is less than 0, this means we would refract something which is above water,
|
||||
// which we don't want to - so in that case, don't refract
|
||||
if (depth2 < 0.25) // delta due to inaccuracies
|
||||
{
|
||||
screenCoords_refract = screenCoords;
|
||||
depth2 = depth1;
|
||||
}
|
||||
depth2 = saturate(depth2);
|
||||
|
||||
float4 reflection = tex2D(reflectionMap, screenCoords_reflect);
|
||||
float4 refraction = tex2D(refractionMap, screenCoords_refract);
|
||||
|
||||
// tangent to object space
|
||||
normal.xyz = normal.xzy;
|
||||
|
||||
iEyeVector.xyz = normalize(iEyeVector.xyz);
|
||||
|
||||
// fresnel
|
||||
float facing = 1.0 - max(abs(dot(iEyeVector.xyz, normal.xyz)), 0);
|
||||
float reflectionFactor = saturate(0.35 + 0.65 * pow(facing, 2));
|
||||
|
||||
// specular
|
||||
float3 lightDir = normalize(lightPosObjSpace0.xyz); // assumes that light 0 is a directional light
|
||||
float3 halfVector = normalize(iEyeVector + lightDir);
|
||||
float specular = pow(max(dot(normal.xyz, halfVector.xyz), 0), 64);
|
||||
|
||||
float opacity = depth2 * saturate(reflectionFactor + specular);
|
||||
opacity *= (1-isUnderwater);
|
||||
|
||||
reflection.xyz += lightSpecularColour0.xyz * specular;
|
||||
|
||||
oColor.xyz = lerp(refraction.xyz, reflection.xyz, opacity);
|
||||
|
||||
oColor.xyz = lerp(oColor.xyz, float3(0.15, 0.40, 0.40), isUnderwater*0.6); // underwater tint color
|
||||
oColor.xyz = lerp(oColor.xyz, float3(0.15, 0.40, 0.40), saturate(isUnderwater * (iDepth / 2000.f))); // underwater fog
|
||||
|
||||
// add fog
|
||||
//float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
||||
//oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
compositor UnderwaterNoMRT
|
||||
{
|
||||
technique
|
||||
{
|
||||
texture rt0 target_width target_height PF_R8G8B8
|
||||
|
||||
target rt0 { input previous }
|
||||
|
||||
target_output
|
||||
{
|
||||
// Start with clear output
|
||||
input none
|
||||
|
||||
pass render_quad
|
||||
{
|
||||
material Water/CompositorNoMRT
|
||||
input 0 rt0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
compositor Underwater
|
||||
{
|
||||
technique
|
||||
{
|
||||
texture_ref scene gbuffer mrt_output
|
||||
texture rt0 target_width target_height PF_R8G8B8
|
||||
|
||||
target rt0 { input previous }
|
||||
|
||||
target_output
|
||||
{
|
||||
// Start with clear output
|
||||
input none
|
||||
|
||||
pass render_quad
|
||||
{
|
||||
material Water/Compositor
|
||||
input 0 rt0
|
||||
input 3 scene 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
vertex_program UnderwaterEffectVP cg
|
||||
{
|
||||
source underwater.cg
|
||||
entry_point main_vp
|
||||
profiles vs_1_1 arbvp1
|
||||
|
||||
default_params
|
||||
{
|
||||
param_named_auto worldViewProj worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fragment_program UnderwaterEffectFP_NoMRT cg
|
||||
{
|
||||
source underwater.cg
|
||||
entry_point main_fp_nomrt
|
||||
profiles ps_2_0 arbfp1
|
||||
}
|
||||
|
||||
fragment_program UnderwaterEffectFP cg
|
||||
{
|
||||
source underwater.cg
|
||||
entry_point main_fp
|
||||
profiles ps_2_0 arbfp1
|
||||
}
|
||||
|
||||
vertex_program Water_VP cg
|
||||
{
|
||||
source water.cg
|
||||
entry_point main_vp
|
||||
profiles vs_2_x arbvp1
|
||||
|
||||
default_params
|
||||
{
|
||||
param_named_auto wvpMat worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
fragment_program Water_FP cg
|
||||
{
|
||||
source water.cg
|
||||
entry_point main_fp
|
||||
profiles ps_2_x arbfp1
|
||||
}
|
||||
|
||||
material Water
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
cull_hardware none
|
||||
|
||||
vertex_program_ref Water_VP
|
||||
{
|
||||
param_named_auto camPosObjSpace camera_position_object_space
|
||||
}
|
||||
fragment_program_ref Water_FP
|
||||
{
|
||||
param_named_auto time time 0.1
|
||||
//param_named_auto fogColour fog_colour
|
||||
//param_named_auto fogParams fog_params
|
||||
param_named_auto renderTargetFlipping render_target_flipping
|
||||
param_named_auto far far_clip_distance
|
||||
param_named_auto lightPosObjSpace0 light_position_object_space 0
|
||||
param_named_auto lightSpecularColour0 light_specular_colour 0
|
||||
param_named isUnderwater float 0
|
||||
}
|
||||
|
||||
texture_unit reflectionMap
|
||||
{
|
||||
texture WaterReflection
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit refractionMap
|
||||
{
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit depthMap
|
||||
{
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit normalMap
|
||||
{
|
||||
texture WaterNormal2.tga
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
technique
|
||||
{
|
||||
scheme Fallback
|
||||
pass
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
diffuse 0 0 0 1
|
||||
emissive 0.6 0.7 1.0
|
||||
ambient 0 0 0
|
||||
texture_unit
|
||||
{
|
||||
// texture names set via code
|
||||
scale 0.1 0.1
|
||||
alpha_op_ex source1 src_manual src_current 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
material Water_Fallback
|
||||
{
|
||||
technique
|
||||
{
|
||||
scheme Fallback
|
||||
pass
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
diffuse 0 0 0 1
|
||||
emissive 0.6 0.7 1.0
|
||||
ambient 0 0 0
|
||||
texture_unit
|
||||
{
|
||||
// texture names set via code
|
||||
scale 0.1 0.1
|
||||
alpha_op_ex source1 src_manual src_current 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material Water/CompositorNoMRT
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_check off
|
||||
vertex_program_ref UnderwaterEffectVP
|
||||
{
|
||||
param_named_auto timeVal time 0.25
|
||||
param_named scale float 0.1
|
||||
}
|
||||
|
||||
fragment_program_ref UnderwaterEffectFP_NoMRT
|
||||
{
|
||||
}
|
||||
|
||||
texture_unit RT
|
||||
{
|
||||
tex_coord_set 0
|
||||
tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture WaterNormal2.tga 2d
|
||||
tex_coord_set 1
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture caustic_0.png 2d
|
||||
tex_coord_set 2
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material Water/Compositor
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_check off
|
||||
vertex_program_ref UnderwaterEffectVP
|
||||
{
|
||||
param_named_auto timeVal time 0.25
|
||||
param_named scale float 0.1
|
||||
}
|
||||
|
||||
fragment_program_ref UnderwaterEffectFP
|
||||
{
|
||||
param_named_auto far far_clip_distance
|
||||
}
|
||||
|
||||
texture_unit RT
|
||||
{
|
||||
tex_coord_set 0
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture WaterNormal2.tga 2d
|
||||
tex_coord_set 2
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture caustic_0.png 2d
|
||||
tex_coord_set 3
|
||||
}
|
||||
|
||||
texture_unit DepthMap
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Loading…
Reference in New Issue