diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 5be24a04e64a..793ec3c3aa51 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -95,19 +95,20 @@ set(SRC RAS_Texture.h RAS_TextUser.h RAS_TexVert.h - RAS_OpenGLFilters/RAS_Blur2DFilter.h - RAS_OpenGLFilters/RAS_Dilation2DFilter.h - RAS_OpenGLFilters/RAS_Erosion2DFilter.h - RAS_OpenGLFilters/RAS_GrayScale2DFilter.h - RAS_OpenGLFilters/RAS_Invert2DFilter.h - RAS_OpenGLFilters/RAS_Laplacian2DFilter.h - RAS_OpenGLFilters/RAS_Prewitt2DFilter.h - RAS_OpenGLFilters/RAS_Sepia2DFilter.h - RAS_OpenGLFilters/RAS_Sharpen2DFilter.h - RAS_OpenGLFilters/RAS_Sobel2DFilter.h - RAS_OpenGLFilters/RAS_VertexShader2DFilter.h ) +data_to_c_simple(RAS_OpenGLFilters/RAS_Blur2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Dilation2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Erosion2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_GrayScale2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Invert2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Laplacian2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Prewitt2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Sepia2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Sharpen2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_Sobel2DFilter.glsl SRC) +data_to_c_simple(RAS_OpenGLFilters/RAS_VertexShader2DFilter.glsl SRC) + add_definitions(${GL_DEFINITIONS}) blender_add_lib(ge_rasterizer "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/gameengine/Rasterizer/RAS_2DFilter.cpp b/source/gameengine/Rasterizer/RAS_2DFilter.cpp index 26da46a8a2ea..9e5baa3fa929 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilter.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilter.cpp @@ -28,12 +28,14 @@ #include "BLI_utildefines.h" // for STRINGIFY -#include "RAS_OpenGLFilters/RAS_VertexShader2DFilter.h" - #include "EXP_Value.h" #include "glew-mx.h" +extern "C" { + extern char datatoc_RAS_VertexShader2DFilter_glsl[]; +} + static char predefinedUniformsName[RAS_2DFilter::MAX_PREDEFINED_UNIFORM_TYPE][40] = { "bgl_RenderedTexture", // RENDERED_TEXTURE_UNIFORM "bgl_DepthTexture", // DEPTH_TEXTURE_UNIFORM @@ -63,7 +65,7 @@ RAS_2DFilter::RAS_2DFilter(RAS_2DFilterData& data) m_textures[i] = 0; } - m_progs[VERTEX_PROGRAM] = STR_String(VertexShader); + m_progs[VERTEX_PROGRAM] = STR_String(datatoc_RAS_VertexShader2DFilter_glsl); m_progs[FRAGMENT_PROGRAM] = data.shaderText; LinkProgram(); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 2d87778e4d0a..42c09b8ae8dc 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -34,17 +34,18 @@ #include "glew-mx.h" -#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h" -#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h" -#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h" - +extern "C" { + extern char datatoc_RAS_Blur2DFilter_glsl[]; + extern char datatoc_RAS_Sharpen2DFilter_glsl[]; + extern char datatoc_RAS_Dilation2DFilter_glsl[]; + extern char datatoc_RAS_Erosion2DFilter_glsl[]; + extern char datatoc_RAS_Laplacian2DFilter_glsl[]; + extern char datatoc_RAS_Sobel2DFilter_glsl[]; + extern char datatoc_RAS_Prewitt2DFilter_glsl[]; + extern char datatoc_RAS_GrayScale2DFilter_glsl[]; + extern char datatoc_RAS_Sepia2DFilter_glsl[]; + extern char datatoc_RAS_Invert2DFilter_glsl[]; +} RAS_2DFilterManager::RAS_2DFilterManager() { @@ -97,34 +98,34 @@ RAS_2DFilter *RAS_2DFilterManager::CreateFilter(RAS_2DFilterData& filterData) case RAS_2DFilterManager::FILTER_MOTIONBLUR: break; case RAS_2DFilterManager::FILTER_BLUR: - shaderSource = BlurFragmentShader; + shaderSource = datatoc_RAS_Blur2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_SHARPEN: - shaderSource = SharpenFragmentShader; + shaderSource = datatoc_RAS_Sharpen2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_DILATION: - shaderSource = DilationFragmentShader; + shaderSource = datatoc_RAS_Dilation2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_EROSION: - shaderSource = ErosionFragmentShader; + shaderSource = datatoc_RAS_Erosion2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_LAPLACIAN: - shaderSource = LaplacianFragmentShader; + shaderSource = datatoc_RAS_Laplacian2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_SOBEL: - shaderSource = SobelFragmentShader; + shaderSource = datatoc_RAS_Sobel2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_PREWITT: - shaderSource = PrewittFragmentShader; + shaderSource = datatoc_RAS_Prewitt2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_GRAYSCALE: - shaderSource = GrayScaleFragmentShader; + shaderSource = datatoc_RAS_GrayScale2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_SEPIA: - shaderSource = SepiaFragmentShader; + shaderSource = datatoc_RAS_Sepia2DFilter_glsl; break; case RAS_2DFilterManager::FILTER_INVERT: - shaderSource = InvertFragmentShader; + shaderSource = datatoc_RAS_Invert2DFilter_glsl; break; } if (!shaderSource) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.glsl new file mode 100644 index 000000000000..a38d65d9d709 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.glsl @@ -0,0 +1,18 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } + + gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h deleted file mode 100644 index 3f1644a5c607..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Blur2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_BLUR2DFILTER_H__ -#define __RAS_BLUR2DFILTER_H__ - -static const char *BlurFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } - - gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + - (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + - sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; -} -); -#endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.glsl new file mode 100644 index 000000000000..e00cd8dc7032 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.glsl @@ -0,0 +1,18 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + vec4 maxValue = vec4(0.0); + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + maxValue = max(sample[i], maxValue); + } + + gl_FragColor = maxValue; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h deleted file mode 100644 index 4e863cb6f8d8..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Dilation2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_DILATION2DFILTER_H__ -#define __RAS_DILATION2DFILTER_H__ - -static const char *DilationFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - vec4 maxValue = vec4(0.0); - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - maxValue = max(sample[i], maxValue); - } - - gl_FragColor = maxValue; -} -); -#endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.glsl new file mode 100644 index 000000000000..785b35f9aa83 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.glsl @@ -0,0 +1,17 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + vec4 minValue = vec4(1.0); + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + minValue = min(sample[i], minValue); + } + + gl_FragColor = minValue; +} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h deleted file mode 100644 index 56e2c22fe2e7..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Erosion2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_EROSION2DFILTER_H__ -#define __RAS_EROSION2DFILTER_H__ - -static const char *ErosionFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - vec4 minValue = vec4(1.0); - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - minValue = min(sample[i], minValue); - } - - gl_FragColor = minValue; -} -); -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.glsl new file mode 100644 index 000000000000..2eba31c96c9d --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.glsl @@ -0,0 +1,8 @@ +uniform sampler2D bgl_RenderedTexture; + +void main(void) +{ + 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_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h deleted file mode 100644 index 932d5b16fed1..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_GrayScale2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_GRAYSCALE2DFILTER_H__ -#define __RAS_GRAYSCALE2DFILTER_H__ - -static const char *GrayScaleFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; - -void main(void) -{ - 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); -} -); -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.glsl new file mode 100644 index 000000000000..2cd8e7dd9b86 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.glsl @@ -0,0 +1,8 @@ +uniform sampler2D bgl_RenderedTexture; + +void main(void) +{ + 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_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h deleted file mode 100644 index dce303916ea2..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Invert2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_INVERT2DFILTER_H__ -#define __RAS_INVERT2DFILTER_H__ - -static const char *InvertFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; - -void main(void) -{ - vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); - gl_FragColor.rgb = 1.0 - texcolor.rgb; - gl_FragColor.a = texcolor.a; -} -); -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.glsl new file mode 100644 index 000000000000..c7c9382ae03c --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.glsl @@ -0,0 +1,20 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } + + gl_FragColor = (sample[4] * 8.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); + gl_FragColor = vec4(gl_FragColor.rgb, 1.0); +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h deleted file mode 100644 index f7ad7a25ab5d..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Laplacian2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_LAPLACIAN2DFILTER_H__ -#define __RAS_LAPLACIAN2DFILTER_H__ - -static const char *LaplacianFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } - - gl_FragColor = (sample[4] * 8.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); - gl_FragColor = vec4(gl_FragColor.rgb, 1.0); -} -); -#endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.glsl new file mode 100644 index 000000000000..6125d91ff300 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.glsl @@ -0,0 +1,24 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } + + vec4 horizEdge = sample[2] + sample[5] + sample[8] - + (sample[0] + sample[3] + sample[6]); + + vec4 vertEdge = sample[0] + sample[1] + sample[2] - + (sample[6] + sample[7] + sample[8]); + + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h deleted file mode 100644 index 4ae6009fdeb4..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Prewitt2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_PREWITT2DFILTER_H__ -#define __RAS_PREWITT2DFILTER_H__ - -static const char *PrewittFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } - - vec4 horizEdge = sample[2] + sample[5] + sample[8] - - (sample[0] + sample[3] + sample[6]); - - vec4 vertEdge = sample[0] + sample[1] + sample[2] - - (sample[6] + sample[7] + sample[8]); - - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; -} - -); -#endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.glsl new file mode 100644 index 000000000000..0ded834855b2 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.glsl @@ -0,0 +1,8 @@ +uniform sampler2D bgl_RenderedTexture; + +void main(void) +{ + 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_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h deleted file mode 100644 index 16b4e71dfdbf..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Sepia2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_SEPIA2DFILTER_H__ -#define __RAS_SEPIA2DFILTER_H__ - -static const char *SepiaFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; - -void main(void) -{ - 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); -} -); -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.glsl new file mode 100644 index 000000000000..2304db6221a5 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.glsl @@ -0,0 +1,18 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } + + gl_FragColor = (sample[4] * 9.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); +} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h deleted file mode 100644 index 7512393815b0..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Sharpen2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_SHARPEN2DFILTER_H__ -#define __RAS_SHARPEN2DFILTER_H__ - -static const char *SharpenFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } - - gl_FragColor = (sample[4] * 9.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); -} -); -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.glsl new file mode 100644 index 000000000000..8865714d54db --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.glsl @@ -0,0 +1,24 @@ +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } + + vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - + (sample[0] + (2.0*sample[3]) + sample[6]); + + vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - + (sample[6] + (2.0*sample[7]) + sample[8]); + + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h deleted file mode 100644 index 088ac10a56a7..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_Sobel2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_SOBEL2DFILTER_H__ -#define __RAS_SOBEL2DFILTER_H__ - -static const char *SobelFragmentShader = STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; - -void main(void) -{ - vec4 sample[9]; - - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } - - vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - - (sample[0] + (2.0*sample[3]) + sample[6]); - - vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - - (sample[6] + (2.0*sample[7]) + sample[8]); - - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; -} -); -#endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.glsl b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.glsl new file mode 100644 index 000000000000..0305b63cd377 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.glsl @@ -0,0 +1,6 @@ +void main(void) +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.h deleted file mode 100644 index 597b9facaec9..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_VertexShader2DFilter.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Tristan Porteries. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_VertexShader2DFilter.h - * \ingroup bgerastoglfilters - */ - -#ifndef __RAS_VERTEX_SHADER_2DFILTER_H__ -#define __RAS_VERTEX_SHADER_2DFILTER_H__ - -static const char *VertexShader = STRINGIFY( - -void main(void) -{ - gl_Position = gl_Vertex; - gl_TexCoord[0] = gl_MultiTexCoord0; -} -); -#endif // __RAS_VERTEX_SHADER_2DFILTER_H__ -