Re: [osg-users] dynamic cube map

2017-12-19 Thread Rômulo Cerqueira
Hi,

I got the depth data from reflected objects. I needed to render the depth 
buffer to texture. Follows my update code:

C++ code:

Code:

// OSG includes
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

// C++ includes
#include 

#define SHADER_PATH_FRAG "normal_depth_map/shaders/normalDepthMap.frag"
#define SHADER_PATH_VERT "normal_depth_map/shaders/normalDepthMap.vert"

#define BOOST_TEST_MODULE "DynamicCubeMap_test"

using namespace osg;

unsigned int numTextures = 6;

enum TextureUnitTypes {
TEXTURE_UNIT_DIFFUSE,
TEXTURE_UNIT_NORMAL,
TEXTURE_UNIT_CUBEMAP
};

osg::ref_ptr _create_scene() {
osg::ref_ptr scene = new osg::Group;

osg::ref_ptr geode = new osg::Geode;
scene->addChild(geode.get());

const float radius = 0.8f;
const float height = 1.0f;
osg::ref_ptr shape;

// sphere
shape = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(-3.0f, 0.0f, 
0.0f), radius));
shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f));
geode->addDrawable(shape.get());

// box
shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(3.0f, 0.0f, 0.0f), 2 
* radius));
shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f));
geode->addDrawable(shape.get());

// cone
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, 
-3.0f), radius, height));
shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f));
geode->addDrawable(shape.get());

// cylinder
shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, 3.0f), 2* 
radius));
shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f));
geode->addDrawable(shape.get());

return scene;
}

osg::NodePath createReflector() {
Geode* node = new Geode;
const float radius = 0.8f;
ref_ptr hints = new TessellationHints;
hints->setDetailRatio(2.0f);
ShapeDrawable* shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), 
radius * 1.5f), hints.get());
shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f));
node->addDrawable(shape);

osg::NodePath nodeList;
nodeList.push_back(node);

return nodeList;
}

class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
public:

typedef std::vector< osg::ref_ptr >  CameraList;

UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, 
CameraList& Cameras):
_reflectorNodePath(reflectorNodePath),
_Cameras(Cameras)
{
}

virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
// first update subgraph to make sure objects are all moved into 
position
traverse(node,nv);

// compute the position of the center of the reflector subgraph
osg::Matrixd worldToLocal = 
osg::computeWorldToLocal(_reflectorNodePath);
osg::BoundingSphere bs = _reflectorNodePath.back()->getBound();
osg::Vec3 position = bs.center();

typedef std::pair ImageData;
const ImageData id[] =
{
ImageData( osg::Vec3( 1,  0,  0), osg::Vec3( 0, -1,  0) ), // +X
ImageData( osg::Vec3(-1,  0,  0), osg::Vec3( 0, -1,  0) ), // -X
ImageData( osg::Vec3( 0,  1,  0), osg::Vec3( 0,  0,  1) ), // +Y
ImageData( osg::Vec3( 0, -1,  0), osg::Vec3( 0,  0, -1) ), // -Y
ImageData( osg::Vec3( 0,  0,  1), osg::Vec3( 0, -1,  0) ), // +Z
ImageData( osg::Vec3( 0,  0, -1), osg::Vec3( 0, -1,  0) )  // -Z
};

for(unsigned int i = 0; i < 6 && i < _Cameras.size(); ++i) {
osg::Matrix localOffset;

localOffset.makeLookAt(position,position+id[i].first,id[i].second);

osg::Matrix viewMatrix = worldToLocal*localOffset;

_Cameras[i]->setReferenceFrame(osg::Camera::ABSOLUTE_RF);

_Cameras[i]->setProjectionMatrixAsFrustum(-1.0,1.0,-1.0,1.0,1.0,1.0);
_Cameras[i]->setViewMatrix(viewMatrix);
}
}

protected:

virtual ~UpdateCameraAndTexGenCallback() {}

osg::NodePath   _reflectorNodePath;
CameraList  _Cameras;
};

class TexMatCullCallback : public osg::NodeCallback
{
public:

TexMatCullCallback(osg::TexMat* texmat):
_texmat(texmat)
{
}

virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
// first update subgraph to make sure objects are all moved into 
position
traverse(node,nv);

osgUtil::CullVisitor* cv = dynamic_cast(nv);
if (cv)
{
osg::Quat q = 
osg::Matrix::inverse(*cv->getModelViewMatrix()).getRotate();


float yaw2 = asin(-2.0f*(q.x()*q.z() - 
q.w()*q.y()));

Re: [osg-users] Normal Mapping using Dynamic Cubemap

2017-12-19 Thread Rômulo Cerqueira
Hi Sebastian,

can you help me to find an example? I've been looking for this solution for 
almost two months.
... 

Thank you!

Cheers,
Rômulo

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] "INSTALL.vcxproj" -- FAILED

2017-12-19 Thread Robert Osfield
HI Eran et. al,

Thanks for the info.  I don't have Windows expertise so will defer to
members of the community with CMake/Windows expertise to look at this.

Robert.

On 19 December 2017 at 16:09, Eran Cohen  wrote:
> Hi Robert,
>
> I have no Cmake knowledge, so I didn't change the Cmake script, but rather 
> manually changed the project configurations for all of the examples in visual 
> studio. Right click on the project, select properties. Go to Linker -> 
> Debugging and change the Generate Program Database File to 
> $(ProjectDir)$(AssemblyName)d.pdb
>
> The .vcxproj of the osganalysis example now looks like this:
>
>
>>
>> < Link >
>>
>> < AdditionalDependencies 
>> >..\..\lib\osgViewerd.lib;..\..\lib\osgTextd.lib;opengl32.lib;..\..\lib\osgGAd.lib;..\..\lib\osgDBd.lib;C:\Users\ceran\Desktop\OpenSceneGraph-3.4.1\3rdParty\x64\lib\zlibd.lib;..\..\lib\osgUtild.lib;..\..\lib\osgd.lib;..\..\lib\OpenThreadsd.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib<
>>  / AdditionalDependencies  >
>>   < AdditionalLibraryDirectories >%(AdditionalLibraryDirectories)< / 
>> AdditionalLibraryDirectories >
>>   < AdditionalOptions >%(AdditionalOptions) /machine:x64< / 
>> AdditionalOptions >
>>   < GenerateDebugInformation >true< / GenerateDebugInformation >
>>   < IgnoreSpecificDefaultLibraries >%(IgnoreSpecificDefaultLibraries)< / 
>> IgnoreSpecificDefaultLibraries >
>>   < ImportLibrary 
>> >C:/Users/ceran/Desktop/OpenSceneGraph-3.4.1/OpenSceneGraph/build/lib/osganalysisd.lib<
>>  / ImportLibrary >
>>   < ProgramDataBaseFile >(ProjectDir)$(AssemblyName)d.pdb< / 
>> ProgramDataBaseFile >
>>   < SubSystem >Console< / SubSystem >
>>   < Version >
>>   < / Version >
>> < / Link >
>>
>
>
> The line in bold is the line that was changed.
>
> Cheers,
> Eran
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72608#72608
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Trying to understand GraphicsWindow system

2017-12-19 Thread Brett Haines
Hi all,

I'm in the middle of building OSG for Android, but I'm having an issue when 
actually linking the library to another appilication.  If fails to link due to 
an "undefined reference to 'graphicswindow_X11'".  I tracked down why X11 is 
being used to the GraphicsWindow header file:


Code:

#define USE_GRAPICSWINDOW_IMPLEMENTATION(ext) \
 extern "C" void +t(void); \
 static osgViewer::GraphicsWindowFunctionProxy 
graphicswindowproxy_##ext(graphicswindow_##ext);

#if defined(_WIN32)
 #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(Win32)
#elif defined(__APPLE__)
 #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(Carbon)
#else
 #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(X11)
#endif




Since X11 doesn't exist on Android, it seems like there isn't an option there 
that Android can use.  Is there something here that I am missing?

Thank you,
Brett

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Normal Mapping using Dynamic Cubemap

2017-12-19 Thread Sebastian Messerschmidt

Hi Rômulo,

Repeating the question won't magically solve it.

If you're after rendering normals and depth into textures (it doesn't 
matter if you are rendering to cubemap-faces IMHO) then see the multiple 
rendering target (MRT) example. Basically you need to attach a depth and 
normal target to your FBO and in a custom shader write the information 
to it (basically that's the first step in deferred rendering). There are 
some deferred-rendering/shading examples based on OSG around in the web. 
If you're unable to find them, I can help you to retrieve them.


In the resolving pass, you need to bind the textures you've rendered to, 
to get the normals/depths.


Beware that there will be issues concerning filtering (since depth and 
normals cannot be lineary interpolated in every case)



Cheers

Sebastian



Am 19.12.2017 um 03:10 schrieb Rômulo Cerqueira:

Hi,

is it possible to generate dynamic cubemaps (with normal mapping textures)?

...

Thank you!

Cheers,
Rômulo

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] "INSTALL.vcxproj" -- FAILED

2017-12-19 Thread Eran Cohen
Hi Robert,

I have no Cmake knowledge, so I didn't change the Cmake script, but rather 
manually changed the project configurations for all of the examples in visual 
studio. Right click on the project, select properties. Go to Linker -> 
Debugging and change the Generate Program Database File to 
$(ProjectDir)$(AssemblyName)d.pdb

The .vcxproj of the osganalysis example now looks like this:


> 
> < Link >
>   
> < AdditionalDependencies 
> >..\..\lib\osgViewerd.lib;..\..\lib\osgTextd.lib;opengl32.lib;..\..\lib\osgGAd.lib;..\..\lib\osgDBd.lib;C:\Users\ceran\Desktop\OpenSceneGraph-3.4.1\3rdParty\x64\lib\zlibd.lib;..\..\lib\osgUtild.lib;..\..\lib\osgd.lib;..\..\lib\OpenThreadsd.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib<
>  / AdditionalDependencies  >
>   < AdditionalLibraryDirectories >%(AdditionalLibraryDirectories)< / 
> AdditionalLibraryDirectories >
>   < AdditionalOptions >%(AdditionalOptions) /machine:x64< / 
> AdditionalOptions >
>   < GenerateDebugInformation >true< / GenerateDebugInformation >
>   < IgnoreSpecificDefaultLibraries >%(IgnoreSpecificDefaultLibraries)< / 
> IgnoreSpecificDefaultLibraries >
>   < ImportLibrary 
> >C:/Users/ceran/Desktop/OpenSceneGraph-3.4.1/OpenSceneGraph/build/lib/osganalysisd.lib<
>  / ImportLibrary >
>   < ProgramDataBaseFile >(ProjectDir)$(AssemblyName)d.pdb< / 
> ProgramDataBaseFile >
>   < SubSystem >Console< / SubSystem >
>   < Version >
>   < / Version >
> < / Link >
> 


The line in bold is the line that was changed.

Cheers,
Eran

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org