diff --git a/.vs/shader3/v14/.suo b/.vs/shader3/v14/.suo
index 5646b53..b065015 100644
Binary files a/.vs/shader3/v14/.suo and b/.vs/shader3/v14/.suo differ
diff --git a/main.cpp b/main.cpp
index 9f30924..eca83af 100644
--- a/main.cpp
+++ b/main.cpp
@@ -81,23 +81,23 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
originalProgram.DetectAttribute("texcoord");
originalProgram.DetectUniform("U_MainTexture");
- //init erosion program
- GPUProgram erosionProgram;
- erosionProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs");
- erosionProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad_erosion.fs");
- erosionProgram.Link();
- erosionProgram.DetectAttribute("pos");
- erosionProgram.DetectAttribute("texcoord");
- erosionProgram.DetectUniform("U_MainTexture");
-
- //init dilation program
- GPUProgram dilationProgram;
- dilationProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs");
- dilationProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad_dilation.fs");
- dilationProgram.Link();
- dilationProgram.DetectAttribute("pos");
- dilationProgram.DetectAttribute("texcoord");
- dilationProgram.DetectUniform("U_MainTexture");
+ //init vertical program
+ GPUProgram verticalProgram;
+ verticalProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs");
+ verticalProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad_gaussian_vertical.fs");
+ verticalProgram.Link();
+ verticalProgram.DetectAttribute("pos");
+ verticalProgram.DetectAttribute("texcoord");
+ verticalProgram.DetectUniform("U_MainTexture");
+
+ //init horizontal program
+ GPUProgram horizontalProgram;
+ horizontalProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs");
+ horizontalProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad_gaussian_horizontal.fs");
+ horizontalProgram.Link();
+ horizontalProgram.DetectAttribute("pos");
+ horizontalProgram.DetectAttribute("texcoord");
+ horizontalProgram.DetectUniform("U_MainTexture");
//init dilation program
GPUProgram gaussianProgram;
@@ -245,11 +245,11 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
fsq.DrawToLeftTop(originalProgram.GetLocation("pos"), originalProgram.GetLocation("texcoord"));
- glUseProgram(erosionProgram.mProgram);
- fsq.DrawToRightTop(erosionProgram.GetLocation("pos"), erosionProgram.GetLocation("texcoord"));
+ glUseProgram(verticalProgram.mProgram);
+ fsq.DrawToRightTop(verticalProgram.GetLocation("pos"), verticalProgram.GetLocation("texcoord"));
- glUseProgram(dilationProgram.mProgram);
- fsq.DrawToLeftBottom(dilationProgram.GetLocation("pos"), dilationProgram.GetLocation("texcoord"));
+ glUseProgram(horizontalProgram.mProgram);
+ fsq.DrawToLeftBottom(horizontalProgram.GetLocation("pos"), horizontalProgram.GetLocation("texcoord"));
glUseProgram(gaussianProgram.mProgram);
glBindTexture(GL_TEXTURE_2D, fbo2.GetBuffer("color"));
diff --git a/res/shader/fullscreenquad_gaussian_horizontal.fs b/res/shader/fullscreenquad_gaussian_horizontal.fs
new file mode 100644
index 0000000..f3048aa
--- /dev/null
+++ b/res/shader/fullscreenquad_gaussian_horizontal.fs
@@ -0,0 +1,21 @@
+
+varying vec2 V_Texcoord;
+
+uniform sampler2D U_MainTexture;
+
+void main()
+{
+ //1 2 1
+ //2 4 2
+ //1 2 1
+ vec4 color = vec4(0.0);
+ float texelOffset = 1/100.0;
+ float weight[5] = float[](0.22,0.19,0.12,0.08,0.01);
+
+ for(int i = 0; i < 5; i++){
+ color += texture2D(U_MainTexture, vec2(V_Texcoord.x+texelOffset*i, V_Texcoord.y))*weight[i];
+ color += texture2D(U_MainTexture, vec2(V_Texcoord.x-texelOffset*i, V_Texcoord.y))*weight[i];
+ }
+
+ gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/res/shader/fullscreenquad_gaussian_vertical.fs b/res/shader/fullscreenquad_gaussian_vertical.fs
new file mode 100644
index 0000000..c417f9f
--- /dev/null
+++ b/res/shader/fullscreenquad_gaussian_vertical.fs
@@ -0,0 +1,21 @@
+
+varying vec2 V_Texcoord;
+
+uniform sampler2D U_MainTexture;
+
+void main()
+{
+ //1 2 1
+ //2 4 2
+ //1 2 1
+ vec4 color = vec4(0.0);
+ float texelOffset = 1/100.0;
+ float weight[5] = float[](0.22,0.19,0.12,0.08,0.01);
+
+ for(int i = 0; i < 5; i++){
+ color += texture2D(U_MainTexture, vec2(V_Texcoord.x, V_Texcoord.y+texelOffset*i))*weight[i];
+ color += texture2D(U_MainTexture, vec2(V_Texcoord.x, V_Texcoord.y-texelOffset*i))*weight[i];
+ }
+
+ gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/shader3.vcxproj b/shader3.vcxproj
index 479874a..98875cd 100644
--- a/shader3.vcxproj
+++ b/shader3.vcxproj
@@ -82,11 +82,9 @@
-
-
-
-
+
+
diff --git a/shader3.vcxproj.filters b/shader3.vcxproj.filters
index a64b41e..4a9eafe 100644
--- a/shader3.vcxproj.filters
+++ b/shader3.vcxproj.filters
@@ -52,19 +52,13 @@
src
-
- src
-
-
- src
-
-
+
src
-
+
src
-
+
src