Hello,

> > I need to do something which is best to describe by taking the
> > CubesAppUnified example as a base.
> > Imagine I want to display a lot of cubes, all of them textured, but
> each of
> > them has some kind of switch (an int for example) which selects the
> texture
> > from a set of five textures. So all of the cubes together need some
> kind of
> > pool of textures and each of them uses the one it is told to use.
> > Additionally imagine that the pool of textures might not contain only
> five
> > textures, but over one hundred, but usually only 10 of them are used.
> So not
> > all of them need to be transferred to the graphics card. How would I
> go
> > about implementing that? I don't think materials would be of any use
> here as
> > you would need like one material per node, which makes them quite
> useless.
> 
> materials can be shared, so you can place the same material on multiple
> geometries (actually they should be shared as much as possible, to make
> the state sorting effective).
> Also there is SwitchMaterial which has an MField of materials and an
> SFUInt32 to choose one of them.
> How often does the switch value change for an individual cube? It seems
> to me that keeping cubes with the same material grouped would be the
> main difficulty.

I thought you might say that, but the actual scenario is way more difficult.
To draw one of the "cubes" I need to use between 3 and 10 textures (out of a
pool of 120 or so) and one of three shaders. So the probability that two
sets of resources are identical is quite low. It doesn't seem to be worth
actually sharing materials, and as I see it, it does not seem to be worth it
using materials at all. 
To draw one core, I need to be able to switch textures and shaders, which is
not a problem, I just don't know how to initialize them.

Pseudo code of what I had in mind:

Action::ResultE Type::drawPrimitives(DrawEnv *pEnv)
{
        If (texture[0].not_initialized()) {
                Texture[0].init();
        }
        Texture[0].activate(pEnv);

        ... fancy drawing routine ...

}

Plus there may be a better location for initializing the textures and
shaders, as the resource working set of a core actually doesn't change, only
sometimes most of the textures might not be used and a different shader
might be active.

Aloha, Andi


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to