Jump to content


Particle code questions.


4 replies to this topic

#1 Madin

    Amateur

  • Member
  • 138 posts

Posted 30 January 2011 - 13:53

I am wondering about an element that I do not understand that is used in the 'ParticleFX' code.
It's the 'ColorScale' element, any idea what it does?

Also is there any clear explanation has to what the 'SortLevel' attribute does, and what the significance of the numbers used in this attribute are?

Thanks!

Edited by Madin, 30 January 2011 - 20:25.


#2 Kris

    <Custom title available>

  • Project Team
  • 3825 posts

Posted 31 January 2011 - 09:02

According to a wiki about C&C Generals:

Quote

ColorScale = x x
scales all the colors. This allows you to make the entire particle system darker or brighter, without having to change the individual colors. Negative numbers darken the particle system while positive numbers brighten it.


Quote

ColorScale =
Negative numbers are darker and positive numbers are brighter


Knowing that C&C 3 uses the SAGE, the parameter works exactly the same like in Generals. As for the SortLevel parameter, no one really knows what it does.







#3 Sgt. Rho

    Kerbal Rocket Scientist

  • Project Leader
  • 6870 posts
  • Projects: Scaring Jebediah.

Posted 31 January 2011 - 09:37

as far as I know, the sort level decides how close or far from the camera the particle is.

If you have 2 particles on the same height, SortLevel=1 I think would be on top, and SortLevel=2 below it.

#4 Ion Cannon!

    Mountain Maniac

  • Gold Member
  • 5812 posts
  • Projects: European Conflict - Particle FX & Coder

Posted 31 January 2011 - 09:51

Colourscale also seems to have an effect on lifetime. I noticed it when a particle I had produced had a long lifetime but didn't seem to stick around long ingame. It wasn't an issue of alpha values or colour values, the colourscale was at -5 or something, I forget the exact number, but changing it back to 0 produced the desired lifetime as opposed to the drastically shortened one. My guess would be the colourscale value meant that even though according to the colours / alphas it should exist, it had become sufficiently dark enough to effectively not be there.
Posted Image

Posted Image

#5 Chronosheep

    Amateur

  • Member
  • 106 posts
  • Projects: C&C: Renovatio

Posted 31 January 2011 - 11:06

I posted this on cncsociety yesterday, but I'll post it here as well, in case anyone else needs it:

Quote

ColorScale is used for randomizing particle brightness.
The brightness of the particles are adjusted up or down by a random number within the range given by the ColorScale variable.
To be precise:
New color = Old color + random offset * (1 - relative age)
The random offset is in the ColorScale range, is calculated per-particle (not per-pixel or per-vertex), and is the same for all color channels.


The SortLevel is used by the game for sorting the order in which transparent objects are rendered. It's worth noting that SortLevel here has the same function as static sorting has in the w3d export settings in 3ds max.

Opaque objects are sorted using depth testing. When an opaque object is rendered, it writes its position in the scene to the depth buffer (depth writing). Objects that are rendered later uses depth testing to compare its own position with that of other things in the scene, and decides whether or not there is something infront of it.

Transparent objects usually also use depth testing to check its position with respect to opaque objects, but it cannot use depth writing. Instead, transparent objects have to be sorted by the game and rendered in order, such that objects in the back are rendered first, and closer objects are rendered over them. (Remember, the color has to be blended, so the order is important with transparent objects).

Now, sort levels are used to override this in some sense. An object with a higher sort level than another will always be drawn ontop of one with a lower sort level. Objects with the same sort level are sorted in the usual way.

All transparent objects should have a sort level of at least 1 (all particles using the C&C3 particle shaders should be considered transparent, even if they are not). Unless you want a specific effect, there is little point in using higher sorting levels. It could for example be useful if you want objects for an UI-like effect to always be rendered ontop of smoke and other particles.

Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users