Skip to content

Commit

Permalink
Fix color correction bug on AMD cards
Browse files Browse the repository at this point in the history
  • Loading branch information
tobspr committed Nov 21, 2015
1 parent 2b3c4a4 commit a5af7c8
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Shader/Includes/ColorCorrection.include
Expand Up @@ -3,21 +3,17 @@

#pragma include "Includes/Configuration.include"

vec3 applyColorLUT(sampler2D lut, vec3 color) {

color = saturate(color);
vec3 applyColorLUT(sampler2D lut, vec3 color)
{
float lutSize = float(textureSize(lut, 0).y);
color = clamp(color, vec3(1.0 / lutSize), vec3(1.0 - 1.0 / lutSize));
color = clamp(color, vec3(0.5 / lutSize), vec3(1.0 - 0.5 / lutSize));
vec2 texcXY = vec2(color.r / lutSize, 1.0 - color.g);
int frameZ = int(color.b * lutSize);
float lerpFactor = fract(color.b * lutSize);


int frameZ = int(color.b * lutSize);
float offsZ = fract(color.b * lutSize);

vec3 sample1 = textureLod(lut, texcXY + vec2(frameZ / lutSize, 0), 0).rgb;
vec3 sample2 = textureLod(lut, texcXY + vec2( (frameZ + 1) / lutSize, 0), 0).rgb;

vec3 sample1 = texture(lut, texcXY + vec2(frameZ / lutSize, 0) ).rgb;
vec3 sample2 = texture(lut, texcXY + vec2( (frameZ + 1) / lutSize, 0)).rgb;


return mix(sample1, sample2, lerpFactor);
}
return mix(sample1, sample2, offsZ);
}

0 comments on commit a5af7c8

Please sign in to comment.