|
|
@ -90,14 +90,15 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
hdrProgram.DetectAttribute("texcoord"); |
|
|
|
hdrProgram.DetectUniform("U_MainTexture"); |
|
|
|
|
|
|
|
//init dilation program
|
|
|
|
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
|
|
|
|
GPUProgram combineProgram; |
|
|
|
combineProgram.AttachShader(GL_VERTEX_SHADER, "res/shader/fullscreenquad.vs"); |
|
|
|
combineProgram.AttachShader(GL_FRAGMENT_SHADER, "res/shader/combine.fs"); |
|
|
|
combineProgram.Link(); |
|
|
|
combineProgram.DetectAttribute("pos"); |
|
|
|
combineProgram.DetectAttribute("texcoord"); |
|
|
|
combineProgram.DetectUniform("U_MainTexture"); |
|
|
|
combineProgram.DetectUniform("U_HDRTexture"); |
|
|
|
|
|
|
|
//init gpu program
|
|
|
|
GPUProgram gpuProgram; |
|
|
@ -167,7 +168,8 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
fbo.Finish(); |
|
|
|
|
|
|
|
FBO HDRfbo; |
|
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA16F, viewportWidth, viewportHeight); |
|
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
|
HDRfbo.AttachColorBuffer("hdrcolor", GL_COLOR_ATTACHMENT1, GL_RGBA16F, viewportWidth, viewportHeight); |
|
|
|
HDRfbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
|
HDRfbo.Finish(); |
|
|
|
|
|
|
@ -225,14 +227,18 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
fsq.DrawToLeftTop(originalProgram.GetLocation("pos"), originalProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
glUseProgram(hdrProgram.mProgram); |
|
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
|
glUniform1i(hdrProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
fsq.DrawToRightTop(hdrProgram.GetLocation("pos"), hdrProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
glUseProgram(combineProgram.mProgram); |
|
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
fsq.DrawToRightBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
glUniform1i(combineProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
|
glUniform1i(combineProgram.GetLocation("U_HDRTexture"), 1); |
|
|
|
fsq.DrawToRightBottom(combineProgram.GetLocation("pos"), combineProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
SwapBuffers(dc); |
|
|
|
} |
|
|
|