Firstly, I checked to ensure all of my tiles were touching when uploading my data -> all okay, definitely the correct UV coordinates and data sent with no obvious rounding errors.

Secondly, I disabled MSAA and checked whether it was the UV coordinates bleeding or the floating point positions being off -> UV coordinates seemed to be bleeding in texture atlas.

I was surprised to see that when I wrote the following simple fragment shader (to test if the v_uv was within the UV coordinates I require):

Code :

#version 330
uniform sampler2D tex;
in vec2 v_uv;
out vec4 f_color;
void main() {
vec4 color = texture(tex, v_uv);
float tile_size = 128.0 / 2048.0;
float top_left_x = 256.0 / 2048.0;
float top_left_y = 256.0 / 2048.0;
if (v_uv.x < top_left_x) {
color = vec4(0.0, 0.0, 0.0, 1.0);
}
if (v_uv.y < top_left_y) {
color = vec4(0.0, 0.0, 0.0, 1.0);
}
if (v_uv.x > top_left_x + tile_size) {
color = vec4(0.0, 0.0, 0.0, 1.0);
}
if (v_uv.y > top_left_y + tile_size) {
color = vec4(0.0, 0.0, 0.0, 1.0);
}
f_color = vec4(color.x, color.y, color.z, color.a);
}

The bleeding texture atlas now showed black lines instead of the original atlas bleeding. How can that be and why is it extrapolating the UV outside of my primitive's edges by a small amount?

Even though I uploaded the UV coordinates of (0.125, 0.125) to (0.1875, 0.1875) for every tile (the texture is located on the 2nd column and 2nd row, 128px of a 2048px atlas).

here the piece of code that generate the shape:

Code cpp:

int rr = 50;
int h = 1000;
int vertices = 25;
beginShape(TRIANGLE_STRIP);
for (int i = 0; i <= vertices; i++) {
float angle = TWO_PI / vertices;
float x = sin(i * angle);
float z = cos(i * angle);
float u = float(i) / vertices;
vertex(x * rr, -h/2, z * rr);
vertex(x * rr, +h/2, z * rr);
}
endShape();

here my default vertex:

Code glsl:

#version 150
#define PROCESSING_COLOR_SHADER
#ifdef GL_ES
precision mediump float;
#endif
in vec4 position;
in vec3 color;
out vec3 Color;
uniform mat4 transform;
in vec2 texCoord;
out vec2 TexCoord;
in vec4 normal;
uniform float u_time;
uniform mat3 normalMatrix;
void main() {
vec4 pos = position;
TexCoord = texCoord;
Color = color;
gl_Position = transform * pos;
}

and here the result:

what i want is try to put the shape into some kind of "spline", or something like a ray, just something like that:

how can i "bend" geometry to generate that points of intersection? i assume is something that i can do in vertexShader, but maybe im wrong. thanks a lot

glActiveTexture(GL_TEXTURE0 + 5);

glBindTexture(GL_TEXTURE_2D, diffusemap);

glBindTexture(GL_TEXTURE_3D, envmap);

And then use both of them in the shader?

In other words, does each texture unit support one texture, or one texture per target? ]]>

Code :

varying vec4 coord;
uniform sampler2D texture;
uniform float highlights;
const float a = 1.357697966704323E-01;
const float b = 1.006045552016985E+00;
const float c = 4.674339906510876E-01;
const float d = 8.029414702292208E-01;
const float e = 1.127806558508491E-01;
void main() {
vec4 color = texture2D(texture, coord.xy);
float maxx = max(color.r, max(color.g, color.b));
float minx = min(color.r, min(color.g, color.b));
float lum = (maxx+minx)/2.0;
float x1 = abs(highlights);
float x2 = lum;
float lum_new = lum < 0.5 ? lum : lum+ a * sign(highlights) * exp(-0.5 * (((x1-b)/c)*((x1-b)/c) + ((x2-d)/e)*((x2-d)/e)));
// gl_FragColor = color * lum_new / lum;
gl_FragColor = vec4(color * lum_new / lum);
}

i probably need some help with a strange beaviour of a lightning-function in a fragment-shader.

This is the relevant shader-code (a bit simplified):

Code :

in Data {
vec4 Vertex;
vec3 Normal;
vec4 Position;
vec4 TexCoord;
} In;
out vec4 color;
vec3 normal = In.Normal;
vec3 LightVec = normalize( gl_LightSource[0].position.xyz - vec3(In.Vertex));
[...]
void main() {
[...]
// --- Create Bumpmap ----------------------------------
if (uniBumpFact > 0) normal = normal + bump(Texture0, uniBumpFact) ;
// --- Shadow ------------------------------------------
float intens = max(dot (-normal, vec3 (LightVec)), 0.0);
color = color * intens;
[...]
}

The problem is that the light on the back side of the vertices is somehow inverted, so the shadow on an object which is drawn fron right to left, appears on the wrong side.

Does anyone have an idea what the problem might be?

Thanks,

Frank ]]>