Sending Textures and Lightmap of BSP to Shader
Posted: Tue Feb 27, 2007 12:18 am
Is it even possible? I'm trying to write a shader that will negate the the bsp textures. I got the textures to turn negative easily but the only thing is that the lightmap does not render. I checked the shader with TyphoonLab's Shader Designer and it works fine but when I run my program with it, the lightmaps don't render? Does anyone know whats wrong or how to fix it?
Here is some of the code:
Vert shader:
Frag shader:
OnSetConstants Callback:
I figure that I have to send the lightmap to the shader somehow, but I don't know how...
Here is some of the code:
Vert shader:
Code: Select all
void main()
{
gl_TexCoord[0]=gl_MultiTexCoord0;
gl_Position = ftransform();
}
Code: Select all
uniform sampler2D tex; //Texture
uniform sampler2D tex1; //Lightmap?
void main()
{
vec4 texval1 = texture2D(tex, vec2(gl_TexCoord[0]));
vec4 texval2 = texture2D(tex1, vec2(gl_TexCoord[0]));
gl_FragColor = ((1-texval1)+texval2)*.5;
}
Code: Select all
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
services->setPixelShaderConstant("tex1", reinterpret_cast<f32*>(1), 0);
}
};