diff options
Diffstat (limited to 'source/gameengine')
20 files changed, 139 insertions, 86 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 06d869a9396..7e32ade37f2 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -475,9 +475,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass); + m_filtermanager.EnableFilter(filtermode, pass, text); } void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index b67b7c8161f..3c2d4ac8e35 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -104,7 +104,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e29a1729fc3..89a07abe21d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -37,6 +37,8 @@ #define BLENDER_HACK_DTIME 0.02 +#include "MEM_guardedalloc.h" + #include "KX_BlenderSceneConverter.h" #include "KX_ConvertActuators.h" @@ -70,7 +72,7 @@ #include "KX_GameObject.h" /* This little block needed for linking to Blender... */ - +#include "BKE_text.h" #include "BLI_blenlib.h" #include "KX_NetworkMessageActuator.h" @@ -879,9 +881,18 @@ void BL_ConvertActuators(char* maggiename, case ACT_2DFILTER_INVERT: filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT; break; + case ACT_2DFILTER_CUSTOMFILTER: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER; + break; case ACT_2DFILTER_NOFILTER: filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; + case ACT_2DFILTER_DISABLED: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED; + break; + case ACT_2DFILTER_ENABLED: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED; + break; default: filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; @@ -890,6 +901,18 @@ void BL_ConvertActuators(char* maggiename, tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); + if (_2dfilter->text) + { + char *buf; + // this is some blender specific code + buf = txt_to_buf(_2dfilter->text); + if (buf) + { + tmp->SetShaderText(STR_String(buf)); + MEM_freeN(buf); + } + } + baseact = tmp; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 7033ae30ac5..9627ad92c4c 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -8,6 +8,9 @@ #include <iostream> +SCA_2DFilterActuator::~SCA_2DFilterActuator() +{ +} SCA_2DFilterActuator::SCA_2DFilterActuator( SCA_IObject *gameobj, @@ -28,13 +31,13 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( { } - -SCA_2DFilterActuator::~SCA_2DFilterActuator() +void SCA_2DFilterActuator::SetShaderText(STR_String& text) { - + m_shaderText = text; } + CValue* SCA_2DFilterActuator::GetReplica() { SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); @@ -69,7 +72,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_rendertools->Update2DFilter(m_type, m_int_arg); + m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText); } return true; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index f1871c8f093..76df95ac399 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -16,6 +16,7 @@ private: short m_flag; float m_float_arg; int m_int_arg; + STR_String m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_IRenderTools* m_rendertools; @@ -32,7 +33,7 @@ public: PyTypeObject* T=&Type ); - + void SetShaderText(STR_String& text); virtual ~SCA_2DFilterActuator(); virtual bool Update(); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index ffa8bdb32e7..388882e67e4 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -593,9 +593,9 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass); + m_filtermanager.EnableFilter(filtermode, pass, text); } void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 4b1e990b717..d90f0e5da45 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -152,7 +152,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 740a4d7a6b3..8576ea1487c 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -12,6 +12,7 @@ #include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h" #include "RAS_OpenGLFilters/RAS_Invert2DFilter.h" +#include "STR_String.h" #include "RAS_ICanvas.h" #include "RAS_2DFilterManager.h" #include <iostream> @@ -48,12 +49,11 @@ numberoffilters(0),texname(-1) int passindex; for(passindex =0; passindex<MAX_RENDER_PASS; passindex++) + { m_filters[passindex] = 0; + m_enabled[passindex] = 0; + } - int programindex; - for(programindex=0; programindex<RAS_2DFILTER_NUMBER_OF_FILTERS; programindex++) - m_programs[programindex] = 0; - } RAS_2DFilterManager::~RAS_2DFilterManager() @@ -129,20 +129,31 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) return 0; } -void RAS_2DFilterManager::StartShaderProgram(int filtermode) +void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { GLint uniformLoc; - bgl::blUseProgramObjectARB(m_programs[filtermode]); - uniformLoc = bgl::blGetUniformLocationARB(m_programs[filtermode], "sampler0"); + bgl::blUseProgramObjectARB(shaderprogram); + uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); if (uniformLoc != -1) { bgl::blUniform1iARB(uniformLoc, 0); } - uniformLoc = bgl::blGetUniformLocationARB(m_programs[filtermode], "tc_offset"); + uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset"); if (uniformLoc != -1) { bgl::blUniform2fvARB(uniformLoc, 9, textureoffsets); } + uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth"); + if (uniformLoc != -1) + { + bgl::blUniform1fARB(uniformLoc,texturewidth); + } + uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight"); + if (uniformLoc != -1) + { + bgl::blUniform1fARB(uniformLoc,textureheight); + } + } void RAS_2DFilterManager::EndShaderProgram() @@ -200,7 +211,7 @@ void RAS_2DFilterManager::UpdateOffsetMatrix(int width, int height) void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) { - if(numberoffilters<=0 || !isshadersupported) + if(!isshadersupported) return; if(canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight()) @@ -213,7 +224,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) bool first = true; for(passindex =0; passindex<MAX_RENDER_PASS; passindex++) { - if(m_filters[passindex]) + if(m_filters[passindex] && m_enabled[passindex]) { if(first) { @@ -253,33 +264,48 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) } } -void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass) +void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text) { if(!isshadersupported) return; - if( pass == -1) + if(pass<0 || pass>=MAX_RENDER_PASS) + return; + + if(mode == RAS_2DFILTER_DISABLED) { - if(m_programs[mode] == 0) - m_programs[mode] = CreateShaderProgram(mode); + m_enabled[pass] = 0; + return; } - else if( pass < MAX_RENDER_PASS ) + + if(mode == RAS_2DFILTER_ENABLED) { - if(mode == RAS_2DFILTER_NOFILTER ) - { - if(m_filters[pass] != 0) - numberoffilters--; - m_filters[pass] = 0; - } - else - { - if(!m_programs[mode]) - m_programs[mode] = CreateShaderProgram(mode); - if(m_programs[mode]) - { - if(m_filters[pass] == 0) - numberoffilters++; - m_filters[pass] = mode; - } - } + m_enabled[pass] = 1; + return; + } + + if(mode == RAS_2DFILTER_NOFILTER) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_enabled[pass] = 0; + m_filters[pass] = 0; + return; + } + + if(mode == RAS_2DFILTER_CUSTOMFILTER) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_filters[pass] = CreateShaderProgram(text.Ptr()); + m_enabled[pass] = 1; + return; + } + + if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_filters[pass] = CreateShaderProgram(mode); + m_enabled[pass] = 1; } } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index e2d9dce170e..45e33db8d2e 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -10,7 +10,7 @@ class RAS_2DFilterManager private: unsigned int CreateShaderProgram(char* shadersource); unsigned int CreateShaderProgram(int filtermode); - void StartShaderProgram(int filtermode); + void StartShaderProgram(unsigned int shaderprogram); void EndShaderProgram(); float textureoffsets[18]; @@ -25,6 +25,8 @@ private: bool isshadersupported; public: enum RAS_2DFILTER_MODE { + RAS_2DFILTER_ENABLED = -2, + RAS_2DFILTER_DISABLED = -1, RAS_2DFILTER_NOFILTER = 0, RAS_2DFILTER_MOTIONBLUR, RAS_2DFILTER_BLUR, @@ -37,13 +39,13 @@ public: RAS_2DFILTER_GRAYSCALE, RAS_2DFILTER_SEPIA, RAS_2DFILTER_INVERT, + RAS_2DFILTER_CUSTOMFILTER, RAS_2DFILTER_NUMBER_OF_FILTERS }; - int m_filters[MAX_RENDER_PASS]; + unsigned int m_filters[MAX_RENDER_PASS]; + short m_enabled[MAX_RENDER_PASS]; - unsigned int m_programs[RAS_2DFILTER_NUMBER_OF_FILTERS]; - RAS_2DFilterManager(); ~RAS_2DFilterManager(); @@ -54,6 +56,6 @@ public: void RenderFilters(RAS_ICanvas* canvas); - void EnableFilter(RAS_2DFILTER_MODE mode, int pass); + void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text); }; #endif diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index e7cb1c9176f..771c34a595f 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -183,7 +183,7 @@ public: virtual void - Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass)=0; + Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0; virtual void diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index ae7f56174e6..2b0bdbc4351 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_BLUR2DFILTER char * BlurFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 6fd7f867d10..9cf233d549a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_DILATION2DFILTER char * DilationFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -12,8 +12,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); maxValue = max(sample[i], maxValue); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index a0fc7486447..667da14c10e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_EROSION2DFILTER char * ErosionFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -12,8 +12,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); minValue = min(sample[i], minValue); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h index c6fc4a0214d..09f58c0a350 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -2,11 +2,11 @@ #define __RAS_GRAYSCALE2DFILTER char * GrayScaleFragmentShader=STRINGIFY( -uniform sampler2D sampler0; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); gl_FragColor = vec4(gray, gray, gray, texcolor.a); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h index 34e6fe29cd3..c3b9ee117c0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -2,12 +2,11 @@ #define __RAS_INVERT2DFILTER char * InvertFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 offset[9]; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); gl_FragColor.rgb = 1.0 - texcolor.rgb; gl_FragColor.a = texcolor.a; } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index f5b44a69c13..684ac4399fa 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_LAPLACION2DFILTER char * LaplacionFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[4] * 8.0) - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index a6897bd33d4..c4b344b2ded 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_PREWITT2DFILTER char * PrewittFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } vec4 horizEdge = sample[2] + sample[5] + sample[8] - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h index cfff00e1287..4ba91b85784 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -2,12 +2,11 @@ #define __RAS_SEPIA2DFILTER char * SepiaFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 offset[9]; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 640983482a9..685471aab07 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_SHARPEN2DFILTER char * SharpenFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[4] * 9.0) - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index da1d34713c9..93480afb250 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_SOBEL2DFILTER char * SobelFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - |