From f47ffbf95e8ff54b11c0aa07f09f0f5b3d611fd2 Mon Sep 17 00:00:00 2001 From: blobt Date: Sat, 25 Jul 2020 23:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=AC=A1blur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/shader3/v14/.suo | Bin 38400 -> 38400 bytes main.cpp | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.vs/shader3/v14/.suo b/.vs/shader3/v14/.suo index 4787b7e1ea8264ff9bf370af61bc066b6b79c770..5646b5325aa1f4a24997cd1b69a4b7deb00e01e4 100644 GIT binary patch delta 2262 zcmbtVZ%kWN6ue;#i95g2SkgG4fH@A?gu(5PK06!=2F{)c0p>^0#E{hq8R=E=})4M;oFYfn4Z8 zI#3rO;(-#AQ`g_A!ni$U8QMt2e&}+$i4JoSm#T2$pBSf(rJS&dZuxM9b#BQJd7Zw4R*GpZLBRo`yK?X%SC+~b^`yGo(=4jV^A-G*y%)2 z8Zm|I3|UQJYF=^C{=_m7OEwWp=Y~I;>qT<(;ln|4G_?$Y%PPXx%@$Z_Ig%8wa=0qE zA=PcN9LvEOD5}-zcm?%Y#0=sb0(M*LVScgR>f5sRqj6_|_{f(#b;HE4#F*kGbcP%o(9g=3{7>^Pgk z7(w)sdm}NQ9AgE3WBxzT!eqruPaMEMK61O`3y&!8& zX{TDxae>M3++a1lK5T{ehn*0C#%*i+|MUH{*zogu9n;D0R>ym8@iw^8aLC3fdDNWN zllUM^?VU|{1=X>1n_6$*SnK*t#MQbadW1x`pq6#nIQ32HWJXj7l`Y%!E^Bn+wQ?)> zi`43kc1uoi2pvx%NT8y3Nn1LwFGnr*iPW^|17if$LdAYA()BPJqQ3r3bj%U~D5`6T z>QP(m?B_PjEMs&9jQ|j``^6@7lw>i47CIcwSwB-^Ku8Rj z;F~9$n)Ae4Ic=M&D3~68j53?6XBIvhd>K9-Y=_iH3W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;R=oOj7I{8MPv_2J@Wh0(0_n-1Y3h&U`Wr*MWjtrvuT6XwAxi7g8(VRY&_6Yfwq zD|)5y);LSliN*Vs`wq;5j$M37o~-W$Py*jveoI#sm>R%I^Eaw z?D05DSXu1JO39l*weLQqLUOC6J=x7CT|89vrKHqL?W$Fkz@po&qtcO|PPq*|Zh_ut zrG<3lDnrmv1hRw|Q^eb)us5zs?h}$e{;EI5ST7uJtY9j*&{)PyFlI67<9Lg16I^h- zx=t11f>Qcb##ij;{9J&Wz^B>9MX)m8=EiXK7G{9K&XzW~8`x{Kb1VO(2W@Hwu|p#K z>N82EH!i94KR&LZ8Z~hLAso*`tYMtwOE=maBrYb!f-zOXV0xz4tup&aU4EQG8z>c9R zFWee!C0m37&b4Gtj(m+q)@6%sW)aB#dZR9QE@V{KpexI_6eoa1&#lddC;LkUNW-;c z5a};1K8Qw#GH#Beo3?|Y=fNJ`1V2w2gxm$(o)|2o$kSW2EJJqc2{DmeF*yr5kA~A% zduhrTjOdQ_6H)v2gb&RL&5$2z(mvVvz$2(<5L&Gbm}idM@L83 rNVoUM(4^;0rxS{gRu@vA){|vQmKq$I?#=-lDqX*t{?)dUCk_7s2tzlq diff --git a/main.cpp b/main.cpp index f93f979..9f30924 100644 --- a/main.cpp +++ b/main.cpp @@ -175,6 +175,10 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); fbo.Finish(); + FBO fbo2; + fbo2.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); + fbo2.AttachDepthBuffer("depth", viewportWidth, viewportHeight); + fbo2.Finish(); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); @@ -192,13 +196,11 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ TranslateMessage(&msg); DispatchMessage(&msg); } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - glUseProgram(gpuProgram.mProgram); + fbo.Bind(); + glUseProgram(gpuProgram.mProgram); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUniform4fv(gpuProgram.GetLocation("U_AmbientLightColor"), 1, ambientLightColor); glUniform4fv(gpuProgram.GetLocation("U_AmbientMaterial"), 1, ambientMaterial); @@ -215,12 +217,20 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ glUniformMatrix4fv(gpuProgram.GetLocation("V"), 1, GL_FALSE, glm::value_ptr(viewMatrix)); glUniformMatrix4fv(gpuProgram.GetLocation("P"), 1, GL_FALSE, glm::value_ptr(projectionMatrix)); glUniformMatrix4fv(gpuProgram.GetLocation("NM"), 1, GL_FALSE, glm::value_ptr(normalMatrix)); - obj.Bind(gpuProgram.GetLocation("pos"), gpuProgram.GetLocation("texcoord"), gpuProgram.GetLocation("normal")); obj.Draw(); + glUseProgram(0); fbo.Unbind(); - glUseProgram(0); + //blur * 2 + fbo2.Bind(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glUseProgram(gaussianProgram.mProgram); + glBindTexture(GL_TEXTURE_2D, fbo.GetBuffer("color")); + glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); + fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); + fbo2.Unbind(); + glFlush(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); @@ -242,6 +252,8 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ fsq.DrawToLeftBottom(dilationProgram.GetLocation("pos"), dilationProgram.GetLocation("texcoord")); glUseProgram(gaussianProgram.mProgram); + glBindTexture(GL_TEXTURE_2D, fbo2.GetBuffer("color")); + glUniform1i(originalProgram.GetLocation("U_MainTexture"), 0); fsq.DrawToRightBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); SwapBuffers(dc);