SSAO: Use a single texture fetch for random.

This commit is contained in:
Vincent Lejeune 2014-01-20 20:43:03 +01:00
parent aeba31c4cf
commit ceb1fdc88a

View File

@ -15,9 +15,9 @@ const float radius = .4f;
const float invSamples = strengh / SAMPLES;
float rand(vec2 co)
vec3 rand(vec2 co)
{
return texture(noise_texture, co).x;
return texture(noise_texture, co).xyz;
}
void main(void)
@ -33,10 +33,7 @@ void main(void)
float len = dot(vec3(1.0), abs(cur.xyz));
if (len < 0.2 || curdepth > 0.999) discard;
// Make a tangent as random as possible
vec3 randvect;
randvect.x = rand(uv);
randvect.y = rand(vec2(randvect.x, FragPos.z));
randvect.z = rand(randvect.xy);
vec3 randvect = rand(uv);
vec3 tangent = normalize(cross(norm, randvect));
vec3 bitangent = cross(norm, tangent);