Re: [osg-users] Loading a SilverLining environment map into an OpenSceneGraph texture

2018-02-16 Thread Trajce Nikolov NICK
Hi,

you can get inspiration from the OpenIG project (http://openig.compro.net)
, there is a SilverLining plugin (
https://github.com/CCSI-CSSI/MuseOpenIG/tree/master/Plugin-SilverLining)
with reflections working together with Triton

On Thu, Feb 15, 2018 at 3:51 PM, Chris Hardy  wrote:

> It turns out this is pretty easy, I just made a couple of silly
> uncaffeinated mistakes. In case anyone gets stuck in the same hole, all you
> have to do is create your own TextureObject and assign it to the
> TextureCubeMap.
>
> Perhaps there are some finer details missing in this solution but the
> output on the screen is at least accurate to what I want for the moment.
>
>
> Code:
>
> unsigned int handle;
> void* ptr = 
> atm->GetEnvironmentMap(ptr, 6);
>
> osg::TextureCubeMap* hdrEnvMap = new osg::TextureCubeMap;
> osg::Texture::TextureObject* textureObject = new
> osg::Texture::TextureObject(hdrEnvMap, (GLuint)ptr, GL_TEXTURE_CUBE_MAP);
> hdrEnvMap->setTextureObject(camera->getGraphicsContext()->getState()->getContextID(),
> textureObject);
>
>
>
>
> My reflections are the wrong way around but that's my own problem I
> suppose. :P
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72962#72962
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


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


[osg-users] Loading a SilverLining environment map into an OpenSceneGraph texture

2018-02-14 Thread Chris Hardy
Hi,

Perhaps this is as much a SilverLining question so I've reached out to Frank 
Kane, but I am attempting to use SilverLining’s GetEnvironmentMap to load an 
HDR cube map into an osg::TextureCubeMap for input into an image based lighting 
scheme. I can’t seem to figure out how to do this properly.

I’ve tried something like the following, based on these old forum posts I’ve 
found: 
http://forum.openscenegraph.org/viewtopic.php?t=15277=next 
http://forum.openscenegraph.org/viewtopic.php?t=12966=next 


Code:
osg::TextureCubeMap* hdrEnvMap = new osg::TextureCubeMap;
hdrEnvMap->setTextureSize(width, height);
hdrEnvMap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
hdrEnvMap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
hdrEnvMap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
hdrEnvMap->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
hdrEnvMap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
hdrEnvMap->setInternalFormat(GL_RGB16F);
hdrEnvMap->setSourceFormat(GL_RGB);
hdrEnvMap->setSourceType(GL_FLOAT);

osg::GraphicsContext* graphicsContext = camera->getGraphicsContext();
unsigned int cid = graphicsContext->getState()->getContextID();
osg::Texture::TextureObject* obj = hdrEnvMap->getTextureObject(cid);
obj->setAllocated(true);

unsigned int handle = obj->id();
void* ptr = 
atmosphere->GetEnvironmentMap(ptr, 6);

osg::Texture::TextureObject *textureObject = new 
osg::Texture::TextureObject(hdrEnvMap, handle, GL_TEXTURE_CUBE_MAP);
textureObject->setAllocated();
hdrEnvMap->setTextureObject(cid, textureObject);
osg::State *state = camera->getGraphicsContext()->getState();

state->setActiveTextureUnit(0);
hdrEnvMap->apply(*state);
state->haveAppliedTextureAttribute(0, hdrEnvMap);



The environment map seems like it’s being returned correctly, as 
GetEnvironmentMap returns true, and I call it elsewhere in my codebase to pass 
to Triton for reflections, which also works okay. So I think it’s a matter of 
not knowing how to initialize the cube map object in OSG properly.

Thanks in advance for any insight.

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





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