few shader updates.

This commit is contained in:
Joey de Vries
2017-03-31 22:39:50 +02:00
parent d2a4a1e655
commit d6733b10db
2 changed files with 2 additions and 9 deletions

View File

@@ -3,12 +3,10 @@ out vec4 FragColor;
in vec3 WorldPos;
uniform samplerCube environmentMap;
uniform float lod;
void main()
{
// vec3 envColor = textureLod(environmentMap, WorldPos, 1.0).rgb;
vec3 envColor = textureLod(environmentMap, WorldPos, lod).rgb;
vec3 envColor = textureLod(environmentMap, WorldPos, 0.0).rgb;
// HDR tonemap and gamma correct
envColor = envColor / (envColor + vec3(1.0));

View File

@@ -8,16 +8,11 @@ const float PI = 3.14159265359f;
void main()
{
// NOTE(Joey): the world vector acts as the normal of a tangent surface
// from the origin, aligned to WorldPos. Given this normal, calculate all
// incoming radiance of the environment. The result of this radiance
// is the radiance of light coming from -Normal direction, which is what
// we use in the PBR shader to sample irradiance.
vec3 N = normalize(WorldPos);
vec3 irradiance = vec3(0.0);
// NOTE(Joey): tangent space calculation from origin point
// tangent space calculation from origin point
vec3 up = vec3(0.0, 1.0, 0.0);
vec3 right = cross(up, N);
up = cross(N, right);