Hello Andreas,

Andreas Halm wrote:
> First it would be nice to have an overview over the endless number of
> classes in system/state/shader and system/state/shl, which are all somehow
> related to shaders - but where to start? ;-)

some of this is backwards compatibility stuff, new code should use 
System/State/Shader:

vp = ShaderProgram::createVertexShader();
fp = ShaderProgram::createFragmentShader();

vp->setProgram( ... );
fp->setProgram( ... );

vp->addUniformVariable("someUniform", someValue);

sh = ShaderProgramChunk::create();
sh->addShader(vp);
sh->addShader(fp);

finally add the chunk to your material.
There is also a ShaderProgramVariableChunk, that looks as if it would 
allow you to use it in multiple materials in combination with different 
ShaderProgramChunks, but that did not work the last time I tried it.

All these user visible types get converted into ShaderExecutableChunk 
and ShaderExecutableVarChunk in the backend.

> Second how are shader attributes realized in OpenSG 2? I mean not attributes
> like glColor or something, but custom per-vertex-attributes like
> 
> #pragma version 130
> uniform vec4 viewport; // the current viewport dimensions (as per
> glGetFloatv(GL_VIEWPORT,...))
> uniform vec4 eyePosition; // the current eye position in modelview
> coordinates
> uniform float scale;
> attribute float radius; // premultiplied with 'scale'
> attribute float halfHeight; // precompute: length(gl_Normal)*scale/2
> ...

we don't really have proper support for custom attributes. You'll have 
to abuse the texture coordinates to get something like it.

> As the attribute id does not change as long as the shader is not recompiled,
> it would be a significant overhead querying the id every time it is used.
> However, the attribute id may (afaik) be different in different windows, so
> it should be handled quite like a texture id.
> Is there anything in OpenSG I can use, or any idea on how to implement that?

I haven't thought about how to implement this, maybe Gerrit already put 
some pieces into the existing shader stuff?

        Cheers,
                Carsten

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to