View Single Post
  #3  
Old 01-03-2013, 07:50 AM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
I am using this method to apply textures & shader

Code:
import viz
viz.go()
.
.
.

tex0 = viz.addTexture('image0.jpg')
tex1 = viz.addTexture('image1.jpg')
tex2 = viz.addTexture('image2.jpg')
tex3 = viz.addTexture('image3.jpg')

node3d.texture(tex0,node = 'node_name', unit = 0)
node3d.texture(tex1,node = 'node_name', unit = 1)
node3d.texture(tex2,node = 'node_name', unit = 2)
node3d.texture(tex3,node = 'node_name', unit = 3)
.
.
.

vertCode = """
.
.
.
"""

fragCode = """
.
.
.
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;

varying .......
.
.
.

void main()
{
. . . tex0 = texture2D(texture0, texcoord); tex1 = texture2D(texture1, texcoord); tex2 = texture2D(texture2, texcoord); tex3 = texture2D(texture3, texcoord); . . . gl_FragColor = function(tex0,tex1,tex2,tex3);
} """ shader = viz.addShader(vert = vertCode, frag = fragCode) uf_texture0 = viz.addUniformInt('texture0',0) uf_texture1 = viz.addUniformInt('texture1',1) uf_texture2 = viz.addUniformInt('texture2',2) uf_texture3 = viz.addUniformInt('texture3',3) . . node3d.apply(shader) node3d.apply(uf_texture0) node3d.apply(uf_texture1) node3d.apply(uf_texture2) node3d.apply(uf_texture3) . .
Using this method I can not apply more than 4 textures. If there any alternate method so that I can take full advantage of fragment shader then please let me know.

Thanks !!
Reply With Quote