From cf51d06dba9c83b416545b757433e1a931db34f1 Mon Sep 17 00:00:00 2001 From: Souradeep-Nanda Date: Wed, 17 Dec 2014 21:59:04 +0530 Subject: [PATCH] Modernized the shaders The shaders were not compatible with my graphics card and were creating weird artifacts i.e. rendering the UV instead of the mesh. I made some minor changes and the problem was solved. --- res/basicShader.fs | 6 ++++-- res/basicShader.vs | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/res/basicShader.fs b/res/basicShader.fs index 1a7154d..cefa2c7 100644 --- a/res/basicShader.fs +++ b/res/basicShader.fs @@ -1,4 +1,6 @@ -#version 120 +#version 330 + +out vec4 color; varying vec2 texCoord0; varying vec3 normal0; @@ -8,6 +10,6 @@ uniform vec3 lightDirection; void main() { - gl_FragColor = texture2D(sampler, texCoord0) * + color = texture2D(sampler, texCoord0) * clamp(dot(-lightDirection, normal0), 0.0, 1.0); } diff --git a/res/basicShader.vs b/res/basicShader.vs index e673548..1b23601 100644 --- a/res/basicShader.vs +++ b/res/basicShader.vs @@ -1,8 +1,8 @@ -#version 120 +#version 330 -attribute vec3 position; -attribute vec2 texCoord; -attribute vec3 normal; +layout(location = 0) in vec3 position; +layout(location = 1) in vec2 texCoord; +layout(location = 2) in vec3 normal; varying vec2 texCoord0; varying vec3 normal0;