[osg-users] Render normal vectors to image

Han Hu huhan8807 at gmail.com
Mon Nov 11 00:43:15 PST 2019


Hi,

I would like to do offscreen rendering of a mesh.
Currently, I have suceeded to do this for both the color (RGB) and depth data using the built-in functions as below.

 
Code:


	osg::ref_ptr<osg::Image> rttImage = new osg::Image;
	osg::ref_ptr<osg::Image> depthImage = new osg::Image;
	
camera->attach(osg::Camera::COLOR_BUFFER, rttImage.get());
	camera->attach(osg::Camera::DEPTH_BUFFER, depthImage.get());

	rttImage->allocateImage(ATInfo.width, ATInfo.height, 1, GL_RGB, GL_UNSIGNED_BYTE);
	depthImage->allocateImage(ATInfo.width, ATInfo.height, 1, GL_DEPTH_COMPONENT, GL_FLOAT);




But I also need to render the normal vectors to images too. I have googled this topic using native opengl, it seems that I have to write shaders for it. But my mesh are defined using the osgb plugin format, so I must implement in the osg.

I would like to know, is there an approach to do this in osg? Thanks!

Thank you!

Cheers,
Han

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







More information about the osg-users mailing list