diff --git a/main.cpp b/main.cpp index 717c6f9..9280661 100644 --- a/main.cpp +++ b/main.cpp @@ -185,8 +185,8 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ float ambientMaterial[] = { 0.2f,0.2f,0.2f,1.0f }; float diffuseLightColor[] = { 1.0f,1.0f,1.0f,1.0f }; float diffuseMaterial[] = { 0.8f, 0.8f, 0.8f, 1.0f }; - float lightPos[] = { 0.0f,1.0f, 0.0f,0.0f }; - float diffuseIntensity = 1.0f; + float lightPos[] = { 1.0f, 3.0f, -0.8f,1.0f }; + float diffuseIntensity = 2.0f; float spotLightDirection[] = { 0.0f, -1.0f, 0.0f, 128.0f };//把最后一位改成...... float spotLightCutoff = 0.0f; @@ -197,21 +197,21 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ float eyePos[] = { 0.0f, 0.0f, 0.0f }; - glm::mat4 model = glm::translate(0.0f, 0.0f, -2.0f) * glm::rotate(-60.0f, 1.0f, 1.0f, 1.0f); + glm::mat4 model = glm::translate(1.0f, 0.0f, 0.0f) * glm::rotate(-60.0f, 1.0f, 1.0f, 1.0f); glm::mat4 normalMatrix = glm::inverseTranspose(model); - glm::mat4 quadModel = glm::translate(0.0f, -1.5f, -2.0f) * glm::rotate(-90.0f, 1.0f, 0.0f, 0.0f) * glm::scale(8.0f, 8.0f, 8.0f); + glm::mat4 quadModel = glm::translate(0.0f, -1.5f, 0.0f) * glm::rotate(-90.0f, 1.0f, 0.0f, 0.0f) * glm::scale(8.0f, 8.0f, 8.0f); glm::mat4 quadNormalMatrix = glm::inverseTranspose(quadModel); - glm::mat4 sphereModel = glm::translate(0.1f, 3.0f, -2.2f) * glm::scale(0.3f, 0.3f, 0.3f); + glm::mat4 sphereModel = glm::translate(lightPos[0], lightPos[1], lightPos[2]) * glm::scale(0.3f, 0.3f, 0.3f); glm::mat4 sphereNormalMatrix = glm::inverseTranspose(sphereModel); - glm::mat4 viewMatrix = glm::lookAt(glm::vec3(1.0f, 0.5f, -10.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, 1.0f, 0.0f)); - glm::mat4 projectionMatrix = glm::perspective(50.0f, 800.0f / 600.0f, 0.1f, 1000.0f); + glm::mat4 viewMatrix = glm::lookAt(glm::vec3(0.5f, 1.9f, -8.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 projectionMatrix = glm::perspective(50.0f, (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f); - glm::mat4 lightMatrix = glm::lookAt(glm::vec3(0.0f, 10.0f, 0.0f), glm::vec3(0.0f, 0.0f, -2.0f), glm::vec3(0.0f, 0.0f, -1.0f)); - glm::mat4 lightprojectionMatrix = glm::ortho(-5.0f, 5.0f, -5.0f, 5.0f, 0.1f, 15.0f); + glm::mat4 lightMatrix = glm::lookAt(glm::vec3(lightPos[0], lightPos[1], lightPos[2]), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f)); + glm::mat4 lightprojectionMatrix = glm::perspective(90.0f, (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f);;//glm::ortho(-5.0f, 5.0f, -5.0f, 5.0f, 0.1f, 15.0f); //初始化fsq FullScreenQuad fsq; @@ -240,7 +240,7 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); - glClearColor(0.1f, 0.1f, 0.1f, 1.0f); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); depthfbo.Bind(); diff --git a/res/shader/depthrender.fs b/res/shader/depthrender.fs index 1a35236..766b1bc 100644 --- a/res/shader/depthrender.fs +++ b/res/shader/depthrender.fs @@ -6,6 +6,6 @@ uniform sampler2D U_MainTexture; void main() { float depthValue=texture2D(U_MainTexture,V_Texcoord).r; - depthValue = pow(depthValue, 2); + depthValue = pow(depthValue, 32); gl_FragColor=vec4(vec3(depthValue),1.0); } \ No newline at end of file diff --git a/res/shader/hdr.fs b/res/shader/hdr.fs index f7a23bb..773311b 100644 --- a/res/shader/hdr.fs +++ b/res/shader/hdr.fs @@ -28,7 +28,7 @@ float CalculateShadow(){ for(int y = -1; y < 1; ++y){ for(int x = -1; x < 1; ++x){ float pcfDepth = texture2D(U_ShadowMap, fragPos.xy + texelSize * vec2(x,y)).r; - shadow += (currentDepth-0.05) > pcfDepth ? 1.0 : 0.0; + shadow += (currentDepth-0.001) > pcfDepth ? 1.0 : 0.0; } } shadow/=9.0;