WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-24-2013, 06:38 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Question Loading a 3D Texture

I couldn't find a ton of documentation in the help files on loading 3D textures.

I am interested in loading a series of 2D images into a 3D texture.
From what I read, the <multimedia:image>.load method should allow me to build a 3d texture.

I am trying to use a series of 2d pngs and turn them into a 3d texture for my shader to access. I have everything setup, the problem is when I try and use 'load' I get the following error:

** ERROR: 'BodyScans\FullBodyThresholded\002.png' cannot be loaded into depth 1 of 3D texture. Valid range is 0-0

I get this error for every image I load.

How do I setup the valid range for a texture? I tried making a 'blanktexture' and manually state I wanted a set number of depth images, but I still got the same error.

Here is my load method:

Code:
	def loadImages(self, dir):
		files = os.listdir(dir)
		for num, f in enumerate(files):
			if f[-3:] == 'png':
				print f
				if self.texture3D == None:
					self.texture3D = viz.addTexture(dir + f, type = viz.TEX_3D)
				self.texture3D.load(dir + f, face = num)
		self.texture3D.compression(viz.COMPRESSION_ARB)
		self.texture3D.hint(viz.PRELOAD_HINT)
Thanks,
George
Reply With Quote
  #2  
Old 01-24-2013, 07:11 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the viz.addBlankTexture command to create 3D textures with a specified depth. Here is a sample script showing how to load images into each depth slot:
Code:
import viz
viz.go()

#Create list of 2D images that will make up 3D texture
files = [ 'launch_stills/sts90launch'+ str(i+1) + '.jpg' for i in range(31) ]

#Create blank 3D texture
tex = viz.addBlankTexture([64,64,len(files)],viz.TEX_3D,minFilter=viz.LINEAR_MIPMAP_LINEAR)

#Load each image into 3D texture
for i,f in enumerate(files):
	tex.load(f,i)
	
#Apply texture to quad
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)

#Create slider to change z texture coordinate of quad
slider = viz.addSlider(pos=(0.5,0.1,0))
def SetDepth(pos):
	m = viz.Matrix.translate(0,0,pos)
	quad.texmat(m)
vizact.onslider(slider,SetDepth)


viz.startlayer(viz.QUADS)

#Lower left
viz.texcoord(0,0,0)
viz.vertex(0.4,0.01,0)

#Upper left
viz.texcoord(1,0,0)
viz.vertex(0.4,0.05,0)

#Upper right
viz.texcoord(1,0,1)
viz.vertex(0.6,0.05,0)

#Lower right
viz.texcoord(0,0,1)
viz.vertex(0.6,0.01,0)

otf = viz.endlayer(parent=viz.SCREEN,texture=tex)
Hope this clears things up.
Reply With Quote
  #3  
Old 01-25-2013, 10:27 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Question

#Edit - Still get the same problem on a Quadro 6000 with JPG or PNG

Unfortunately, I am still running into the same error, even when I copy and paste in your code.

I made a small subset of jpg images to see if there was a problem with the png format, and I still encounter the following error.

** ERROR: 'BodyScans/Test/3.jpg' cannot be loaded into depth 1 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/4.jpg' cannot be loaded into depth 2 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/5.jpg' cannot be loaded into depth 3 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/6.jpg' cannot be loaded into depth 4 of 3D texture. Valid range is 0-0

Do you happen to know what the error is exactly referring to for the 0-0 range?

I end up just having the first texture applied to the object.

I am developing on a laptop using an NVIDIA GTX 675M.
Are 3D Textures not be supported on these cards? Couldn't find any documentation only

I'll give it a shot on a Quadro in a few minutes.

Thank you,
George

Last edited by shivanangel; 01-25-2013 at 10:33 AM. Reason: Update
Reply With Quote
  #4  
Old 01-25-2013, 10:32 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Can you post the copy/pasted code you are running? Your original code sample was not using viz.addBlankTexture to create the 3D texture and specify the depth dimension.
Reply With Quote
  #5  
Old 01-25-2013, 10:36 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
I am now using your code and I still get the same error.
Only difference is I change the images being used to a different directory.

Code:
import viz
viz.go()

#Create list of 2D images that will make up 3D texture
files = [ 'BodyScans/Test/'+ str(i+1) + '.jpg' for i in range(1,6) ]

#Create blank 3D texture
tex = viz.addBlankTexture([512,512,len(files)],viz.TEX_3D, minFilter=viz.LINEAR_MIPMAP_LINEAR)

#Load each image into 3D texture
for i,f in enumerate(files):
	tex.load(f,i)
	
#Apply texture to quad
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)

#Create slider to change z texture coordinate of quad
slider = viz.addSlider(pos=(0.5,0.1,0))
def SetDepth(pos):
	m = viz.Matrix.translate(0,0,pos)
	quad.texmat(m)
vizact.onslider(slider,SetDepth)


viz.startlayer(viz.QUADS)

#Lower left
viz.texcoord(0,0,0)
viz.vertex(0.4,0.01,0)

#Upper left
viz.texcoord(1,0,0)
viz.vertex(0.4,0.05,0)

#Upper right
viz.texcoord(1,0,1)
viz.vertex(0.6,0.05,0)

#Lower right
viz.texcoord(0,0,1)
viz.vertex(0.6,0.01,0)

otf = viz.endlayer(parent=viz.SCREEN,texture=tex)
Reply With Quote
  #6  
Old 01-25-2013, 10:55 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
What version of Vizard are you using? And to be clear, do you get any errors if you run the original script I posted, without any changes?
Reply With Quote
  #7  
Old 01-25-2013, 10:59 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
I'm running 4.06.0138

I get no errors with your code.
Reply With Quote
  #8  
Old 01-25-2013, 11:08 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Can you run the following script and post the entire output?
Code:
import viz
viz.go()

#Create list of 2D images that will make up 3D texture
files = [ 'BodyScans/Test/'+ str(i+1) + '.jpg' for i in range(1,6) ]

#Create blank 3D texture
tex = viz.addBlankTexture([512,512,len(files)],viz.TEX_3D)
print tex.getSize()

#Load each image into 3D texture
for i,f in enumerate(files):
	tex.load(f,i)
Reply With Quote
  #9  
Old 01-25-2013, 11:13 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
************************************************** ****************************
** Load Time: 1.59 seconds
************************************************** ****************************
** Loading VizardBodyPlanes.py
************************************************** ****************************
[512, 512, 5]
** ERROR: 'BodyScans/Test/3.jpg' cannot be loaded into depth 1 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/4.jpg' cannot be loaded into depth 2 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/5.jpg' cannot be loaded into depth 3 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/6.jpg' cannot be loaded into depth 4 of 3D texture. Valid range is 0-0
** Load Time: 0.15 seconds
Reply With Quote
  #10  
Old 01-25-2013, 11:23 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I believe the issue is that the image dimensions of the files don't match the 3D image dimensions. Are all the files you are loading 512x512?
Reply With Quote
  #11  
Old 01-25-2013, 11:31 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Attached are the image, they all look good to me.
Attached Thumbnails
Click image for larger version

Name:	image.png
Views:	935
Size:	44.4 KB
ID:	562  
Reply With Quote
  #12  
Old 01-25-2013, 01:38 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Question

Sample of the actual images attached.
The errors spits out for every single one of the images when I try to load them.

Thanks,
~George
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	914
Size:	32.3 KB
ID:	568   Click image for larger version

Name:	2.png
Views:	930
Size:	36.6 KB
ID:	569   Click image for larger version

Name:	3.png
Views:	924
Size:	58.1 KB
ID:	570   Click image for larger version

Name:	4.png
Views:	934
Size:	68.5 KB
ID:	571   Click image for larger version

Name:	5.png
Views:	884
Size:	59.1 KB
ID:	572  

Reply With Quote
  #13  
Old 01-25-2013, 02:33 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I just tried your sample images and they loaded fine. They are 100x100 though, but that might just be the forum resizing the images. The error message you are getting should only occur if the image your are loading does not match the 3D image width/height dimension, or if the pixel formats differ.
Reply With Quote
  #14  
Old 01-25-2013, 02:43 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
That is the forum resizing the images.
They all check out to be 512x512 inside Photoshop...
Reply With Quote
  #15  
Old 01-25-2013, 02:53 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
I just tried downloading the forum images and I get back the 512x512 for some reason... However I tried changing the last one to half the size to see what error I get... and it isn't a dimension error I seem to be getting on the other images.
I get a dimension error on the last one:

** ERROR: 'BodyScans/Test/3.png' cannot be loaded into depth 1 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/4.png' cannot be loaded into depth 2 of 3D texture. Valid range is 0-0
** ERROR: 'BodyScans/Test/5.png' cannot be loaded into depth 3 of 3D texture. Valid range is 0-0
** ERROR: Size of 'BodyScans/Test/6.png' (256 x 256) does not match size of 3D image (512 x 512)
Reply With Quote
  #16  
Old 01-25-2013, 03:03 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
OK, I just made some crappy images in Photoshop, all white jpgs with numbers and they appear to work properly.

Seems that something is wrong with the pngs, even though Photoshop and Matlab ( the original producer of the image) doesn't say anything is...

The images appear to be 8 bit on inspection as well.
Reply With Quote
  #17  
Old 01-25-2013, 03:10 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Looks like all the images are grayscale only.
Converting to RGB fixes the problem.

Sorry to run you around on this problem!
Reply With Quote
Reply

Tags
viz.tex_3d

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
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
Avatar texture swaping sleiN13 Vizard 5 06-24-2011 12:48 AM
How to apply shader and render texture to an object whj Vizard 0 04-23-2010 12:23 PM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 12:14 PM
how I can get my texture to appear exactly as is defined mspusch Vizard 1 04-23-2005 12:12 PM


All times are GMT -7. The time now is 06:46 AM.


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