› Foros › PC › Software libre
base_texture.bind(0);
spots_texture.bind(1);
shader.begin();
shader.setUniformi("base_texture", 0);
shader.setUniformi("spots_texture", 1);
shader.setUniformf("base_color", new Color(255, 0, 0, 255));
shader.setUniformf("spots_color", new Color(0, 255, 0, 255));
mesh.render(shader, GL20.GL_TRIANGLE_FAN);
shader.end();
attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main()
{
v_texCoord = a_texCoord;
gl_Position = a_position;
}
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texCoord;
uniform sampler2D base_texture;
uniform sampler2D spots_texture;
uniform vec4 base_color;
uniform vec4 spots_color;
void main()
{
gl_FragColor = base_color * texture2D(base_texture, v_texCoord) + spots_color * texture2D(spots_texture, v_texCoord);
}
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texCoord;
uniform sampler2D base_texture;
uniform sampler2D spots_texture;
uniform vec4 base_color;
uniform vec4 spots_color;
void main()
{
vec4 base_pixel = texture2D(base_texture, v_texCoord);
vec4 spots_pixel = texture2D(spots_texture, v_texCoord);
gl_FragColor = base_pixel*base_color*vec4(base_pixel.a-spots_pixel.a) + spots_pixel*spots_color*vec4(spots_pixel.a);
}
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
luciferfran escribió:Mira si algo de aquí te vale tiene sobre API OpenGL y sobre Shaders, el módulo 2 programación gráfica.
http://cedv.morcy.es/index.php?sec=material
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texCoord;
uniform sampler2D base_texture;
uniform sampler2D spots_texture;
uniform vec4 base_color;
uniform vec4 spots_color;
void main(){
vec4 base_pixel = texture2D(base_texture, v_texCoord) * base_color;
vec4 spots_pixel = texture2D(spots_texture, v_texCoord) * spots_color;
gl_FragColor = mix(base_pixel, spots_pixel, spots_pixel.a);
}