Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: [Workaround] Scene.RenderAllParticleSystems() messes up Shader Alpha !?  (Read 715 times)
Shadowsong
Customers
Community Member
*****
Posts: 328


« on: September 16, 2010, 09:04:56 AM »

After hours of trial and error I am pretty sure this is a bug. Or at least it is very weird.

Ok I have two shaders. The first one renders to a rendersurface and the second one uses that surface as a texture.

The first shader calculates stuff and stores values in RGB and A separately so it might happen that A=0 while RGB still hold important data. This works fine so far.

BUT as soon as I call Scene.RenderAllParticleSystems() it messes everything up!!
From then on, it seems like there is an internal global alphatest activated!

All pixels with alpha < 0.03 are no longer drawn!

So I guess the RenderParticles method sets some internal alphatest value and does not set it back to normal.

Also I have to say, I don't use AlphaTest anywhere in my program. I also tried setting the AlphaTestValue to 0 and/or setting AlphaTest to True/False for all meshes and particlesystems but it still caps at 0.03 and doesn't change anything.
So this is most likely a TV bug.


To display what happens in more detail:

WITHOUT CALLING RENDERPARTICLESYSTEMS IN MY PROGRAM ANYWHERE:

Shader1: return float4(1, 1, 1, 1)
Shader2: read pixel from Shader1's rendertarget = (1, 1, 1, 1)

Shader1: return float4(1, 1, 1, 0.1)
Shader2: read pixel from Shader1's rendertarget = (1, 1, 1, 0.1)



WITH CALLING RENDERPARTICLESYSTEMS IN MY PROGRAM ANYWHERE:

Shader1: return float4(1, 1, 1, 1)
Shader2: read pixel from Shader1's rendertarget = (1, 1, 1, 1)

Shader1: return float4(1, 1, 1, 0.1)
Shader2: read pixel from Shader1's rendertarget = (0, 0, 0, 0)



EDIT:
It also seems to mess up other things such as render target resolution? I am not sure about this but it seems like I get more artifacts and less overall resolution. Maybe the Particle Shaders mess around with renderstates? I have no idea how to reset the renderstates to whatever they were before / should be. However, RenderParticles is definitely buggy.
« Last Edit: September 17, 2010, 06:33:04 AM by Shadowsong » Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
ALP
« Reply #1 on: September 17, 2010, 05:46:19 AM »

Quite weird...

It looks like the problem is AlphaTest indeed. It's really the symptom ( not writting in the
I will check if something is changed. It looks like the AlphaTest is set with an AlphaRef value of 1.

Does it happen if you call TVParticleSystem.Render and not RenderAllParticleSystems?

If you use a shader to render your mesh, you could try to disable alphatest inside the shader pass.
Add "ALPHATESTENABLE = FALSE" inside the technique pass.

It's quite weird that it impacts so much the other render because renderstates are supposed to be rechanged when a mesh is drawn...
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Shadowsong
Customers
Community Member
*****
Posts: 328


« Reply #2 on: September 17, 2010, 06:32:23 AM »

Wow THANKS !!!

Adding "ALPHATESTENABLE = FALSE" just fixed it!! Damn I could have thought of that myself...

So I guess the alphatest gets set to TRUE by the particle system and is never rechanged.

I might even have an explanation for the 0.03 as borderline. The function TVParticleSystem.SetEmitterAlphaTest(...) has the standard value 8 for iAlphaRef. And 8 / 255 = 0.03 !

Also no problem with artifacts/resolution, that was totally my fault.

Oh and if this helps you: yes the same effect happens with TVParticleSystem.Render().

So everything is fine now!

Three happy ones for Sylvain Smiley Smiley Smiley
« Last Edit: September 17, 2010, 06:44:40 AM by Shadowsong » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks