• 10
• 12
• 12
• 14
• 18
• entries
27
25
• views
6335

# GPUPhysics: A hell with shaders

104 views

Today I began implementing the shaders for GPUPhysics and discovered a lot of limitations that were sooo annoying.

For example the fact that you cannot have a sampler array that you index with a variable. I was totally counting on that (and it's very important to get it working), but as it seems I will have to find a way around the problem. Any tips would be greatly appreciated. Currently I'm doing it this way as a walk-around (compiling with ps_3_0, HLSL):

//...//tex_shapes is an array of 10 samplerCUBEsint a = anything;for(int i=0;i<10;i++){  if(i==a)    lala = texCUBE(tex_shapes,texcoord);}//...

But this generates a LOT of assembly code [sad]... there's got to be a better way! I want to have the appropriate indices stored in a texture and look them up (rounded to integers).

Another way I thought of is using 6 volume textures that have 10 layers. Each of these volume textures would be a set representing one cube side. Then I would do some kind of fake cube-texture lookup using a depth texture coordinate instead of an index to access the right layer. This would actually be good in the sence that I could have more than 10 layars if I like to (the number of 10 was chosen due to 16 textures limitation on Shader Model 3). But the problem is, that I don't know how to do this fake cube texture lookup.
To simplify the case: Imagine we have only 6 2D textures representing the sides of a cube map. How could I do a "cubemap lookup" using these instead of a real cubemap? I guess that's the problem of tomorrow, now I'm going to bed...

## 1 Comment

Have been away in Stockholm at a course, and was ill a few days. (This is for my own record only...)