Hi Ümit,

When you need some hints about what I already did, then just ask me! And if you 
need big portions of code, just go ahead (I saw your project is GPL, right?).

About osgAudio, I'm terrobly sorry, but if I'm alone I won't be the one that 
will design and code osgAudio. I really need that EVERYONE that want to see 
osgAudio work together. If you want I can give you hints on haow to include the 
existing osgAL to your project, but not much more.

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/


Le Fri, 28 Nov 2008 08:15:41 +0100, Ümit Uzun <[EMAIL PROTECTED]> a écrit:

> Hi Sukender,
>
>>>- Use an image sequence of normal maps, that has the advantage of being 
>>>almost the same code as for >>a non animated bump.
>>>- Or look at (procedural) shaders, that will have the advantage of not 
>>>taking memory for textures, even if >>you want a very smooth animation.
>
> Actually I will mix of two, I create one normal map from wave texture and
> then animate on the water surface by changing texture coordinates so it can
> be seen moving and waving water surface.
>
> I will try as soon as possible but now I will look at OpenAL for couple of
> weeks :) I need sounds as you. I think you use osgAL on your project but I
> will try to use OpenAL till the osgAudio is released. I am waiting 2.10
> release with hoping osgAudio nodekit :)
>
>>>Just for curiosity: what are you working on?
> I am trying to create submarine simulator but I am naive on this topic :) I
> am learning GLSL and OpenGL. For now I want to create water simuation as you
> can see from http://dangerdeep.sourceforge.net/ But it is too hard for me at
> the present.
>
> Best Regards.
>
> 2008/11/27 Sukender <[EMAIL PROTECTED]>
>
>> Hi Ümit,
>>
>> Considering you want to *animate* your bump/normal map, you may:
>> - Use an image sequence of normal maps, that has the advantage of being
>> almost the same code as for a non animated bump.
>> - Or look at (procedural) shaders, that will have the advantage of not
>> taking memory for textures, even if you want a very smooth animation.
>>
>> I just can't help you for shaders because I don't know anything about them.
>> Try searching the web.
>>
>> For non animated bumps, well maybe many wrote examples or code using it but
>> I can't indicate you where.
>> For my part, I used a bump for the loading screen of a tiny game: the bump
>> is loaded from a gray-scale, then converted to a normal map using my
>> function, applied to a quad, and then modulated by the color texture. The
>> light source then moves during the loading process. The code can be found at
>>
>> http://paratrooper.svn.sourceforge.net/viewvc/paratrooper/trunk/Src/App.cpp?view=markup(search
>>  for "TexEnvCombine::DOT3_RGB" and you'll find a block of code about
>> the "logo"). Code is GPL, but as long as you just take a few lines, there's
>> no problem for me using it the way you want.
>> Once it works for you, you'll be able to replace the texture by an image
>> sequence.
>>
>> However, you should try to have a look to shaders. If you find or acheive
>> to write a nice animation, please tell me!
>>
>> Hope it helps.
>>
>> Just for curiosity: what are you working on?
>>
>> Sukender
>> PVLE - Lightweight cross-platform game engine -
>> http://pvle.sourceforge.net/
>>
>>
>> Le Thu, 27 Nov 2008 08:27:53 +0100, Ümit Uzun <[EMAIL PROTECTED]> a
>> écrit:
>>
>> > Hi Sukender,
>> >
>> > Thanks for reply. Sorry I can't express my expected result because of my
>> > english :P Yes you understood me albeit my bad express. I have RGB
>> texture
>> > and want to create bump map animated surface to make more realistic
>> surface.
>> > I find normal map usage only osgVolume.cpp sample. If you know more
>> sample,
>> > please let me know.
>> >
>> > Thanks for helps.
>> > Best Regards.
>> >
>> > 2008/11/27 Sukender <[EMAIL PROTECTED]>
>> >
>> >> Hi Ümit,
>> >>
>> >> Err... I'm terribly sorry but I did not understood all of what you
>> wrote...
>> >> (maybe my english?)
>> >>
>> >> What do you call "Ocean wave texture"? Is that simply the RGB texture
>> >> describing the color of your ocean's surface? If so, then the color of
>> the
>> >> texture is rarely related to bump/normal mapping. You'll have to create
>> from
>> >> scratch (or find) a bump/normal map. You can try using a picture edition
>> >> software (such as "the Gimp") and use filters or generators to create a
>> >> gray-scaled image (where white=high and black=low). This is what I often
>> do
>> >> when I don't need to bee 100% realistic: that's just a nice bump map.
>> >>
>> >> I know you can create normal mapping for low polys from hi polys, but
>> >> that's not the goal of the function I told you. createNormalMap() only
>> >> converts a gray-scaled image to a normal map (texture that is blueish).
>> The
>> >> normal map can be then used more easily in OSG/OpenGL, using
>> >> TexEnvCombine::DOT3_RGB. If you need examples, you can look at the OSG
>> >> samples (I guess there is a normal map somewhere), or ask me.
>> >>
>> >> Note that using Google, I easily found some bump maps examples:
>> >> http://www.filterforge.com/filters/216-bump.jpg
>> >> http://www.m3corp.com/a/download/3d_textures/bump/instantcarpet.jpg
>> >>
>> >> I just hope this answers your questions.
>> >>
>> >> Sukender
>> >> PVLE - Lightweight cross-platform game engine -
>> >> http://pvle.sourceforge.net/
>> >>
>> >>
>> >> Le Wed, 26 Nov 2008 16:01:29 +0100, Ümit Uzun <[EMAIL PROTECTED]> a
>> >> écrit:
>> >>
>> >> > Hi Sukender,
>> >> >
>> >> > I have searched about Normal Map and I see that to create normal map
>> we
>> >> need
>> >> > 2 models( high detailed polygon and low detailed polygon ) and then we
>> >> can
>> >> > create normal map using ray casting to find high detailed models
>> normals
>> >> at
>> >> > intersected areas and then save this normal as a texture which name is
>> >> > NormalMap.
>> >> >
>> >> > But my question is, I want to create NormalMap the ocean waves. But I
>> >> > haven't any models. Can I use Ocean wave texture to create
>> bumpmapping? I
>> >> > mean Can I create NormalMap from related wave texture?
>> >> >
>> >> > If I send the my oceanwave texture to the createNormalMap function,
>> then
>> >> I
>> >> > think. take back bluish normal map Sukender?
>> >> >
>> >> > 2008/11/26 Sukender <[EMAIL PROTECTED]>
>> >> >
>> >> >> This is not related to GLSL, but if someone needs it, I quickly wrote
>> a
>> >> >> function that transforms a gray-scale bump map into a normal map:
>> >> >>
>> http://pvle.sourceforge.net/Doc/Html/Utility3D_8cpp-source.html#l00115
>> >> >> Hope this may be useful to someone, even if the function is not that
>> >> clean.
>> >> >>
>> >> >> Sukender
>> >> >> PVLE - Lightweight cross-platform game engine -
>> >> >> http://pvle.sourceforge.net/
>> >> >>
>> >> >>
>> >> >> Le Wed, 26 Nov 2008 13:29:33 +0100, Morné Pistorius <
>> >> >> [EMAIL PROTECTED]> a écrit:
>> >> >>
>> >> >> > Thanks,
>> >> >> > I managed to implement a standard bump mapping shader in OSG.
>>  Below
>> >> is a
>> >> >> > code snippet that does it if it might help someone else.  Shaders
>> are
>> >> >> > attached.
>> >> >> >
>> >> >> > Cheers,
>> >> >> > Morne
>> >> >> >
>> >> >> > osg::Node * VOSGFloorGrid::CreateBumpMappedFloor()
>> >> >> > {
>> >> >> >   const int BASE_TEX_UNIT = 0;
>> >> >> >   const int BUMP_TEX_UNIT = 1;
>> >> >> >   const int TANGENT_ATR_UNIT = 6;
>> >> >> >   const int BINORMAL_ATR_UNIT = 7;
>> >> >> >
>> >> >> >   osg::Geode* geode = new osg::Geode;
>> >> >> >
>> >> >> >   // set up the Geometry.
>> >> >> >   osg::Geometry* geom = new osg::Geometry;
>> >> >> >
>> >> >> >   osg::Vec3 width, depth, topleft;
>> >> >> >   topleft = osg::Vec3( -Size/2.0, -Size/2.0, 0.0 );
>> >> >> >   width = osg::Vec3( Size, 0.0, 0.0 );
>> >> >> >   depth = osg::Vec3( 0.0, Size, 0.0 );
>> >> >> >
>> >> >> >   osg::Vec3Array* coords = new osg::Vec3Array(4);
>> >> >> >   (*coords)[0] = topleft;
>> >> >> >   (*coords)[1] = topleft+width;
>> >> >> >   (*coords)[2] = topleft+width+depth;
>> >> >> >   (*coords)[3] = topleft+depth;
>> >> >> >
>> >> >> >   geom->setVertexArray(coords);
>> >> >> >
>> >> >> >   osg::Vec3Array* norms = new osg::Vec3Array(1);
>> >> >> >   (*norms)[0] = osg::Vec3( 0.0, 1.0, 0.0 );
>> >> >> >
>> >> >> >   geom->setNormalArray(norms);
>> >> >> >   geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
>> >> >> >
>> >> >> >   osg::Vec4Array* color = new osg::Vec4Array(1);
>> >> >> >   (*color)[0] = osg::Vec4(1.0f,1.0f,1.0f,1.0f);
>> >> >> >
>> >> >> >   geom->setColorArray( color );
>> >> >> >   geom->setColorBinding( osg::Geometry::BIND_OVERALL );
>> >> >> >
>> >> >> >   osg::Vec2Array* tcoords = new osg::Vec2Array(4);
>> >> >> >   float n = 5.0f;  // no of times the texture is repeated
>> >> >> >   (*tcoords)[0].set( 0.0f, 0.0f );
>> >> >> >   (*tcoords)[1].set( n, 0.0f );
>> >> >> >   (*tcoords)[2].set( n, n );
>> >> >> >   (*tcoords)[3].set( 0.0f, n );
>> >> >> >   geom->setTexCoordArray( BASE_TEX_UNIT, tcoords );
>> >> >> >   geom->setTexCoordArray( BUMP_TEX_UNIT, tcoords );
>> >> >> >
>> >> >> >   geom->addPrimitiveSet( new osg::DrawArrays(
>> >> osg::PrimitiveSet::QUADS, 0
>> >> >> ,
>> >> >> > coords->size() ) );
>> >> >> >   geode->addDrawable( geom );
>> >> >> >
>> >> >> >   // Compute smoothed normals
>> >> >> >   osgUtil::SmoothingVisitor smoother;
>> >> >> >   smoother.apply( *geode );
>> >> >> >
>> >> >> >   // model texture
>> >> >> >   osg::Texture2D * diffuse = new osg::Texture2D;
>> >> >> >   diffuse->setImage( osgDB::readImageFile( m_sSystemPath +
>> >> >> > "/Resources/Floor.tga" ) );
>> >> >> >   diffuse->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT
>> );
>> >> >> >   diffuse->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT
>> );
>> >> >> >   diffuse->setResizeNonPowerOfTwoHint( false );
>> >> >> >   diffuse->setMaxAnisotropy( 8.0f );
>> >> >> >
>> >> >> >   // bump map texture
>> >> >> >   osg::Texture2D * normal = new osg::Texture2D;
>> >> >> >   normal->setImage( osgDB::readImageFile( m_sSystemPath +
>> >> >> > "/Resources/FloorNormalMap.tga" ) );
>> >> >> >   normal->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT
>> );
>> >> >> >   normal->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT
>> );
>> >> >> >   normal->setResizeNonPowerOfTwoHint( false );
>> >> >> >   normal->setMaxAnisotropy( 8.0f );
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >>
>> //////////////////////////////////////////////////////////////////////////
>> >> >> >   // Set up bump mapping shaders
>> >> >> >
>> >> >> >   // Load and compile shader source
>> >> >> >   osg::Program * bump = new osg::Program;
>> >> >> >   osg::Shader * bumpVertexShader = new osg::Shader(
>> >> osg::Shader::VERTEX
>> >> >> );
>> >> >> >   osg::Shader * bumpPixelShader  = new osg::Shader(
>> >> osg::Shader::FRAGMENT
>> >> >> );
>> >> >> >   bumpVertexShader->loadShaderSourceFromFile( m_sSystemPath +
>> >> >> > "/Resources/bumpmap.vert" );
>> >> >> >   bumpPixelShader->loadShaderSourceFromFile( m_sSystemPath +
>> >> >> > "/Resources/bumpmap.frag" );
>> >> >> >   bump->addShader( bumpVertexShader );
>> >> >> >   bump->addShader( bumpPixelShader );
>> >> >> >
>> >> >> >   // Set up the shader stateset
>> >> >> >   osg::StateSet * stateset = geode->getOrCreateStateSet();
>> >> >> >   stateset->setTextureAttribute( BASE_TEX_UNIT, diffuse );
>> >> >> >   stateset->setTextureAttribute( BUMP_TEX_UNIT, normal );
>> >> >> >   stateset->setAttributeAndModes( bump, osg::StateAttribute::ON );
>> >> >> >
>> >> >> >   // Compute tangent space for geometry
>> >> >> >   osg::ref_ptr< osgUtil::TangentSpaceGenerator > tsg = new
>> >> >> > osgUtil::TangentSpaceGenerator;
>> >> >> >   tsg->generate( geom, BUMP_TEX_UNIT );
>> >> >> >   geom->setVertexAttribData( TANGENT_ATR_UNIT,
>> >> osg::Geometry::ArrayData(
>> >> >> > tsg->getTangentArray(), osg::Geometry::BIND_PER_VERTEX, GL_FALSE )
>> );
>> >> >> >   geom->setVertexAttribData( BINORMAL_ATR_UNIT,
>> >> osg::Geometry::ArrayData(
>> >> >> > tsg->getBinormalArray(), osg::Geometry::BIND_PER_VERTEX, GL_FALSE )
>> );
>> >> >> >   bump->addBindAttribLocation( "rm_Tangent", TANGENT_ATR_UNIT );
>> >> >> >   bump->addBindAttribLocation( "rm_Binormal", BINORMAL_ATR_UNIT );
>> >> >> >
>> >> >> >   // Initialise Uniforms
>> >> >> >   // Vertex shader
>> >> >> >   osg::Vec3 Pos( 0, 0, 1000 );
>> >> >> >   stateset->addUniform( new osg::Uniform( "fvLightPosition", Pos )
>> );
>> >> >> >   stateset->addUniform( new osg::Uniform( "fvEyePosition", Pos ) );
>> >> >> >   stateset->addUniform( new osg::Uniform( "bumpMap", BUMP_TEX_UNIT
>> )
>> >> );
>> >> >> >   stateset->addUniform( new osg::Uniform( "bumpMap", BUMP_TEX_UNIT
>> )
>> >> );
>> >> >> >
>> >> >> >   // Fragment shader
>> >> >> >   stateset->addUniform( new osg::Uniform( "fvAmbient", osg::Vec4(
>> >> 0.36,
>> >> >> > 0.36, 0.36, 1.0 ) ) );
>> >> >> >   stateset->addUniform( new osg::Uniform( "fvSpecular", osg::Vec4(
>> >> 0.49,
>> >> >> > 0.49, 0.49, 1.0 ) ) );
>> >> >> >   stateset->addUniform( new osg::Uniform( "fvDiffuse", osg::Vec4(
>> >> 0.88,
>> >> >> > 0.88, 0.88, 1.0 ) ) );
>> >> >> >   stateset->addUniform( new osg::Uniform( "fSpecularPower", 100.0f
>> )
>> >> );
>> >> >> >
>> >> >> >   return geode;
>> >> >> > }
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Mon, Nov 24, 2008 at 5:02 PM, Alejandro Aguilar Sierra <
>> >> >> > [EMAIL PROTECTED]> wrote:
>> >> >> >
>> >> >> >> Hi,
>> >> >> >>
>> >> >> >> I suggest you to see the osgshaders example (how osg deals with
>> glsl)
>> >> >> >> and then consult chapter 11 of the orange book (OpenGL shading
>> >> >> >> language). You can find the shaders used in the book at
>> >> >> >> http://3dshaders.com/
>> >> >> >>
>> >> >> >> Hope it helps.
>> >> >> >>
>> >> >> >> -- A.
>> >> >> >>
>> >> >> >> On Mon, Nov 24, 2008 at 10:39 AM, Morné Pistorius
>> >> >> >> <[EMAIL PROTECTED]> wrote:
>> >> >> >> > Hi all,
>> >> >> >> > I added bump mapping to a model using osgFX::BumpMapping, but I
>> >> need
>> >> >> >> > something more flexible.  My model has two sided lighting and
>> osgFX
>> >> >> >> doesn't
>> >> >> >> > support that.  Do we have GLSL shaders for bumpmapping in OSG?
>>  I
>> >> >> think
>> >> >> >> that
>> >> >> >> > would be easier to modify to suit my needs than the assembler
>> coded
>> >> >> >> shaders
>> >> >> >> > used in osgFX.  If anyone has an example of applying normal
>> mapping
>> >> >> with
>> >> >> >> > shaders in OSG, I would greatly appreciate it.
>> >> >> >> > Thank you kindly,
>> >> >> >> > Morne
>> >> >> >> > _______________________________________________
>> >> >> >> > osg-users mailing list
>> >> >> >> > [email protected]
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >> >> >> >
>> >> >> >> >
>> >> >> >> _______________________________________________
>> >> >> >> osg-users mailing list
>> >> >> >> [email protected]
>> >> >> >>
>> >> >>
>> >>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >> >>
>> >> >> _______________________________________________
>> >> >> osg-users mailing list
>> >> >> [email protected]
>> >> >>
>> >>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >>
>> >> _______________________________________________
>> >> osg-users mailing list
>> >> [email protected]
>> >>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to