hello,
I have setup some geometry like this
PT(GeomVertexArrayFormat) array = new GeomVertexArrayFormat();
array->add_column(InternalName::make("vertex"), 3, Geom::NT_float32, Geom::C_point);
array->add_column(InternalName::make("normal"), 3, Geom::NT_float32, Geom::C_point);
array->add_column(InternalName::make("alphaUV"), 2, Geom::NT_float32, Geom::C_texcoord);
array->add_column(InternalName::make("colorUV"), 2, Geom::NT_float32, Geom::C_texcoord);
PT(GeomVertexFormat )unregistered_format = new GeomVertexFormat();
unregistered_format->add_array(array);
CPT(GeomVertexFormat) format = GeomVertexFormat::register_format(unregistered_format);
PT(GeomVertexData) vData = new GeomVertexData("myFormat", format, Geom::UH_dynamic);
GeomVertexRewriter vertices = GeomVertexRewriter(vData, "vertex");
GeomVertexRewriter normals = GeomVertexRewriter(vData, "normal");
GeomVertexRewriter alphaUV = GeomVertexRewriter(vData, "alphaUV");
GeomVertexRewriter colorUV = GeomVertexRewriter(vData, "colorUV");
I have filled in all the data and I can see the geometry rendering on screen.
I have then loaded a texture like this
PT(Texture) pDirt = TexturePool::load_texture("dirt.dds");
myGeometryNode.set_texture(pDirt);
I load my shader like this
CPT(Shader) myGeometryShader;
myGeometryShader = ShaderPool::load_shader("myShader.cg");
myGeometryNode.set_shader(myGeometryShader);
here the implementation of my shader
//Cg
void vshader(
uniform float4x4 mat_modelproj,
in float4 vtx_position : POSITION,
in float3 vtx_normal : NORMAL,
in float2 vtx_texcoord0: TEXCOORD0,
in float2 vtx_texcoord1: TEXCOORD1,
out float2 l_texcoord0: TEXCOORD0,
out float2 l_texcoord1: TEXCOORD1,
out float4 l_position : POSITION)
{
l_position = mul(mat_modelproj, vtx_position);
l_texcoord0 = vtx_texcoord0;
l_texcoord1 = vtx_texcoord1;
}
void fshader(
uniform sampler2D tex_0 : TEXUNIT0,
in float2 l_texcoord0: TEXCOORD0,
in float2 l_texcoord1: TEXCOORD1,
out float4 o_color : COLOR)
{
float4 c0 = tex2D(tex_0, l_texcoord1); // dirt
o_color = c0;
}
with this my model is rendered but instead of the “dirt” texture I see the whole model in a dark blue color.
Anyone knows what I am doing wrong ?
chrys