I'm trying to port a shadertoy shader to an SFML application.
The problem I have is with this line:
float g = texture(iChannel0, uv+vec2(nh-0.07, 0.0)*nh).g;
I Think that iChannel0
is a 2D sampler and is the video running in the browser.
I need to substitute the iChannel0
with something else but not sure how since I'm totally new to GLSL.
I have a vertex shader that looks like this:
void main()
{
// Transforming The Vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// transform the texture coordinates
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
// forward the vertex color
gl_FrontColor = gl_Color;
}
and in my fragment shader I have the rest of the modified code including the above line containing the iChannel0 parameter.
The shader is applied as a post effect to the whole screen.
I was able to convert everything else with the exception of that last line.
Thanks for your help.
OK, I got it to work like this:
At the top of my fragment shader file, I added:
uniform sampler2D sourceTexture;
I changed:
float g = texture(iChannel0, uv+vec2(nh-0.07, 0.0)*nh).g;
to:
float g = texture2D(sourceTexture, uv+vec2(nh-0.07, 0.0)*nh).g;
and in my SFML code:
shader->setParameter("sourceTexture", sf::Shader::CurrentTexture);