|
@ -90,6 +90,15 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
hdrProgram.DetectAttribute("texcoord"); |
|
|
hdrProgram.DetectAttribute("texcoord"); |
|
|
hdrProgram.DetectUniform("U_MainTexture"); |
|
|
hdrProgram.DetectUniform("U_MainTexture"); |
|
|
|
|
|
|
|
|
|
|
|
//¸ß˹ģºý
|
|
|
|
|
|
GPUProgram gaussianProgram; |
|
|
|
|
|
gaussianProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); |
|
|
|
|
|
gaussianProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/fullscreenquad_gaussian.fs"); |
|
|
|
|
|
gaussianProgram.Link(); |
|
|
|
|
|
gaussianProgram.DetectAttribute("pos"); |
|
|
|
|
|
gaussianProgram.DetectAttribute("texcoord"); |
|
|
|
|
|
gaussianProgram.DetectUniform("U_MainTexture"); |
|
|
|
|
|
|
|
|
//combine program
|
|
|
//combine program
|
|
|
GPUProgram combineProgram; |
|
|
GPUProgram combineProgram; |
|
|
combineProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); |
|
|
combineProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); |
|
@ -188,7 +197,6 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
FBO fbo; |
|
|
FBO fbo; |
|
|
fbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
fbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
fbo.Finish(); |
|
|
|
|
|
|
|
|
|
|
|
FBO HDRfbo; |
|
|
FBO HDRfbo; |
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
@ -252,8 +260,16 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
glUseProgram(0); |
|
|
glUseProgram(0); |
|
|
HDRfbo.Unbind(); |
|
|
HDRfbo.Unbind(); |
|
|
|
|
|
|
|
|
glFlush(); |
|
|
|
|
|
|
|
|
fbo.Bind(); |
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
fbo.Unbind(); |
|
|
|
|
|
|
|
|
|
|
|
glFlush(); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
|
|
|
|
@ -267,10 +283,15 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
glUniform1i(hdrProgram.GetLocation("U_MainTexture"), 0); |
|
|
glUniform1i(hdrProgram.GetLocation("U_MainTexture"), 0); |
|
|
fsq.DrawToRightTop(hdrProgram.GetLocation("pos"), hdrProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToRightTop(hdrProgram.GetLocation("pos"), hdrProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo.GetBuffer("color")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.DrawToLeftBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|
glUseProgram(combineProgram.mProgram); |
|
|
glUseProgram(combineProgram.mProgram); |
|
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
glUniform1i(combineProgram.GetLocation("U_MainTexture"), 0); |
|
|
glUniform1i(combineProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
glUniform1i(combineProgram.GetLocation("U_HDRTexture"), 1); |
|
|
glUniform1i(combineProgram.GetLocation("U_HDRTexture"), 1); |
|
|