WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-18-2012, 06:12 AM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
Multi-Texturing Issues

We are experimenting with Vizard 4 Trial Version. We are implementing Advanced Shaders. While Implementing them we are facing problems. For shaders we need to map multiple textures & cubemaps over the object. Vizard only permits 4 textures/Cubemaps. We can apply those textures on units (layers) 0, 1,2 & 3; but not on units 4,5,6 etc. Are these issues because of trial version? If Vizard only permits 4 textures then how to apply more than 4 textures?
Reply With Quote
  #2  
Old 01-02-2013, 10:11 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The Trial version of Vizard does not impose any limitations on the number of textures you can apply to an object. What kind of graphics card do you have? Are you using a fragment shader to blend the multiple textures? I know most nVidia drivers only support 4 texture units when using the fixed function pipeline to combine the textures. However, depending on the driver, a lot more units are supported when using a fragment shader to combine the textures.

Run the following script. The first number it prints out will be the maximum number of fixed function texture units supported by your driver. The second number will be the maximum number of fragment shader texture units supported.
Code:
import viz
viz.go()
print viz.getOption('gl.max_texture_units')
print viz.getOption('gl.max_texture_image_units')
Reply With Quote
  #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
  #4  
Old 01-04-2013, 12:31 AM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
for

Code:
import viz
viz.go()
print viz.getOption('gl.max_texture_units')
print viz.getOption('gl.max_texture_image_units')
I am getting output as
************************************************** **********
4
32
** Load Time: 0.18 seconds
Reply With Quote
  #5  
Old 01-04-2013, 10:01 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Your driver should support up to 32 textures when using a fragment shader. Try running the following script:
Code:
import viz
viz.go()

IMAGES = [ 'images/tile_grass.jpg'
			,'images/tile_gray.jpg'
			,'images/tile_slate.jpg'
			,'images/tile_stone.jpg'
			,'images/tile_wood.jpg'
]

quad = viz.addTexQuad(pos=(0,1.8,2))

for x,name in enumerate(IMAGES):
	tex = viz.addTexture(name)
	quad.texture(tex,unit=x)
	quad.apply(viz.addUniformInt('tex{}'.format(x),x))

frag = """
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;
uniform sampler2D tex4;
void main()
{
	vec2 uv = gl_TexCoord[0].st;
	if(uv.x > 0.8) {
		gl_FragColor = texture2D(tex4,uv);
	} else if(uv.x > 0.6) {
		gl_FragColor = texture2D(tex3,uv);
	} else if(uv.x > 0.4) {
		gl_FragColor = texture2D(tex2,uv);
	} else if(uv.x > 0.2) {
		gl_FragColor = texture2D(tex1,uv);
	} else {
		gl_FragColor = texture2D(tex0,uv);
	}
}
"""

quad.apply(viz.addShader(frag=frag))
It should render the attached image below. If it does not, then please post the graphics card and driver version you are using.
Attached Thumbnails
Click image for larger version

Name:	texture_shader.jpg
Views:	1097
Size:	24.2 KB
ID:	552  
Reply With Quote
Reply

Tags
layers, multi texturing, textures

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi User Environment moneim230 Vizard 5 05-17-2011 05:56 PM
Issues with Calibration Rig adam.rodgers Precision Position Tracker (PPT) 2 12-02-2008 10:13 PM
Read file....many issues Uttama_vizard Vizard 9 07-08-2008 02:16 PM
Video Texturing cheezus69 Vizard 2 04-14-2008 03:26 AM
Mirror issues Frank Verberne Vizard 2 04-08-2008 10:37 AM


All times are GMT -7. The time now is 12:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC