How to not overwrite a models texture with the glsl fragment shader

jrs's picture

Hi All,

How do I keep glsl from overwriting the texture details that get loaded with a model? I've attached an example composition where I texture the teapot with its image port. This works fine outside a shader but as soon as I place it inside my model goes white.

Apart from having a search on the web and not being able to find it I came across this thread - https://kineme.net/Discussion/GeneralDiscussion/Fisheyeviewplugin

which at one stage talks about the same thing. Chris mentioned adding the following to the vertex shader:

gl_FrontColor = gl_Color;

And the following to the fragment shader

gl_FragColor = gl_Color;

but it doesn't work. I get the feeling this is something simple and easy but I just can't see where I'm going wrong

Cheers James

PreviewAttachmentSize
glsl_texture_passthrough.qtz75.66 KB

franz's picture
Re: How to not overwrite a models texture with the glsl ...

it is not a "passthrough" but allows to have a texture input in the shader. gl_FragColor = gl_Color * texture2D(texture, gl_TexCoord[0].xy);

(provided you have some texture coords.)

jrs's picture
Re: How to not overwrite a models texture with the glsl ...

Thanks Franz,

I'd tried that and was still getting weird results - turned out it was a combination of a bug in my shader code and also that I had the texture still connected to the object as well as the shader when I only needed the shader.