diff options
Diffstat (limited to 'engine/src/core-effects/Common/MatDefs/Post/Posterization.frag')
-rw-r--r-- | engine/src/core-effects/Common/MatDefs/Post/Posterization.frag | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/engine/src/core-effects/Common/MatDefs/Post/Posterization.frag b/engine/src/core-effects/Common/MatDefs/Post/Posterization.frag new file mode 100644 index 0000000..d184bc6 --- /dev/null +++ b/engine/src/core-effects/Common/MatDefs/Post/Posterization.frag @@ -0,0 +1,18 @@ +uniform sampler2D m_Texture;
+varying vec2 texCoord;
+
+uniform int m_NumColors;
+uniform float m_Gamma;
+uniform float m_Strength;
+
+void main() {
+ vec4 texVal = texture2D(m_Texture, texCoord);
+
+ texVal = pow(texVal, vec4(m_Gamma));
+ texVal = texVal * vec4(m_NumColors);
+ texVal = floor(texVal);
+ texVal = texVal / vec4(m_NumColors);
+ texVal = pow(texVal, vec4(1.0/m_Gamma));
+
+ gl_FragColor = mix(texture2D(m_Texture, texCoord), texVal, m_Strength);
+}
\ No newline at end of file |