Add normal scale factor
+ some minor tweaks: higher shadowmap resolution and light rotate speed
This commit is contained in:
parent
482aa93cce
commit
0e8e98026c
@ -78,6 +78,7 @@ public:
|
||||
// TODO: Not always required (not when rendering shadows) - make functions separate?
|
||||
shader.setFloat("diffuseStrength", material.diffuse);
|
||||
shader.setFloat("specularStrength", material.specular);
|
||||
shader.setFloat("normalScale", material.normal_scale);
|
||||
|
||||
mesh.render();
|
||||
}
|
||||
@ -268,8 +269,8 @@ public:
|
||||
int screen_width = 1280;
|
||||
int screen_height = 720;
|
||||
|
||||
int shadow_width = 2048;
|
||||
int shadow_height = 2048;
|
||||
int shadow_width = 8192;
|
||||
int shadow_height = 8192;
|
||||
|
||||
unsigned int depthMap;
|
||||
unsigned int depthMapFBO;
|
||||
|
@ -13,6 +13,8 @@ struct Material {
|
||||
float diffuse = 0.8;
|
||||
|
||||
float specular = 0.2;
|
||||
|
||||
float normal_scale = 3.0;
|
||||
};
|
||||
|
||||
#endif //ECSGAME_MATERIAL_H
|
||||
|
@ -16,6 +16,7 @@ uniform mediump vec3 cameraPosition;
|
||||
|
||||
uniform mediump float diffuseStrength;
|
||||
uniform mediump float specularStrength;
|
||||
uniform mediump float normalScale;
|
||||
|
||||
mediump float ShadowCalculation(vec4 fragPosLightSpace)
|
||||
{
|
||||
@ -47,6 +48,7 @@ void main()
|
||||
|
||||
// Get normal from normal map in the range [-1,1]
|
||||
mediump vec3 map_normal = normalize(texture(normalmap, TexCoord).rgb * 2.0 - 1.0);
|
||||
map_normal.xy *= normalScale;
|
||||
mediump vec3 final_normal = normalize(TBN * map_normal);
|
||||
|
||||
// Alpha Scissors
|
||||
|
2
main.cpp
2
main.cpp
@ -204,7 +204,7 @@ int main() {
|
||||
renderSystem->render(world, defaultShader, shadowShader, debugShader);
|
||||
|
||||
ring->get<Transform>()->rotate(delta * 100.0, glm::vec3(0.0, 1.0, 0.0));
|
||||
sun->get<DirectionalLight>()->direction = glm::normalize(glm::vec3(glm::rotate(glm::mat4(1), (float)elapsed_time, glm::vec3(0.0, 1.0, 0.0)) * glm::vec4(1.0, 1.0, 1.0, 0.0)));
|
||||
sun->get<DirectionalLight>()->direction = glm::normalize(glm::vec3(glm::rotate(glm::mat4(1), (float)elapsed_time * 0.3f, glm::vec3(0.0, 1.0, 0.0)) * glm::vec4(1.0, 1.0, 1.0, 0.0)));
|
||||
|
||||
/* Swap front and back buffers */
|
||||
glfwSwapBuffers(window);
|
||||
|
Loading…
x
Reference in New Issue
Block a user