Hi hab ein Problem mit GLSL
Ich will das sich die Farbe von der Texture von der glColor(gl_Color) anhängt.
Wie wenn ich eine komplett weisse Textur hab und dann glColor(255,0,0,255) einsetze, dann wird die ganze Texture Rot.
So das Problem ist jetzt aber wenn ich ein PostProcess-Shader einsetze dann arbeitet der nur mit den Texturen Eingenschaften.
Aber nicht mit den gl_Color.
Dachte mir das Problem so zu lösen.
Die Transparenz mit glColor kann ich somit jetzt bestimmen,
aber die Textur ist immer noch weiss.
Hier ein Blur Effect
Vertex:
|
C-/C++-Quelltext
|
1
2
3
4
5
|
void main(void){
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}
|
Fragment
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
uniform sampler2D uTexture;
uniform float textureWidth;
uniform float textureHeight;
uniform float radius;
const int gaussRadius = 11;
const float gaussFilter[gaussRadius] = float[gaussRadius](
0.0402,0.0623,0.0877,
0.1120,0.1297,0.1362,
0.1297,0.1120,0.0877,
0.0623,0.0402
);
void main() {
vec2 uShift = vec2(textureWidth,textureHeight);
vec2 texCoord = gl_TexCoord[0].xy - float(int(gaussRadius/2)) * uShift;
vec3 color = vec3(0.0, 0.0, 0.0);
for (int i = 0; i < gaussRadius; ++i) {
color += (gaussFilter[i]+(radius/100.0)) * texture2D(uTexture, texCoord).rgb;
texCoord += uShift;
}
gl_FragColor = vec4(color,1.0);
gl_FragColor = min(gl_FragColor,gl_Color);
}
|