[osg-users] How to implement a Laser Simulation?

David Heitbrink david-heitbrink at uiowa.edu
Wed May 29 15:09:23 PDT 2019


I did a similar project with adaptive headlamps a couple years ago.

The way I would do this is to think about this as sort of a spot light with a projector slide. So we can also think about this also a spot light with a shadow. 

So what I did was to setup a "slide" scene in which I would render the shape of what I wanted projected. So in your case you can setup a pre-render camera with like a 512x512 with the clear color set to black. You can then just render a single green line. You can do what - ever with this line, or do the laser light show thing and do a smiley face - whatever.

Then I would setup a camera do be your sort of laser light head, so you can add another camera in your scene for this. With this second pre-render camera we can do a depth pass. So with this you aim your depth camera at where you want to aim your laser. With this pre-render camera, you basically attach your normal scene, then only output the depth.
 
Now once you do your main rendering pass, you pass in the model-view matrix from the depth camera into your shader and you treat this like you would doing a shadow for a spot light, there are lots of tutorials on how to do this. But what you also do is once you have your shadow coordinate, you use this to do a texture lookup with your slide scene. 

So then you treat the shadow camera just like say a normal spot light shadow, except you  instead of just treating the light like a normal spot like, you take the same shadow coordinate, and lookup your slide scene for the light color. 

I published a paper on this for the Image Society a couple of years ago.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76152#76152







More information about the osg-users mailing list