Re: [osg-users] [osgOcean] SkyDome with a repeating Texture2D
Hi Kim, Thanks for the reply. Well, I know it is only to showcase the osgOcean but still we need something to show the atmosphere / (at least) the sky. Currently I am using the skydome in my project because I don't know anything that's better. Now the problem is the skydome is always stretched in my project. And that makes the stars in the night scene bigger (like 5 pixels bigger) which is weird and unnatural. So I am trying to solve this by not clamping the texture from edge to edge, but repeat the same texture instead. I hope this makes sense. Thank you! Cheers, Bawenang "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44457#44457 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] SkyDome with a repeating Texture2D
Hi, First of all, I would like to ask a permission to use and modify the SkyDome used in the oceanExample and make it into a separate library. I know that it is not really a part of osgOcean library, but I reckon that the devs should be the same. So I asked the question here. Like the title above, I wanted to change the SkyDome and make it to use a repeating Texture2D instead of the TextureCubeMap. I need the SkyDome to display the starfield repeatedly, while also making the texture stretching be as natural as possible (ie. not overstretched like the current SkyDome). It still didn't work because it showed the color array of the SphereSegment geometry. The SphereSegment class is the same as the one in oceanExample. However, I've reworked the SkyDome class. This is my SkyDome class. Thank you! Cheers, Bawenang Code: SkyDome.h class OSGATMOSPHERE_EXPORT SkyDome : public SphereSegment { public: /** * Sky Dome Parameters struct * */ struct SkyDomeParams { float radius; unsigned intlongSteps; unsigned intlatSteps; std::string starfieldTexName; ///Ctor SkyDomeParams() //: radius(1) : radius(1900) , longSteps(4) , latSteps(4) , starfieldTexName("") { } ///Ctor with params SkyDomeParams(float r, unsigned int longitudeStep, unsigned int latitudeStep, const std::string& texName) //: radius(1) : radius(r) , longSteps(longitudeStep) , latSteps(latitudeStep) , starfieldTexName(texName) { } ///Copy Ctor SkyDomeParams(const SkyDomeParams& copy) { this->radius = copy.radius; this->longSteps = copy.longSteps; this->latSteps = copy.latSteps; this->starfieldTexName = copy.starfieldTexName; } ///Assignment Op SkyDomeParams& operator = (const SkyDomeParams& copy) { this->radius = copy.radius; this->longSteps = copy.longSteps; this->latSteps = copy.latSteps; this->starfieldTexName = copy.starfieldTexName; return *this; } ///Dtor ~SkyDomeParams() { } }; SkyDome( void ); SkyDome( const SkyDome& copy, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY ); SkyDome( float radius, unsigned int longSteps, unsigned int latSteps, const std::string& starfieldTexName ); SkyDome( const SkyDomeParams& skyDomeParams ); protected: ~SkyDome(void); public: void setupStateSet( ); void create( float radius, unsigned int latSteps, unsigned int longSteps, const std::string& starfieldTexName ); void create( const SkyDomeParams& skyDomeParams ); //++ BAWE-2028: SKYDOME /** * */ inline void setStarField( const std::string& starfieldTexName ) { if (!mStarfieldTexture.valid()) { mStarfieldTexture = new osg::Texture2D; _setTextureParams( ); } _createTexture( starfieldTexName ); } void showPolyLine(bool isShowLine); //-- BAWE-2028: SKYDOME private: osg::ref_ptr _createShader(void); void _setTextureParams( ); void _createTexture( const std::string& starfieldTexName ); void _createFromParams(); SkyDomeParams mSkyDomeParams; boolmIsShowPolyLine; osg::ref_ptrmStarfieldTexture; }; Code: SkyDome.cpp SkyDome::SkyDome( void ) : mIsShowPolyLine (false) , mSkyDomeParams () { } SkyDome::SkyDome( const SkyDome& copy, const osg::CopyOp& copyop ): SphereSegment( copy, copyop ) { } SkyDome::SkyDome( float radius, unsigned int longSteps, unsigned int latSteps, const std::s
Re: [osg-users] [osgOcean] Above Water Fog artifacts.
kcbale wrote: > Hi Bawenang, > > > At a quick glance, I can see the problem mix problem. Thanks for reporting > it. > > With regard to the sky dome, you'll have to add the fogging code into the > skydome shader, it can be found in the resources. The skydome was only really > there for the example program and they've all be chosen to blend nicely with > the fogging colour, obviously this doesn't suit all applications. > > However, one problem with fogging the sky dome is that all of the sky with be > fogged, essentially creating a flat colour since the sky dome (in the example > app) will always be a fixed distance, moving with the camera. > > > K. > > > > > On 7 October 2011 09:08, Bawenang Rukmoko < ()> wrote: > > > Hi, > > > > I've found some artifacts on the above water for scene shader. > > > > 1. When I tried implementing billboard tree with some transparent pixels, > > the transparent parts look not quite transparent. Like shown in the first > > picture. > > > > I believe it's because of these lines in the osgOcean_ocean_scene.frag: > > > > Code: > > float fogFactor = computeFogFactor( osgOcean_AboveWaterFogDensity, > > gl_FogFragCoord ); > > final_color = mix( osgOcean_AboveWaterFogColor, final_color, > > fogFactor ); > > > > > > > > And when I added a line in that shader like this: > > > > Code: > > float fogFactor = computeFogFactor( osgOcean_AboveWaterFogDensity, > > gl_FogFragCoord ); > > final_color = mix( osgOcean_AboveWaterFogColor, final_color, > > fogFactor ); > > final_color.a = textureColor.a; > > > > > > > > It worked like in the second picture. > > > > 2. I believe the fog is only implemented to the objects but not the sky > > dome (as can be seen in the third picture). How do I make it also work with > > the sky dome? Thanks. > > > > > > > > Thank you! > > > > Cheers, > > Bawenang > > > > > > "There's no place like 127.0.0.1" > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=43245#43245 > > (http://forum.openscenegraph.org/viewtopic.php?p=43245#43245) > > > > > > > > > > ___ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > > > -- > Post generated by Mail2Forum OIC. I thought I can make the sky dome be fogged per pixel like the ocean surface does. But when I think about it, you were right. Nevertheless , I'll still try it though and see how will it become. Thanks. "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43427#43427 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] A few question about alpha and osgOcean's shader
OIC. Yeah that makes sense. I've tried to test the alpha between 0.04 - 0.06 and it worked. However, it worked when I placed it before the view dependent culling. I think the alpha got screwed by the culling's shader because I happened to experience an artifact when I was trying to use a billboard plants. The billboard plants only consist of a quad with a texture of trees on one side and opaque (alpha 0.0) pixels for transparency. However, the transparency seems rather weird, if I rotated the camera, it would occasionally be transparent or not, depending on the rotation of the camera. Dunno if this is an artifact from my application or it is actually from osgOcean, but you might try to test it yourself. Thanks again. kcbale wrote: > There are two culls to ensure that the view dependent effects work with the > composite viewer. In order to get prerender passes to work with multiple > views each view has to have it's own FBOs to render to. The ViewData class > stores this view dependent data so that it doesn't get overwritten. > > It's not quite finished yet, the post render effects don't currently work > correctly with multiple views. It's something I've been working on but > haven't finished yet. > > I would probably test for an alpha that is <= 0.05. > > > K. > > On 3 August 2011 10:23, Bawenang Rukmoko < ()> wrote: > > > Thanks for the reply. To put it simply what I wanted to do is similar to > > the glare shader in osgOcean. Whereas glare is decided by the luminance aux > > buffer that has the value of over or equal to osgOcean_GlareThreshold, my > > shader would be decided by the alpha channel of a 3D model's texture that > > equals to 0.05. > > > > BTW, about the culling traversal, I'm rather confused because there's the > > cull from: > > http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767 > > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767) > > and then there's > > http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#1008 > > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#1008). > > > > > > kcbale wrote: > > > > > Hi Bawenang, > > > > > > I'm not 100% sure what you're trying to do, but I would say that the > > > error is due to the floating point comparison, try testing for a small > > > range rather than an explicit value. > > > > > > > > > > > > > > > > On a side note osgOcean uses a custom cull traversal > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767 > > > > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767) > > > > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767 > > > > > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767))) > > > so I'm not sure how that would react to having prerender cameras added > > > as children of ocean scene - It might work, but I haven't tested it. > > > > > > > > > Regards, > > > > > > > > > Kim. > > > > > > > > > > > > > > > On 3 August 2011 08:50, Bawenang Rukmoko < ()> wrote: > > > > > > > > > > Hi, > > > > > > > > I'm trying to get this shader to work: > > > > > > > > > > > > Code: > > > > > > > > #vertex > > > > void main( void ) > > > > { > > > > gl_TexCoord[0] = gl_MultiTexCoord0; > > > > gl_Position = ftransform(); > > > > } > > > > > > > > #fragment > > > > #extension GL_ARB_texture_rectangle : enable > > > > > > > > uniform sampler2DRect colorTexture; > > > > const float alphaValue = 0.05; //The alpha value that indicates the > > > > part that will be visible. else gl_FragColor = vec4(0.0) > > > > > > > > void main( void ) > > > > { > > > > vec4 color = texture2DRect(colorTexture, gl_TexCoord[0].st); > > > > > > > > if(color.a == alphaValue) > > > > { > > > > gl_FragColor = vec4(1.0,0.0,0.0,1.0); > > > > } > > > > else &g
Re: [osg-users] [osgOcean] A few question about alpha and osgOcean's shader
Thanks for the reply. To put it simply what I wanted to do is similar to the glare shader in osgOcean. Whereas glare is decided by the luminance aux buffer that has the value of over or equal to osgOcean_GlareThreshold, my shader would be decided by the alpha channel of a 3D model's texture that equals to 0.05. BTW, about the culling traversal, I'm rather confused because there's the cull from: http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767 and then there's http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#1008. kcbale wrote: > Hi Bawenang, > > I'm not 100% sure what you're trying to do, but I would say that the error is > due to the floating point comparison, try testing for a small range rather > than an explicit value. > > > On a side note osgOcean uses a custom cull traversal > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767 > > (http://code.google.com/p/osgocean/source/browse/trunk/src/osgOcean/OceanScene.cpp#767)) > so I'm not sure how that would react to having prerender cameras added as > children of ocean scene - It might work, but I haven't tested it. > > > Regards, > > > Kim. > > > > > On 3 August 2011 08:50, Bawenang Rukmoko < ()> wrote: > > > Hi, > > > > I'm trying to get this shader to work: > > > > > > Code: > > > > #vertex > > void main( void ) > > { > > gl_TexCoord[0] = gl_MultiTexCoord0; > > gl_Position = ftransform(); > > } > > > > #fragment > > #extension GL_ARB_texture_rectangle : enable > > > > uniform sampler2DRect colorTexture; > > const float alphaValue = 0.05; //The alpha value that indicates the part > > that will be visible. else gl_FragColor = vec4(0.0) > > > > void main( void ) > > { > > vec4 color = texture2DRect(colorTexture, gl_TexCoord[0].st); > > > > if(color.a == alphaValue) > > { > > gl_FragColor = vec4(1.0,0.0,0.0,1.0); > > } > > else > > gl_FragColor = vec4(0.0); > > } > > > > > > > > This shader is just the first pass (RTT camera pass) of what I intend to > > do. I am trying to implement a certain kind of shader into the scene. I am > > trying to isolate the part that the shader will work on by getting the > > alpha channel. If alpha channel = 0.05 then it will be rendered to a > > texture, if not then it will just be black. I've got lots of .ive models > > with the textures of 1.0 alpha and 0.05 alpha. However what I'm getting is > > just a blank black screen. I was thinking that maybe one of osgOcean's > > shader screwed up the alpha values or so. Can anybody help me with this > > please? Thanks a lot in advance. > > > > Thank you! > > > > Cheers, > > Bawenang > > > > > > "There's no place like 127.0.0.1" > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=41811#41811 > > (http://forum.openscenegraph.org/viewtopic.php?p=41811#41811) > > > > > > > > > > > > ___ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > -- > Post generated by Mail2Forum "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41817#41817 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] A few question about alpha and osgOcean's shader
Hi, I'm trying to get this shader to work: Code: #vertex void main( void ) { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); } #fragment #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect colorTexture; const float alphaValue = 0.05; //The alpha value that indicates the part that will be visible. else gl_FragColor = vec4(0.0) void main( void ) { vec4 color = texture2DRect(colorTexture, gl_TexCoord[0].st); if(color.a == alphaValue) { gl_FragColor = vec4(1.0,0.0,0.0,1.0); } else gl_FragColor = vec4(0.0); } This shader is just the first pass (RTT camera pass) of what I intend to do. I am trying to implement a certain kind of shader into the scene. I am trying to isolate the part that the shader will work on by getting the alpha channel. If alpha channel = 0.05 then it will be rendered to a texture, if not then it will just be black. I've got lots of .ive models with the textures of 1.0 alpha and 0.05 alpha. However what I'm getting is just a blank black screen. I was thinking that maybe one of osgOcean's shader screwed up the alpha values or so. Can anybody help me with this please? Thanks a lot in advance. Thank you! Cheers, Bawenang "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41811#41811 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
benang wrote: > Thanks for the reply. > > Well I know I shouldn't and I wouldn't if I don't have this artefact of the > culled tip of the ship. I noticed that you're replying as a guest, not a > member of this forum, so I'm not sure that you can see all of my screenshots > that I've put here. If not, then I'll give you an illustration. > > Imagine a quake clone game. You've got a part of the weapon's model visible > at the bottom of the screen, near the HUD, that will also move along with > your first person camera. Now, in my application, that weapon will be culled > and won't be rendered perfectly, even invisible at times, based on that > camera's (and model along with it) translation and rotation. Now if I > disabled near / far computation, the screen turns blank because the glare > shader is also enabled. If I disable both the near / far computation and the > glare shader, the scene seemed normal and right. However there's another > artefact. The above water fog isn't implemented correctly. Even when there > are two objects with the same distance with the camera, one of them can be > rendered as if it's inside a fog and one of them is not. > > As for the missing model if I enabled glare, I've found the answer. It seems > like osgOcean hates targa. One of my model's textures is a targa image file > and that's why it wasn't rendered. When I changed it to a jpg, it worked just > fine. Maybe you should put this as a warning somewhere in the documentation > or such. > > Thanks again. > > > Kim Bale wrote: > > You should need to use osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR. > > > > *shouldn't > > > > > > K. > > > > On 28 February 2011 06:25, Bawenang Rukmoko < ()> wrote: > > > > > No reply yet? I guess I've got to do this the hard way, researching them > > > myself. :( > > > > > > Thanks anyway guys. > > > > > > Thank you! > > > > > > Cheers, > > > Bawenang > > > > > > > > > "There's no place like 127.0.0.1" > > > > > > -- > > > Read this topic online here: > > > > > > http://forum.openscenegraph.org/viewtopic.php?p=37165#37165 > > > (http://forum.openscenegraph.org/viewtopic.php?p=37165#37165) > > > > > > > > > > > > > > > > > > > > > ___ > > > osg-users mailing list > > > () > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > > > > > > > > > > > -- > > Post generated by Mail2Forum > "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37243#37243 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
Hi, Ok, after many googling (and stumbling around aimlessly) I've found a similar situation (and a revelation): http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2008-April/009746.html So I think I'll try that one suggestion. Adding another camera pass that will only render the tip of my ship (which will have the osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR settings) and merge it with the scene. Wish me luck. :) PS: Should I also put my code here? It's pretty situational though. Thank you! Cheers, Bawenang "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37242#37242 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
Thanks for the reply. Well I know I shouldn't and I wouldn't if I don't have this artefact of the tip of the ship was not culled. I noticed that you're replying as a guest, not a member of this forum, so I'm not sure that you can see all of my screenshots that I've put here. If not, then I'll give you an illustration. Imagine a quake clone game. You've got a part of the weapon's model visible at the bottom of the screen, near the HUD, that will also move along with your first person camera. Now, in my application, that weapon will be culled and won't be rendered perfectly, even invisible at times, based on that camera's (and model along with it) translation and rotation. Now if I disabled near / far computation, the screen turns blank because the glare shader is also enabled. If I disable both the near / far computation and the glare shader, the scene seemed normal and right. However there's another artefact. The above water fog isn't implemented correctly. Even when there are two objects with the same distance with the camera, one of them can be rendered as if it's inside a fog and one of them is not. As for the missing model if I enabled glare, I've found the answer. It seems like osgOcean hates targa. One of my model's textures is a targa image file and that's why it wasn't rendered. When I changed it to a jpg, it worked just fine. Maybe you should put this as a warning somewhere in the documentation or such. Thanks again. Kim Bale wrote: > You should need to use osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR. > > *shouldn't > > > K. > > On 28 February 2011 06:25, Bawenang Rukmoko < ()> wrote: > > > No reply yet? I guess I've got to do this the hard way, researching them > > myself. :( > > > > Thanks anyway guys. > > > > Thank you! > > > > Cheers, > > Bawenang > > > > > > "There's no place like 127.0.0.1" > > > > -- > > Read this topic online here: > > > > http://forum.openscenegraph.org/viewtopic.php?p=37165#37165 > > (http://forum.openscenegraph.org/viewtopic.php?p=37165#37165) > > > > > > > > > > > > > > ___ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > > > > > -- > Post generated by Mail2Forum "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37237#37237 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
No reply yet? I guess I've got to do this the hard way, researching them myself. :( Thanks anyway guys. Thank you! Cheers, Bawenang "There's no place like 127.0.0.1" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37165#37165 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
Hi, I've tried meddling around and put "camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);" on both the cameras of "OceanScene::renderToTexturePass()" and "OceanScene::glareCombinerPass()". The results are: 1. If I put it on the RTT method, it will cause the glare to be disabled and no glare rendered. 2. If I put it on the glareCombinerPass method, the screen would turn black like the one I experienced. 3. Furthermore, I think I know what causes the models' (ships in this case) color to be changed erratically if the camera angle is changed. I think it is because of the above water fog's calculation that has gone wrong if I use "camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);" So now I've got a situation here. If I don't use "camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);", the front of the ship will be culled and displays wrongly. But if do, the whole shaders from osgOcean will be corrupted. Any other idea to solve this guys? I'm so lost right now. :( Thank you! Fare Thee Well, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37087#37087 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Shader again.
Hi, @Kim: Well for starter, I can't render a more complex model if I enabled glare. First I was successful in rendering the smiley ball. But then I tried with a much larger model but it didn't render, although it can definitely be loaded, if I activated the glare. But if I deactivate it, the model can be rendered. Secondly, I am actually using Delta 3D but seeing that it is actually built on top of OSG, it's actually the same thing, right? I attached the camera on one of the nodes of a model (a ship) and it will also display a part of the front of the ship (like an FPS game that will render a part of the character's weapon). But another artefact appears. The front of the ship is often culled and can actually disappear from time to time. So I tried disabling the near/far calculation from the camera with setComputeNearFarMode() set to "osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR". It worked if the glare (again) is disabled. If it isn't then the screen would be all black. If it is disabled, another artefact came up though. While the player's ship is not culled, the ship or other objects lightings will be screwed. The objects will occasionally flashes (like their material properties have been changed or so), and the lighting is so messed up. I'll put the screenshot here for your pleasure. @Mahendra What do you mean? For the glow shader? The glow shader I am using are actually based on the article on nvidia's website here: http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html. The actual algorithm is the shader would glow the area with an alpha of below 1.0f. Now when I looked at the glare shader, it was actually pretty much the same but the parameter is the other way around. The alpha value between _glareThreshold and 1.0f would be glared and the rest is not. So I used the alpha of between 0.0f - 0.1f for my glow parameter. If you want to get the material properties, you can use your own shader and render it to texture so you can isolate the model using a parameter (for me it is the alpha channel). I don't know how else besides using shaders. Oh yea, I would like to say thanks to the osgOcean's devs because you've made my life easier by making the RTT and downsampling methods so I won't have to make them myself. :D Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37006#37006 Attachments: http://forum.openscenegraph.org//files/error4_423.jpg http://forum.openscenegraph.org//files/error3_858.jpg http://forum.openscenegraph.org//files/error2_371.jpg http://forum.openscenegraph.org//files/error1_291.jpg http://forum.openscenegraph.org//files/blank_531.jpg http://forum.openscenegraph.org//files/without_glare_195.jpg http://forum.openscenegraph.org//files/with_glare_785.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] Shader again.
Hi, I seem to stumbled a lot on osgOcean's shaders. I've got lots of graphics artefacts because of them. Can you point me to the ones that are actually working on them? I may need to disturb them a bit with my questions. Thanks. Oh yea BTW I've successfully made my own bloom shader. Here's the screenshot. :D Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36945#36945 Attachments: http://forum.openscenegraph.org//files/glow2_129.jpg http://forum.openscenegraph.org//files/glow_139.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Extracting the texture from an ive and use it for a shader's sample2DRect uniform
Hi, Nevermind. I've found my mistake. I was just wondering why it didn't work and the texture can't be loaded from the shader. It's all because my own stupidity of using sample2DRect instead of sample2D. And I've just found out that the base texture from an ive is actually pre-determined as the texture number 0 and the uniform parameter "baseTexture". :D Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36406#36406 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Extracting the texture from an ive and use it for a shader's sample2DRect uniform
Hi, I am trying to extract the texture from an .ive that is read using osgDB into a node and will be passed as a sample2DRect uniform for the shader. So to make it sort, how do I do that? The code so far: Code: osgDB::Registry::instance()->getDataFilePathList().push_back("resources/SmileFace"); const std::string smileyFilename = "SmilingFaceDiff0.IVE"; //osgDB::Registry::instance()->getDataFilePathList().push_back("resources/SmileFace2"); //const std::string smileyFilename = "SmilingFace.IVE"; osg::ref_ptr smiley = osgDB::readNodeFile(smileyFilename); if(smiley.valid()) { //Set StateSet osg::StateSet* ss = new osg::StateSet; ss->setTextureMode(0, GL_LIGHTING, osg::StateAttribute::OFF); ss->addUniform( new osg::Uniform( "baseTexture", 0 ) ); //Umm, where did baseTexture come from? need to extract from the ive smiley->setStateSet(ss); //Set Programs osg::ref_ptr program = new osg::Program; char vertexSource[]= "void main(void)\n" "{\n" "gl_Position = ftransform();\n" "gl_TexCoord[0] = gl_MultiTexCoord0;\n" "}\n"; char fragmentSource[]= "uniform sampler2DRect baseTexture;\n" "\n" "void main(void)\n" "{\n" " gl_FragColor = texture2DRect( baseTexture, gl_TexCoord[0] );\n" " gl_FragColor.a = 0.05;\n" "}\n"; program->setName( "alpha_test" ); program->addShader(new osg::Shader(osg::Shader::VERTEX, vertexSource)); program->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragmentSource)); ss->setAttributeAndModes( program, osg::StateAttribute::ON ); } Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36403#36403 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] [ASK] Need help for a shader related issue
Hi, Because I can post URLs now, I'll post the source of what I want to implement. http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36212#36212 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] Greetings, and a few bug.
Hi, Oops sorry, the if condition was my first attempt to check and fix the bug. It turns out that it was not working and the bug was somewhere else. The whole method is this: Code: float FFTOceanSurface::getSurfaceHeightAt(float x, float y, osg::Vec3f* normal) { if(_isDirty) build(); // ocean surface coordinates float oceanX, oceanY; // translate x, y to oceanSurface origin coordinates oceanX = -_startPos.x() + x; oceanY = _startPos.y() - y; // calculate the corresponding tile on the ocean surface unsigned int ix = oceanX/_tileResolution; unsigned int iy = oceanY/_tileResolution; unsigned int frame = _oldFrame; // Test if the tile is valid if(ix < _numTiles && iy < _numTiles) { //++ BAWE-20101109: BUG FIX. //NOTE: 20101112 - Not working but what the heck... if (_oldFrame < _mipmapData.size()) { const OceanTile& data = _mipmapData[_oldFrame][0]; float tile_x = oceanX - ix * _tileResolution; float tile_y = oceanY - iy * _tileResolution; //++ BAWE-20101119: BUG FIX // Absolute value of dx & dy tile_x = tile_x > 0 ? tile_x : -tile_x; tile_y = tile_y > 0 ? tile_y : -tile_y; //-- BAWE-20101119: BUG FIX if (normal != 0) { *normal = data.normalBiLinearInterp(tile_x, tile_y); } return data.biLinearInterp(tile_x, tile_y); } //-- BAWE-20101109: BUG FIX } return 0.0f; } Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36211#36211 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgOcean] I am in a puzzle about the realization of osgOcean's 'Glare effect'
A noob trying to help a bit. Try looking at "OceanScene::preRenderCull()" method. You'll see that it's being used there to render the scene. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36179#36179 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] [ASK] Need help for a shader related issue
Hi, This is my second post here. I split it here because I am actually confused about a shader related problem and I decided to post it here. I'm trying to implement a glow shader in osgOcean like the one explained at GPU Gems chapter 21 on NVIDIA's site (can't post the link because it looks like You must have 2 posts before you can post URL's/Links). On the page it was explained that we can use the alpha channel to determine the glow and brighteness of the glow of an object. So an alpha of 0.0 = glowing brightly, 0.5 = glowing not to brightly, 1.0 = not glowing / normal texture. However I see that the glare effect also uses alpha channel to determine which one to be glared. I see that in "OceanScene::downsamplePass()", there are these lines in the fragment shader: Code: " color = color*0.25;\n" "\n" " if(color.a >= osgOcean_GlareThreshold) " " gl_FragColor = color;\n" " else\n" "gl_FragColor = vec4(0.0);" "\n" So in a way you are determining which part glare should be implemented by their alpha channel, only reversed in this part. If the alpha is equal to or bigger than the threshold, it will be glared. So, what I'm confused of right now is how can I make a glow shader that won't collide with the glare shader, so maybe I can actually use them both at the same time? Thank you! Cheers, Bawenang PS: LOL! > You must have 2 posts before you can post URL's/Links. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36178#36178 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] Greetings, and a few bug.
Hi, I actually have been using osgOcean for a year now. Well, I actually use Delta 3D which uses OSG and in turn osgOcean. It's a pretty good library for rendering ocean, would be better if you can add atmospheric scattering using Mie and Rayleigh approximation for real time day-night situation. But beggars can't be chosers, right? :D Anyway I've found 2 bugs on osgOcean. One I still haven't been able to solve, that is the glare functionality. It seems like the glare would also affect the skybox and not only the ocean. I believe it's a shader issue when you are downsampling the rendered texture with glare. The other one is the "FFTOceanSurface::getSurfaceHeightAt()" method. It would crash from time to time due to negative tile_x and/or tile_y value whereas they are used to determine an index for vectors in "OceanTile::normalBiLinearInterp()" and "OceanTile::biLinearInterp()" function. I know that because I used the method quite a lot for determining a ship's transformation when there's a wave. Below is the fix for the said problem: Code: ... if (_oldFrame < _mipmapData.size()) { const OceanTile& data = _mipmapData[_oldFrame][0]; float tile_x = oceanX - ix * _tileResolution; float tile_y = oceanY - iy * _tileResolution; //++ BAWE-20101119: BUG FIX // Absolute value of dx & dy tile_x = tile_x > 0 ? tile_x : -tile_x; tile_y = tile_y > 0 ? tile_y : -tile_y; //-- BAWE-20101119: BUG FIX if (normal != 0) { *normal = data.normalBiLinearInterp(tile_x, tile_y); } return data.biLinearInterp(tile_x, tile_y); } Thank you! Cheers, Bawenang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=36177#36177 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org