Considering Panda: shaders, video, outdoor


I have a few questions before I decide whether to commit to Panda3D for a project:

  1. I read here about the 3DS egg exporter. Does this exporter also include the models shaders?

  2. Is there a way to display a video texture on the background of the scene (HUD) so that when I navigate around the scene the video is fixed?

  3. I have seen some realistic outdoor screenshots. I would like to position a light source for the sun based on the time of day, so at midday the sun is high in a bright sky and at night the sun is gone and the sky dark. Is there a module that would make this doable?


hi there:

about question1) i’m not a max user so i dont know. propably not. but panda comes with a buildin shader generator for the most common stuff like normalmaps and the likes.

  1. you can display video on any surface you like. including gui-elements. if neccessary you can change the render-order by hand so yes. its well possible.

3)its not like there is a module or anything. using lights (in your case a directional light) is pretty much standart for every engine released in the last 10 years. panda handles it,too. lighting objects from a light-source is as easy as placing a directional light. how you visually represent the sun is up to you. prerenderd skyboxes, 3d-scenes rendered in the background, skydomes, or a combination of all. its up to you. but everything is possible.

rbp, about your third point. I recently wrote some code that does just what you have described - it automatically moves the sun and changes the colour of the sky based on the time of day, and also realistically displays stars in the sky at night, based on your exact global coords (like crysis). This only took me one or two afternoons to write - so yes, it is easily possible using panda3d.

thomas, could you elaborate at all on your response to 2? That’s something I’m trying to do as well, so I was planning to start playing around with putting video in my 3D scene. In another thread that you started, you indicated that openCV was the way to go for that; is that how I should be proceeding, by looking into openCV?

You load movies as textures using a MovieTexture which loads similarly to regular textures. Check the media player sample for a reference implementation. That thread about OpenCV looks like its more relevant to getting the webcam output although it might also apply to getting video into panda from sources outside of video files.

thanks for the info Thomas.
The video solution sounds good.
I didn’t have high hope about the shaders. Just I read that the OSG model format in the OpenSceneGraph community supports GLSL, but their 3DS exporter is not that good.

aurilliance: that’s helpful to know it took you just 2 afternoons, because I wasn’t planning to place GPS based star locations.

jhocking: Regarding OpenCV, it’s a great library for image processing but I found the webcam feed really poor quality, like 300x200 pixels when my webcam supports far better. If you’re after a high resolution camera feed I would invest time elsewhere. Unfortunately I can’t recommend an alternative because I’m still looking.
Do you happen to know of another good webcam interface library (ideally cross platform)?


Thanks for the info about OpenCV, I’ll see if it looks crummy when I test it out. Also other threads I’ve seen indicate one other approach to getting a webcam showing in Panda so I’ll try that too:

oh wow, there is a WebcamVideo class!

Yes, but it only works on windows. And in the current 1.5.4, I believe it’s also broken.

do you know what library it wraps? DirectShow?

aw man it’s Windows only?

Well here are a couple cross-platform libraries, maybe one of these could be used with Panda?

More generally, those were among the first few results when I googled “cross platform webcam library” so I’ll bet there are more if I did a little more digging.

opencv already is crossplatform.
please note that using webcam input as texture is not exactly the same as using a video file.
if you just want to use a videofile then panda relies on differnt libraries to play them. afaik ffmpeg
in this case the opencv stuff is not what you’r looking for.
opencv textures are of intrest when you want to display webcam-video. and when you use ARtoolkit on it.

aside from the recent fixes for opencv/artookit noone ever touched the webcam support for years. and when it was introduced it was windows-only. some code was prepared for linux ,too but those are just stubs which dont do anything.
however. using opencv should work with the current cvs and upcomming version of panda, on windows aswell as linux (dunno about mac but i guess it should work too)

about the resolution. this might be less a problem of opencv itself rather than requesting the right resolution. 320x240 is supported by pretty much every webcam. so it simply might be a default value which is used. guess this needs more investigation. have you tried the panda-cvs version? cause my webcam’s stream is 640x480 already (native resolution is 1600x1200 which is ways too much anyway)

btw last thing panda needs is YET another webcam input library. we already have like 3 libraries or so which are theoretically capable of getting it. in best case we need to fix up one, openCV would be the one in question since it’s basically working already.

Yes, exactly.

Apparently the limited resolution with OpenCV webcam streaming is a known problem. By default it only provides a feed of 320x240 but can be hacked to 640x480.

ARToolkit has a class ARVideo for webcam feed - is that included in Panda3D?

Nope, for the reason that I didn’t think anyone would need yet another webcam class.
I could integrate it, if many people are interested, but that would be after 1.6.0 is released.

thomas is right, the priority ought to be fixing up what we already have, not integrating a new library. I haven’t read rbp’s link yet, but can we use that hack with Panda?

Hmm. Normally, we try hard not to edit the thirdparty packages themselves, because it will be an even bigger pain to upgrade. In this particular case, maybe we can make an exception to that rule.