WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-29-2008, 06:14 AM
theuberk theuberk is offline
Member
 
Join Date: Jul 2007
Posts: 44
multiple shadows using projector

I'm trying to create multiple shadows using the projector module. It seems however that only one projected can exist at one time. For example, the following code only produces one shadow (proj2):

Code:
enviro = viz.add('C:\\Program Files\\WorldViz\\Vizard30\\resources\\tut_ground.wrl')
image1 = viz.add('cars\\carShadow.png')
image2 = viz.add('cars\\carShadow2.png')
proj1 = projector.add(image1)
proj1.translate(0,0,0)
proj1.rotate(0,90,0)
proj1.affect(enviro)
proj1.ortho(2,2)
proj2 = projector.add(image2)
proj2.translate(6,0,0)
proj2.rotate(0,90,0)
proj2.affect(enviro)
proj2.ortho(2,2)
Any help would be greatly appreciated.

Last edited by theuberk; 01-29-2008 at 06:20 AM.
Reply With Quote
  #2  
Old 01-29-2008, 07:36 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You need to apply the second projection texture to a different texture unit. Try the following code:
Code:
import viz
import projector

viz.go()

enviro = viz.add('tut_ground.wrl')
image1 = viz.add('eyeshadow.jpg')
image2 = viz.add('eyeshadow.jpg')

proj1 = projector.add(image1)
proj1.translate(1,0,10)
proj1.rotate(0,90,0)
proj1.affect(enviro) #Apply projection texture to default texture unit 1
proj1.ortho(2,2)

proj2 = projector.add(image2)
proj2.translate(-1,0,10)
proj2.rotate(0,90,0)
proj2.affect(enviro,2) #Apply projection texture to texture unit 2
proj2.ortho(2,2)
Reply With Quote
  #3  
Old 01-30-2008, 08:02 AM
theuberk theuberk is offline
Member
 
Join Date: Jul 2007
Posts: 44
Perfect thanks! I didn't see anything about texture units in the documentation.
Reply With Quote
  #4  
Old 01-30-2008, 08:13 AM
theuberk theuberk is offline
Member
 
Join Date: Jul 2007
Posts: 44
I tried that out but it only seems to work for up to 3 shadows. I need it to work for up to 20 or so. Is this possible?
Reply With Quote
  #5  
Old 01-30-2008, 09:28 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The limit depends on your graphics cards. Some graphics cards support only 4 texture units. Some newer cards can support up to 16.
Reply With Quote
  #6  
Old 01-31-2008, 08:24 AM
theuberk theuberk is offline
Member
 
Join Date: Jul 2007
Posts: 44
I checked the specs on the graphics cards I'm using (2 x 8800GTS - 512MB in SLI), and numerous sources say that there are 64 texture mapping units on these cards. After reading THIS FORUM THREAD, I'm suspecting it may be an OpenGL problem, however I'm not sure at all. Any ideas what the problem might be?
Reply With Quote
  #7  
Old 02-01-2008, 10:29 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I believe OpenGL has a limit of 4 texture units when using the fixed function pipeline, which is what the projector plugin uses. To use more texture units you would have to use shaders for projecting the texture onto a model. There is a description about it on nVidias website.
Reply With Quote
  #8  
Old 02-05-2008, 01:44 PM
theuberk theuberk is offline
Member
 
Join Date: Jul 2007
Posts: 44
Is there a better way than the projector plugin to implement shadows in vizard?
Reply With Quote
  #9  
Old 02-06-2008, 07:19 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Click here for a post that contains an example of dynamic projected shadows. It works reasonably well as long as the shadow casting objects are contained in a small area.
Reply With Quote
  #10  
Old 01-30-2009, 07:08 AM
omidbrb omidbrb is offline
Member
 
Join Date: Dec 2008
Posts: 27
Quote:
Originally Posted by farshizzo View Post
I believe OpenGL has a limit of 4 texture units when using the fixed function pipeline, which is what the projector plugin uses. To use more texture units you would have to use shaders for projecting the texture onto a model.
I used the example provided in this thread, but with multiple avatars. Still only 3 avatars have shadows. Is there any demo that is not relying on the projector plugin?

Thanks,
Omid
Reply With Quote
  #11  
Old 02-05-2009, 01:41 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
When you used the shadow module were all your avatars contained within the area defined by your SHADOW_AREA value. You can increase that value but then the resolution of the shadows will not be as sharp. You can then also increase the resolution of the shadows but that will use up more texture memory.
Reply With Quote
  #12  
Old 02-06-2009, 02:08 AM
omidbrb omidbrb is offline
Member
 
Join Date: Dec 2008
Posts: 27
But one should make a seperate Shadow.ShadowProjector objects for each avatar. Hence, as I get, SHADOW_AREA is not the area that all the shadows should be contained in, rather it represents a box that each shadow should fit in. Please correct me if I'm wrong.

I suspect that because ShadowProjector is using the projector module in wizard and the projector module is limited by OpenGL's limit of 4 textures on a surface, only 3 avatar shadow textures + the surface's own texture is being applied.

Do you know of any alternatives?

Best,
Omid
Reply With Quote
  #13  
Old 02-06-2009, 09:41 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Here's a few more avatars added to the shadow example. SHADOW_AREA is set to 10,10 and SHADOW_RES is set to 512 to maintain sharp shadows. Are you able to get 5 shadows here?

Code:
import viz
viz.go()

#Add ground model
ground = viz.add('tut_ground.wrl')

#Add avatars
avatar = viz.add('vcc_female.cfg',pos=(-4,0,12),euler=(180,0,0))
avatar2 = viz.add('duck.cfg',pos=(-2,0,12),euler=(180,0,0))
avatar3 = viz.add('vcc_male.cfg',pos=(0,0,12),euler=(180,0,0))
avatar4 = viz.add('male.cfg',pos=(2,0,12),euler=(180,0,0))
avatar5 = viz.add('female.cfg',pos=(4,0,12),euler=(180,0,0))

avatar.state(5)
avatar2.state(1)
avatar3.state(7)
avatar4.state(9)
avatar5.state(5)


#Shadow resolution (power of two)
#Higher values mean sharper shadows, but take more texture memory
SHADOW_RES = 512

#Postion of shadow projector
SHADOW_POS = [0,10,12]

#Controls size of orthographic shadow projector
#Large values mean larger area is covered, but resolution will be diluted
SHADOW_AREA = [10,10]

#Create shadow projector
import Shadow
shadow = Shadow.ShadowProjector(size=SHADOW_RES,pos=SHADOW_POS,area=SHADOW_AREA)

#Add avatar as a shadow caster
shadow.addCaster(avatar)
shadow.addCaster(avatar2)
shadow.addCaster(avatar3)
shadow.addCaster(avatar4)
shadow.addCaster(avatar5)

#Add ground as shadow receiver
shadow.addReceiver(ground)
Reply With Quote
  #14  
Old 02-24-2009, 02:56 AM
omidbrb omidbrb is offline
Member
 
Join Date: Dec 2008
Posts: 27
Yes it worked. Thanks. My misunderstanding was that I thought SHADOW_POS and SHADOW_AREA refers to the shadow itslef.
Reply With Quote
Reply

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
Shadows in Vizard Vinicius Lima Vizard 4 07-26-2010 05:56 PM
3d projector Vinicius Lima Vizard 21 03-05-2008 03:51 PM
Multiple labs Plymouth Vizard 1 03-05-2007 09:43 AM
Multiple Stages in one Program Amit Vizard 7 11-11-2005 10:20 AM
multiple timer trouble exhale Vizard 2 04-26-2005 12:21 AM


All times are GMT -7. The time now is 04:21 AM.


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