diff options
Diffstat (limited to 'data/shaders')
-rw-r--r-- | data/shaders/fill-light.frag | 7 | ||||
-rw-r--r-- | data/shaders/fill-light.vert | 4 | ||||
-rw-r--r-- | data/shaders/lighting.frag | 11 | ||||
-rw-r--r-- | data/shaders/lighting.vert | 4 |
4 files changed, 14 insertions, 12 deletions
diff --git a/data/shaders/fill-light.frag b/data/shaders/fill-light.frag index 975e403..fcd2b4f 100644 --- a/data/shaders/fill-light.frag +++ b/data/shaders/fill-light.frag @@ -19,10 +19,11 @@ uniform sampler2D normalmap; uniform bool has_normals; uniform float alpha; +uniform float shininess; varying vec3 col_ambi_diff; varying vec3 col_emit; -varying float shininess; +varying float col_spec; void main() { @@ -41,7 +42,7 @@ void main() { norm = normalize(normal); /* Ambient */ - ambi = col_ambi_diff * (gl_LightModel.ambient.rgb + vec3(0.5, 0.5, 0.5)); + ambi = col_ambi_diff * (gl_LightModel.ambient.rgb + vec3(0.2, 0.2, 0.2)); /* Emission */ emit = col_emit; @@ -55,7 +56,7 @@ void main() { spec_fac = pow(spec_fac, shininess); diff = col_ambi_diff * gl_LightSource[2].diffuse.rgb * diff_fac; - spec = gl_LightSource[2].specular.rgb * spec_fac; + spec = gl_LightSource[2].specular.rgb * spec_fac * col_spec; gl_FragColor = vec4(min(tex.r * (ambi.r + diff.r) + spec.r, 1.0), min(tex.g * (ambi.g + diff.g) + spec.g, 1.0), diff --git a/data/shaders/fill-light.vert b/data/shaders/fill-light.vert index 1688820..57371ae 100644 --- a/data/shaders/fill-light.vert +++ b/data/shaders/fill-light.vert @@ -16,7 +16,7 @@ varying vec3 light2vc; varying vec3 col_ambi_diff; varying vec3 col_emit; -varying float shininess; +varying float col_spec; void main() { @@ -32,7 +32,7 @@ void main() { /* Material properties */ col_ambi_diff = gl_Color.rgb; col_emit = gl_FrontMaterial.emission.rgb; - shininess = gl_FrontMaterial.shininess; + col_spec = gl_FrontMaterial.specular.r; /* Coordinates */ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag index bf03dbb..b95397d 100644 --- a/data/shaders/lighting.frag +++ b/data/shaders/lighting.frag @@ -15,16 +15,17 @@ varying vec3 normal; varying vec3 light0vc; varying vec3 light1vc; +varying vec3 col_ambi_diff; +varying vec3 col_emit; +varying float col_spec; + uniform sampler2D texture; uniform sampler2D normalmap; uniform bool has_normals; uniform bool texture_emits; uniform float alpha; - -varying vec3 col_ambi_diff; -varying vec3 col_emit; -varying float shininess; +uniform float shininess; void main() { @@ -68,7 +69,7 @@ void main() { R = normalize(-reflect(L, norm)); spec_fac = max(0.0, dot(R, E)); spec_fac = pow(spec_fac, shininess); - spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac; + spec += col_spec * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac; /* Light 1: Diffuse background glow */ diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(0.0, dot(vec3(light1vc), norm)); diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert index 783978c..aaaee00 100644 --- a/data/shaders/lighting.vert +++ b/data/shaders/lighting.vert @@ -17,7 +17,7 @@ varying vec3 light1vc; varying vec3 col_ambi_diff; varying vec3 col_emit; -varying float shininess; +varying float col_spec; /* Only use one component of this, assume it's some shade of grey */ void main() { @@ -35,8 +35,8 @@ void main() { /* Material properties */ col_ambi_diff = gl_Color.rgb; + col_spec = gl_FrontMaterial.specular.r; col_emit = gl_FrontMaterial.emission.rgb; - shininess = gl_FrontMaterial.shininess; /* Coordinates */ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |