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

