Browse Source

basic lighting

Kajetan Johannes Hammerle 3 years ago
parent
commit
117c49ea18
2 changed files with 5 additions and 4 deletions
  1. 0 2
      Main.cpp
  2. 5 2
      resources/fragment.fs

+ 0 - 2
Main.cpp

@@ -6,8 +6,6 @@
 #include "gaming-core/wrapper/GL.h"
 
 int main() {
-    MarchingCubes::test();
-    // return 0;
     WindowOptions options(4, 0, {1024, 620}, false, "test");
     TextInput* input = nullptr;
     Window w(input, options);

+ 5 - 2
resources/fragment.fs

@@ -10,7 +10,10 @@ in vec3 varNormalG;
 
 out vec4 color;
 
+const vec3 light = vec3(-0.746, -0.373, -0.224);
+
 void main(void) {
-    //vec3 f = texture(textureSamp, (varTextureG + vec3(0.0, height, 0.0)) * 8.0).xyz;
-    color = vec4(varNormalG, 1.0);
+    vec3 f = texture(textureSamp, (varTextureG + vec3(0.0, height, 0.0)) * 8.0).xyz;
+    float l = max(dot(light, varNormalG), 0.0) * 0.7 + 0.3;
+    color = vec4(f * l, 1.0);
 }