kbale / osgocean

An ocean rendering nodekit for OpenSceneGraph
GNU Lesser General Public License v3.0
108 stars 56 forks source link

osgOcean and ParticleGen Transparency #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a particle effect that has a transparency on its particles...

What is the expected output? What do you see instead?

I'm having a problem with my particle generator when i use it in the same
scene as osgOcean (dtOcean). All the transparent alpha pixels seem to glow
instead of being invisible. Also the particles transparency value has no
effect anymore...so instead of slowly vanishing...the particles just pop
out of existence.

attached is a screen shot of what i get....the picture shows a screen with
and with out osgOcean (dtOcean)....notice how the particles look...

i tried disabling the glare shader....but that had abs no effect....

i also noticed that it matters from which side you look at the
particles.....sometimes the transparency gets semi fixed....so i'm thinking
its a lighting thing...but don't know...

What version of the product are you using? On what operating system?

osgOcean 1.0.1
and dtOcean (part of Delta3D)

Win XP VS2008

Original issue reported on code.google.com by maxims...@gmail.com on 27 Jan 2010 at 1:41

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Have you tried the version in the trunk?

I added MRT support for the glare effect which should allow you to use alpha 
textures 
at the same time as the glare effect. 

Kim.

Original comment by kcb...@googlemail.com on 27 Jan 2010 at 9:19

GoogleCodeExporter commented 9 years ago
Hi KIm,

I downloaded the trunk release...(192)...but having trouble compiling it.... 
does it
compile against OSG 2.8.2?  i'm going to try again....

Maxim

Original comment by maxims...@gmail.com on 27 Jan 2010 at 7:41

GoogleCodeExporter commented 9 years ago
NM...looks like CMake wasn't setting some libs up correctly....

Original comment by maxims...@gmail.com on 27 Jan 2010 at 8:59

GoogleCodeExporter commented 9 years ago
Ok, compiled it...  placed it in Delta3D, but i still see the particle 
problem....no
change using the 192 trunk version. Accept for a crash i get on the 
release....debug
runs though.... 

Original comment by maxims...@gmail.com on 27 Jan 2010 at 9:29

GoogleCodeExporter commented 9 years ago
fixed the crash.....   but the transparency problem still persists.... 

Original comment by maxims...@gmail.com on 27 Jan 2010 at 9:55

GoogleCodeExporter commented 9 years ago
Ah yes, I think I know the problem. 

You need to apply a shader to the particle system which sets the luminance 
value in 
the glare framebuffer target to zero. See the default shader for this:

i.e. here we set the luminance value in the 2nd FBO to zero so that the glare 
pass 
ignores it.

if(osgOcean_EnableGlare){
  gl_FragData[1] = vec4(0.0);
}

You can use the default shader as your base but you will need to remove things 
like 
lighting etc so that your particle system blends correctly.

Let me know how you get on,

Kim.

Original comment by kcb...@googlemail.com on 27 Jan 2010 at 10:30

GoogleCodeExporter commented 9 years ago
Thanks Kim,

I will have to try it...   I haven't touched shaders yet...but i plan to get to 
them
eventually.....   when i do i'll let u know if i found a fix for this....

Original comment by maxims...@gmail.com on 2 Feb 2010 at 10:58

GoogleCodeExporter commented 9 years ago
Maximster,

Do you ever get this to work?  I'm having the same problem.  Kim, when you 
mention the 
bit about the shaders, where do you set that up? In the shader file or in your 
code?

Original comment by dpwi...@gmail.com on 14 May 2010 at 7:56

GoogleCodeExporter commented 9 years ago
Hi Dp?

You'll need to attach a shader which writes to the luminance buffer then make 
sure 
your your particle system is a child of OceanScene. 

When osgOcean render objects with the glare pass enabled it renders to two 
framebuffers. The first is the color buffer, the second is the luminance 
buffer. If 
the value written to the luminance buffer is greater than the glare threshold 
it'll 
get picked up by the glare pass and will appear to twinkle. 

If you do not want your object to appear in the glare pass you have to make 
sure that 
the value written to the luminance buffer is 0. So you'll need to attach a very 
simple shader to the particle system, something like this:

void main(void){
   gl_TexCoord[0].st = gl_MultiTexCoord0.st;
   gl_Position = ftransform();
}

uniform sampler2D pTexture;
void main(void){
   gl_FragData[0] = texture2D( pTexture, gl_TexCoord[0].st );
   if(osgOcean_EnableGlare){
      // writing zero to the luminance buffer
      // this object will get ignored.
      gl_FragData[1] = vec4(0.0);
   }
}

Let me know how you get on.

Kim.

Original comment by kcb...@googlemail.com on 15 May 2010 at 8:59

GoogleCodeExporter commented 9 years ago
Kim,
Thanks for the quick response.  Only question I have is how do I attach a 
shader just to the particle system?  I'm creating my 
particle system in code and attaching it to a delta 3D object:

mProp = dynamic_cast<dtCore::Object*>((*iter)->GetActor());
propBubbles = new dtCore::ParticleSystem;
propBubbles->LoadFile("/effects/cavitation4.osg");
propBubbles->SetTransform(dtCore::Transform(0,2,-0,180,-90,0));
mProp->AddChild(propBubbles.get());

What is the method for attaching a shader to a particle system?  I assume I'd 
add it, right after creating it in code, yes?

Thanks for your help!

Danny

Original comment by dpwi...@gmail.com on 17 May 2010 at 3:38

GoogleCodeExporter commented 9 years ago
Hi Danny,

I'm afraid I've never used Delta3D. However, in OSG a particle system has a 
state which 
you can attach a shader to. 

Regards,

Kim.

Original comment by kcb...@googlemail.com on 18 May 2010 at 8:04

GoogleCodeExporter commented 9 years ago
In delta 3d, you can grab the actual OSG node, and do all your changes to it
directly... usually its GetOSGNode()->

Original comment by maxims...@gmail.com on 4 Jun 2010 at 5:00

GoogleCodeExporter commented 9 years ago
Maximster,
did you get this to work in Delta3D?  

Original comment by dpwi...@gmail.com on 4 Jun 2010 at 6:08

GoogleCodeExporter commented 9 years ago
Hey dpwilli,

No, we never got the time to look into this, and then my client changed his mind
about the particles all together and went with solid geometry....

Eventually im still planign to look into it or build my own ocean on top of 
osgOcean,
because it looks like dtOcean is not updated as fast as osgOcean is...its 
missing new
options... and i think it introduces a glare bug to the skydome

Original comment by maxims...@gmail.com on 7 Jun 2010 at 3:56