Hi all,
I’m new to shaders, and I’m trying to create a shader which does nothing special. Basically, I want the resulting rendering with my own shader to be the exact same as the rendering when I’m not using my own shader.
The problem is, I can do this if I don’t use textures, but simply vertex colors, or if I only use textures and not simply colors, but not if I use both.
Following is my current shader (CG) code:
//Cg
void vshader(uniform float4x4 mat_modelproj,
in float4 vtx_position:POSITION,
in float2 vtx_texcoord0:TEXCOORD0,
out float4 l_position:POSITION,
out float2 l_texcoord0:TEXCOORD0)
{
l_position = mul(mat_modelproj, vtx_position);
l_texcoord0 = vtx_texcoord0;
}
void fshader(uniform sampler2D tex_0,
in float2 l_texcoord0:TEXCOORD0,
out float4 o_color:COLOR0)
{
float4 texColor = tex2D(tex_0, l_texcoord0);
o_color = texColor;
}
So basically, my question is; how should I write the fragment shader such that it uses texture if available, and just the interpolated vertex color if no texture is available?
Thanks a lot!
Kind regards,
Barno