I'm just starting glsl(From cg, so not madly different, but different enough)
and basically I'm not sure why but i can't access anything other than the first binded texture.
this code below generates a vertex/pixel shader based on spec,
vert shader it outputed
only texture 2 appears to be texture 1 still..
is there a way to access texture handles through glstate in glsl?
and basically I'm not sure why but i can't access anything other than the first binded texture.
this code below generates a vertex/pixel shader based on spec,
'ShaderGEN V0.1 ' 'A system designed to generate shaders to replicate 'gl's fixed function functionality. Type ShaderGen Method NewShader(name:String) Local vertFile:String = name+"Vert.glsl" Local pixFile:String = name+"Pix.glsl" vfile=WriteFile(vertfile) pfile=WriteFile(pixfile) useLights=0 End Method Method GenLights() useLights=True End Method Method addTexture( blendMode ) texblend[texnum]=blendmode texnum:+1 useTextures=1 End Method Method genPPLights() useppLights=True End Method Method Generate() If useTextures For Local j=1 To TexNum WriteLine vfile,"varying vec2 texCoord"+j+";" Next EndIf writeHeader(vfile) writeVertexTForm() If useTextures For Local j=1 To texNum WriteLine vfile,"texCoord"+j+"= vec2(gl_MultiTexCoord"+(j-1)+");" Next EndIf writeEnd(vfile) Local pixOut:String = "gl_FragColor = " If useTextures For Local j=1 To TexNum WriteLine pfile,"varying vec2 texCoord"+j+";" WriteLine pfile,"uniform sampler2D cTexture"+j+";" If j>1 Select texblend[j-1] Case T_Normal pixOut="gl_FragColor = " Case T_ADD pixOut=pixOut+"+" Case T_Modulated pixOut=pixOut+"*" Case T_Subtract pixOut=pixOut+"-" Default Throw "Undefined texture blending mode." End Select EndIf pixOut=pixOut+"texture2D(cTexture"+j+",texCoord"+J+")" Next pixOut=pixOut+";" EndIf writeHeader(pfile) WriteLine pfile,pixout writeend(pfile) CloseFile vfile CloseFile pfile End Method Method writeVertexTForm() WriteLine vfile,"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" End Method Method writeHeader(file) WriteLine file,"void main()" WriteLine file,"{" End Method Method writeEnd(file) WriteLine file,"}" End Method Field useLights,useTextures Field usePPLights,texNum Field vfile,pfile Field texBlend:Int[32] Field dred!,dgreen!,dblue! Field sred!,sgreen!,sblue! End Type
vert shader it outputed
void main() { gl_position = gl_ModelViewProjectionMatrix * gl_Vertex; }
varying vec2 texCoord1; uniform sampler2D cTexture1; varying vec2 texCoord2; uniform sampler2D cTexture2; void main() { gl_FragColor = texture2D(cTexture1,texCoord1)+texture2D(cTexture2,texCoord2); }
only texture 2 appears to be texture 1 still..
is there a way to access texture handles through glstate in glsl?