wgj000
01-19-2007, 01:12 PM
Well here is my lovely little fragment shader. And it all works great. Except for one little thing. When the loop count goes from 6 to 7 I get "The GLSL fragment shader will run in software - available number of texture instructions exceeded." Hmmm... That will not do at all. I am pretty sure that "texture instructions" refers to "texture3D." And I think that the loop is being parallized. And I think that because singleCoord is calculated in the loop that the texture3D command is being parallized along with the loop resulting in more than one call to texture3D. Of course I'm gussing, but it seems to make sense. The thing is, there really needs to be only one call to texture3D. The loop only finds one valid value for singleCoord so I can't think of any reason for texture3D to be parallized. So my question is, how can I insure that only one call to texture3D is made after the loop is finished?
uniform sampler3D textures;
uniform mat4 surveySpace;
uniform vec4 textureInfo[500];
varying vec4 vertex; // come straight from gl_Vertex in the vertex shader
void main(void){
vec4 singleCoord=vec4(2.0, 2.0, 0.0, 0.0);
vec4 fragColor = vec4(1.0, 1.0, 1.0, 1.0);
mat4 tileSpace=surveySpace;
vec4 coord;
for(int textureIndex=0;textureIndex<6;textureIndex++){
tileSpace[0][0] =surveySpace[0][0]/textureInfo[textureIndex].z;
tileSpace[1][0] =surveySpace[1][0]/textureInfo[textureIndex].z;
tileSpace[2][0] =surveySpace[2][0]/textureInfo[textureIndex].z;
tileSpace[3][0] =(surveySpace[3][0]-textureInfo[textureIndex].x)/textureInfo[textureIndex].z;
tileSpace[0][1] =surveySpace[0][1]/textureInfo[textureIndex].w;
tileSpace[1][1] =surveySpace[1][1]/textureInfo[textureIndex].w;
tileSpace[2][1] =surveySpace[2][1]/textureInfo[textureIndex].w;
tileSpace[3][1] =(surveySpace[3][1]-textureInfo[textureIndex].y)/textureInfo[textureIndex].w;
coord =tileSpace * vertex;
if( coord.x >= 0.0 && coord.y >= 0.0 && coord.x <= 1.0 && coord.y <= 1.0 ){
singleCoord = coord;
singleCoord.z = float(textureIndex)/10.0;
}
}
if( singleCoord.x >= 0.0 && singleCoord.y >= 0.0 && singleCoord.x <= 1.0 && singleCoord.y <= 1.0 ){
fragColor = texture3D(textures,singleCoord.xyz);
}
gl_FragColor = fragColor;
}
uniform sampler3D textures;
uniform mat4 surveySpace;
uniform vec4 textureInfo[500];
varying vec4 vertex; // come straight from gl_Vertex in the vertex shader
void main(void){
vec4 singleCoord=vec4(2.0, 2.0, 0.0, 0.0);
vec4 fragColor = vec4(1.0, 1.0, 1.0, 1.0);
mat4 tileSpace=surveySpace;
vec4 coord;
for(int textureIndex=0;textureIndex<6;textureIndex++){
tileSpace[0][0] =surveySpace[0][0]/textureInfo[textureIndex].z;
tileSpace[1][0] =surveySpace[1][0]/textureInfo[textureIndex].z;
tileSpace[2][0] =surveySpace[2][0]/textureInfo[textureIndex].z;
tileSpace[3][0] =(surveySpace[3][0]-textureInfo[textureIndex].x)/textureInfo[textureIndex].z;
tileSpace[0][1] =surveySpace[0][1]/textureInfo[textureIndex].w;
tileSpace[1][1] =surveySpace[1][1]/textureInfo[textureIndex].w;
tileSpace[2][1] =surveySpace[2][1]/textureInfo[textureIndex].w;
tileSpace[3][1] =(surveySpace[3][1]-textureInfo[textureIndex].y)/textureInfo[textureIndex].w;
coord =tileSpace * vertex;
if( coord.x >= 0.0 && coord.y >= 0.0 && coord.x <= 1.0 && coord.y <= 1.0 ){
singleCoord = coord;
singleCoord.z = float(textureIndex)/10.0;
}
}
if( singleCoord.x >= 0.0 && singleCoord.y >= 0.0 && singleCoord.x <= 1.0 && singleCoord.y <= 1.0 ){
fragColor = texture3D(textures,singleCoord.xyz);
}
gl_FragColor = fragColor;
}