State dependant rendering of objects

Hey guys,

I am currently working on my bachelor thesis which is about creating a 3D-Visualisation of a warehouse using the GWT plugin gwt-g3d.

I’ve come as far as being able to display the structual layout quite efficiently. Rendering 2 million+ vertextes at a decent framerate since i keep all the rendering within the shaders and minimize my gl.draw() calls. However I think i’ve come to a dead end using this technique since it is very static. What i need is a way to make my application more dynamic.
As I am used to object orientated programming in Java the shader language is quite hard to get my head around. Here’s what I’m talking about…

I’m trying to render multiple areas (the number of these ares is UNKNOWN at initialisation) of my visualisation in a different manner (a different color to start with). So ive tried something like this within the fragment shader:


uniform vec3 alteredCoords[]; //a coordArray of positions that i want to render alternatively

// color each of these coords in grey
for (int i = 0; i < alteredCoords.length(); i++) {
if ( position.x == alteredCoords[i].x && position.y == alteredCoords[i].y && position.z == alteredCoords[i].z) {
gl_FragColor = vec4(100.0/255.0, 100.0/255.0, 100.0/255.0, 1.0);
return;
}
}

I know that this wont work as it is, because the array needs a constant size and there are casting issues… try to ignore that for now since this wont work anyways because the shader language doesn’t support dynamically sized arrays.

What i need is some sort of workaround for this issue…

any ideas?

Help please :smiley:

EDIT:
to give you a better understanding of what i’m talking about here’s a screenshot of what my layout looks like atm:

Notice that i’ve implemented my idea for a single area (grey square) already… all i need is some way to dynamically render multiple areas that way

Ok since you also asked that on stackoverflow it seem you really want help, so I’ll try to help you. However, either it’s just me after 2 days of refactoring code or your explanation of your problem isn’t really clear.

So basically you want to render an arbitrary amound of these shelves and depending on their location they should be colored somehow?

yes I am really desperate for help =P

Exactly, as soon as i’ve figured out a mechanism to address any number of locations dynamically i can realize what’s missing in my application.

I am unsure of how clear my explanation is so far… so if there are questions regarding code or anything else just go for it, i’ll try to answer as much as i can =D

On my way home from work i’ve thought about my post and maybe i should simply have asked: Is there any data type in the shading language that does not need a constant size and can be used for saving data (much like an ArrayList…)

Sometimes just talking about the problem helps :slight_smile:

No there isn’t. If you need to give a shader a large amount of data you usually do it with a texture.

Now for the problem. Do you need to color them only according to their x,y location? If yes, I would simply create one buffer to draw a single shelf. Then draw them using two for loops, update the loction with an x,y offset uniform in the vertex shader and color with an uniform in the fragment shader.

thank you already!

i will try this out tmrw at work…
can you send me ur skype via pm?

greets!