Hi there,
I'm new here and maybe the problem that I discribe is allready resolved in another thread...
Okay, my problem:
I want to use 3 Textures in my shader and these textures I want to mix them but I don't know what I have to do to get this working.
Here is my code so far (c++):
void AClass::init(unsigned int wndWidth, unsigned int wndHeight)
{
if (!mOffScreenTarget.create(wndWidth, wndHeight))
return;
mOffScreenTarget.setSmooth(true);
mSchriftTex.loadFromFile("IntroGrafiken\\Logo.png");
mSchriftSprite.setTexture(mSchriftTex);
mRauschenSoftTex.loadFromFile("IntroGrafiken\\Rauschen.png");
mRauschenSoftSprite.setTexture(mRauschenSoftTex);
mRauschenHardTex.loadFromFile("IntroGrafiken\\20_rauschen.gif");
mRauschenHardSprite.setTexture(mRauschenHardTex);
mShader.loadFromFile("IntroShader\\IntroShader.vert","IntroShader\\IntroShader.frag");
mShader.setParameter("schriftZugTextureSampler", mSchriftTex);
mShader.setParameter("rauschSoftTextureSampler", mRauschenSoftTex);
mShader.setParameter("rauscheHardTextureSampler", mRauschenHardTex);
}
and my draw-function:
sf::RenderStates state = sf::RenderStates::Default;
state.shader = &mShader;
mOffScreenTarget.clear(sf::Color::White);
mOffScreenTarget.draw(mSchriftSprite, state);
mOffScreenTarget.draw(mRauschenHardSprite, state);
mOffScreenTarget.draw(mRauschenSoftSprite, state);
mOffScreenTarget.display();
window.draw(sf::Sprite(mOffScreenTarget.getTexture()));
But this don't work. With this code all Sprites get drawn simple. But I want to mix them.
The shader code works I think...but I don't know what I have to do to get what I want!!!
Okay, I hope so you understand what I want and I hope my english isn't soo bad^^
Maybe you can post here some code...cause that says often more to me :)
Best regards
JoseMan
okay.
Here is my Vertex-Shader:
#version 330 core
void main()
{
vec4 vertex = gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}
And the fragment-shader:
#version 330 core
vec2 uvSchriftZugTexture;
vec2 uvRauschTexture;
// Ouput data
vec4 color;
uniform sampler2D schriftZugTextureSampler;
uniform sampler2D rauschSoftTextureSampler;
uniform sampler2D rauscheHardTextureSampler;
uniform float alpha;
vec4 colSchriftZugTexture;
vec4 colRauschSoft;
vec4 colRauschHard;
void main()
{
uvSchriftZugTexture = gl_TexCoord[0];
uvRauschTexture = gl_TexCoord[0];
colSchriftZugTexture = texture2D( schriftZugTextureSampler, uvSchriftZugTexture).rgba;
colRauschSoft = texture2D( rauschSoftTextureSampler, uvRauschTexture).rgba;
colRauschHard = texture2D( rauscheHardTextureSampler, uvRauschTexture).rgba;
color = mix(colSchriftZugTexture,colRauschSoft,0.55);
color = mix(color,colRauschHard,0.30);
gl_FragColor = color;
}
All I want to do is use the simple glsl-"mix"-function with 3 textures...but I don't know how to handle that with sfml.