separate posterizer shader, new testing map
This commit is contained in:
@ -48,20 +48,19 @@ void main()
|
||||
float dist = distance(lights[i].position, fragPosition);
|
||||
|
||||
float power = smoothstep(lights[i].distanceFar, lights[i].distanceNear, dist);
|
||||
// float far = smoothstep(30.0, 1.0, dist) / 3.0;
|
||||
// float power = near + far * far * far;
|
||||
power = power * power;
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
// lightDot += lights[i].color.rgb * light * NdotL;
|
||||
// lightDot += lights[i].color.rgb * power * NdotL;
|
||||
lightDot += lights[i].color.rgb * power * lights[i].power * NdotL;
|
||||
// lightDot += lights[i].color.rgb * power * lights[i].power;
|
||||
|
||||
}
|
||||
}
|
||||
finalColor.rgb = (texelColor.rgb * lightDot);
|
||||
// finalColor.rgb = normal;
|
||||
// float c1 = smoothstep(5.0, 5.1, fragPosition.x + fragPosition.y + fragPosition.z);
|
||||
// float c2 = smoothstep(5.2, 5.1, fragPosition.x + fragPosition.y + fragPosition.z);
|
||||
// finalColor.rgb += vec3(1) * c1 * c2;
|
||||
// finalColor.rg = gl_FragCoord.xy / 1000.0;
|
||||
// finalColor.rgb = normal; // Kinda testing stuff
|
||||
// finalColor = (texelColor * vec4(lightDot, 1.0));
|
||||
// finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
// finalColor.rgb = fragPosition;
|
||||
}
|
||||
}
|
||||
|
33
assets/shaders/posterizer.glsl
Normal file
33
assets/shaders/posterizer.glsl
Normal file
@ -0,0 +1,33 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 fragPosition;
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
in vec3 fragNormal;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
#define POSTERIZE 5.0
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
const int bayer16[16] = int[16](0, 8, 2, 10,
|
||||
12, 4, 14, 6,
|
||||
3, 11, 1, 9,
|
||||
15, 7, 13, 5);
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||
int col = int(mod(gl_FragCoord.x, 4));
|
||||
int row = int(mod(gl_FragCoord.y, 4));
|
||||
float threshold = float(bayer16[col + 4 * row]) / 16.0 - 0.5;
|
||||
texelColor.rgb = clamp(texelColor.rgb + vec3(threshold * 0.1), 0.01, 0.99);
|
||||
|
||||
finalColor.a = 1.0;
|
||||
finalColor.rgb = floor(texelColor.rgb * POSTERIZE) / POSTERIZE;
|
||||
}
|
@ -28,16 +28,16 @@ void main() {
|
||||
int row = int(mod(gl_FragCoord.y, 4));
|
||||
float threshold = float(bayer16[col + 4 * row]) / 16.0 - 0.5;
|
||||
grey = clamp(grey + threshold * 0.1 , 0.01, 0.99);
|
||||
// texelColor.rgb = clamp(texelColor.rgb + vec3(threshold * 0.1), 0.01, 0.99);
|
||||
texelColor.rgb = clamp(texelColor.rgb + vec3(threshold * 0.1), 0.01, 0.99);
|
||||
|
||||
vec2 paluv = vec2(grey, 0.5);
|
||||
vec4 paletteValue = texture(texture1, paluv);
|
||||
finalColor.a = 1.0;
|
||||
// finalColor.rgb = vec3(floor(grey * POSTERIZE) / POSTERIZE );
|
||||
|
||||
// finalColor.rgb = floor(texelColor.rgb * POSTERIZE) / POSTERIZE;
|
||||
finalColor.rgb = floor(texelColor.rgb * POSTERIZE) / POSTERIZE;
|
||||
|
||||
finalColor.rgb = paletteValue.rgb;
|
||||
// finalColor.rgb = paletteValue.rgb;
|
||||
//
|
||||
// finalColor.rgb = vec3(mean) + paletteValue.rgb;
|
||||
}
|
||||
|
Reference in New Issue
Block a user