Hi
I thought also about separating register_combiners and vertex_programs but I thought it would be not very much used but perhaps it could be done in a way as C++ scoping
example
shader0.txt:
shader spec_tex
{
register_combiner reg_comb
{
…
}
implementation
{
{// first pass
fragment_op=register_combiner(reg_comb)
}
}
}
}
shader1.text
shader shader_two
{
extern register_combiner extern_rc = spec_tex::reg_comb;
implementation
{
{
fragment_op=extern_rc
}
}
}
to make this work I think there is the need of managing shaders independent from the parser. I would like to develop the shader classes, being able to setup them with c++ code. If that works, there could be the parser that setup shaders. I can imagine a kind of intermediate ‘byte’ code that is accepted by a shader to setup itself and the parser generates the byte code for the shader library. An advantage would be that you can test your shader as a text file and than later you decide to save it as byte code to reduce storage amount and prevent the unauthorized editing.
I think it would be useful to develop the shaderlib as a DLL WITH dynamic loading, so you can exchange the dll and the shader files when for example a new graphics card is supported by the shader lib.
I thought also about the possibility to setup vertex programs constant by the shader lib to track lighting/material properties.
supose you have a particel system where a particle should fade by reducing its alpha value, but the alpha value should be controlled by the particle not by the shader.
I would like to have a kind of parameter tracking from the app to the shader lib, as similar as your vertex shader constants
shader particle
{
parameter // parameters that will be accepted later in the shader
{
texture part_tex;
vec4f part_color;
}
implementation
{
{
blend_func=GL_src_alpha,GL_one_minus_src_alpha;
bind_texture(0,part_tex);
fragment_op=modulate;
primary_color=part_color;
}
}
}
you app code would be
particle::render()
{
ShaderLib::SelectShader(“particle”);
ShaderLib::SetParameter(“part_color”,vec4f(1,1,1,1-(cur_time/life_time));
ShaderLib::SetParameter(“part_tex”,mytexture);
ShaderLib::SetGeometry(particle_geometry); // could be a vertex buffer …
ShaderLib::Render();
}
Bye
ScottManDeath