OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

A few question about alpha and osgOcean's shader


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean]
View previous topic :: View next topic  
Author Message
benang
User


Joined: 31 Jan 2011
Posts: 21

PostPosted: Wed Aug 03, 2011 7:50 am    Post subject:
A few question about alpha and osgOcean's shader
Reply with quote

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(color.rgb,1.0);
    }
   else
      gl_FragColor = vec4(0.0);
}


This shader is just the second pass (after the RTT camera pass) of what I intend to do. I am trying to implement a certain kind of shader into the scene based on the alpha channel. So I need 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.e. all the fragment color is vec4(0.0) ). I was thinking that maybe one of osgOcean's shader screwed up the alpha values or so. Can anybody help me with this please?

BTW, what I want to do is just to isolate a certain part before using it into something else. If I can't do that using alpha channel, can anybody tell me another option?

Thank you!

Cheers,
Bawenang

_________________
"There's no place like 127.0.0.1"
Back to top
View user's profile Send private message
kcbale
User


Joined: 04 Mar 2011
Posts: 68

PostPosted: Wed Aug 03, 2011 8:32 am    Post subject:
A few question about alpha and osgOcean's shader
Reply with quote

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) 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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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

------------------------
&quot;There's no place like 127.0.0.1&quot;

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
benang
User


Joined: 31 Jan 2011
Posts: 21

PostPosted: Wed Aug 03, 2011 9:23 am    Post subject:
Re: A few question about alpha and osgOcean's shader
Reply with quote

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) 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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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

------------------------
&quot;There's no place like 127.0.0.1&quot;

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum

_________________
"There's no place like 127.0.0.1"
Back to top
View user's profile Send private message
kcbale
User


Joined: 04 Mar 2011
Posts: 68

PostPosted: Wed Aug 03, 2011 9:45 am    Post subject:
A few question about alpha and osgOcean's shader
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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:
Quote:
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. 



Quote:
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:

Quote:
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

------------------------
&quot;There's no place like 127.0.0.1&quot;

------------------
Read this topic online here:

Quote:
Quote:
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


------------------------
&quot;There's no place like 127.0.0.1&quot;

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=41817#41817






_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
benang
User


Joined: 31 Jan 2011
Posts: 21

PostPosted: Wed Aug 03, 2011 11:23 am    Post subject:
Re: A few question about alpha and osgOcean's shader
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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:
Quote:
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. 



Quote:
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:

Quote:
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

------------------------
&quot;There's no place like 127.0.0.1&quot;

------------------
Read this topic online here:

Quote:
Quote:
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


------------------------
&quot;There's no place like 127.0.0.1&quot;

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=41817#41817






_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum

_________________
"There's no place like 127.0.0.1"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Scale problem while transforming obje... YuraIU02 General 1 Sat Apr 15, 2017 4:26 pm View latest post
No new posts shader 崔 献军 General 1 Fri Apr 07, 2017 1:55 am View latest post
No new posts Merge Shader::Program from differents... Paradox General 1 Tue Feb 28, 2017 3:53 pm View latest post
No new posts Check if sampler2D is valid in fragme... romulogcerqueira General 10 Tue Dec 27, 2016 4:52 am View latest post
No new posts Is it possible to draw an ive object ... mgreene General 2 Mon Dec 12, 2016 8:23 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP