Re: [osg-users] Untextured materials = pure black

2008-11-03 Thread Jefferson Pinheiro
Yes, that solved the problem. Many thanks, you both!

I'm posting the code, for reference.

osg::ref_ptr stateSet(root->getOrCreateStateSet());
osg::Image* image = new osg::Image;
// allocate the image data, noPixels x 1 x 1 with 4 rgba floats -
equivilant to a Vec4!
int noPixels = 1;
image->allocateImage(noPixels,1,1,GL_RGBA,GL_FLOAT);
image->setInternalTextureFormat(GL_RGBA);
// fill in the image data.
osg::Vec4* dataPtr = (osg::Vec4*)image->data();
osg::Vec4 color(1,1,1,1);
*dataPtr = color;
// make fake texture
osg::Texture2D* fakeTex = new osg::Texture2D;
fakeTex->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_EDGE);
fakeTex->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_EDGE);
fakeTex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
fakeTex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
fakeTex->setImage(image);
// add fake texture
stateSet->setTextureAttribute(0,fakeTex,osg::StateAttribute::ON);
stateSet->setTextureMode(0,GL_TEXTURE_1D,osg::StateAttribute::OFF);
stateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
stateSet->setTextureMode(0,GL_TEXTURE_3D,osg::StateAttribute::OFF);


2008/11/3 Jean-Sébastien Guay <[EMAIL PROTECTED]>

> Hello Jefferson,
>
>  Can you tell me, please, how to set a default texture for the root?
>>
>
> See src/osgShadow/ShadowMap.cpp around line 290, which starts with this
> comment:
>
>// fake texture for baseTexture, add a fake texture
>// we support by default at least one texture layer
>// without this fake texture we can not support
>// textured and not textured scene
>
> You can set this 1x1 white texture at the root of your graph, and if any
> node has a different texture on unit 0 it will override it automatically.
>
> Hope this helps,
>
>
> J-S
> --
> __
> Jean-Sebastien Guay[EMAIL PROTECTED]
>   http://www.cm-labs.com/
>http://whitestar02.webhop.org/
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jefferson Pinheiro
(51) 9192 3535
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Untextured materials = pure black

2008-11-03 Thread Jean-Sébastien Guay

Hello Jefferson,


Can you tell me, please, how to set a default texture for the root?


See src/osgShadow/ShadowMap.cpp around line 290, which starts with this 
comment:


// fake texture for baseTexture, add a fake texture
// we support by default at least one texture layer
// without this fake texture we can not support
// textured and not textured scene

You can set this 1x1 white texture at the root of your graph, and if any 
node has a different texture on unit 0 it will override it automatically.


Hope this helps,

J-S
--
__
Jean-Sebastien Guay[EMAIL PROTECTED]
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Untextured materials = pure black

2008-11-03 Thread Jefferson Pinheiro
Can you tell me, please, how to set a default texture for the root?

2008/11/2 Jean-Sébastien Guay <[EMAIL PROTECTED]>

> Hi Jefferson,
>
> Just to add to what Terry said:
>
>  b) set a simple default texture (for example, a 1x1 white texture) on
>> the root node of your scene.
>>
>
> This is what ShadowMap does (and the new ViewDependentShadow too) which is
> why you don't have that problem when using ShadowMap. SoftShadowMap could be
> modified to do it too, but hasn't yet, which probably just means not too
> many people use it.
>
> J-S
> --
> __
> Jean-Sebastien Guay[EMAIL PROTECTED]
>   http://www.cm-labs.com/
>http://whitestar02.webhop.org/
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jefferson Pinheiro
(51) 9192 3535
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Untextured materials = pure black

2008-11-01 Thread Jean-Sébastien Guay

Hi Jefferson,

Just to add to what Terry said:


b) set a simple default texture (for example, a 1x1 white texture) on
the root node of your scene.


This is what ShadowMap does (and the new ViewDependentShadow too) which 
is why you don't have that problem when using ShadowMap. SoftShadowMap 
could be modified to do it too, but hasn't yet, which probably just 
means not too many people use it.


J-S
--
__
Jean-Sebastien Guay[EMAIL PROTECTED]
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Untextured materials = pure black

2008-11-01 Thread Terry Welsh
Hi Jefferson,
When using a shader that expects a texture, you must supply a texture
or the result is undefined.  I think with most graphics cards the
texture read just results in black.  So if you want to have models
that don't have a specific texture you should:
a) use another shader that doesn't do a texture read, or
b) set a simple default texture (for example, a 1x1 white texture) on
the root node of your scene.

- Terry

> Message: 4
> Date: Fri, 31 Oct 2008 23:30:23 -0300
> From: "Jefferson Pinheiro" <[EMAIL PROTECTED]>
> Subject: [osg-users] Untextured materials = pure black
> To: osg-users@lists.openscenegraph.org
> Message-ID:
><[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Every material that has no texture associated becomes completely black when
> I do one of the following:
>
> - change the shadow technique from ShadowMap to SoftShadowMap
> - add any of the GLSL bloom shader I found on the net (
> http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=27976&postdays=0&postorder=asc&start=0or
> http://www.gamedev.net/community/forums/topic.asp?topic_id=395186)
>
> Any idea why this is happening?
>
> Details:
>
> I have a single light, declared thusly:
>
>osg::Vec3 lightPosition(4,4,8); // my prog's scale is big
>osg::LightSource* ls = new osg::LightSource;
>ls->getLight()->setPosition(osg::Vec4(lightPosition,1));
>ls->getLight()->setAmbient(osg::Vec4(0.5,0.5,0.5,1.0));
>ls->getLight()->setDiffuse(osg::Vec4(0.9,0.9,0.9,1.0));
>shadowedScene->addChild(ls);
>
> I'm posting direct links to the shaders, case you're lazy to open those ones
> :)
>
> http://magiadosdoces.com/temp/PP_GL_Bloom1.fx
> http://magiadosdoces.com/temp/PP_GL_Bloom2.fx
> http://magiadosdoces.com/temp/PP_GL_Bloom3.fx
> http://magiadosdoces.com/temp/PP_GL_Bloom4.fx
> http://magiadosdoces.com/temp/shader.frag
>
> And this is how I'm loading the shaders:
>osg::ref_ptr stateSet(root->getOrCreateStateSet());
>osg::Program* program = new osg::Program;
>osg::Shader* frag = new osg::Shader( osg::Shader::FRAGMENT );
>frag->loadShaderSourceFromFile("Shaders/shader.frag");
>program->addShader(frag);
>stateSet.get()->setAttributeAndModes(program, osg::StateAttribute::ON);
>
> I'm using OSG 2.6, Windows Vista 64, Geforce 8800M GTS.
>
> Oh and by the way, the bloom shader effect doesn't works even on the
> textured surfaces. They simply remain the same. Image:
> http://magiadosdoces.com/temp/car.jpg
>
> Thanks,
> Jefferson
> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20081031/e7d8b42c/attachment-0001.htm>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Untextured materials = pure black

2008-10-31 Thread Jefferson Pinheiro
Every material that has no texture associated becomes completely black when
I do one of the following:

- change the shadow technique from ShadowMap to SoftShadowMap
- add any of the GLSL bloom shader I found on the net (
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=27976&postdays=0&postorder=asc&start=0or
http://www.gamedev.net/community/forums/topic.asp?topic_id=395186)

Any idea why this is happening?

Details:

I have a single light, declared thusly:

osg::Vec3 lightPosition(4,4,8); // my prog's scale is big
osg::LightSource* ls = new osg::LightSource;
ls->getLight()->setPosition(osg::Vec4(lightPosition,1));
ls->getLight()->setAmbient(osg::Vec4(0.5,0.5,0.5,1.0));
ls->getLight()->setDiffuse(osg::Vec4(0.9,0.9,0.9,1.0));
shadowedScene->addChild(ls);

I'm posting direct links to the shaders, case you're lazy to open those ones
:)

http://magiadosdoces.com/temp/PP_GL_Bloom1.fx
http://magiadosdoces.com/temp/PP_GL_Bloom2.fx
http://magiadosdoces.com/temp/PP_GL_Bloom3.fx
http://magiadosdoces.com/temp/PP_GL_Bloom4.fx
http://magiadosdoces.com/temp/shader.frag

And this is how I'm loading the shaders:
osg::ref_ptr stateSet(root->getOrCreateStateSet());
osg::Program* program = new osg::Program;
osg::Shader* frag = new osg::Shader( osg::Shader::FRAGMENT );
frag->loadShaderSourceFromFile("Shaders/shader.frag");
program->addShader(frag);
stateSet.get()->setAttributeAndModes(program, osg::StateAttribute::ON);

I'm using OSG 2.6, Windows Vista 64, Geforce 8800M GTS.

Oh and by the way, the bloom shader effect doesn't works even on the
textured surfaces. They simply remain the same. Image:
http://magiadosdoces.com/temp/car.jpg

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