diff --git a/.vs/shader3/v14/.suo b/.vs/shader3/v14/.suo index 166c1eb..d57249a 100644 Binary files a/.vs/shader3/v14/.suo and b/.vs/shader3/v14/.suo differ diff --git a/main.cpp b/main.cpp index de97841..8f7514b 100644 --- a/main.cpp +++ b/main.cpp @@ -75,42 +75,38 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ //combine program GPUProgram combineProgram1; combineProgram1.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); - combineProgram1.AttachShader(GL_FRAGMENT_SHADER, "res/shader/zpdd.fs"); + combineProgram1.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad.fs"); combineProgram1.Link(); combineProgram1.DetectAttribute("pos"); combineProgram1.DetectAttribute("texcoord"); - combineProgram1.DetectUniform("U_BaseTexture"); - combineProgram1.DetectUniform("U_BlendTexture"); + combineProgram1.DetectUniform("U_MainTexture"); //combine program GPUProgram combineProgram2; combineProgram2.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); - combineProgram2.AttachShader(GL_FRAGMENT_SHADER, "res/shader/zpdd_inverse.fs"); + combineProgram2.AttachShader(GL_FRAGMENT_SHADER, "res/shader/smooth.fs"); combineProgram2.Link(); combineProgram2.DetectAttribute("pos"); combineProgram2.DetectAttribute("texcoord"); - combineProgram2.DetectUniform("U_BaseTexture"); - combineProgram2.DetectUniform("U_BlendTexture"); + combineProgram2.DetectUniform("U_MainTexture"); //combine program GPUProgram combineProgram3; combineProgram3.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); - combineProgram3.AttachShader(GL_FRAGMENT_SHADER, "res/shader/zpdd_dark.fs"); + combineProgram3.AttachShader(GL_FRAGMENT_SHADER, "res/shader/sharpen.fs"); combineProgram3.Link(); combineProgram3.DetectAttribute("pos"); combineProgram3.DetectAttribute("texcoord"); - combineProgram3.DetectUniform("U_BaseTexture"); - combineProgram3.DetectUniform("U_BlendTexture"); + combineProgram3.DetectUniform("U_MainTexture"); //combine program GPUProgram combineProgram4; combineProgram4.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); - combineProgram4.AttachShader(GL_FRAGMENT_SHADER, "res/shader/zpdd_light.fs"); + combineProgram4.AttachShader(GL_FRAGMENT_SHADER, "res/shader/edge_detect.fs"); combineProgram4.Link(); combineProgram4.DetectAttribute("pos"); combineProgram4.DetectAttribute("texcoord"); - combineProgram4.DetectUniform("U_BaseTexture"); - combineProgram4.DetectUniform("U_BlendTexture"); + combineProgram4.DetectUniform("U_MainTexture"); @@ -169,37 +165,25 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ glUseProgram(combineProgram1.mProgram); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, head); - glUniform1i(combineProgram1.GetLocation("U_BaseTexture"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, grass); - glUniform1i(combineProgram1.GetLocation("U_BlendTexture"), 1); + glUniform1i(combineProgram1.GetLocation("U_MainTexture"), 0); fsq.DrawToLeftTop(combineProgram1.GetLocation("pos"), combineProgram1.GetLocation("texcoord")); glUseProgram(combineProgram2.mProgram); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, head); - glUniform1i(combineProgram2.GetLocation("U_BaseTexture"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, grass); - glUniform1i(combineProgram2.GetLocation("U_BlendTexture"), 1); + glUniform1i(combineProgram2.GetLocation("U_MainTexture"), 0); fsq.DrawToRightTop(combineProgram2.GetLocation("pos"), combineProgram2.GetLocation("texcoord")); glUseProgram(combineProgram3.mProgram); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, head); - glUniform1i(combineProgram3.GetLocation("U_BaseTexture"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, grass); - glUniform1i(combineProgram3.GetLocation("U_BlendTexture"), 1); + glUniform1i(combineProgram3.GetLocation("U_MainTexture"), 0); fsq.DrawToLeftBottom(combineProgram3.GetLocation("pos"), combineProgram3.GetLocation("texcoord")); glUseProgram(combineProgram4.mProgram); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, head); - glUniform1i(combineProgram4.GetLocation("U_BaseTexture"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, grass); - glUniform1i(combineProgram4.GetLocation("U_BlendTexture"), 1); + glUniform1i(combineProgram4.GetLocation("U_MainTexture"), 0); fsq.DrawToRightBottom(combineProgram4.GetLocation("pos"), combineProgram4.GetLocation("texcoord")); glDisable(GL_BLEND); diff --git a/res/shader/edge_detect.fs b/res/shader/edge_detect.fs new file mode 100644 index 0000000..74281e3 --- /dev/null +++ b/res/shader/edge_detect.fs @@ -0,0 +1,28 @@ + +varying vec2 V_Texcoord; + +uniform sampler2D U_MainTexture; + +void main() +{ + //1 2 1 + //2 4 2 + //1 2 1 + vec4 color = vec4(0.0); + int coreSize = 3; + float texelOffset = 1/150.0; + float kernel[9]; + + kernel[6]=0;kernel[7]=1;kernel[8]=0; + kernel[3]=1;kernel[4]=-4;kernel[5]=1; + kernel[0]=0;kernel[1]=1;kernel[2]=0; + + int index = 0; + for(int y=0; y - - - - + + + + diff --git a/shader3.vcxproj.filters b/shader3.vcxproj.filters index e28ec95..a041bdb 100644 --- a/shader3.vcxproj.filters +++ b/shader3.vcxproj.filters @@ -46,16 +46,16 @@ - + src - + src - + src - + src