Implement sun as an disk area light.
Solid angle is defaulted to sun's one.
This commit is contained in:
parent
fcba1dab86
commit
4a8afd2d40
@ -4,7 +4,8 @@ uniform sampler2D dtex;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
uniform mat4 invproj;
|
||||
uniform float sunangle = .54;
|
||||
|
||||
//uniform int hasclouds;
|
||||
//uniform vec2 wind;
|
||||
|
||||
@ -37,7 +38,16 @@ void main() {
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
vec3 D = direction;
|
||||
vec3 R = reflect(eyedir, norm);
|
||||
float angle = 3.14 * sunangle / 180;
|
||||
float d = cos(angle);
|
||||
float r = sin(angle);
|
||||
float DdotR = dot (D, R);
|
||||
vec3 S = R - DdotR * D;
|
||||
vec3 Lightdir = DdotR < d ? normalize (d * D + normalize (S) * r) : R;
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * dot(Lightdir, norm);
|
||||
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
|
@ -9,6 +9,7 @@ uniform float splitmax;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
uniform float sunangle = .54;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
@ -51,7 +52,16 @@ void main() {
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
vec3 D = direction;
|
||||
vec3 R = reflect(eyedir, norm);
|
||||
float angle = 3.14 * sunangle / 180;
|
||||
float d = cos(angle);
|
||||
float r = sin(angle);
|
||||
float DdotR = dot (D, R);
|
||||
vec3 S = R - DdotR * D;
|
||||
vec3 Lightdir = DdotR < d ? normalize (d * D + normalize (S) * r) : R;
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, Lightdir, col, roughness) * dot(norm, Lightdir);
|
||||
|
||||
|
||||
vec3 outcol = NdotL * col;
|
||||
|
Loading…
Reference in New Issue
Block a user