mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
shader does work at least...
This commit is contained in:
@@ -1,73 +1,12 @@
|
|||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
precision mediump float;
|
||||||
precision mediump float;
|
|
||||||
#else
|
|
||||||
#define LOWP
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
varying vec4 vertexWorldPos;
|
|
||||||
uniform vec4 backColor;
|
|
||||||
|
|
||||||
uniform float width;
|
|
||||||
uniform float height;
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 tex;
|
//gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
||||||
vec4 color2=vec4(0.0,0.0,0.0,0);
|
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
float stepx=(1.0/width)*4.0;
|
|
||||||
float stepy=(1.0/height)*4.0;
|
|
||||||
vec4 color;
|
|
||||||
|
|
||||||
tex.x=v_texCoords.x+stepx;
|
|
||||||
tex.y=v_texCoords.y+stepy;
|
|
||||||
color=v_color * texture2D(u_texture, tex);
|
|
||||||
color2.r+=color.r;
|
|
||||||
color2.g+=color.g;
|
|
||||||
color2.b+=color.b;
|
|
||||||
color2.a+=color.a;
|
|
||||||
|
|
||||||
tex.x=v_texCoords.x-stepx;
|
|
||||||
tex.y=v_texCoords.y+stepy;
|
|
||||||
color=v_color * texture2D(u_texture, tex);
|
|
||||||
color2.r+=color.r;
|
|
||||||
color2.g+=color.g;
|
|
||||||
color2.b+=color.b;
|
|
||||||
color2.a+=color.a;
|
|
||||||
|
|
||||||
tex.x=v_texCoords.x-stepx;
|
|
||||||
tex.y=v_texCoords.y-stepy;
|
|
||||||
color=v_color * texture2D(u_texture, tex);
|
|
||||||
color2.r+=color.r;
|
|
||||||
color2.g+=color.g;
|
|
||||||
color2.b+=color.b;
|
|
||||||
color2.a+=color.a;
|
|
||||||
|
|
||||||
tex.x=v_texCoords.x+stepx;
|
|
||||||
tex.y=v_texCoords.y-stepy;
|
|
||||||
color=v_color * texture2D(u_texture, tex);
|
|
||||||
color2.r+=color.r;
|
|
||||||
color2.g+=color.g;
|
|
||||||
color2.b+=color.b;
|
|
||||||
color2.a+=color.a;
|
|
||||||
|
|
||||||
tex.x=v_texCoords.x;
|
|
||||||
tex.y=v_texCoords.y;
|
|
||||||
color=v_color * texture2D(u_texture, tex);
|
|
||||||
color2.r+=color.r;
|
|
||||||
color2.g+=color.g;
|
|
||||||
color2.b+=color.b;
|
|
||||||
color2.a+=color.a;
|
|
||||||
|
|
||||||
color2.r/=5.0;
|
|
||||||
color2.g/=5.0;
|
|
||||||
color2.b/=5.0;
|
|
||||||
color2.a/=5.0;
|
|
||||||
|
|
||||||
|
|
||||||
gl_FragColor = color2;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
precision mediump float;
|
attribute vec4 a_position;
|
||||||
|
attribute vec4 a_color;
|
||||||
|
attribute vec2 a_texCoord0;
|
||||||
|
|
||||||
attribute vec2 position;
|
uniform mat4 u_projTrans;
|
||||||
|
|
||||||
|
varying vec4 v_color;
|
||||||
|
varying vec2 v_texCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(position, 1, 1);
|
v_color = a_color;
|
||||||
|
v_texCoords = a_texCoord0;
|
||||||
|
gl_Position = u_projTrans * a_position;
|
||||||
}
|
}
|
||||||
@@ -402,10 +402,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
// now the actual drawing part //
|
// now the actual drawing part //
|
||||||
lightmapFrameBuffer.inAction {
|
lightmapFrameBuffer.inAction {
|
||||||
// TODO gaussian blur p=8
|
// TODO gaussian blur p=8
|
||||||
TerrarumGDX.shaderBlur.setUniformf("width", lightmapFrameBuffer.width.toFloat())
|
|
||||||
TerrarumGDX.shaderBlur.setUniformf("height", lightmapFrameBuffer.height.toFloat())
|
batch.shader = TerrarumGDX.shaderBlur
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
batch.shader = null//TerrarumGDX.shaderBlur
|
//batch.shader.setUniform3fv("iResolution", floatArrayOf(lightmapFrameBuffer.width.toFloat(), lightmapFrameBuffer.height.toFloat(), 0f), 0, 12)
|
||||||
|
//batch.shader.setUniformi("iChannel0", 0)
|
||||||
|
//batch.shader.setUniform2fv("direction", floatArrayOf(8f, 8f), 0, 8)
|
||||||
|
|
||||||
|
|
||||||
// using custom code for camera; this is obscure and tricky
|
// using custom code for camera; this is obscure and tricky
|
||||||
|
|||||||
Reference in New Issue
Block a user