Upload
BIN
Data/textures/Ashes.jpg
Normal file
After Width: | Height: | Size: 226 KiB |
BIN
Data/textures/Gras.jpg
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
Data/textures/Mud.jpg
Normal file
After Width: | Height: | Size: 276 KiB |
BIN
Data/textures/Pebbles.jpg
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
Data/textures/Rock.jpg
Normal file
After Width: | Height: | Size: 248 KiB |
BIN
Data/textures/Sand.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
Data/textures/Snow.jpg
Normal file
After Width: | Height: | Size: 174 KiB |
BIN
Data/textures/black.jpg
Normal file
After Width: | Height: | Size: 285 B |
BIN
Data/textures/lava.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_1.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_10.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_11.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_12.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_13.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_14.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_15.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_16.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_17.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_18.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_19.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_2.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_20.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_21.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_22.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_23.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_24.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_25.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_26.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_27.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_28.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_29.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_3.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_4.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_5.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
Data/textures/lava_6.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_7.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lava_8.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
Data/textures/lava_9.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/lm_terrain.tga
Normal file
BIN
Data/textures/postprocess/noise1.png
Normal file
After Width: | Height: | Size: 563 KiB |
BIN
Data/textures/postprocess/noise2.png
Normal file
After Width: | Height: | Size: 218 KiB |
BIN
Data/textures/postprocess/pencil.png
Normal file
After Width: | Height: | Size: 40 KiB |
12
Data/textures/postprocess/readme.txt
Normal file
@ -0,0 +1,12 @@
|
||||
noise2.png from nvidia shader library
|
||||
http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
pencil.png based on the work of Shawn Hargreaves
|
||||
http://www.talula.demon.co.uk/postprocessing/postprocessing.html
|
||||
|
||||
water.png taken from sauerbraten (author not known)
|
||||
http://sauerbraten.org
|
||||
|
||||
other textures by tbw
|
||||
The textures are free for non-commercial and commercial use. You're free to use and modify them.
|
||||
Attribution would be nice.
|
BIN
Data/textures/postprocess/scope.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
Data/textures/postprocess/water.png
Normal file
After Width: | Height: | Size: 233 KiB |
BIN
Data/textures/skydome.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Data/textures/splat_1.tga
Normal file
BIN
Data/textures/splat_2.tga
Normal file
BIN
Data/textures/splat_3.tga
Normal file
BIN
Data/textures/splat_4.tga
Normal file
After Width: | Height: | Size: 768 KiB |
BIN
Data/textures/splatting_test.png
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
Data/textures/water/default_water_source_animated_normal.png
Normal file
After Width: | Height: | Size: 26 KiB |
1
Data/textures/water/readme.txt
Normal file
@ -0,0 +1 @@
|
||||
water.png from http://members.gamedev.net/jasjas/normalmap1.png (free)
|
BIN
Data/textures/water/water.png
Normal file
After Width: | Height: | Size: 2.3 MiB |
67
IPostProcess.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef _IPOSTPROCESS_H
|
||||
#define _IPOSTPROCESS_H
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
class IPostProcess : virtual public IReferenceCounted
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
IPostProcess(const core::stringc& name)
|
||||
{
|
||||
// create screen quad vertices
|
||||
Vertices[0] = video::S3DVertex(-1.f, -1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 0.f, 1.f);
|
||||
Vertices[1] = video::S3DVertex(-1.f, 1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 0.f, 0.f);
|
||||
Vertices[2] = video::S3DVertex( 1.f, 1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 1.f, 0.f);
|
||||
Vertices[3] = video::S3DVertex( 1.f, -1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 1.f, 1.f);
|
||||
|
||||
// setup the corresponding indices
|
||||
Indices[0] = 0;
|
||||
Indices[1] = 1;
|
||||
Indices[2] = 2;
|
||||
Indices[3] = 2;
|
||||
Indices[4] = 3;
|
||||
Indices[5] = 0;
|
||||
|
||||
// set the name of the postprocess
|
||||
Name = name;
|
||||
}
|
||||
|
||||
protected:
|
||||
// screend quad mesh
|
||||
video::S3DVertex Vertices[4];
|
||||
u16 Indices[6];
|
||||
|
||||
// name of the postprocess
|
||||
core::stringc Name;
|
||||
|
||||
// input and output target for the postprocess
|
||||
core::stringc RenderTarget;
|
||||
core::stringc RenderSource;
|
||||
|
||||
public:
|
||||
// set the rendertarget
|
||||
virtual void setRenderTarget(const core::stringc& renderTarget) { RenderTarget = renderTarget; }
|
||||
|
||||
// returns the rendertarget
|
||||
virtual const core::stringc& getRenderTarget() { return RenderTarget; }
|
||||
|
||||
// sets the rendersource (texturelayer 0 of the postprocess material)
|
||||
virtual void setRenderSource(const core::stringc& renderSource) { RenderSource = renderSource; }
|
||||
|
||||
// returns the rendersource
|
||||
virtual const core::stringc& getRenderSource() { return RenderSource; }
|
||||
|
||||
// returns the name of the postprocess
|
||||
virtual const core::stringc& getName() { return Name; }
|
||||
|
||||
// returns the SMaterial struct of the postprocess
|
||||
virtual video::SMaterial& getMaterial() = 0;
|
||||
|
||||
// renders the postprocess
|
||||
virtual void render() = 0;
|
||||
};
|
||||
|
||||
#endif
|
432
PostProcessManager.cpp
Normal file
@ -0,0 +1,432 @@
|
||||
#include "PostProcessManager.h"
|
||||
#include "IPostProcess.h"
|
||||
#include "ShaderPostProcess.h"
|
||||
|
||||
CPostProcessManager::CPostProcessManager(IrrlichtDevice* device)
|
||||
: Device(device)
|
||||
{
|
||||
// store driver flags
|
||||
bool flagMipMaps = Device->getVideoDriver()->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
|
||||
bool flag32Bit = Device->getVideoDriver()->getTextureCreationFlag(video::ETCF_ALWAYS_32_BIT);
|
||||
|
||||
// set new flags for rtt creation
|
||||
Device->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
|
||||
Device->getVideoDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT);
|
||||
|
||||
// load the rtt and effect configuration
|
||||
loadRTTConfig("config/rtt.xml");
|
||||
loadEffectConfig("config/effect.xml");
|
||||
|
||||
// prepare the depth material for depth pass
|
||||
DepthMaterial = new CShaderMaterial(Device, "Depth", "material/depth.vsh", "main", video::EVST_VS_1_1, "material/depth.psh", "main", video::EPST_PS_2_0, video::EMT_SOLID);
|
||||
DepthMaterial->setVertexShaderFlag(ESC_WORLD);
|
||||
DepthMaterial->setVertexShaderFlag(ESC_VIEW);
|
||||
DepthMaterial->setVertexShaderFlag(ESC_PROJECTION);
|
||||
|
||||
// restore driver flags
|
||||
Device->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flagMipMaps);
|
||||
Device->getVideoDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, flag32Bit);
|
||||
}
|
||||
|
||||
CPostProcessManager::~CPostProcessManager()
|
||||
{
|
||||
// drop all post process objects
|
||||
for(u32 i=0; i<EPPE_COUNT; i++)
|
||||
{
|
||||
for(u32 j=0; j<EffectChain[i].size(); j++)
|
||||
{
|
||||
IPostProcess* postProcess = EffectChain[i][j];
|
||||
if (postProcess)
|
||||
postProcess->drop();
|
||||
}
|
||||
}
|
||||
|
||||
// and drop the depth material
|
||||
if (DepthMaterial) {
|
||||
delete DepthMaterial;
|
||||
DepthMaterial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CPostProcessManager::SwapAuxBuffers()
|
||||
{
|
||||
// swap the in and out buffers
|
||||
video::ITexture* tmp = RenderTargetMap["auxIn"];
|
||||
video::ITexture* tmp2 = RenderTargetMap["auxOut"];
|
||||
|
||||
RenderTargetMap["auxIn"] = tmp2;
|
||||
RenderTargetMap["auxOut"] = tmp;
|
||||
}
|
||||
|
||||
void CPostProcessManager::prepare()
|
||||
{
|
||||
// set auxOut RTT as RenderTarget
|
||||
Device->getVideoDriver()->setRenderTarget(RenderTargetMap["auxOut"]);
|
||||
}
|
||||
|
||||
void CPostProcessManager::render(E_POSTPROCESS_EFFECT effect)
|
||||
{
|
||||
if (effect<EPPE_COUNT)
|
||||
{
|
||||
// first swap the in and out buffers
|
||||
if (EffectChain[effect].size())
|
||||
SwapAuxBuffers();
|
||||
|
||||
// run through the effect chain
|
||||
for (u32 i=0; i<EffectChain[effect].size(); i++)
|
||||
{
|
||||
// retrieve the post process
|
||||
IPostProcess* postProcess = EffectChain[effect][i];
|
||||
|
||||
// bind input buffer
|
||||
if( !postProcess->getRenderSource().empty())
|
||||
postProcess->getMaterial().setTexture(0, RenderTargetMap[postProcess->getRenderSource()]);
|
||||
|
||||
// bind output buffer
|
||||
if( !postProcess->getRenderTarget().empty())
|
||||
Device->getVideoDriver()->setRenderTarget(RenderTargetMap[postProcess->getRenderTarget()]);
|
||||
else
|
||||
Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
|
||||
|
||||
// render the post process
|
||||
postProcess->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPostProcessManager::update()
|
||||
{
|
||||
// render the final pass
|
||||
render(EPPE_FINAL_PASS);
|
||||
}
|
||||
|
||||
void CPostProcessManager::clearDepthPass()
|
||||
{
|
||||
// clear all nodes from the depth pass
|
||||
DepthPassNodes.clear();
|
||||
}
|
||||
|
||||
void CPostProcessManager::addNodeToDepthPass(scene::ISceneNode *node)
|
||||
{
|
||||
// add node to the depth pass array
|
||||
if(DepthPassNodes.binary_search(node) == -1)
|
||||
DepthPassNodes.push_back(node);
|
||||
}
|
||||
|
||||
void CPostProcessManager::removeNodeFromDepthPass(scene::ISceneNode *node)
|
||||
{
|
||||
// remove node from depth pass array
|
||||
s32 index = DepthPassNodes.binary_search(node);
|
||||
if(index != -1)
|
||||
DepthPassNodes.erase(index);
|
||||
}
|
||||
|
||||
void CPostProcessManager::renderDepth(const video::SColor& defaultDepth)
|
||||
{
|
||||
if(DepthPassNodes.size())
|
||||
{
|
||||
// animate and render the camera to ensure correct depth and normal information
|
||||
scene::ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
|
||||
if (camera)
|
||||
{
|
||||
camera->OnRegisterSceneNode();
|
||||
camera->OnAnimate(Device->getTimer()->getTime());
|
||||
camera->render();
|
||||
DepthMaterial->setPixelShaderConstant("MaxDistance", camera->getFarValue());
|
||||
}
|
||||
// set depth render target texture as render target
|
||||
Device->getVideoDriver()->setRenderTarget(RenderTargetMap["rttDepth"], true, true, defaultDepth);
|
||||
|
||||
// render all nodes that are stored in the depth pass array
|
||||
for(u32 i=0; i<DepthPassNodes.size(); i++)
|
||||
{
|
||||
// get the scene node from the array
|
||||
scene::ISceneNode* node = DepthPassNodes[i];
|
||||
|
||||
if (node->isVisible())
|
||||
{
|
||||
// save the scene node materials
|
||||
core::array<video::E_MATERIAL_TYPE> bufferMaterialList(node->getMaterialCount());
|
||||
bufferMaterialList.set_used(0);
|
||||
|
||||
for(u32 j=0; j<node->getMaterialCount(); j++)
|
||||
bufferMaterialList.push_back(node->getMaterial(j).MaterialType);
|
||||
|
||||
// apply the depth material
|
||||
node->setMaterialType(DepthMaterial->getMaterialType());
|
||||
|
||||
// animate the node
|
||||
node->OnAnimate(Device->getTimer()->getTime());
|
||||
|
||||
// render the node
|
||||
node->render();
|
||||
|
||||
// reset the scene node to the original material
|
||||
for(u32 j=0; j<node->getMaterialCount(); j++)
|
||||
node->getMaterial(j).MaterialType = bufferMaterialList[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CEffectChain& CPostProcessManager::getEffectChain(E_POSTPROCESS_EFFECT effect)
|
||||
{
|
||||
// return the desired effect chain
|
||||
if (effect < EPPE_COUNT)
|
||||
return EffectChain[effect];
|
||||
else
|
||||
return EffectChain[EPPE_NO_EFFECT];
|
||||
}
|
||||
|
||||
void CPostProcessManager::loadRTTConfig(const char* fileName)
|
||||
{
|
||||
// create a xml reader
|
||||
io::IrrXMLReader* xmlReader = io::createIrrXMLReader(fileName);
|
||||
|
||||
// we'll be looking for the rendertarget tag in the xml
|
||||
const core::stringc renderTargetTag(L"RenderTarget");
|
||||
|
||||
while(xmlReader && xmlReader->read())
|
||||
{
|
||||
switch(xmlReader->getNodeType())
|
||||
{
|
||||
case io::EXN_ELEMENT:
|
||||
{
|
||||
// we are in the Setup section and we find a rendertarget to parse
|
||||
if (renderTargetTag.equals_ignore_case(xmlReader->getNodeName()))
|
||||
{
|
||||
// get the rtt parameters
|
||||
core::stringc id = xmlReader->getAttributeValueSafe("id");
|
||||
u32 width = (u32) xmlReader->getAttributeValueAsInt("width");
|
||||
u32 height = (u32) xmlReader->getAttributeValueAsInt("height");
|
||||
f32 scale = (f32) xmlReader->getAttributeValueAsFloat("scale");
|
||||
video::ECOLOR_FORMAT colorFormat = (video::ECOLOR_FORMAT) xmlReader->getAttributeValueAsInt("colorFormat");
|
||||
|
||||
// set width and height of the rtt
|
||||
if (scale > 0.0f)
|
||||
{
|
||||
width = (u32) (scale*Device->getVideoDriver()->getScreenSize().Width);
|
||||
height = (u32) (scale*Device->getVideoDriver()->getScreenSize().Height);
|
||||
}
|
||||
if (width==0 || height==0)
|
||||
{
|
||||
width = Device->getVideoDriver()->getScreenSize().Width;
|
||||
height = Device->getVideoDriver()->getScreenSize().Height;
|
||||
}
|
||||
// add the rendertarget with its properties and store it in the render target map
|
||||
video::ITexture* texture = Device->getVideoDriver()->addRenderTargetTexture(core::dimension2d<u32>(width, height), id, colorFormat);
|
||||
RenderTargetMap[id] = texture;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete xmlReader;
|
||||
}
|
||||
|
||||
void CPostProcessManager::loadEffectConfig(const char* fileName)
|
||||
{
|
||||
// create a xml reader
|
||||
io::IrrXMLReader* xmlReader = io::createIrrXMLReader(fileName);
|
||||
|
||||
// we'll be looking for these tags in the xml file
|
||||
const core::stringc effectTag("Effect");
|
||||
const core::stringc shaderPostProcessTag("ShaderPostProcess");
|
||||
const core::stringc renderSourceTag("RenderSource");
|
||||
const core::stringc renderTargetTag("RenderTarget");
|
||||
const core::stringc psConstant("PixelShaderConstant");
|
||||
const core::stringc vsConstant("VertexShaderConstant");
|
||||
const core::stringc textureTag("Texture");
|
||||
|
||||
// each effect chain is a sequence of postprocesses
|
||||
CEffectChain* currentEffectChain = NULL;
|
||||
CShaderPostProcess* currentPostProcess = NULL;
|
||||
|
||||
while(xmlReader && xmlReader->read())
|
||||
{
|
||||
switch(xmlReader->getNodeType())
|
||||
{
|
||||
case io::EXN_ELEMENT:
|
||||
{
|
||||
// we are in the Setup section and we find a effect to parse
|
||||
if (effectTag.equals_ignore_case(xmlReader->getNodeName()))
|
||||
{
|
||||
// get the E_POSTPROCESS_EFFECT parameter
|
||||
s32 id = xmlReader->getAttributeValueAsInt("id");
|
||||
core::stringc name = xmlReader->getAttributeValueSafe("name");
|
||||
|
||||
// get the correct effect chain and reset the postprocess
|
||||
currentEffectChain = NULL;
|
||||
currentPostProcess = NULL;
|
||||
if (id>=0 && id<EPPE_COUNT)
|
||||
{
|
||||
E_POSTPROCESS_EFFECT effect = (E_POSTPROCESS_EFFECT) id;
|
||||
currentEffectChain = &EffectChain[effect];
|
||||
currentEffectChain->setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
// we are in the shader post process section and have a valid currentEffect
|
||||
if (shaderPostProcessTag.equals_ignore_case(xmlReader->getNodeName()) && currentEffectChain)
|
||||
{
|
||||
// get the postprocess name
|
||||
core::stringc name = xmlReader->getAttributeValueSafe("name");
|
||||
|
||||
// get vertex shader config
|
||||
core::stringc vsFile = xmlReader->getAttributeValueSafe("vsFile");
|
||||
core::stringc vsEntry = "main";
|
||||
if (xmlReader->getAttributeValue("vsEntry"))
|
||||
vsEntry = xmlReader->getAttributeValueSafe("vsEntry");
|
||||
video::E_VERTEX_SHADER_TYPE vsType = (video::E_VERTEX_SHADER_TYPE) xmlReader->getAttributeValueAsInt("vsType");
|
||||
|
||||
// get pixel shader config
|
||||
core::stringc psFile = xmlReader->getAttributeValueSafe("psFile");
|
||||
core::stringc psEntry = "main";
|
||||
if (xmlReader->getAttributeValue("psEntry"))
|
||||
psEntry = xmlReader->getAttributeValueSafe("psEntry");
|
||||
video::E_PIXEL_SHADER_TYPE psType = (video::E_PIXEL_SHADER_TYPE) xmlReader->getAttributeValueAsInt("psType");
|
||||
video::E_MATERIAL_TYPE baseMaterial = (video::E_MATERIAL_TYPE) xmlReader->getAttributeValueAsInt("baseMaterial");
|
||||
|
||||
// get additional built in shader constants for vertexshader
|
||||
bool vsUseElapsedTime = xmlReader->getAttributeValueAsInt("vsUseElapsedTime") != 0;
|
||||
bool vsUseRandom = xmlReader->getAttributeValueAsInt("vsUseRandom") != 0;
|
||||
bool vsUseBufferWidth = xmlReader->getAttributeValueAsInt("vsUseBufferWidth") != 0;
|
||||
bool vsUseBufferHeight = xmlReader->getAttributeValueAsInt("vsUseBufferHeight") != 0;
|
||||
bool vsUseProjection = xmlReader->getAttributeValueAsInt("vsUseProjection") != 0;
|
||||
bool vsUseView = xmlReader->getAttributeValueAsInt("vsUseView") != 0;
|
||||
bool vsUseWorld = xmlReader->getAttributeValueAsInt("vsUseWorld") != 0;
|
||||
bool vsUseWorldView = xmlReader->getAttributeValueAsInt("vsUseWorldView") != 0;
|
||||
bool vsUseWorldViewProj = xmlReader->getAttributeValueAsInt("vsUseWorldViewProj") != 0;
|
||||
|
||||
// get additional built in shader constants for pixelshader
|
||||
bool psUseElapsedTime = xmlReader->getAttributeValueAsInt("psUseElapsedTime") != 0;
|
||||
bool psUseRandom = xmlReader->getAttributeValueAsInt("psUseRandom") != 0;
|
||||
bool psUseBufferWidth = xmlReader->getAttributeValueAsInt("psUseBufferWidth") != 0;
|
||||
bool psUseBufferHeight = xmlReader->getAttributeValueAsInt("psUseBufferHeight") != 0;
|
||||
bool psUseProjection = xmlReader->getAttributeValueAsInt("psUseProjection") != 0;
|
||||
bool psUseView = xmlReader->getAttributeValueAsInt("psUseView") != 0;
|
||||
bool psUseWorld = xmlReader->getAttributeValueAsInt("psUseWorld") != 0;
|
||||
bool psUseWorldView = xmlReader->getAttributeValueAsInt("psUseWorldView") != 0;
|
||||
bool psUseWorldViewProj = xmlReader->getAttributeValueAsInt("psUseWorldViewProj") != 0;
|
||||
|
||||
// create a new shader post process material
|
||||
currentPostProcess = new CShaderPostProcess(Device, name, vsFile, vsEntry, vsType, psFile, psEntry, psType, baseMaterial);
|
||||
|
||||
// set pixel shader flags
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_TIME, psUseElapsedTime);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_RANDOM, psUseRandom);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_BUFFERWIDTH, psUseBufferWidth);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_BUFFERHEIGHT, psUseBufferHeight);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_PROJECTION, psUseProjection);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_VIEW, psUseView);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_WORLD, psUseWorld);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_WORLDVIEW, psUseWorldView);
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderFlag(ESC_WORLDVIEWPROJ, psUseWorldViewProj);
|
||||
|
||||
// set vertex shader flags
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_TIME, vsUseElapsedTime);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_RANDOM, vsUseRandom);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_BUFFERWIDTH, vsUseBufferWidth);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_BUFFERHEIGHT, vsUseBufferHeight);
|
||||
// set buffer size for DirectX vertex shaders
|
||||
// (vertexshader performs 0.5 texel offset for correct texture sampling,
|
||||
// this is not necessary for OpenGL)
|
||||
if(Device->getVideoDriver()->getDriverType() == video::EDT_DIRECT3D9)
|
||||
{
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_BUFFERWIDTH);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_BUFFERHEIGHT);
|
||||
}
|
||||
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_PROJECTION, vsUseProjection);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_VIEW, vsUseView);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_WORLD, vsUseWorld);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_WORLDVIEW, vsUseWorldView);
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderFlag(ESC_WORLDVIEWPROJ, vsUseWorldViewProj);
|
||||
|
||||
// push back the post process into the effect chain
|
||||
currentEffectChain->push_back(currentPostProcess);
|
||||
}
|
||||
|
||||
// read vertex shader constants from the xml-file
|
||||
if (vsConstant.equals_ignore_case(xmlReader->getNodeName()) &&
|
||||
currentPostProcess)
|
||||
{
|
||||
// add the defined constants to the postprocess
|
||||
core::stringc name = xmlReader->getAttributeValueSafe("name");
|
||||
f32 value = xmlReader->getAttributeValueAsFloat("value");
|
||||
currentPostProcess->getShaderMaterial()->setVertexShaderConstant(name, value);
|
||||
}
|
||||
|
||||
// read pixel shader constants from the xml-file
|
||||
if (psConstant.equals_ignore_case(xmlReader->getNodeName()) &&
|
||||
currentPostProcess)
|
||||
{
|
||||
// add the defined constants to the postprocess
|
||||
core::stringc name = xmlReader->getAttributeValueSafe("name");
|
||||
f32 value = xmlReader->getAttributeValueAsFloat("value");
|
||||
currentPostProcess->getShaderMaterial()->setPixelShaderConstant(name, value);
|
||||
}
|
||||
|
||||
// read input texture properties from the xml-file
|
||||
if (textureTag.equals_ignore_case(xmlReader->getNodeName()) &&
|
||||
currentPostProcess)
|
||||
{
|
||||
// read texture properties
|
||||
u32 index = (u32) xmlReader->getAttributeValueAsInt("index");
|
||||
core::stringc texPath = xmlReader->getAttributeValueSafe("path");
|
||||
core::stringc texName = xmlReader->getAttributeValueSafe("name");
|
||||
video::E_TEXTURE_CLAMP texClamp = (video::E_TEXTURE_CLAMP)xmlReader->getAttributeValueAsInt("textureClamp");
|
||||
s8 texLODBias = (s8) xmlReader->getAttributeValueAsInt("lodBias");
|
||||
bool bilinearFilter = true;
|
||||
bool trilinearFilter = false;
|
||||
bool anisotropicFilter = false;
|
||||
if (xmlReader->getAttributeValue("bilinearFilter"))
|
||||
bilinearFilter = xmlReader->getAttributeValueAsInt("bilinearFilter") != 0;
|
||||
if (xmlReader->getAttributeValue("trilinearFilter"))
|
||||
trilinearFilter = xmlReader->getAttributeValueAsInt("trilinearFilter") != 0;
|
||||
if (xmlReader->getAttributeValue("anisotropicFilter"))
|
||||
anisotropicFilter = xmlReader->getAttributeValueAsInt("anisotropicFilter") != 0;
|
||||
|
||||
if(index < video::MATERIAL_MAX_TEXTURES)
|
||||
{
|
||||
// set texture and clamp
|
||||
if(!texPath.empty())
|
||||
currentPostProcess->getMaterial().TextureLayer[index].Texture = Device->getVideoDriver()->getTexture(texPath);
|
||||
|
||||
// set texture properties
|
||||
currentPostProcess->getMaterial().TextureLayer[index].TextureWrapU = texClamp;
|
||||
currentPostProcess->getMaterial().TextureLayer[index].TextureWrapV = texClamp;
|
||||
currentPostProcess->getMaterial().TextureLayer[index].LODBias = texLODBias;
|
||||
currentPostProcess->getMaterial().TextureLayer[index].BilinearFilter = bilinearFilter;
|
||||
currentPostProcess->getMaterial().TextureLayer[index].TrilinearFilter = trilinearFilter;
|
||||
currentPostProcess->getMaterial().TextureLayer[index].AnisotropicFilter = anisotropicFilter == true ? 0xFF : 0;
|
||||
|
||||
// set texture name (used for glsl)
|
||||
if(!texName.empty())
|
||||
currentPostProcess->getShaderMaterial()->setTextureName(index, texName);
|
||||
}
|
||||
}
|
||||
|
||||
// read render target for the postprocess from the xml-file
|
||||
if (renderSourceTag.equals_ignore_case(xmlReader->getNodeName()) &&
|
||||
currentEffectChain && currentPostProcess)
|
||||
{
|
||||
// set render target of the postprocess
|
||||
core::stringc texPath = xmlReader->getAttributeValueSafe("path");
|
||||
currentPostProcess->setRenderSource(texPath);
|
||||
}
|
||||
|
||||
// read render target for the postprocess from the xml-file
|
||||
if (renderTargetTag.equals_ignore_case(xmlReader->getNodeName()) &&
|
||||
currentEffectChain && currentPostProcess)
|
||||
{
|
||||
// set render target of the postprocess
|
||||
core::stringc texPath = xmlReader->getAttributeValueSafe("path");
|
||||
currentPostProcess->setRenderTarget(texPath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete xmlReader;
|
||||
}
|
131
PostProcessManager.h
Normal file
@ -0,0 +1,131 @@
|
||||
#ifndef _POSTPROCESSMANAGER_H
|
||||
#define _POSTPROCESSMANAGER_H
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
// forward declarations
|
||||
class IPostProcess;
|
||||
class CShaderPostProcess;
|
||||
class CShaderMaterial;
|
||||
|
||||
// available effects
|
||||
//
|
||||
// if you want to create a new effect
|
||||
// 1) add another EPPE_* constant
|
||||
// 2) define its behaviour in the effect.xml configuration file
|
||||
// 3) define additional render target textures in the rtt.xml configuration file
|
||||
// 4) put the used shader programs into the media/shaders/hlsl and media/shaders/glsl subfolders
|
||||
enum E_POSTPROCESS_EFFECT
|
||||
{
|
||||
EPPE_FINAL_PASS = 0,
|
||||
EPPE_NO_EFFECT,
|
||||
EPPE_INVERT,
|
||||
EPPE_SEPIA,
|
||||
EPPE_GRAY_SCALE,
|
||||
EPPE_SIMPLE_BLOOM,
|
||||
EPPE_ADAPTIVE_BLOOM,
|
||||
EPPE_MOTION_BLUR,
|
||||
EPPE_NIGHT_VISION,
|
||||
EPPE_DREAM_VISION,
|
||||
EPPE_POSTERIZE,
|
||||
EPPE_SHARPEN,
|
||||
EPPE_EMBOSSED,
|
||||
EPPE_TILING,
|
||||
EPPE_DISPLACEMENT,
|
||||
EPPE_SCRATCHED,
|
||||
EPPE_PENCIL,
|
||||
EPPE_BLUR,
|
||||
EPPE_WATER,
|
||||
EPPE_COLOR,
|
||||
EPPE_PULSING,
|
||||
EPPE_SHAKE,
|
||||
EPPE_DESATURATE,
|
||||
EPPE_RADIAL_BLUR,
|
||||
EPPE_DEPTH_OF_FIELD,
|
||||
EPPE_VIGNETTE,
|
||||
EPPE_UNDER_WATER,
|
||||
EPPE_GUI,
|
||||
EPPE_COUNT
|
||||
};
|
||||
|
||||
class CEffectChain : public core::array<IPostProcess*>
|
||||
{
|
||||
protected:
|
||||
// name of the effect
|
||||
core::stringc Name;
|
||||
|
||||
public:
|
||||
// set the name of the effect
|
||||
virtual void setName(const core::stringc& name) { Name = name; }
|
||||
|
||||
// get the name of the effect
|
||||
virtual const core::stringc& getName() const { return Name; }
|
||||
};
|
||||
|
||||
class CPostProcessManager
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CPostProcessManager(IrrlichtDevice* device);
|
||||
|
||||
// destructor
|
||||
virtual ~CPostProcessManager();
|
||||
|
||||
protected:
|
||||
// the irrlicht device
|
||||
IrrlichtDevice* Device;
|
||||
|
||||
// additional render target textures (defined in rtt.xml)
|
||||
core::map<const core::stringc, video::ITexture*> RenderTargetMap;
|
||||
|
||||
// the effect chains that store the post process passes (defined in effect.xml)
|
||||
CEffectChain EffectChain[EPPE_COUNT];
|
||||
|
||||
// list of nodes for depth pass
|
||||
core::array<scene::ISceneNode*> DepthPassNodes;
|
||||
|
||||
// material for depth pass
|
||||
CShaderMaterial* DepthMaterial;
|
||||
|
||||
// performs aux buffer swaping
|
||||
void SwapAuxBuffers();
|
||||
|
||||
// loads the rtt.xml and fills the RenderTargetMap
|
||||
void loadRTTConfig(const char* fileName);
|
||||
|
||||
// loads the effect.xml and fills the EffectChain
|
||||
void loadEffectConfig(const char* fileName);
|
||||
|
||||
public:
|
||||
video::ITexture* getRenderTarget(const core::stringc& renderTarget) { return RenderTargetMap[renderTarget]; }
|
||||
|
||||
// performs depth and normal generation pass
|
||||
void renderDepth(const video::SColor& defaultDepth = video::SColor(0xFFFFFFFF));
|
||||
|
||||
// prepares the postprocessing by setting the aux0 buffer as the scene render target
|
||||
// use this function before calling smgr->drawAll()
|
||||
void prepare();
|
||||
|
||||
// renders the desired effect
|
||||
void render(E_POSTPROCESS_EFFECT effect);
|
||||
|
||||
// renders the aux buffer to the framebuffer
|
||||
// call this function after applying all desired effects and before calling gui->drawAll()
|
||||
void update();
|
||||
|
||||
// removes all nodes from depth pass
|
||||
void clearDepthPass();
|
||||
|
||||
// adds node to the depth pass
|
||||
void addNodeToDepthPass(scene::ISceneNode *node);
|
||||
|
||||
// removes a node from the depth pass
|
||||
void removeNodeFromDepthPass(scene::ISceneNode *node);
|
||||
|
||||
// returns a specific effect chain
|
||||
CEffectChain& getEffectChain(E_POSTPROCESS_EFFECT effect);
|
||||
};
|
||||
|
||||
#endif
|
238
ShaderMaterial.cpp
Normal file
@ -0,0 +1,238 @@
|
||||
#include "ShaderMaterial.h"
|
||||
|
||||
CShaderMaterial::CShaderMaterial(IrrlichtDevice* device, const core::stringc& name,
|
||||
io::path vsFile, core::stringc vsEntry, video::E_VERTEX_SHADER_TYPE vsType,
|
||||
io::path psFile, core::stringc psEntry, video::E_PIXEL_SHADER_TYPE psType,
|
||||
video::E_MATERIAL_TYPE baseMaterial) : Device(device), Name(name), PixelShaderFlags(0), VertexShaderFlags(0)
|
||||
{
|
||||
s32 userdata = 0;
|
||||
io::path vsPath;
|
||||
io::path psPath;
|
||||
|
||||
// log action
|
||||
core::stringc msg = core::stringc("compiling material ") + name;
|
||||
Device->getLogger()->log(msg.c_str(), ELL_INFORMATION);
|
||||
|
||||
// create destination path for (driver specific) shader files
|
||||
if(Device->getVideoDriver()->getDriverType() == video::EDT_OPENGL)
|
||||
{
|
||||
vsPath = core::stringc("./shaders/glsl/") + vsFile;
|
||||
psPath = core::stringc("./shaders/glsl/") + psFile;
|
||||
userdata = 1;
|
||||
}
|
||||
if(Device->getVideoDriver()->getDriverType() == video::EDT_DIRECT3D9)
|
||||
{
|
||||
vsPath=core::stringc("./shaders/hlsl/") + vsFile;
|
||||
psPath=core::stringc("./shaders/hlsl/") + psFile;
|
||||
userdata = 0;
|
||||
}
|
||||
|
||||
// create shader material
|
||||
video::IGPUProgrammingServices* gpu = Device->getVideoDriver()->getGPUProgrammingServices();
|
||||
s32 matID = gpu->addHighLevelShaderMaterialFromFiles(
|
||||
vsPath, vsEntry.c_str(), vsType,
|
||||
psPath, psEntry.c_str(), psType,
|
||||
this, baseMaterial, userdata);
|
||||
|
||||
// set material type
|
||||
Material.MaterialType = (video::E_MATERIAL_TYPE)matID;
|
||||
|
||||
// set the default texturenames and texture wrap
|
||||
// these are overridden by the effect.xml configuration
|
||||
for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
TextureName[i] = core::stringc("texture") + core::stringc(i);
|
||||
Material.TextureLayer[i].TextureWrapU = video::ETC_REPEAT;
|
||||
Material.TextureLayer[i].TextureWrapV = video::ETC_REPEAT;
|
||||
}
|
||||
}
|
||||
|
||||
void CShaderMaterial::OnSetConstants(video::IMaterialRendererServices* services, s32 userdata)
|
||||
{
|
||||
// set the constants for the pixelshader
|
||||
if(PixelShaderConstant.size())
|
||||
{
|
||||
core::map<const core::stringc, f32>::Iterator psParamIter = PixelShaderConstant.getIterator();
|
||||
for(; !psParamIter.atEnd(); psParamIter++)
|
||||
{
|
||||
services->setPixelShaderConstant(
|
||||
psParamIter.getNode()->getKey().c_str(),
|
||||
&psParamIter.getNode()->getValue(),
|
||||
1);
|
||||
}
|
||||
}
|
||||
if(PixelShaderUniform.size())
|
||||
{
|
||||
core::map<const core::stringc, SUniformDescriptor>::Iterator psParamIter = PixelShaderUniform.getIterator();
|
||||
for(; !psParamIter.atEnd(); psParamIter++)
|
||||
{
|
||||
services->setPixelShaderConstant(
|
||||
psParamIter.getNode()->getKey().c_str(),
|
||||
psParamIter.getNode()->getValue().ParamPointer,
|
||||
psParamIter.getNode()->getValue().ParamCount);
|
||||
}
|
||||
}
|
||||
|
||||
// set the constants for the vertexshader
|
||||
if(VertexShaderConstant.size())
|
||||
{
|
||||
core::map<const core::stringc, f32>::Iterator vsParamIter = VertexShaderConstant.getIterator();
|
||||
for(; !vsParamIter.atEnd(); vsParamIter++)
|
||||
{
|
||||
services->setVertexShaderConstant(
|
||||
vsParamIter.getNode()->getKey().c_str(),
|
||||
&vsParamIter.getNode()->getValue(),
|
||||
1);
|
||||
}
|
||||
}
|
||||
if(VertexShaderUniform.size())
|
||||
{
|
||||
core::map<const core::stringc, SUniformDescriptor>::Iterator vsParamIter = VertexShaderUniform.getIterator();
|
||||
for(; !vsParamIter.atEnd(); vsParamIter++)
|
||||
{
|
||||
services->setVertexShaderConstant(
|
||||
vsParamIter.getNode()->getKey().c_str(),
|
||||
vsParamIter.getNode()->getValue().ParamPointer,
|
||||
vsParamIter.getNode()->getValue().ParamCount);
|
||||
}
|
||||
}
|
||||
|
||||
// set the elapsed time if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_TIME) || getVertexShaderFlag(ESC_TIME))
|
||||
{
|
||||
// get the elapsed time in ms
|
||||
f32 elapsedTime = Device->getTimer()->getTime()* 0.001f;
|
||||
|
||||
if(getPixelShaderFlag(ESC_TIME))
|
||||
services->setPixelShaderConstant("ElapsedTime", &elapsedTime, 1);
|
||||
if(getVertexShaderFlag(ESC_TIME))
|
||||
services->setVertexShaderConstant("ElapsedTime", &elapsedTime, 1);
|
||||
}
|
||||
|
||||
// set a random value if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_RANDOM) || getVertexShaderFlag(ESC_RANDOM))
|
||||
{
|
||||
// create a random value in the intervall [0, 1]
|
||||
f32 random = (f32) rand() / (f32) RAND_MAX;
|
||||
|
||||
if(getPixelShaderFlag(ESC_RANDOM))
|
||||
services->setPixelShaderConstant("RandomValue", &random, 1);
|
||||
if(getVertexShaderFlag(ESC_RANDOM))
|
||||
services->setVertexShaderConstant("RandomValue", &random, 1);
|
||||
}
|
||||
|
||||
// set the projection matrix if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_PROJECTION) || getVertexShaderFlag(ESC_PROJECTION))
|
||||
{
|
||||
// get the projection matrix
|
||||
core::matrix4 projMatrix = Device->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
|
||||
if(getPixelShaderFlag(ESC_PROJECTION))
|
||||
services->setPixelShaderConstant("ProjMatrix", projMatrix.pointer(), 16);
|
||||
if(getVertexShaderFlag(ESC_PROJECTION))
|
||||
services->setVertexShaderConstant("ProjMatrix", projMatrix.pointer(), 16);
|
||||
}
|
||||
|
||||
// set the view matrix if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_VIEW) || getVertexShaderFlag(ESC_VIEW))
|
||||
{
|
||||
// get the view matrix
|
||||
core::matrix4 viewMatrix = Device->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
|
||||
if(getPixelShaderFlag(ESC_VIEW))
|
||||
services->setPixelShaderConstant("ViewMatrix", viewMatrix.pointer(), 16);
|
||||
if(getVertexShaderFlag(ESC_VIEW))
|
||||
services->setVertexShaderConstant("ViewMatrix", viewMatrix.pointer(), 16);
|
||||
}
|
||||
|
||||
// set the world matrix if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_WORLD) || getVertexShaderFlag(ESC_WORLD))
|
||||
{
|
||||
// get the world matrix
|
||||
core::matrix4 worldMatrix = Device->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
|
||||
if(getPixelShaderFlag(ESC_WORLD))
|
||||
services->setPixelShaderConstant("WorldMatrix", worldMatrix.pointer(), 16);
|
||||
if(getVertexShaderFlag(ESC_WORLD))
|
||||
services->setVertexShaderConstant("WorldMatrix", worldMatrix.pointer(), 16);
|
||||
}
|
||||
|
||||
// set the world view matrix if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_WORLDVIEW) || getVertexShaderFlag(ESC_WORLDVIEW))
|
||||
{
|
||||
// calculate the world view matrix
|
||||
core::matrix4 worldViewMatrix = Device->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
worldViewMatrix *= Device->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
|
||||
if(getPixelShaderFlag(ESC_WORLDVIEW))
|
||||
services->setPixelShaderConstant("WorldViewMatrix", worldViewMatrix.pointer(), 16);
|
||||
if(getVertexShaderFlag(ESC_WORLDVIEW))
|
||||
services->setVertexShaderConstant("WorldViewMatrix", worldViewMatrix.pointer(), 16);
|
||||
}
|
||||
|
||||
// set the world view projection matrix if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_WORLDVIEWPROJ) || getVertexShaderFlag(ESC_WORLDVIEWPROJ))
|
||||
{
|
||||
// calculate the world view projection matrix
|
||||
core::matrix4 worldViewProjMatrix = Device->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
worldViewProjMatrix *= Device->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
worldViewProjMatrix *= Device->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
|
||||
if(getPixelShaderFlag(ESC_WORLDVIEWPROJ))
|
||||
services->setPixelShaderConstant("WorldViewProjMatrix", worldViewProjMatrix.pointer(), 16);
|
||||
if(getVertexShaderFlag(ESC_WORLDVIEWPROJ))
|
||||
services->setVertexShaderConstant("WorldViewProjMatrix", worldViewProjMatrix.pointer(), 16);
|
||||
}
|
||||
|
||||
// set the camera position if the shader wants it
|
||||
scene::ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
|
||||
if (camera && (getPixelShaderFlag(ESC_CAMERAPOSITION) || getVertexShaderFlag(ESC_CAMERAPOSITION)) )
|
||||
{
|
||||
// get the camera position
|
||||
f32 cameraPosition[3];
|
||||
camera->getAbsolutePosition().getAs3Values(cameraPosition);
|
||||
|
||||
if(getPixelShaderFlag(ESC_CAMERAPOSITION))
|
||||
services->setPixelShaderConstant("CameraPosition", &cameraPosition[0], 3);
|
||||
if(getVertexShaderFlag(ESC_CAMERAPOSITION))
|
||||
services->setVertexShaderConstant("CameraPosition", &cameraPosition[0], 3);
|
||||
}
|
||||
|
||||
// set buffer dimensions
|
||||
if(Material.TextureLayer[0].Texture != NULL)
|
||||
{
|
||||
// set buffer width if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_BUFFERWIDTH) || getVertexShaderFlag(ESC_BUFFERWIDTH))
|
||||
{
|
||||
// get the texture width
|
||||
f32 width = (f32) Material.TextureLayer[0].Texture->getSize().Width;
|
||||
|
||||
if(getPixelShaderFlag(ESC_BUFFERWIDTH))
|
||||
services->setPixelShaderConstant("BufferWidth", &width, 1);
|
||||
if(getVertexShaderFlag(ESC_BUFFERWIDTH))
|
||||
services->setVertexShaderConstant("BufferWidth", &width, 1);
|
||||
}
|
||||
// set buffer height if the shader wants it
|
||||
if (getPixelShaderFlag(ESC_BUFFERHEIGHT) || getVertexShaderFlag(ESC_BUFFERHEIGHT))
|
||||
{
|
||||
// get the texture height
|
||||
f32 height = (f32) Material.TextureLayer[0].Texture->getSize().Height;
|
||||
|
||||
if(getPixelShaderFlag(ESC_BUFFERHEIGHT))
|
||||
services->setPixelShaderConstant("BufferHeight", &height, 1);
|
||||
if(getVertexShaderFlag(ESC_BUFFERHEIGHT))
|
||||
services->setVertexShaderConstant("BufferHeight", &height, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// set texture names for OpenGL Shaders
|
||||
// (this is not necessary for DirectX)
|
||||
if(userdata == 1)
|
||||
{
|
||||
for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
if(Material.TextureLayer[i].Texture != NULL)
|
||||
services->setPixelShaderConstant(TextureName[i].c_str(), (f32*) &i, 1);
|
||||
}
|
||||
}
|
||||
}
|
117
ShaderMaterial.h
Normal file
@ -0,0 +1,117 @@
|
||||
#ifndef _SHADERMATERIAL_H
|
||||
#define _SHADERMATERIAL_H
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
// built in shader constants
|
||||
// combine using bitwise or
|
||||
enum E_SHADER_CONSTANT
|
||||
{
|
||||
ESC_TIME = 0x1,
|
||||
ESC_RANDOM = 0x2,
|
||||
ESC_BUFFERWIDTH = 0x4,
|
||||
ESC_BUFFERHEIGHT = 0x8,
|
||||
ESC_PROJECTION = 0x10,
|
||||
ESC_VIEW = 0x20,
|
||||
ESC_WORLD = 0x40,
|
||||
ESC_WORLDVIEW = 0x80,
|
||||
ESC_WORLDVIEWPROJ = 0x100,
|
||||
ESC_CAMERAPOSITION = 0x200
|
||||
};
|
||||
|
||||
struct SUniformDescriptor
|
||||
{
|
||||
SUniformDescriptor() : ParamPointer(0), ParamCount(0) {}
|
||||
SUniformDescriptor(const f32* paramPointer, u32 paramCount)
|
||||
: ParamPointer(paramPointer), ParamCount(paramCount) {}
|
||||
|
||||
const irr::f32* ParamPointer;
|
||||
irr::u32 ParamCount;
|
||||
};
|
||||
|
||||
class CShaderMaterial : public video::IShaderConstantSetCallBack
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CShaderMaterial(IrrlichtDevice* device, const core::stringc& name,
|
||||
io::path vsFile, core::stringc vsEntry, video::E_VERTEX_SHADER_TYPE vsType,
|
||||
io::path psFile, core::stringc psEntry, video::E_PIXEL_SHADER_TYPE psType,
|
||||
video::E_MATERIAL_TYPE baseMaterial);
|
||||
|
||||
protected:
|
||||
// the irrlicht device
|
||||
IrrlichtDevice* Device;
|
||||
|
||||
// shader constant maps
|
||||
core::map<const core::stringc, f32> PixelShaderConstant;
|
||||
core::map<const core::stringc, SUniformDescriptor> PixelShaderUniform;
|
||||
core::map<const core::stringc, f32> VertexShaderConstant;
|
||||
core::map<const core::stringc, SUniformDescriptor> VertexShaderUniform;
|
||||
|
||||
// texture names
|
||||
core::stringc TextureName[video::MATERIAL_MAX_TEXTURES];
|
||||
|
||||
// material id
|
||||
core::stringc Name;
|
||||
|
||||
// material
|
||||
video::SMaterial Material;
|
||||
|
||||
// additional built in shader constants
|
||||
u32 PixelShaderFlags;
|
||||
u32 VertexShaderFlags;
|
||||
|
||||
public:
|
||||
// OnSetConstants callback to transfer shader constant to the gpu program
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userdata);
|
||||
|
||||
// sets pixel shader constant
|
||||
void setPixelShaderConstant(const core::stringc& name, f32 value) { PixelShaderConstant[name] = value; }
|
||||
// sets pixel shader constant (keep in mind, that the pointer shows to a persistent variable, usually a member of another object)
|
||||
void setPixelShaderConstant(const core::stringc& name, const f32* value, const u32 count) { PixelShaderUniform[name] = SUniformDescriptor(value, count); }
|
||||
|
||||
// returns pixel shader constant
|
||||
f32 getPixelShaderConstant(const core::stringc& name) { return PixelShaderConstant[name]; }
|
||||
|
||||
// returns a pixel shader constant iterator
|
||||
core::map<const core::stringc, f32>::Iterator getPixelShaderConstantIterator() { return PixelShaderConstant.getIterator(); }
|
||||
|
||||
// sets pixel shader flag (bitwise or combination)
|
||||
void setPixelShaderFlag(E_SHADER_CONSTANT flag, bool enabled=true) { PixelShaderFlags = (PixelShaderFlags & (~flag)) | ((((u32)!enabled)-1) & flag); }
|
||||
|
||||
// returns pixel shader flag
|
||||
bool getPixelShaderFlag(E_SHADER_CONSTANT flag) const { return (PixelShaderFlags& flag)!=0; }
|
||||
|
||||
// sets vertex shader constants
|
||||
void setVertexShaderConstant(const core::stringc& name, f32 value) { VertexShaderConstant[name] = value; }
|
||||
// sets vertex shader constant (keep in mind, that the pointer shows to a persistent variable, usually a member of another object)
|
||||
void setVertexShaderConstant(const core::stringc& name, const f32* value, const u32 count) { VertexShaderUniform[name] = SUniformDescriptor(value, count); }
|
||||
|
||||
// returns vertex shader constant
|
||||
f32 getVertexShaderConstant(const core::stringc& name) { return VertexShaderConstant[name]; }
|
||||
|
||||
// returns a vertex shader constant iterator
|
||||
core::map<const core::stringc, f32>::Iterator getVertexShaderConstantIterator() { return VertexShaderConstant.getIterator(); }
|
||||
|
||||
// sets vertex shader flag
|
||||
void setVertexShaderFlag(E_SHADER_CONSTANT flag, bool enabled=true) { VertexShaderFlags = (VertexShaderFlags & (~flag)) | ((((u32)!enabled)-1) & flag); }
|
||||
|
||||
// returns vertex shader flag
|
||||
bool getVertexShaderFlag(E_SHADER_CONSTANT flag) const { return (VertexShaderFlags& flag)!=0; }
|
||||
|
||||
// sets texture name (used for opengl gpu programs)
|
||||
void setTextureName(u32 index, const core::stringc& name) { TextureName[index] = name; }
|
||||
|
||||
// returns the SMaterial struct of the shader material
|
||||
virtual video::SMaterial& getMaterial() { return Material; }
|
||||
|
||||
// returns the material type of the shader material
|
||||
virtual video::E_MATERIAL_TYPE getMaterialType() const { return Material.MaterialType; }
|
||||
|
||||
// returns the name of the material
|
||||
const core::stringc& getName() const { return Name; }
|
||||
};
|
||||
|
||||
#endif
|
43
ShaderPostProcess.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "ShaderPostProcess.h"
|
||||
|
||||
CShaderPostProcess::CShaderPostProcess(IrrlichtDevice* device, const core::stringc& name,
|
||||
io::path vsFile, core::stringc vsEntry, video::E_VERTEX_SHADER_TYPE vsType,
|
||||
io::path psFile, core::stringc psEntry, video::E_PIXEL_SHADER_TYPE psType,
|
||||
video::E_MATERIAL_TYPE baseMaterial)
|
||||
: IPostProcess(name), Device(device)
|
||||
{
|
||||
// get the shader material fomr the material manager
|
||||
ShaderMaterial = new CShaderMaterial(device, name, vsFile, vsEntry, vsType, psFile, psEntry, psType, baseMaterial);
|
||||
|
||||
// set material parameters
|
||||
getMaterial().Lighting = false;
|
||||
getMaterial().BackfaceCulling = false;
|
||||
getMaterial().ZBuffer = video::ECFN_NEVER;
|
||||
}
|
||||
|
||||
CShaderPostProcess::~CShaderPostProcess()
|
||||
{
|
||||
// drop the shader material
|
||||
if (ShaderMaterial) {
|
||||
delete ShaderMaterial;
|
||||
ShaderMaterial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CShaderPostProcess::render()
|
||||
{
|
||||
// clear the projection matrix
|
||||
Device->getVideoDriver()->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
|
||||
|
||||
// clear the view matrix
|
||||
Device->getVideoDriver()->setTransform(video::ETS_VIEW, core::IdentityMatrix);
|
||||
|
||||
// set the transform
|
||||
Device->getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix );
|
||||
|
||||
// select the post proc material
|
||||
Device->getVideoDriver()->setMaterial(getMaterial());
|
||||
|
||||
// render the screen quad
|
||||
Device->getVideoDriver()->drawIndexedTriangleList(Vertices, 4, Indices, 2);
|
||||
}
|
37
ShaderPostProcess.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef _SHADERPOSTPROCESS_H
|
||||
#define _SHADERPOSTPROCESS_H
|
||||
|
||||
#include "IPostProcess.h"
|
||||
#include "ShaderMaterial.h"
|
||||
|
||||
class CShaderPostProcess : public IPostProcess
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CShaderPostProcess(IrrlichtDevice* device, const core::stringc& name,
|
||||
io::path vsFile, core::stringc vsEntry, video::E_VERTEX_SHADER_TYPE vsType,
|
||||
io::path psFile, core::stringc psEntry, video::E_PIXEL_SHADER_TYPE psType,
|
||||
video::E_MATERIAL_TYPE baseMaterial);
|
||||
|
||||
// destructor
|
||||
virtual ~CShaderPostProcess();
|
||||
|
||||
protected:
|
||||
// the irrlicht device
|
||||
IrrlichtDevice* Device;
|
||||
|
||||
// shader material of the postprocess
|
||||
CShaderMaterial* ShaderMaterial;
|
||||
|
||||
public:
|
||||
// returns the material of the postprocess
|
||||
virtual video::SMaterial& getMaterial() { return ShaderMaterial->getMaterial(); }
|
||||
|
||||
// returns the shader material object of the postprocess
|
||||
virtual CShaderMaterial* getShaderMaterial() { return ShaderMaterial; }
|
||||
|
||||
// renders the postprocess
|
||||
virtual void render();
|
||||
};
|
||||
|
||||
#endif
|
BIN
TerrainTest
Executable file
103
TerrainTest.cbp
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="TerrainTest" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="TerrainTest" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="../TerrainTest" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="TerrainTest" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="../TerrainTest" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add directory="/home/omikronn/Projects/irrlicht_test/trunk/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="Irrlicht" />
|
||||
<Add library="GL" />
|
||||
<Add library="GLU" />
|
||||
<Add library="Xxf86vm" />
|
||||
<Add directory="/home/omikronn/Projects/irrlicht_test/trunk/lib/Linux" />
|
||||
</Linker>
|
||||
<Unit filename="IPostProcess.h" />
|
||||
<Unit filename="PostProcessManager.cpp" />
|
||||
<Unit filename="PostProcessManager.h" />
|
||||
<Unit filename="ShaderMaterial.cpp" />
|
||||
<Unit filename="ShaderMaterial.h" />
|
||||
<Unit filename="ShaderPostProcess.cpp" />
|
||||
<Unit filename="ShaderPostProcess.h" />
|
||||
<Unit filename="TerrainTexturing.cpp" />
|
||||
<Unit filename="TerrainTexturing.h" />
|
||||
<Unit filename="WaterSceneNode.cpp" />
|
||||
<Unit filename="WaterSceneNode.h" />
|
||||
<Unit filename="main.cpp" />
|
||||
<Unit filename="shaders/glsl/material/depth.psh" />
|
||||
<Unit filename="shaders/glsl/material/depth.vsh" />
|
||||
<Unit filename="shaders/glsl/material/water.psh" />
|
||||
<Unit filename="shaders/glsl/material/water.vsh" />
|
||||
<Unit filename="shaders/glsl/postprocess/accumulate.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/brightpass.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/color.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/depthoffield.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/desaturate.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/displacement.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/downscale2x2.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/dreamvision.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/embossed.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/finalpass_fxaa.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/grayscale.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/hblur.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/invert.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/luminance_adapt.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/luminance_init.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/luminance_iter.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/motionblur.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/nightvision.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/pencil.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/posterize.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/pulsing.vsh" />
|
||||
<Unit filename="shaders/glsl/postprocess/radialblur.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/scratched.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/screenquad.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/sepia.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/shake.vsh" />
|
||||
<Unit filename="shaders/glsl/postprocess/sharpen.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/simplebloom.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/tiling.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/underwater.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/underwater.vsh" />
|
||||
<Unit filename="shaders/glsl/postprocess/vblur.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/vertex.vsh" />
|
||||
<Unit filename="shaders/glsl/postprocess/vignette.psh" />
|
||||
<Unit filename="shaders/glsl/postprocess/water.psh" />
|
||||
<Unit filename="shaders/glsl/terrain.psh" />
|
||||
<Unit filename="shaders/glsl/terrain.vsh" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
2013
TerrainTest.depend
Normal file
74
TerrainTest.layout
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="shaders/glsl/terrain.vsh" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="96" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ShaderPostProcess.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="852" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="WaterSceneNode.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2234" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="shaders/glsl/material/water.psh" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2317" topLine="36" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="PostProcessManager.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ShaderMaterial.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="834" topLine="30" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="TerrainTexturing.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="329" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="shaders/glsl/postprocess/water.psh" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="496" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4920" topLine="48" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="IPostProcess.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1178" topLine="16" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="PostProcessManager.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="806" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="TerrainTexturing.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3917" topLine="70" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="shaders/glsl/terrain.psh" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="213" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ShaderMaterial.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="46" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
105
TerrainTexturing.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "TerrainTexturing.h"
|
||||
|
||||
TerrainTexturing::TerrainTexturing(IrrlichtDevice *pDevice, scene::ISceneManager* pSceneMgr)
|
||||
{
|
||||
//Assign all parameters
|
||||
m_pSceneMgr = pSceneMgr;
|
||||
m_pDriver = pSceneMgr->getVideoDriver();
|
||||
|
||||
io::path vertShader;
|
||||
io::path fragShader;
|
||||
io::path vsFile = "terrain.vsh";
|
||||
io::path psFile = "terrain.psh";
|
||||
|
||||
// log action
|
||||
core::stringc msg = core::stringc("compiling material terrainsplat");
|
||||
pDevice->getLogger()->log(msg.c_str(), ELL_INFORMATION);
|
||||
|
||||
// create destination path for (driver specific) shader files
|
||||
if (m_pDriver->getDriverType() == video::EDT_OPENGL) {
|
||||
vertShader = core::stringc("./shaders/glsl/") + vsFile;
|
||||
fragShader = core::stringc("./shaders/glsl/") + psFile;
|
||||
}
|
||||
|
||||
//Create the shader material
|
||||
m_nShaderMaterial = m_pDriver->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles(vertShader, "main", video::EVST_VS_1_1,
|
||||
fragShader, "main", video::EPST_PS_1_1,
|
||||
this, video::EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
m_pTextureSplat = new STextureSplat();
|
||||
m_pMultitextureNode = new SMultiTextureNode;
|
||||
}
|
||||
|
||||
TerrainTexturing::~TerrainTexturing()
|
||||
{
|
||||
if (m_pMultitextureNode != NULL) {
|
||||
delete m_pMultitextureNode;
|
||||
m_pMultitextureNode = NULL;
|
||||
}
|
||||
if (m_pTextureSplat != NULL) {
|
||||
delete m_pTextureSplat;
|
||||
m_pTextureSplat = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool TerrainTexturing::addNode(scene::ISceneNode *pNode)
|
||||
{
|
||||
if (m_pMultitextureNode->pNode == pNode) {
|
||||
return false;
|
||||
} else {
|
||||
m_pMultitextureNode->pNode = pNode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TerrainTexturing::STextureSplat *TerrainTexturing::addTextures(scene::ISceneNode *pNode, video::ITexture *pAlpha, video::ITexture *pRed, video::ITexture *pGreen, video::ITexture *pBlue)
|
||||
{
|
||||
if (m_pMultitextureNode->pNode == pNode) {
|
||||
m_pTextureSplat->pAlphaTexture = pAlpha;
|
||||
m_pTextureSplat->pRedTexture = pRed;
|
||||
m_pTextureSplat->pGreenTexture = pGreen;
|
||||
m_pTextureSplat->pBlueTexture = pBlue;
|
||||
return m_pTextureSplat;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TerrainTexturing::drawAll()
|
||||
{
|
||||
//meshbuffer trick, only draw non culled nodes
|
||||
if (!m_pSceneMgr->isCulled(m_pMultitextureNode->pNode)) {
|
||||
m_pMultitextureNode->pNode->OnRegisterSceneNode();
|
||||
m_pMultitextureNode->pNode->updateAbsolutePosition();
|
||||
|
||||
//Reset the transformation
|
||||
if (m_pMultitextureNode->pNode->getType() == scene::ESNT_TERRAIN) {
|
||||
m_pDriver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||
} else {
|
||||
m_pDriver->setTransform(video::ETS_WORLD, m_pMultitextureNode->pNode->getAbsoluteTransformation());
|
||||
}
|
||||
|
||||
//set the splatting textures
|
||||
m_pMultitextureNode->pNode->setMaterialTexture(0, m_pTextureSplat->pAlphaTexture);
|
||||
m_pMultitextureNode->pNode->setMaterialTexture(1, m_pTextureSplat->pRedTexture);
|
||||
m_pMultitextureNode->pNode->setMaterialTexture(2, m_pTextureSplat->pGreenTexture);
|
||||
m_pMultitextureNode->pNode->setMaterialTexture(3, m_pTextureSplat->pBlueTexture);
|
||||
|
||||
//pass the shader material to the terrain node
|
||||
if (m_pMultitextureNode->pNode->getType() == scene::ESNT_TERRAIN) {
|
||||
m_pMultitextureNode->pNode->setMaterialType((video::E_MATERIAL_TYPE)m_nShaderMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerrainTexturing::OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
|
||||
{
|
||||
int layer0 = 0;
|
||||
int layer1 = 1;
|
||||
int layer2 = 2;
|
||||
int layer3 = 3;
|
||||
|
||||
services->setPixelShaderConstant("alphaMap1", (float*)&layer0, 1);
|
||||
services->setPixelShaderConstant("layer_red", (float*)&layer1, 1);
|
||||
services->setPixelShaderConstant("layer_green", (float*)&layer2, 1);
|
||||
services->setPixelShaderConstant("layer_blue", (float*)&layer3, 1);
|
||||
}
|
44
TerrainTexturing.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef TERRAINTEXTURING_H
|
||||
#define TERRAINTEXTURING_H
|
||||
|
||||
#include <irrlicht.h>
|
||||
#include <SMaterial.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
class TerrainTexturing: public video::IShaderConstantSetCallBack
|
||||
{
|
||||
public:
|
||||
struct STextureSplat {
|
||||
video::ITexture *pAlphaTexture;
|
||||
video::ITexture *pRedTexture;
|
||||
video::ITexture *pGreenTexture;
|
||||
video::ITexture *pBlueTexture;
|
||||
};
|
||||
|
||||
private:
|
||||
struct SMultiTextureNode {
|
||||
scene::ISceneNode *pNode;
|
||||
STextureSplat* pAlpha;
|
||||
};
|
||||
|
||||
public:
|
||||
TerrainTexturing(IrrlichtDevice *pDevice, scene::ISceneManager* pSceneMgr);
|
||||
~TerrainTexturing();
|
||||
|
||||
void drawAll();
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices* pServices,s32 userData);
|
||||
bool addNode(scene::ISceneNode *pNode);
|
||||
STextureSplat *addTextures(scene::ISceneNode *pNode, video::ITexture *pAlpha, video::ITexture *pRed, video::ITexture *pGreen, video::ITexture *pBlue);
|
||||
|
||||
private:
|
||||
scene::ISceneManager *m_pSceneMgr;
|
||||
video::IVideoDriver *m_pDriver;
|
||||
scene::ISceneNode *m_pNode;
|
||||
SMultiTextureNode *m_pMultitextureNode;
|
||||
STextureSplat *m_pTextureSplat;
|
||||
int m_nShaderMaterial;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
277
WaterSceneNode.cpp
Normal file
@ -0,0 +1,277 @@
|
||||
#include "WaterSceneNode.h"
|
||||
//#include "ECustomSceneNodeTypes.h"
|
||||
#include "ShaderMaterial.h"
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
CWaterSceneNode::CWaterSceneNode(scene::ISceneNode* parent, IrrlichtDevice* device, scene::ISceneManager* mgr, s32 id,
|
||||
core::dimension2d<u32> rttSize, core::dimension2d<f32> waterSize) :
|
||||
scene::ISceneNode(parent, mgr, id), Device(device)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CWaterSceneNode");
|
||||
#endif
|
||||
|
||||
// create the shader material name
|
||||
// use the pointer to create a unique name
|
||||
core::stringw name("water_");
|
||||
name += (long)this;
|
||||
|
||||
// create a plane mesh
|
||||
scene::IMesh* mesh = mgr->getGeometryCreator()->createPlaneMesh(waterSize);
|
||||
|
||||
// create the water mesh scene node
|
||||
WaterMeshSceneNode = mgr->addMeshSceneNode(mesh, this);
|
||||
|
||||
// create new camera
|
||||
Camera=SceneManager->addCameraSceneNode(
|
||||
0,
|
||||
core::vector3d<f32>(0,0,0),
|
||||
core::vector3d<f32>(0,0,100),
|
||||
-1,
|
||||
false);
|
||||
|
||||
// create the refraction render target texture
|
||||
core::stringw rttRefraction(name);
|
||||
rttRefraction += "_rtt_refraction";
|
||||
RefractionMap = mgr->getVideoDriver()->addRenderTargetTexture(rttSize, rttRefraction);
|
||||
|
||||
// create the reflection render target texture
|
||||
core::stringw rttReflection(name);
|
||||
rttReflection += "_rtt_reflection";
|
||||
ReflectionMap = mgr->getVideoDriver()->addRenderTargetTexture(rttSize, rttReflection);
|
||||
|
||||
// create the shader material
|
||||
WaterMaterial = new CShaderMaterial(Device, name, "material/water.vsh", "main", video::EVST_VS_2_a, "material/water.psh", "main", video::EPST_PS_3_0, video::EMT_SOLID);
|
||||
WaterMaterial->getMaterial().TextureLayer[0].Texture = mgr->getVideoDriver()->getTexture("./Data/textures/water/water.png");
|
||||
WaterMaterial->getMaterial().TextureLayer[1].Texture = ReflectionMap;
|
||||
WaterMaterial->getMaterial().TextureLayer[2].Texture = RefractionMap;
|
||||
WaterMaterial->getMaterial().TextureLayer[3].Texture = mgr->getVideoDriver()->getTexture("rttDepth");
|
||||
|
||||
// set the texture properties for the material
|
||||
for (u32 i=1; i<video::MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
WaterMaterial->getMaterial().TextureLayer[i].TextureWrapU = video::ETC_MIRROR;
|
||||
WaterMaterial->getMaterial().TextureLayer[i].TextureWrapV = video::ETC_MIRROR;
|
||||
}
|
||||
|
||||
// set the vertex shader constants
|
||||
WaterMaterial->setVertexShaderFlag(ESC_WORLD, true);
|
||||
WaterMaterial->setVertexShaderFlag(ESC_VIEW, true);
|
||||
WaterMaterial->setVertexShaderFlag(ESC_PROJECTION, true);
|
||||
WaterMaterial->setVertexShaderFlag(ESC_TIME, true);
|
||||
WaterMaterial->setVertexShaderConstant("ReflectedViewMatrix", Camera->getViewMatrix().pointer(), 16);
|
||||
WaterMaterial->setVertexShaderConstant("WaveLength", &WaterData.WaveLength, 1);
|
||||
WaterMaterial->setVertexShaderConstant("WindForce", &WaterData.WindForce.X, 2);
|
||||
|
||||
// set the pixel shader constants
|
||||
WaterMaterial->setPixelShaderFlag(ESC_CAMERAPOSITION, true);
|
||||
WaterMaterial->setPixelShaderConstant("WaterColor", &WaterData.WaterColor.r, 4);
|
||||
WaterMaterial->setPixelShaderConstant("DeepColor", &WaterData.DeepColor.r, 4);
|
||||
WaterMaterial->setPixelShaderConstant("WaveHeight", &WaterData.WaveHeight, 1);
|
||||
WaterMaterial->setPixelShaderConstant("BlendFactor", &WaterData.BlendFactor, 1);
|
||||
WaterMaterial->setPixelShaderConstant("DepthBias", &WaterData.DepthBias, 1);
|
||||
WaterMaterial->setPixelShaderConstant("DepthExponent", &WaterData.DepthExponent, 1);
|
||||
WaterMaterial->setPixelShaderConstant("SpecExponent", &WaterData.SpecExponent, 1);
|
||||
WaterMaterial->setPixelShaderConstant("SpecAlpha", &WaterData.SpecAlpha, 1);
|
||||
WaterMaterial->setPixelShaderConstant("FresnelExponent", &WaterData.FresnelExponent, 1);
|
||||
WaterMaterial->setPixelShaderConstant("WaterTransparency", &WaterData.WaterTransparency, 1);
|
||||
|
||||
// setclip plane offsets
|
||||
ReflectionClipPlaneOffet = 2.0f;
|
||||
RefractionClipPlaneOffet = 2.0f;
|
||||
|
||||
// set the material
|
||||
WaterMeshSceneNode->getMaterial(0) = WaterMaterial->getMaterial();
|
||||
WaterMeshSceneNode->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
|
||||
// set noce visible
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
CWaterSceneNode::~CWaterSceneNode()
|
||||
{
|
||||
// drop the water material
|
||||
if (WaterMaterial != NULL) {
|
||||
delete WaterMaterial;
|
||||
WaterMaterial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CWaterSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible)
|
||||
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
|
||||
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
void CWaterSceneNode::OnAnimate(u32 timeMs)
|
||||
{
|
||||
// call base OnAnimate
|
||||
ISceneNode::OnAnimate(timeMs);
|
||||
}
|
||||
|
||||
void CWaterSceneNode::updateRefractionMap(f32 clip)
|
||||
{
|
||||
//get current camera
|
||||
scene::ICameraSceneNode* currentCamera = SceneManager->getActiveCamera();
|
||||
float distanceToSurface = abs(currentCamera->getPosition().Y - RelativeTranslation.Y);
|
||||
|
||||
// get the video driver
|
||||
video::IVideoDriver* videoDriver = SceneManager->getVideoDriver();
|
||||
|
||||
// render to refraction
|
||||
videoDriver->setRenderTarget(RefractionMap, true, true, video::SColor(0,0,0,0));
|
||||
|
||||
// enable refraction clip plane
|
||||
core::plane3d<f32> refractionClipPlane(
|
||||
0, RelativeTranslation.Y-(RefractionClipPlaneOffet+distanceToSurface*0.1f)*clip, 0,
|
||||
0, clip, 0);
|
||||
videoDriver->setClipPlane(0, refractionClipPlane, true);
|
||||
|
||||
// draw the scene
|
||||
SceneManager->drawAll();
|
||||
|
||||
// disable refraction clip plane
|
||||
videoDriver->enableClipPlane(0, false);
|
||||
}
|
||||
|
||||
void CWaterSceneNode::updateReflectionMap()
|
||||
{
|
||||
//get current camera
|
||||
scene::ICameraSceneNode* currentCamera = SceneManager->getActiveCamera();
|
||||
|
||||
// get the video driver
|
||||
video::IVideoDriver* videoDriver = SceneManager->getVideoDriver();
|
||||
|
||||
// render to reflection
|
||||
videoDriver->setRenderTarget(ReflectionMap, true, true, video::SColor(0,0,0,0));
|
||||
|
||||
// set the FOV and far value
|
||||
Camera->setNearValue(currentCamera->getNearValue());
|
||||
Camera->setFarValue(currentCamera->getFarValue());
|
||||
Camera->setFOV(currentCamera->getFOV());
|
||||
|
||||
// set the position of the water camera
|
||||
core::vector3df position = currentCamera->getAbsolutePosition();
|
||||
position.Y = -position.Y + 2.0f*RelativeTranslation.Y;
|
||||
Camera->setPosition(position);
|
||||
|
||||
// set the target of the water camera
|
||||
core::vector3df target = currentCamera->getTarget();
|
||||
target.Y = -target.Y+2.0f*RelativeTranslation.Y;
|
||||
Camera->setTarget(target);
|
||||
|
||||
// set the reflection camera as active camera
|
||||
SceneManager->setActiveCamera(Camera);
|
||||
|
||||
// enable reflection clip plane
|
||||
core::plane3d<f32> reflectionClipPlane(
|
||||
0, RelativeTranslation.Y-ReflectionClipPlaneOffet, 0,
|
||||
0, 1, 0);
|
||||
videoDriver->setClipPlane(0, reflectionClipPlane, true);
|
||||
|
||||
// draw the scene
|
||||
SceneManager->drawAll();
|
||||
|
||||
// disable reflection clip plane
|
||||
videoDriver->enableClipPlane(0, false);
|
||||
|
||||
// reset active camera
|
||||
SceneManager->setActiveCamera(currentCamera);
|
||||
}
|
||||
|
||||
void CWaterSceneNode::updateWater()
|
||||
{
|
||||
//get current camera
|
||||
scene::ICameraSceneNode* currentCamera=SceneManager->getActiveCamera();
|
||||
|
||||
// get the video driver
|
||||
video::IVideoDriver* videoDriver = SceneManager->getVideoDriver();
|
||||
|
||||
if (IsVisible && currentCamera && videoDriver)
|
||||
{
|
||||
// set under water
|
||||
if (currentCamera->getAbsolutePosition().Y < RelativeTranslation.Y)
|
||||
UnderWater = true;
|
||||
else
|
||||
UnderWater = false;
|
||||
|
||||
// hide the water
|
||||
setVisible(false);
|
||||
|
||||
// update the render target textures
|
||||
if (UnderWater)
|
||||
{
|
||||
updateRefractionMap(1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateReflectionMap();
|
||||
updateRefractionMap(-1.0f);
|
||||
}
|
||||
|
||||
// set MaxDistance pixel shader constant
|
||||
WaterMaterial->setPixelShaderConstant("MaxDistance", currentCamera->getFarValue());
|
||||
|
||||
//show the node again
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CWaterSceneNode::render()
|
||||
{
|
||||
}
|
||||
|
||||
const core::aabbox3d<f32>& CWaterSceneNode::getBoundingBox() const
|
||||
{
|
||||
return WaterMeshSceneNode->getBoundingBox();
|
||||
}
|
||||
|
||||
ESCENE_NODE_TYPE CWaterSceneNode::getType() const
|
||||
{
|
||||
return scene::ESNT_UNKNOWN;//(ESCENE_NODE_TYPE)ECSNT_WATER;
|
||||
}
|
||||
|
||||
u32 CWaterSceneNode::getMaterialCount() const
|
||||
{
|
||||
return WaterMeshSceneNode->getMaterialCount();
|
||||
}
|
||||
|
||||
video::SMaterial& CWaterSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
return WaterMeshSceneNode->getMaterial(i);
|
||||
}
|
||||
|
||||
// Writes attributes of the scene node.
|
||||
void CWaterSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
ISceneNode::serializeAttributes(out, options);
|
||||
}
|
||||
|
||||
// Reads attributes of the scene node.
|
||||
void CWaterSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
ISceneNode::deserializeAttributes(in, options);
|
||||
}
|
||||
|
||||
ISceneNode* CWaterSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
|
||||
{
|
||||
if (!newParent)
|
||||
newParent = Parent;
|
||||
if (!newManager)
|
||||
newManager = SceneManager;
|
||||
|
||||
CWaterSceneNode* nb = new CWaterSceneNode(newParent, Device, newManager, ID);
|
||||
|
||||
nb->cloneMembers(this, newManager);
|
||||
|
||||
delete nb;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
150
WaterSceneNode.h
Normal file
@ -0,0 +1,150 @@
|
||||
#ifndef _WATERSCENENODE_H
|
||||
#define _WATERSCENENODE_H
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
||||
class CShaderMaterial;
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
// water properties (shader constants)
|
||||
struct SWater
|
||||
{
|
||||
SWater()
|
||||
{
|
||||
// set default water properties
|
||||
WaterColor = video::SColorf(video::SColor(255,10,50,60));
|
||||
DeepColor = video::SColorf(video::SColor(255,5,5,10));
|
||||
WaveHeight = 0.07f;
|
||||
WaveLength = 50.0f;
|
||||
WindForce = core::vector2d<f32>(5.f, 5.f);
|
||||
FresnelExponent = 1.0f;
|
||||
DepthBias = 60.0f;
|
||||
DepthExponent = 3.0f;
|
||||
SpecExponent = 2.0f;
|
||||
SpecAlpha = 0.0f;
|
||||
BlendFactor = 0.4f;
|
||||
WaterTransparency = 100.0f;
|
||||
}
|
||||
// water color
|
||||
video::SColorf WaterColor;
|
||||
// depth color of the water
|
||||
video::SColorf DeepColor;
|
||||
// direction an speed of waves
|
||||
core::vector2d<f32> WindForce;
|
||||
// wave height (strength of pertubation by normal map)
|
||||
f32 WaveHeight;
|
||||
// wave lentgh
|
||||
f32 WaveLength;
|
||||
// fesnel exponent (mixing reflection and refraction)
|
||||
f32 FresnelExponent;
|
||||
// poition of the sun (specular effect)
|
||||
core::vector3d<f32> SunPos;
|
||||
// power of the specular effect
|
||||
f32 SpecExponent;
|
||||
// alpha of the specular effect
|
||||
f32 SpecAlpha;
|
||||
// blend factor (mixing of water color, refraction and reflection)
|
||||
f32 BlendFactor;
|
||||
// depth bias (higher bias makes the water intransparent)
|
||||
f32 DepthBias;
|
||||
// depth exponent (higher exponent makes the shore line sharper)
|
||||
f32 DepthExponent;
|
||||
// the transparency of the water (lower values make the water clearer)
|
||||
f32 WaterTransparency;
|
||||
};
|
||||
|
||||
class CWaterSceneNode : public scene::ISceneNode
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CWaterSceneNode(scene::ISceneNode* parent, IrrlichtDevice* device, scene::ISceneManager* mgr, s32 id = -1,
|
||||
core::dimension2d<u32> rttSize = core::dimension2d<u32>(512, 512),
|
||||
core::dimension2d<f32> waterSize = core::dimension2d<f32>(10000,10000));
|
||||
|
||||
// destructor
|
||||
~CWaterSceneNode();
|
||||
private:
|
||||
// irrlicht device
|
||||
IrrlichtDevice* Device;
|
||||
protected:
|
||||
// Bounding box
|
||||
core::aabbox3d<f32> BBox;
|
||||
|
||||
// material of the node
|
||||
CShaderMaterial* WaterMaterial;
|
||||
SWater WaterData;
|
||||
|
||||
|
||||
// offsets of the clip planes used for reflection and refraction drawing
|
||||
f32 ReflectionClipPlaneOffet;
|
||||
f32 RefractionClipPlaneOffet;
|
||||
|
||||
// is active camera under the water surface
|
||||
bool UnderWater;
|
||||
|
||||
// water mesh scene node
|
||||
IMeshSceneNode* WaterMeshSceneNode;
|
||||
|
||||
// camera for creating reflection map
|
||||
scene::ICameraSceneNode* Camera;
|
||||
|
||||
// updates the refraction render target texture
|
||||
void updateRefractionMap(f32 clip);
|
||||
|
||||
// updates the refraction render target texture
|
||||
void updateReflectionMap();
|
||||
|
||||
public:
|
||||
// refraction, reflection render target texture
|
||||
video::ITexture* RefractionMap;
|
||||
video::ITexture* ReflectionMap;
|
||||
|
||||
// get Under water state
|
||||
const bool getUnderWater() { return UnderWater; }
|
||||
|
||||
// scene node registration
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
// animates the node
|
||||
virtual void OnAnimate(u32 timeMs);
|
||||
|
||||
// return the water propertie
|
||||
const SWater& getWaterData() { return WaterData; }
|
||||
|
||||
// updates the water
|
||||
// (must be called before rendering the scene)
|
||||
virtual void updateWater();
|
||||
|
||||
// renders the node
|
||||
virtual void render();
|
||||
|
||||
// returns the bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
// returns the node type
|
||||
virtual ESCENE_NODE_TYPE getType() const;
|
||||
|
||||
// returns the material count
|
||||
virtual u32 getMaterialCount() const;
|
||||
|
||||
// returns the material
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
// clones the node
|
||||
virtual ISceneNode* clone(ISceneNode* newParent = 0, ISceneManager* newManager = 0);
|
||||
|
||||
// Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const;
|
||||
|
||||
// Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options = 0);
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
728
config/effect.xml
Normal file
@ -0,0 +1,728 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Setup of the PostProcessManager (effectchains)
|
||||
|
||||
parameters for Effect:
|
||||
**********************
|
||||
id: E_POSTPROCESS_EFFECT, id of the effect
|
||||
name: name of the effect
|
||||
|
||||
parameters for ShaderPostProcess:
|
||||
***************************
|
||||
name: name of the shader postprocess
|
||||
vsFile: vertex shader program (located in media/shaders/hlsl/ for DirectX and in media/shaders/glsl for OpenGL)
|
||||
vsEntry: entrypoint for the vertex shader program (be carefule opengl-driver in irrlicht ignores this),
|
||||
Default: main
|
||||
vsType: E_VERTEX_SHADER_TYPE, Default: EVST_VS_1_1
|
||||
psFile: pixel shader program (located in media/shaders/hlsl/ for DirectX and in media/shaders/glsl for OpenGL)
|
||||
psEntry: entrypoint for the pixel shader program (be carefule opengl-driver in irrlicht ignores this),
|
||||
Default: main
|
||||
psType: E_PIXEL_SHADER_TYPE, Default: EPST_PS_1_1
|
||||
psUseElapsedTime: if set to 1 the elapsed device time im ms is passed to the pixelshader -> "uniform float ElapsedTime",
|
||||
Default: 0, disabled
|
||||
psUseRandom: if set to 1 a random value interval [0, 1] is passed to the pixelshader -> "uniform float RandomValue",
|
||||
Default: 0, disabled
|
||||
psUseBufferWidth: if set to 1 the width of the input buffer is passed to the pixelshader -> "uniform float BufferWidth",
|
||||
Default: 0, disabled
|
||||
psUseBufferHeight: if set to 1 the height of the input buffer is passed to the pixelshader -> "uniform float BufferHeight",
|
||||
Default: 0, disabled
|
||||
psUseProjection: if set to 1 the projection matrix is passed to the pixelshader -> "uniform ProjMatrix",
|
||||
Default: 0, disabled
|
||||
psUseView: if set to 1 the view matrix is passed to the pixelshader -> "uniform ViewMatrix",
|
||||
Default: 0, disabled
|
||||
psUseWorld: if set to 1 the world matrix is passed to the pixelshader -> "uniform WorldMatrix",
|
||||
Default: 0, disabled
|
||||
psUseWorldViewProj: if set to 1 the world view projection matrix is passed to the pixelshader -> "uniform WorldViewProjMatrix",
|
||||
Default: 0, disabled
|
||||
vsUseElapsedTime: if set to 1 the elapsed device time im ms is passed to the vertexshader -> "uniform float ElapsedTime",
|
||||
Default: 0, disabled
|
||||
vsUseRandom: if set to 1 a random value interval [0, 1] is passed to the vertexshader -> "uniform float RandomValue",
|
||||
Default: 0, disabled
|
||||
vsUseBufferWidth: if set to 1 the width of the input buffer is passed to the vertexshader -> "uniform float BufferWidth",
|
||||
Default: 0, disabled
|
||||
vsUseBufferHeight: if set to 1 the height of the input buffer is passed to the vertexshader -> "uniform float BufferHeight",
|
||||
Default: 0, disabled
|
||||
vsUseProjection: if set to 1 the projection matrix is passed to the vertexshader -> "uniform ProjMatrix",
|
||||
Default: 0, disabled
|
||||
vsUseView: if set to 1 the view matrix is passed to the vertexshader -> "uniform ViewMatrix",
|
||||
Default: 0, disabled
|
||||
vsUseWorld: if set to 1 the world matrix is passed to the vertexshader -> "uniform WorldMatrix",
|
||||
Default: 0, disabled
|
||||
vsUseWorldViewProj: if set to 1 the world view projection matrix is passed to the vertexshader -> "uniform WorldViewProjMatrix",
|
||||
Default: 0, disabled
|
||||
baseMaterial: E_MATERIAL_TYPE, Default: EMT_SOLID
|
||||
|
||||
parameters for PixelShaderConstant:
|
||||
***********************************
|
||||
name: name of the variable in the shader program (uniform float name) />
|
||||
value: value that is passed to the shader variable by setPixelShaderConstant(name, &value, 1)
|
||||
|
||||
parameters for VertexShaderConstant:
|
||||
************************************
|
||||
name: name of the variable in the shader program (uniform float name) />
|
||||
value: value that is passed to the shader variable by setVertexShaderConstant(name, &value, 1)
|
||||
|
||||
parameters for Texture:
|
||||
***********************
|
||||
index: index of the texturelayer
|
||||
path: path to render target texture
|
||||
textureClamp: E_TEXTURE_CLAMP, Default: ETC_REPEAT
|
||||
name: name of the texture (only used for glsl shaders), Default: texture0, texture1, ...
|
||||
lodBias: bias for the mipmap choosing decision, Default: 0
|
||||
bilinearFilter: bilinear filtering, Default: true
|
||||
trilinearFilter: trilinear filtering, Default: 0, disabled
|
||||
anisotropicFilter: anisotropic filtering, Default: 0, disabled
|
||||
|
||||
parameters for RenderSource:
|
||||
****************************
|
||||
path: path to texture
|
||||
|
||||
parameters for RenderTarget:
|
||||
****************************
|
||||
path: path to render target texture
|
||||
if path is empty the rendertarget is set to ERT_FRAME_BUFFER
|
||||
|
||||
********************************************************************************************************
|
||||
vsType: psType: textureClamp: baseMaterial:
|
||||
********************************************************************************************************
|
||||
EVST_VS_1_1 = 0, EPST_PS_1_1 = 0, ETC_REPEAT = 0, one of the E_MATERIAL_TYPE enums
|
||||
EVST_VS_2_0 = 1, EPST_PS_1_2 = 1, ETC_CLAMP = 1,
|
||||
EVST_VS_2_a = 2, EPST_PS_1_3 = 2, ETC_CLAMP_TO_EDGE = 2,
|
||||
EVST_VS_3_0 = 3, EPST_PS_1_4 = 3, ETC_CLAMP_TO_BORDER = 3,
|
||||
EVST_VS_4_0 = 4, EPST_PS_2_0 = 4, ETC_MIRROR = 4,
|
||||
EVST_VS_4_1 = 5, EPST_PS_2_a = 5, ETC_MIRROR_CLAMP = 5,
|
||||
EVST_VS_5_0 = 6, EPST_PS_2_b = 6, ETC_MIRROR_CLAMP_TO_EDGE = 6,
|
||||
EPST_PS_3_0 = 7, ETC_MIRROR_CLAMP_TO_BORDER = 7,
|
||||
EPST_PS_4_0 = 8,
|
||||
EPST_PS_4_1 = 9,
|
||||
EPST_PS_5_0 = 10,
|
||||
-->
|
||||
<Setup>
|
||||
<!-- EPPE_FINAL_PASS = 0 -->
|
||||
<Effect id="0" name="Render To Screen">
|
||||
<ShaderPostProcess name="FinalPass" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/finalpass_fxaa.psh" psType="7" psUseBufferWidth="1" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_NOEFFECT = 1 -->
|
||||
<Effect id="1" name="No Effect">
|
||||
<ShaderPostProcess name="Full Screen Quad" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_INVERT = 2 -->
|
||||
<Effect id="2" name="Invert">
|
||||
<ShaderPostProcess name="Invert" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/invert.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_SEPIA = 3 -->
|
||||
<Effect id="3" name="Sepia">
|
||||
<ShaderPostProcess name="Sepia" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/sepia.psh" psType="4" >
|
||||
<PixelShaderConstant name="Toning" value="1.0" />
|
||||
<PixelShaderConstant name="Desaturation" value="0.0" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_GRAYSCALE = 4 -->
|
||||
<Effect id="4" name="Grayscale">
|
||||
<ShaderPostProcess name="Grayscale" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/grayscale.psh" psType="4" >
|
||||
<PixelShaderConstant name="BaseGray" value="0.0" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_SIMPLE_BOOLM = 5 -->
|
||||
<Effect id="5" name="Simple Bloom">
|
||||
<ShaderPostProcess name="Simple Bloom" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/simplebloom.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="8.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_ADAPTIVE_BLOOM = 6 -->
|
||||
<Effect id="6" name="Adaptive Bloom">
|
||||
<!-- downscale pass -->
|
||||
<ShaderPostProcess name="Downscale" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/downscale2x2.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="rtt1" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- luminance pass -->
|
||||
<ShaderPostProcess name="Luminance Pass 1 (Init)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_init.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt_lg0" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 2 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg0" />
|
||||
<RenderTarget path="rtt_lg1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 3 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg1" />
|
||||
<RenderTarget path="rtt_lg2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 4 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg2" />
|
||||
<RenderTarget path="rtt_lg3" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 5 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg3" />
|
||||
<RenderTarget path="rtt_lg4" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- luminance adaption -->
|
||||
<ShaderPostProcess name="Luminance Pass 6 (Adaption)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_adapt.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.1" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="rtt_lg4" textureClamp="1" />
|
||||
<RenderSource path="prevLum" />
|
||||
<RenderTarget path="finalLum" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- brightpass -->
|
||||
<ShaderPostProcess name="Brightpass" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/brightpass.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="3.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="finalLum" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- save luminance for next adaption step -->
|
||||
<ShaderPostProcess name="Luminance (Save)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="finalLum" />
|
||||
<RenderTarget path="prevLum" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- blur 1st pass -->
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt0" />
|
||||
<RenderTarget path="rtt1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 2nd pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt0" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt3" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt3" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 3rd pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt5" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt5" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 4th pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt6" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt6" />
|
||||
<RenderTarget path="rtt7" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt7" />
|
||||
<RenderTarget path="rtt6" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- upscale blur -->
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt6" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- accumulate blur and original buffer-->
|
||||
<ShaderPostProcess name="Accumulate (Final Pass)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/accumulate.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="1.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="rtt0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_MOTION_BLUR = 7 -->
|
||||
<Effect id="7" name="Motion Blur">
|
||||
<ShaderPostProcess name="Motion Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/motionblur.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.45" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="prevBuffer" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Save Frame" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxOut" />
|
||||
<RenderTarget path="prevBuffer" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_NIGHT_VISION = 8 -->
|
||||
<Effect id="8" name="Night Vision">
|
||||
<ShaderPostProcess name="Nightvison" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/nightvision.psh" psType="4" psUseRandom="1" >
|
||||
<PixelShaderConstant name="LuminanceThreshold" value="0.01" />
|
||||
<PixelShaderConstant name="ColorAmplification" value="0.4" />
|
||||
<PixelShaderConstant name="NoiseStrength" value="1.2" />
|
||||
<PixelShaderConstant name="VisionColorR" value="0.1" />
|
||||
<PixelShaderConstant name="VisionColorG" value="0.99" />
|
||||
<PixelShaderConstant name="VisionColorB" value="0.1" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/noise1.png" />
|
||||
<Texture index="2" path="./Data/textures/postprocess/scope.png" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_DREAM_VISION = 9 -->
|
||||
<Effect id="9" name="Dream Vision">
|
||||
<ShaderPostProcess name="Dreamvision" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/dreamvision.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_POSTERIZE = 10 -->
|
||||
<Effect id="10" name="Posterize">
|
||||
<ShaderPostProcess name="Posterize" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/posterize.psh" psType="4" >
|
||||
<PixelShaderConstant name="NumColors" value="8.0" />
|
||||
<PixelShaderConstant name="Gamma" value="0.6" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_SHARPEN = 11 -->
|
||||
<Effect id="11" name="Sharpen Edges">
|
||||
<ShaderPostProcess name="Sharpen" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/sharpen.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<UseBufferWidth/>
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_EMBOSSED = 12 -->
|
||||
<Effect id="12" name="Embossed">
|
||||
<ShaderPostProcess name="Embossed" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/embossed.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<PixelShaderConstant name="Contrast" value="2.0" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_TILING = 13 -->
|
||||
<Effect id="13" name="Tiling">
|
||||
<ShaderPostProcess name="Tiling" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/tiling.psh" psType="4" >
|
||||
<PixelShaderConstant name="NumTilesX" value="102.0" />
|
||||
<PixelShaderConstant name="NumTilesY" value="96.0" />
|
||||
<PixelShaderConstant name="Threshhold" value="0.1" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_DISPLACEMENT = 14 -->
|
||||
<Effect id="14" name="Displacement">
|
||||
<ShaderPostProcess name="Displacement" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/displacement.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.05" />
|
||||
<Texture index="0" textureClamp="4" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/water.png" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_SCRATCHED = 15 -->
|
||||
<Effect id="15" name="Scratched">
|
||||
<ShaderPostProcess name="Scratched" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/scratched.psh" psType="4" psUseElapsedTime="1" >
|
||||
<PixelShaderConstant name="Speed1" value="0.03" />
|
||||
<PixelShaderConstant name="Speed2" value="0.01" />
|
||||
<PixelShaderConstant name="ScratchIntensity" value="0.65" />
|
||||
<PixelShaderConstant name="IS" value="0.01" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/noise2.png" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_PENCIL = 16 -->
|
||||
<Effect id="16" name="Pencil Scetch">
|
||||
<ShaderPostProcess name="Pencil Scetch" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/pencil.psh" psType="4" psUseElapsedTime="1">
|
||||
<PixelShaderConstant name="Brightness" value="1.5" />
|
||||
<PixelShaderConstant name="EffectStrength" value="15.0" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/pencil.png" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_BLUR = 17 -->
|
||||
<Effect id="17" name="Gaussian Blur">
|
||||
<ShaderPostProcess name="Downscale" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/downscale2x2.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="blur0" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="blur0" />
|
||||
<RenderTarget path="blur1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="blur1" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_WATER = 18 -->
|
||||
<Effect id="18" name="Water">
|
||||
<ShaderPostProcess name="Water" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/water.psh" psType="4" psUseElapsedTime="1" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.05" />
|
||||
<PixelShaderConstant name="Speed" value="0.05" />
|
||||
<Texture index="0" textureClamp="4" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/water.png" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_COLOR = 19 -->
|
||||
<Effect id="19" name="Color">
|
||||
<ShaderPostProcess name="Color" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/color.psh" psType="4" >
|
||||
<PixelShaderConstant name="ColorR" value="0.7" />
|
||||
<PixelShaderConstant name="ColorG" value="1.0" />
|
||||
<PixelShaderConstant name="ColorB" value="2.0" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_PULSING = 20 -->
|
||||
<Effect id="20" name="Pulsing">
|
||||
<ShaderPostProcess name="Pulsing" vsFile="postprocess/pulsing.vsh" vsType="1" psFile="postprocess/screenquad.psh" psType="4" vsUseElapsedTime="1" >
|
||||
<VertexShaderConstant name="Speed" value="0.25" />
|
||||
<VertexShaderConstant name="Speed2" value="2.2" />
|
||||
<VertexShaderConstant name="Pulse" value="0.65" />
|
||||
<VertexShaderConstant name="PulseE" value="1.5" />
|
||||
<VertexShaderConstant name="CenterX" value="0.5" />
|
||||
<VertexShaderConstant name="CenterY" value="0.5" />
|
||||
<Texture index="0" textureClamp="0" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_SHAKE = 21 -->
|
||||
<Effect id="21" name="Shaking">
|
||||
<ShaderPostProcess name="Shake" vsFile="postprocess/shake.vsh" vsType="1" psFile="postprocess/screenquad.psh" psType="4" vsUseRandom="1" >
|
||||
<VertexShaderConstant name="Sharpness" value="2.2" />
|
||||
<VertexShaderConstant name="Shake" value="0.1" />
|
||||
<Texture index="0" textureClamp="4" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_DESTAURATE = 22 -->
|
||||
<Effect id="22" name="Desaturation">
|
||||
<ShaderPostProcess name="Desaturate" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/desaturate.psh" psType="4" >
|
||||
<PixelShaderConstant name="Desaturation" value="0.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_RADIAL_BLUR = 23 -->
|
||||
<Effect id="23" name="Radial Blur">
|
||||
<ShaderPostProcess name="Radial Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/radialblur.psh" psType="4" >
|
||||
<PixelShaderConstant name="SampleDist" value="0.60" />
|
||||
<PixelShaderConstant name="SampleStrength" value="1.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_DEPTH_OF_FIELD = 24 -->
|
||||
<Effect id="24" name="Depth of Field">
|
||||
<!-- donwscale pass -->
|
||||
<ShaderPostProcess name="Downscale" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/downscale2x2.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="blur0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- blur pass -->
|
||||
<ShaderPostProcess name="Horizontal Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="blur0" />
|
||||
<RenderTarget path="blur1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="blur1" />
|
||||
<RenderTarget path="blur0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- depth of field -->
|
||||
<ShaderPostProcess name="Depth of Field" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/depthoffield.psh" psType="4" >
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="blur0" textureClamp="1" />
|
||||
<Texture index="2" path="rttDepth" textureClamp="1" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_VIGNETTE = 25 -->
|
||||
<Effect id="25" name="Vignette">
|
||||
<ShaderPostProcess name="Vignette" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vignette.psh" psType="4" >
|
||||
<PixelShaderConstant name="EdgeDarkness" value="0.9" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_UNDER_WATER = 26 -->
|
||||
<Effect id="26" name="Underwater">
|
||||
<ShaderPostProcess name="Underwater" vsFile="postprocess/underwater.vsh" vsType="1" psFile="postprocess/underwater.psh" psType="4" vsUseElapsedTime="1" psUseElapsedTime="1">
|
||||
<PixelShaderConstant name="EffectStrength" value="0.025" />
|
||||
<PixelShaderConstant name="Speed" value="0.01" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="./Data/textures/postprocess/water.png" />
|
||||
<Texture index="2" path="rttDepth" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
<!-- EPPE_ADAPTIVE_BLOOM = 27 -->
|
||||
<Effect id="27" name="GUI">
|
||||
<!-- downscale pass -->
|
||||
<ShaderPostProcess name="Downscale" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/downscale2x2.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="rtt1" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- luminance pass -->
|
||||
<ShaderPostProcess name="Luminance Pass 1 (Init)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_init.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt_lg0" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 2 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg0" />
|
||||
<RenderTarget path="rtt_lg1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 3 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg1" />
|
||||
<RenderTarget path="rtt_lg2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 4 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg2" />
|
||||
<RenderTarget path="rtt_lg3" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Luminance Pass 5 (Iteration)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_iter.psh" psType="4" psUseBufferWidth="1" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt_lg3" />
|
||||
<RenderTarget path="rtt_lg4" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- luminance adaption -->
|
||||
<ShaderPostProcess name="Luminance Pass 6 (Adaption)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/luminance_adapt.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="0.1" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="rtt_lg4" textureClamp="1" />
|
||||
<RenderSource path="prevLumGUI" />
|
||||
<RenderTarget path="finalLum" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- brightpass -->
|
||||
<ShaderPostProcess name="Brightpass" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/brightpass_gui.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="3.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="finalLum" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- save luminance for next adaption step -->
|
||||
<ShaderPostProcess name="Luminance (Save)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="finalLum" />
|
||||
<RenderTarget path="prevLumGUI" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- blur 1st pass -->
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt0" />
|
||||
<RenderTarget path="rtt1" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt1" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 2nd pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt0" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt3" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt3" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 3rd pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt5" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt5" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- donwscale and blur 4th pass -->
|
||||
<ShaderPostProcess name="Downscale Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt6" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Horizontal Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/hblur.psh" psType="4" psUseBufferWidth="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt6" />
|
||||
<RenderTarget path="rtt7" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Vertical Blur (Pass 3)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/vblur.psh" psType="4" psUseBufferHeight="1">
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt7" />
|
||||
<RenderTarget path="rtt6" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- upscale blur -->
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 0)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt6" />
|
||||
<RenderTarget path="rtt4" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 1)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt4" />
|
||||
<RenderTarget path="rtt2" />
|
||||
</ShaderPostProcess>
|
||||
<ShaderPostProcess name="Upscale Blur (Pass 2)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/screenquad.psh" psType="4" >
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<RenderSource path="rtt2" />
|
||||
<RenderTarget path="rtt0" />
|
||||
</ShaderPostProcess>
|
||||
|
||||
<!-- accumulate blur and original buffer-->
|
||||
<ShaderPostProcess name="Accumulate (Final Pass)" vsFile="postprocess/vertex.vsh" vsType="0" psFile="postprocess/accumulate.psh" psType="4" >
|
||||
<PixelShaderConstant name="EffectStrength" value="1.5" />
|
||||
<Texture index="0" textureClamp="1" />
|
||||
<Texture index="1" path="rtt0" textureClamp="1" />
|
||||
<RenderSource path="auxIn" />
|
||||
<RenderTarget path="auxOut" />
|
||||
</ShaderPostProcess>
|
||||
</Effect>
|
||||
|
||||
</Setup>
|
61
config/rtt.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Setup of the PostProcessManager (render target textures)
|
||||
|
||||
parameters for RenderTarget:
|
||||
****************************
|
||||
id: unique path or name of the render target texture
|
||||
colorFormat: ECOLOR_FORMAT of the render target texture
|
||||
width: width of the render target texture
|
||||
height: height of the render target texture
|
||||
scale: scale of the texture (dimesion=ScreenSize*scale)
|
||||
if scale is given then width and height are ignored
|
||||
|
||||
**********************
|
||||
colorFormat:
|
||||
**********************
|
||||
ECF_A1R5G5B5 = 0,
|
||||
ECF_R5G6B5 = 1,
|
||||
ECF_R8G8B8 = 2,
|
||||
ECF_A8R8G8B8 = 3,
|
||||
ECF_R16F = 4,
|
||||
ECF_G16R16F = 5,
|
||||
ECF_A16B16G16R16F = 6,
|
||||
ECF_R32F = 7,
|
||||
ECF_G32R32F = 8,
|
||||
ECF_A32B32G32R32F = 9,
|
||||
ECF_UNKNOWN = 10,
|
||||
-->
|
||||
<Setup>
|
||||
<!-- default auxiliary buffers (auxIn, auxOut and rttDepth)-->
|
||||
<RenderTarget id="auxIn" colorFormat="10" scale="1.0" />
|
||||
<RenderTarget id="auxOut" colorFormat="10" scale="1.0" />
|
||||
<RenderTarget id="rttDepth" colorFormat="6" scale="1.0" />
|
||||
|
||||
<!-- additional render target textures adaptive bloom-->
|
||||
<RenderTarget id="rtt0" colorFormat="10" scale="0.5"/>
|
||||
<RenderTarget id="rtt1" colorFormat="10" scale="0.5"/>
|
||||
<RenderTarget id="rtt2" colorFormat="10" scale="0.25"/>
|
||||
<RenderTarget id="rtt3" colorFormat="10" scale="0.25"/>
|
||||
<RenderTarget id="rtt4" colorFormat="10" scale="0.125"/>
|
||||
<RenderTarget id="rtt5" colorFormat="10" scale="0.125"/>
|
||||
<RenderTarget id="rtt6" colorFormat="10" scale="0.0625"/>
|
||||
<RenderTarget id="rtt7" colorFormat="10" scale="0.0625"/>
|
||||
<RenderTarget id="rtt_lg0" colorFormat="4" width="256" height="256" />
|
||||
<RenderTarget id="rtt_lg1" colorFormat="4" width="64" height="64" />
|
||||
<RenderTarget id="rtt_lg2" colorFormat="4" width="16" height="16" />
|
||||
<RenderTarget id="rtt_lg3" colorFormat="4" width="4" height="4" />
|
||||
<RenderTarget id="rtt_lg4" colorFormat="4" width="1" height="1" />
|
||||
<RenderTarget id="prevLum" colorFormat="4" width="1" height="1" />
|
||||
<RenderTarget id="finalLum" colorFormat="4" width="1" height="1" />
|
||||
|
||||
<!-- GUI -->
|
||||
<RenderTarget id="prevLumGUI" colorFormat="4" width="1" height="1" />
|
||||
|
||||
<!-- motionblur -->
|
||||
<RenderTarget id="prevBuffer" colorFormat="10" scale ="1.0" />
|
||||
|
||||
<!-- depth of field and blur-->
|
||||
<RenderTarget id="blur0" colorFormat="10" scale="0.5" />
|
||||
<RenderTarget id="blur1" colorFormat="10" scale="0.5" />
|
||||
</Setup>
|
143
main.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
#include <irrlicht.h>
|
||||
|
||||
#include "TerrainTexturing.h"
|
||||
#include "PostProcessManager.h"
|
||||
#include "ShaderPostProcess.h"
|
||||
#include "WaterSceneNode.h"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#define MAP_CHUNK_SIZE 256
|
||||
#define MAP_SCALE 10
|
||||
#define MAP_SCALE_Y 0.08 * MAP_SCALE
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
//Set up device and receiver
|
||||
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480), 32, false, false, false);
|
||||
|
||||
video::IVideoDriver *driver = device->getVideoDriver();
|
||||
scene::ISceneManager *smgr = device->getSceneManager();
|
||||
|
||||
//Create the camera
|
||||
SKeyMap keyMap[8];
|
||||
keyMap[0].Action = EKA_MOVE_FORWARD;
|
||||
keyMap[0].KeyCode = KEY_UP;
|
||||
keyMap[1].Action = EKA_MOVE_FORWARD;
|
||||
keyMap[1].KeyCode = KEY_KEY_W;
|
||||
|
||||
keyMap[2].Action = EKA_MOVE_BACKWARD;
|
||||
keyMap[2].KeyCode = KEY_DOWN;
|
||||
keyMap[3].Action = EKA_MOVE_BACKWARD;
|
||||
keyMap[3].KeyCode = KEY_KEY_S;
|
||||
|
||||
keyMap[4].Action = EKA_STRAFE_LEFT;
|
||||
keyMap[4].KeyCode = KEY_LEFT;
|
||||
keyMap[5].Action = EKA_STRAFE_LEFT;
|
||||
keyMap[5].KeyCode = KEY_KEY_A;
|
||||
|
||||
keyMap[6].Action = EKA_STRAFE_RIGHT;
|
||||
keyMap[6].KeyCode = KEY_RIGHT;
|
||||
keyMap[7].Action = EKA_STRAFE_RIGHT;
|
||||
keyMap[7].KeyCode = KEY_KEY_D;
|
||||
|
||||
scene::ICameraSceneNode *camera = smgr->addCameraSceneNodeFPS(0, 100, 0.6, -1, keyMap, 8);
|
||||
camera->setPosition(core::vector3df(1300, 250, 0));
|
||||
camera->setTarget(core::vector3df(600, 0, 600));
|
||||
camera->setNearValue(0.01);
|
||||
|
||||
scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture("Data/textures/skydome.jpg"), 16, 8, 0.95f, 2.0f);
|
||||
skydome->setRotation(core::vector3df(0, -100, 0));
|
||||
TerrainTexturing *texture_manager = new TerrainTexturing(device, smgr);
|
||||
|
||||
CPostProcessManager *postProcessManager = new CPostProcessManager(device);
|
||||
irr::scene::CWaterSceneNode *waterNode;
|
||||
|
||||
//Create a terrain like in the terrain sample
|
||||
scene::ITerrainSceneNode *terrain = smgr->addTerrainSceneNode("Data/textures/splatting_test.png",
|
||||
0, // parent node
|
||||
-1, // node id
|
||||
core::vector3df(00.f, -(MAP_SCALE_Y * MAP_CHUNK_SIZE) / 2, 00.f), // position
|
||||
core::vector3df(0.f, 0.f, 0.f), // rotation
|
||||
core::vector3df(MAP_SCALE, MAP_SCALE_Y, MAP_SCALE), // scale
|
||||
video::SColor(255, 255, 255, 255), // vertexColor
|
||||
5, // maxLOD
|
||||
scene::ETPS_17, // patchSize
|
||||
3); // smoothFactor
|
||||
|
||||
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
terrain->scaleTexture(1.0f, 20.0f);
|
||||
terrain->setScale(core::vector3df(5, 2, 5));
|
||||
|
||||
//Add it to the manager
|
||||
texture_manager->addNode(terrain);
|
||||
|
||||
//Set the passes
|
||||
//First Pass, with Sand, Gras and Rock
|
||||
texture_manager->addTextures(terrain,
|
||||
driver->getTexture("Data/textures/splat_1.tga"),
|
||||
driver->getTexture("Data/textures/Gras.jpg"),
|
||||
driver->getTexture("Data/textures/Sand.jpg"),
|
||||
driver->getTexture("Data/textures/Rock.jpg"));
|
||||
|
||||
waterNode = new scene::CWaterSceneNode(smgr->getRootSceneNode(),
|
||||
device,
|
||||
smgr,
|
||||
-1,
|
||||
core::dimension2d<u32>(256, 256),
|
||||
core::dimension2d<f32>((MAP_SCALE * MAP_CHUNK_SIZE) * 3, (MAP_SCALE * MAP_CHUNK_SIZE) * 3));
|
||||
|
||||
waterNode->setPosition(core::vector3df((MAP_SCALE * MAP_CHUNK_SIZE) / 2, 0, (MAP_SCALE * MAP_CHUNK_SIZE) / 2));
|
||||
waterNode->drop();
|
||||
|
||||
postProcessManager->addNodeToDepthPass(terrain);
|
||||
|
||||
//FPS measurement
|
||||
int lastFPS = -1;
|
||||
|
||||
while (device->run()) {
|
||||
//Draw the scene
|
||||
driver->beginScene(true, true, video::SColor(50, 50, 50, 50));
|
||||
|
||||
postProcessManager->renderDepth(); //create the depth information of the scene
|
||||
waterNode->updateWater(); //update the water node (prepare reflection and refraction rtt)
|
||||
postProcessManager->prepare(); //prepare scene for post processing (render into the PostProcess rtt)
|
||||
|
||||
smgr->drawAll();
|
||||
texture_manager->drawAll();
|
||||
|
||||
//apply postprocessing
|
||||
if (waterNode->getUnderWater()) {
|
||||
//set the underwater vars
|
||||
CShaderPostProcess* underWaterPass = (CShaderPostProcess*)postProcessManager->getEffectChain(EPPE_UNDER_WATER)[0];
|
||||
underWaterPass->getShaderMaterial()->setPixelShaderConstant("WaterColor", &waterNode->getWaterData().WaterColor.r, 4);
|
||||
underWaterPass->getShaderMaterial()->setPixelShaderConstant("BlendFactor", &waterNode->getWaterData().BlendFactor, 1);
|
||||
postProcessManager->render(EPPE_UNDER_WATER);
|
||||
}
|
||||
|
||||
//finalize post processing
|
||||
//(render to the framebuffer)
|
||||
postProcessManager->update();
|
||||
|
||||
driver->endScene();
|
||||
|
||||
//Display the FPS
|
||||
int fps = driver->getFPS();
|
||||
|
||||
if (lastFPS != fps) {
|
||||
core::stringw str = L"Texture Splatting with water - Move with Mouse and WASD/Arrow Keys - FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
}
|
||||
|
||||
//Cleanup
|
||||
device->drop();
|
||||
delete waterNode;
|
||||
delete postProcessManager;
|
||||
delete texture_manager;
|
||||
|
||||
return 0;
|
||||
}
|
2047
shaders/fxaa3_11.h
Normal file
13
shaders/glsl/terrain.psh
Normal file
@ -0,0 +1,13 @@
|
||||
uniform sampler2D alphaMap;
|
||||
uniform sampler2D layer_red;
|
||||
uniform sampler2D layer_green;
|
||||
uniform sampler2D layer_blue;
|
||||
|
||||
void main() {
|
||||
vec4 alphaChannel = texture2D(alphaMap, gl_TexCoord[0].xy);
|
||||
vec4 RedChannel = texture2D(layer_red, gl_TexCoord[1].xy);
|
||||
vec4 GreenChannel = texture2D(layer_green, gl_TexCoord[1].xy);
|
||||
vec4 BlueChannel = texture2D(layer_blue, gl_TexCoord[1].xy);
|
||||
|
||||
gl_FragColor = vec4(alphaChannel.r * RedChannel + alphaChannel.g * GreenChannel + alphaChannel.b * BlueChannel) * vec4(1, 1, 1, alphaChannel.a);
|
||||
}
|
6
shaders/glsl/terrain.vsh
Normal file
@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = ftransform();
|
||||
}
|
18
shaders/hlsl/postprocess/accumulate.psh
Normal file
@ -0,0 +1,18 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D BlurBuffer : register(s1);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// Bloom color
|
||||
float4 col0 = tex2D(BlurBuffer, texCoord.xy);
|
||||
|
||||
// Scene
|
||||
float4 col1 = tex2D(SceneBuffer, texCoord.xy);
|
||||
|
||||
// Tonemap (using photographic exposure mapping)
|
||||
float4 col2 = 1.0-exp2(-EffectStrength*col0);
|
||||
|
||||
return (col2+col1);
|
||||
}
|
40
shaders/hlsl/postprocess/brightpass.psh
Normal file
@ -0,0 +1,40 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D LumBuffer : register(s1);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
float4 lumCol = tex2D(LumBuffer, float2(0.5,0.5));
|
||||
float4 texCol = tex2D(SceneBuffer, texCoord);
|
||||
|
||||
// There are a number of ways we can try and convert the RGB value into
|
||||
// a single luminance value:
|
||||
|
||||
// 1. Do a very simple mathematical average:
|
||||
//float lumValue = dot(texCol.rgb, float3(0.33, 0.33, 0.33));
|
||||
|
||||
// 2. Perform a more accurately weighted average:
|
||||
//float lumValue = dot(texCol.rgb, ITU_R_709);
|
||||
|
||||
// 3. Take the maximum value of the incoming, same as computing the
|
||||
// brightness/value for an HSV/HSB conversion:
|
||||
//float lumValue = max(texCol.r, max(texCol.g, texCol.b));
|
||||
|
||||
// 4. Compute the luminance component as per the HSL colour space:
|
||||
float lumValue = 0.5*(max(texCol.r, max(texCol.g, texCol.b))+min(texCol.r, min(texCol.g,texCol.b)));
|
||||
|
||||
// 5. Use the magnitude of the colour
|
||||
//float lumValue = length(texCol.rgb);
|
||||
|
||||
if(lumValue < min(lumCol.r*EffectStrength, 0.99))
|
||||
{
|
||||
texCol.rgb = 0.0;
|
||||
}
|
||||
return texCol;
|
||||
}
|
||||
|
24
shaders/hlsl/postprocess/color.psh
Normal file
@ -0,0 +1,24 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float ColorR;
|
||||
uniform float ColorG;
|
||||
uniform float ColorB;
|
||||
|
||||
float4 main(float2 texCoord: TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
float4 texCol = tex2D(SceneBuffer, texCoord);
|
||||
float lum = dot(texCol.rgb, ITU_R_601);
|
||||
float4 finalCol = float4
|
||||
(
|
||||
pow(lum, 1.0/ColorR),
|
||||
pow(lum, 1.0/ColorG),
|
||||
pow(lum, 1.0/ColorG),
|
||||
texCol.a
|
||||
)*ColorB+texCol*(1.0-ColorB);
|
||||
|
||||
return finalCol;
|
||||
}
|
29
shaders/hlsl/postprocess/depthoffield.psh
Normal file
@ -0,0 +1,29 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D BlurBuffer : register(s1);
|
||||
uniform sampler2D DistanceBuffer : register(s2);
|
||||
|
||||
float getDepth(float2 coords)
|
||||
{
|
||||
float4 texDepth = tex2D(DistanceBuffer, coords);
|
||||
return texDepth.a;
|
||||
}
|
||||
|
||||
float4 main(float2 texCoord: TEXCOORD0):COLOR0
|
||||
{
|
||||
float4 sharp = tex2D(SceneBuffer, texCoord);
|
||||
float4 blur = tex2D(BlurBuffer, texCoord);
|
||||
float dist = saturate(getDepth(texCoord)*10.0);
|
||||
float factor = 0.0;
|
||||
|
||||
if (dist < 0.05)
|
||||
factor = 1.0;
|
||||
else if(dist < 0.1)
|
||||
factor = 20.0 *(0.1 - dist);
|
||||
else if(dist < 0.5)
|
||||
factor=0;
|
||||
else
|
||||
factor = 2.0 *(dist - 0.5);
|
||||
|
||||
factor = clamp(factor, 0.0, 0.90);
|
||||
return lerp(sharp, blur, factor);
|
||||
}
|
19
shaders/hlsl/postprocess/desaturate.psh
Normal file
@ -0,0 +1,19 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float Desaturation;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
float4 texColor = tex2D(SceneBuffer, texCoord);
|
||||
|
||||
float3 gray = dot(texColor.rgb, ITU_R_601);
|
||||
float3 result = lerp(texColor, gray.xxx, Desaturation);
|
||||
return float4(result, 1.0);
|
||||
}
|
13
shaders/hlsl/postprocess/displacement.psh
Normal file
@ -0,0 +1,13 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D NormalTex : register(s1);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float4 normalCol = 2.0*tex2D(NormalTex, texCoord)-1.0;
|
||||
return tex2D(SceneBuffer, texCoord+normalCol.xy*EffectStrength);
|
||||
}
|
22
shaders/hlsl/postprocess/downscale2x2.psh
Normal file
@ -0,0 +1,22 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float2 texSize = float2(1.0/BufferWidth, 1.0/BufferHeight);
|
||||
float4 average=0.0;
|
||||
const float2 samples[4] = {
|
||||
{-0.5, -0.5},
|
||||
{-0.5, 0.5},
|
||||
{ 0.5, -0.5},
|
||||
{ 0.5, 0.5}
|
||||
};
|
||||
for (int i=0; i<4; ++i)
|
||||
{
|
||||
average += tex2D(SceneBuffer, texCoord+texSize*samples[i]);
|
||||
}
|
||||
float4 finalCol = average*0.25;
|
||||
return finalCol;
|
||||
}
|
31
shaders/hlsl/postprocess/dreamvision.psh
Normal file
@ -0,0 +1,31 @@
|
||||
// based on http://www.geeks3d.com/20091112/shader-library-dream-vision-post-processing-filter-glsl/
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 finalCol = tex2D(SceneBuffer, texCoord);
|
||||
float4 dreamCol = finalCol;
|
||||
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.001);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.003);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.005);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.007);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.009);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord+0.011);
|
||||
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.001);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.003);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.005);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.007);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.009);
|
||||
dreamCol += tex2D(SceneBuffer, texCoord-0.011);
|
||||
dreamCol = dreamCol/9.5;
|
||||
|
||||
return lerp(finalCol, dreamCol, EffectStrength);
|
||||
}
|
||||
|
||||
|
||||
|
17
shaders/hlsl/postprocess/embossed.psh
Normal file
@ -0,0 +1,17 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
uniform float Contrast;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float2 texSize = float2(1.0/BufferWidth, 1.0/BufferHeight);
|
||||
float4 finalCol;
|
||||
finalCol.a = 1.0;
|
||||
finalCol.rgb = 0.5;
|
||||
finalCol -= tex2D(SceneBuffer, texCoord-texSize)*Contrast;
|
||||
finalCol += tex2D(SceneBuffer, texCoord+texSize)*Contrast;
|
||||
finalCol.rgb = (finalCol.r+finalCol.g+finalCol.b)/3.0;
|
||||
return finalCol;
|
||||
}
|
44
shaders/hlsl/postprocess/finalpass_fxaa.psh
Normal file
@ -0,0 +1,44 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
|
||||
#define FXAA_PC 1
|
||||
#define FXAA_HLSL_3 1
|
||||
#define FXAA_QUALITY__PRESET 23
|
||||
#define FXAA_GREEN_AS_LUMA 1
|
||||
#include "media/shaders/fxaa3_11.h"
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
FxaaFloat2 fxaaQualityRcpFrame = FxaaFloat2(1.0/BufferWidth, 1.0/BufferHeight);
|
||||
FxaaFloat4 fxaaConsoleRcpFrameOpt = FxaaFloat4(-0.5/BufferWidth, -0.5/BufferHeight, 0.5/BufferWidth, 0.5/BufferHeight);
|
||||
FxaaFloat4 fxaaConsoleRcpFrameOpt2 = FxaaFloat4(-2.0/BufferWidth, -2.0/BufferHeight, 2.0/BufferWidth, 2.0/BufferHeight);
|
||||
FxaaFloat4 fxaaConsole360RcpFrameOpt2 = FxaaFloat4(8.0/BufferWidth, 8.0/BufferHeight, -4.0/BufferWidth, -4.0/BufferHeight);
|
||||
FxaaFloat fxaaQualitySubpix = 0.75;
|
||||
FxaaFloat fxaaQualityEdgeThreshold = 0.166;
|
||||
FxaaFloat fxaaQualityEdgeThresholdMin = 0.0625;
|
||||
FxaaFloat fxaaConsoleEdgeSharpness = 8.0;
|
||||
FxaaFloat fxaaConsoleEdgeThreshold = 0.125;
|
||||
FxaaFloat fxaaConsoleEdgeThresholdMin = 0.05;
|
||||
FxaaFloat4 fxaaConsole360ConstDir = FxaaFloat4(1.0, -1.0, 0.25, -0.25);
|
||||
FxaaFloat4 texCoord2 = FxaaFloat4(texCoord.x, texCoord.y, texCoord.x, texCoord.y)+fxaaConsoleRcpFrameOpt;
|
||||
|
||||
return FxaaPixelShader(
|
||||
texCoord,
|
||||
texCoord2,
|
||||
SceneBuffer,
|
||||
SceneBuffer,
|
||||
SceneBuffer,
|
||||
fxaaQualityRcpFrame,
|
||||
fxaaConsoleRcpFrameOpt,
|
||||
fxaaConsoleRcpFrameOpt2,
|
||||
fxaaConsole360RcpFrameOpt2,
|
||||
fxaaQualitySubpix,
|
||||
fxaaQualityEdgeThreshold,
|
||||
fxaaQualityEdgeThresholdMin,
|
||||
fxaaConsoleEdgeSharpness,
|
||||
fxaaConsoleEdgeThreshold,
|
||||
fxaaConsoleEdgeThresholdMin,
|
||||
fxaaConsole360ConstDir);
|
||||
}
|
17
shaders/hlsl/postprocess/grayscale.psh
Normal file
@ -0,0 +1,17 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BaseGray;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
float4 texColor = tex2D(SceneBuffer, texCoord);
|
||||
float gray = BaseGray+dot(texColor.rgb, ITU_R_601);
|
||||
return float4(gray.xxx, 1.0);
|
||||
}
|
54
shaders/hlsl/postprocess/hblur.psh
Normal file
@ -0,0 +1,54 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float blurSize = 1.0/BufferWidth;
|
||||
float4 finalCol = 0.0;
|
||||
|
||||
// gauss distribution with mean:0 std:2
|
||||
float weight[9] = {
|
||||
0.0295,
|
||||
0.0673,
|
||||
0.1235,
|
||||
0.1786,
|
||||
0.2022,
|
||||
0.1786,
|
||||
0.1235,
|
||||
0.0673,
|
||||
0.0295
|
||||
};
|
||||
|
||||
// blur in x (horizontal)
|
||||
// take the samples with the distance blurSize between them
|
||||
for (int i=0; i<9; i++)
|
||||
finalCol += tex2D(SceneBuffer, float2(texCoord.x+(i-4)*blurSize, texCoord.y))*weight[i];
|
||||
|
||||
return finalCol;
|
||||
}
|
||||
|
||||
|
||||
float4 main7x7(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float blurSize = 1.0/BufferWidth;
|
||||
float4 finalCol = 0.0;
|
||||
|
||||
// gauss distribution with mean:0 std:1
|
||||
float weight[7] = {
|
||||
0.0050,
|
||||
0.0540,
|
||||
0.2410,
|
||||
0.4000,
|
||||
0.2410,
|
||||
0.0540,
|
||||
0.0050
|
||||
};
|
||||
|
||||
// blur in x (horizontal)
|
||||
// take the samples with the distance blurSize between them
|
||||
for (int i=0; i<7; i++)
|
||||
finalCol += tex2D(SceneBuffer, float2(texCoord.x+(i-3)*blurSize, texCoord.y))*weight[i];
|
||||
|
||||
return finalCol;
|
||||
}
|
6
shaders/hlsl/postprocess/invert.psh
Normal file
@ -0,0 +1,6 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
return float4(1.0-tex2D(SceneBuffer, texCoord).rgb, 1.0);
|
||||
}
|
11
shaders/hlsl/postprocess/luminance_adapt.psh
Normal file
@ -0,0 +1,11 @@
|
||||
uniform sampler2D PrevLumBuffer : register(s0);
|
||||
uniform sampler2D TargetLumBuffer : register(s1);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 prevLum = tex2D(PrevLumBuffer, texCoord);
|
||||
float4 targetLum = tex2D(TargetLumBuffer, texCoord);
|
||||
return saturate(prevLum+(targetLum-prevLum)*EffectStrength);
|
||||
}
|
46
shaders/hlsl/postprocess/luminance_init.psh
Normal file
@ -0,0 +1,46 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
float2 texSize = float2(1.0/BufferWidth, 1.0/BufferHeight);
|
||||
float4 texCol = 0.0;
|
||||
float average = 0.0;
|
||||
for (int v=0; v<2; v++)
|
||||
{
|
||||
for (int u=0; u<2; u++)
|
||||
{
|
||||
texCol = tex2D(SceneBuffer, texCoord+texSize*float2(u, v));
|
||||
|
||||
// There are a number of ways we can try and convert the RGB value into
|
||||
// a single luminance value:
|
||||
|
||||
// 1. Do a very simple mathematical average:
|
||||
//float lumValue = dot(texCol.rgb, float3(0.33f, 0.33f, 0.33f));
|
||||
|
||||
// 2. Perform a more accurately weighted average:
|
||||
//float lumValue = dot(texCol.rgb, ITU_R_709);
|
||||
|
||||
// 3. Take the maximum value of the incoming, same as computing the
|
||||
// brightness/value for an HSV/HSB conversion:
|
||||
//float lumValue = max(texCol.r, max(texCol.g, texCol.b));
|
||||
|
||||
// 4. Compute the luminance component as per the HSL colour space:
|
||||
float lumValue = 0.5*(max(texCol.r, max(texCol.g, texCol.b))+min(texCol.r, min(texCol.g,texCol.b)));
|
||||
|
||||
// 5. Use the magnitude of the colour
|
||||
//float lumValue = length(texCol.rgb);
|
||||
|
||||
average += lumValue;
|
||||
}
|
||||
}
|
||||
average *= 0.25;
|
||||
return float4(average, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
20
shaders/hlsl/postprocess/luminance_iter.psh
Normal file
@ -0,0 +1,20 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float2 texSize = float2(1.0/BufferWidth, 1.0/BufferHeight);
|
||||
float4 average = 0.0;
|
||||
for (int v=0; v<4; v++)
|
||||
{
|
||||
for (int u=0; u<4; u++)
|
||||
{
|
||||
average += tex2D(SceneBuffer, texCoord+texSize*float2(u, v));
|
||||
}
|
||||
}
|
||||
average *= 0.0625;
|
||||
return average;
|
||||
}
|
||||
|
12
shaders/hlsl/postprocess/motionblur.psh
Normal file
@ -0,0 +1,12 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D PrevBuffer : register(s1);
|
||||
|
||||
uniform float EffectStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
return lerp(
|
||||
tex2D(SceneBuffer, texCoord),
|
||||
tex2D(PrevBuffer, texCoord),
|
||||
EffectStrength);
|
||||
}
|
37
shaders/hlsl/postprocess/nightvision.psh
Normal file
@ -0,0 +1,37 @@
|
||||
// based on http://www.geeks3d.com/20091009/shader-library-night-vision-post-processing-filter-glsl/
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D NoiseTex : register(s1);
|
||||
uniform sampler2D MaskTex : register(s2);
|
||||
|
||||
uniform float RandomValue;
|
||||
uniform float LuminanceThreshold;
|
||||
uniform float ColorAmplification;
|
||||
uniform float NoiseStrength;
|
||||
uniform float VisionColorR;
|
||||
uniform float VisionColorG;
|
||||
uniform float VisionColorB;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 finalCol;
|
||||
|
||||
// noise
|
||||
float2 noiseCoord;
|
||||
noiseCoord.x = RandomValue; // 0.4*sin(ElapsedTime*50.0);
|
||||
noiseCoord.y = RandomValue; // 0.4*cos(ElapsedTime*50.0);
|
||||
float3 noiseCol = tex2D(NoiseTex, (texCoord*NoiseStrength)+noiseCoord).rgb;
|
||||
|
||||
// light amplification
|
||||
float3 texCol = tex2D(SceneBuffer, texCoord+(noiseCol.xy*0.001)).rgb;
|
||||
texCol = saturate((texCol.rgb-LuminanceThreshold)/(ColorAmplification-LuminanceThreshold));
|
||||
|
||||
// mask
|
||||
float4 maskCol = tex2D(MaskTex, texCoord);
|
||||
|
||||
// calculate final color
|
||||
finalCol.rgb = lerp((texCol+(noiseCol*0.2))*float3(VisionColorR, VisionColorG, VisionColorB), maskCol.rgb, maskCol.a);
|
||||
finalCol.a = 1.0;
|
||||
|
||||
return finalCol;
|
||||
}
|
33
shaders/hlsl/postprocess/pencil.psh
Normal file
@ -0,0 +1,33 @@
|
||||
// based on the work of Shawn Hargreaves
|
||||
// http://www.talula.demon.co.uk/postprocessing/postprocessing.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D Pencil : register(s1);
|
||||
|
||||
uniform float Brightness;
|
||||
uniform float EffectStrength;
|
||||
uniform float ElapsedTime;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float4 col0 = float4(1.0, 0.0, 0.0, 0.0);
|
||||
float4 col1 = float4(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
// noise
|
||||
float2 noiseCoord;
|
||||
noiseCoord.x = 0.4*sin(ElapsedTime*50.0);
|
||||
noiseCoord.y = 0.4*cos(ElapsedTime*50.0);
|
||||
|
||||
float4 texCol = Brightness*tex2D(SceneBuffer, texCoord);
|
||||
float4 pen0 = tex2D(Pencil, (texCoord*EffectStrength)+noiseCoord);
|
||||
|
||||
float4 col2 = (1.0-texCol)*(pen0);
|
||||
|
||||
float pen1 = dot(col2, col0);
|
||||
float pen2 = dot(col2, col1);
|
||||
|
||||
float4 finalCol = float4(pen2, pen2, pen2, pen1);
|
||||
finalCol = (1.0-finalCol)*(1.0-finalCol.a);
|
||||
finalCol = saturate((finalCol-0.5)*2.0*texCol)*float4(1.0, 0.9, 0.8, 1.0);
|
||||
return finalCol;
|
||||
}
|
19
shaders/hlsl/postprocess/posterize.psh
Normal file
@ -0,0 +1,19 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float NumColors;
|
||||
uniform float Gamma;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float4 texCol = tex2D(SceneBuffer, texCoord);
|
||||
float3 col0 = texCol.rgb;
|
||||
col0 = pow(col0, Gamma);
|
||||
col0 = col0*NumColors;
|
||||
col0 = floor(col0);
|
||||
col0 = col0/NumColors;
|
||||
col0 = pow(col0, 1.0/Gamma);
|
||||
return float4(col0, texCol.a);
|
||||
}
|
43
shaders/hlsl/postprocess/pulsing.vsh
Normal file
@ -0,0 +1,43 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform float BufferWidth;
|
||||
uniform float BufferHeight;
|
||||
uniform float Speed;
|
||||
uniform float Speed2;
|
||||
uniform float Pulse;
|
||||
uniform float PulseE;
|
||||
uniform float CenterX;
|
||||
uniform float CenterY;
|
||||
uniform float ElapsedTime;
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 Pos:POSITION;
|
||||
float2 Tex:TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Pos:POSITION;
|
||||
float2 Tex:TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main(VS_INPUT input)
|
||||
{
|
||||
float2 offset = float2(0.5/BufferWidth, 0.5/BufferHeight);
|
||||
|
||||
VS_OUTPUT output;
|
||||
output.Pos = input.Pos;
|
||||
|
||||
float r = ElapsedTime*Speed;
|
||||
float2 cs = float2(sin(r), cos(r));
|
||||
r = 2.0*(pow(0.5*(sin(Speed2*ElapsedTime)+1.0), PulseE)-0.5);
|
||||
r = 1 + Pulse*r;
|
||||
|
||||
float2 ctr = float2(CenterX, CenterY);
|
||||
float2 t = r*(float2(input.Tex.xy + offset)-ctr);
|
||||
output.Tex = (((float2((t.x*cs.x - t.y*cs.y),(t.x*cs.y + t.y*cs.x))))+ctr);
|
||||
|
||||
return output;
|
||||
}
|
48
shaders/hlsl/postprocess/radialblur.psh
Normal file
@ -0,0 +1,48 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float SampleDist;
|
||||
uniform float SampleStrength;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float samples[10] = {
|
||||
-0.08,
|
||||
-0.05,
|
||||
-0.03,
|
||||
-0.02,
|
||||
-0.01,
|
||||
0.01,
|
||||
0.02,
|
||||
0.03,
|
||||
0.05,
|
||||
0.08
|
||||
};
|
||||
|
||||
// Vector from pixel to the center of the screen
|
||||
float2 dir = 0.5-texCoord;
|
||||
|
||||
// Distance from pixel to the center (distant pixels have stronger effect)
|
||||
float dist = sqrt(dir.x*dir.x+dir.y*dir.y);
|
||||
|
||||
// Now that we have dist, we can normlize vector
|
||||
dir = normalize(dir);
|
||||
|
||||
// Save the color to be used later
|
||||
float4 color = tex2D(SceneBuffer, texCoord);
|
||||
|
||||
// Average the pixels going along the vector
|
||||
float4 sum = color;
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
sum += tex2D(SceneBuffer, texCoord+dir*samples[i]*SampleDist);
|
||||
}
|
||||
sum /= 11.0;
|
||||
|
||||
// Calculate amount of blur based on
|
||||
// distance and a strength parameter
|
||||
// We need 0 <= t <= 1
|
||||
float t = clamp(dist*SampleStrength, 0.0, 1.0);
|
||||
|
||||
//Blend the original color with the averaged pixels
|
||||
return lerp(color, sum, t);
|
||||
}
|
24
shaders/hlsl/postprocess/scratched.psh
Normal file
@ -0,0 +1,24 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
uniform sampler2D Noise2DSamp : register(s1);
|
||||
|
||||
uniform float ElapsedTime;
|
||||
uniform float Speed1;
|
||||
uniform float Speed2;
|
||||
uniform float ScratchIntensity;
|
||||
uniform float IS;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
float scanLine = (ElapsedTime*Speed1);
|
||||
float side = (ElapsedTime*Speed2);
|
||||
float4 texCol = tex2D(SceneBuffer, texCoord);
|
||||
float2 noise = float2(texCoord.x+side, scanLine);
|
||||
float scratch = tex2D(Noise2DSamp, noise).x;
|
||||
scratch = 2.0*(scratch-ScratchIntensity)/IS;
|
||||
scratch = 1.0-abs(1.0-scratch);
|
||||
scratch = max(0.0, scratch);
|
||||
return texCol+float4(scratch.xxx, 0.0);
|
||||
}
|
6
shaders/hlsl/postprocess/screenquad.psh
Normal file
@ -0,0 +1,6 @@
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR
|
||||
{
|
||||
return tex2D(SceneBuffer, texCoord);
|
||||
}
|
25
shaders/hlsl/postprocess/sepia.psh
Normal file
@ -0,0 +1,25 @@
|
||||
// nvidia shader library
|
||||
// http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
|
||||
|
||||
uniform sampler2D SceneBuffer : register(s0);
|
||||
|
||||
uniform float Toning;
|
||||
uniform float Desaturation;
|
||||
|
||||
float4 main(float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
// digital ITU Recommendations
|
||||
const float3 ITU_R_601 = float3(0.2990, 0.5870, 0.1140);
|
||||
const float3 ITU_R_709 = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
const float3 PaperTone = float3(1.0, 0.95, 0.7);
|
||||
const float3 StainTone = float3(0.2, 0.05, 0.0);
|
||||
|
||||
float3 texColor = PaperTone*tex2D(SceneBuffer, texCoord).rgb;
|
||||
float gray = dot(texColor.rgb, ITU_R_601);
|
||||
float3 muted = lerp(texColor, gray.xxx, Desaturation);
|
||||
float3 sepia = lerp(StainTone, PaperTone, gray);
|
||||
float3 result = lerp(muted, sepia, Toning);
|
||||
|
||||
return float4(result, 1.0);
|
||||
}
|