I am trying to draw an outline for an object with the stencil buffer, but uses the textures of the object that its an outline to, instead of the color given in its fragment shader.
"important" parts of the rendering process:
//when it first loads in
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_STENCIL_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
glDepthFunc(GL_LESS);
//in render loop
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
glStencilMask(0x00);
//draws lights and a grid on the floor here
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilMask(0xFF);
//draws all of the objects here
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
glStencilMask(0x00);
//draws objects here again but slightly scaled for the outlined with a different fragment shader
applied (the one mentionned below)
glStencilMask(0xFF);
glStencilFunc(GL_ALWAYS, 0, 0xFF);
fragment shader for the outline:
#version 460 core
out vec4 FragColor;
void main()
{
FragColor = vec4(1, 0, 1, 1);
}