diff --git a/assets/13.glsl b/assets/13.glsl deleted file mode 100644 index 5cd61868c..000000000 --- a/assets/13.glsl +++ /dev/null @@ -1,16 +0,0 @@ -vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { - vec4 color = vec4(0.0); - vec2 off1 = vec2(1.411764705882353) * direction; - vec2 off2 = vec2(3.2941176470588234) * direction; - vec2 off3 = vec2(5.176470588235294) * direction; - color += texture2D(image, uv) * 0.1964825501511404; - color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344; - color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344; - color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732; - color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732; - color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057; - color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057; - return color; -} - -#pragma glslify: export(blur13) \ No newline at end of file diff --git a/assets/4096.frag b/assets/4096.frag index 1a9f88268..abf3dd0ff 100644 --- a/assets/4096.frag +++ b/assets/4096.frag @@ -1,37 +1,11 @@ -varying vec2 texcoord; +varying vec4 v_color; +varying vec2 v_texCoords; +uniform sampler2D u_texture; -uniform sampler2D renderTexture; -uniform mat4 Bayer; -uniform int pixelSize; void main(void) { - // create texture coordinates based on pixelSize // - - // vec2 discrete = (gl_FragCoord.xy + 0.001) / texcoord / pixelSize; // + vec4 color = texture2D(u_texture, v_texCoords); + color = floor(15.0 * color + 0.5) / 15.0; - vec2 pixelSizeVec = vec2(float(pixelSize), float(pixelSize)); - - vec2 discrete = (gl_FragCoord.xy + 0.001) / texcoord / pixelSizeVec; - - discrete = floor(discrete * texcoord) / discrete; - - vec3 color = texture2D(renderTexture, discrete).rgb; - - // increase contrast (Bayer matrix operation reduces it) // - float contrast = 1.65; - color = mix(vec3(0.5), color, contrast); - - // add Bayer matrix entry to current pixel // - // vec2 entry = mod(gl_FragCoord.xy / pixelSizeVec, vec2(4, 4)); - - // color.r = color.r + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5; - // color.g = color.g + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5; - // color.b = color.b + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5; - - // find nearest 8-bit color // - color.r = floor(8.0 * color.r + 0.5) / 8.0; - color.g = floor(8.0 * color.g + 0.5) / 8.0; - color.b = floor(4.0 * color.b + 0.5) / 4.0; - - gl_FragColor = vec4(color, 1.0); + gl_FragColor = color; } \ No newline at end of file diff --git a/assets/4096.vert b/assets/4096.vert index 263070a46..17d96ca8d 100644 --- a/assets/4096.vert +++ b/assets/4096.vert @@ -1,7 +1,14 @@ -varying vec2 texcoord; +attribute vec4 a_position; +attribute vec4 a_color; +attribute vec2 a_texCoord0; -void main(void) { // fairly usual fullscreen quad setup // - vec2 corners = sign(gl_Vertex.xy); - texcoord = 0.5 * corners + vec2(0.5); - gl_Position = vec4(corners, 0.0, 1.0); +uniform mat4 u_projTrans; + +varying vec4 v_color; +varying vec2 v_texCoords; + +void main() { + v_color = a_color; + v_texCoords = a_texCoord0; + gl_Position = u_projTrans * a_position; } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ColorLimiterTest.kt b/src/net/torvald/terrarum/ColorLimiterTest.kt new file mode 100644 index 000000000..5e27f97cf --- /dev/null +++ b/src/net/torvald/terrarum/ColorLimiterTest.kt @@ -0,0 +1,67 @@ +package net.torvald.terrarum + +import com.badlogic.gdx.ApplicationAdapter +import com.badlogic.gdx.Gdx +import com.badlogic.gdx.backends.lwjgl.LwjglApplication +import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration +import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.GL20 +import com.badlogic.gdx.graphics.Texture +import com.badlogic.gdx.graphics.g2d.SpriteBatch +import com.badlogic.gdx.graphics.glutils.ShaderProgram + +/** + * Created by minjaesong on 2017-07-05. + */ + +fun main(args: Array) { // LWJGL 3 won't work? java.lang.VerifyError + val config = LwjglApplicationConfiguration() + //config.useGL30 = true + config.vSyncEnabled = false + config.resizable = false + config.width = 1072 + config.height = 742 + config.foregroundFPS = 9999 + LwjglApplication(ColorLimiterTest, config) +} + +object ColorLimiterTest : ApplicationAdapter() { + + lateinit var img: Texture + lateinit var shader4096: ShaderProgram + + lateinit var batch: SpriteBatch + + + override fun create() { + ShaderProgram.pedantic = false + + shader4096 = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/4096.frag")) + img = Texture("assets/test_texture.tga") + + batch = SpriteBatch() + } + + override fun render() { + Gdx.graphics.setTitle("TestTestTest — F: ${Gdx.graphics.framesPerSecond}") + + Gdx.gl.glClearColor(.157f, .157f, .157f, 0f) + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) + + + batch.inUse { + batch.shader = shader4096 + //batch.shader.setUniformf("iResolution", Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat()) + + batch.color = Color.WHITE + batch.draw(img, 0f, 0f) + + + batch.shader = null + } + } + + override fun dispose() { + img.dispose() + } +} \ No newline at end of file