Browse Source

多次blur

master
blobt 5 years ago
parent
commit
f47ffbf95e
  1. BIN
      .vs/shader3/v14/.suo
  2. 24
      main.cpp

BIN
.vs/shader3/v14/.suo

24
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);

Loading…
Cancel
Save