Afx And Tgea (tse)?
by Thomas Phillips · in Torque Game Engine Advanced · 12/13/2006 (8:10 pm) · 115 replies
Has anyone here picked up AFX? Any idea how tightly coupled it is to TGE? Can anyone say where the integration points would be for TGEA (TSE)?
For those who live under a rock and don't know what I'm talking about, visit this page and take a look:
http://www.garagegames.com/products/127/
Tom
For those who live under a rock and don't know what I'm talking about, visit this page and take a look:
http://www.garagegames.com/products/127/
Tom
#22
Just wanted to say that I'm 100% planning to buy the combo when you release it for TGEA. I'm currently mainly a TGB developer but once I'm done developing my current game I'll likely move onto a 3D project. If I'm not learning something new I'm not living :)
Anyway, I've been digging the updates and it's good to see you are moving along relatively well. If there will be any sort of chance to buy a "beta" version early so I can play around with it until the real release, please let me know. I honestly wouldn't want to do a TGEA project without this addon tech.
Thanks,
Aaron.
02/16/2007 (2:07 pm)
Jeff:Just wanted to say that I'm 100% planning to buy the combo when you release it for TGEA. I'm currently mainly a TGB developer but once I'm done developing my current game I'll likely move onto a 3D project. If I'm not learning something new I'm not living :)
Anyway, I've been digging the updates and it's good to see you are moving along relatively well. If there will be any sort of chance to buy a "beta" version early so I can play around with it until the real release, please let me know. I honestly wouldn't want to do a TGEA project without this addon tech.
Thanks,
Aaron.
#23
Keep grinding and we'll make it worth your while. :)
02/18/2007 (2:31 pm)
Same here. While we're not developing a "fantasy" genre game... Some of the technology and effects you're working in will be absolutely invaluable.Keep grinding and we'll make it worth your while. :)
#24
While our design is more an RTS like approach, the effects shown in AFX TGE were fantastic and the docs indicate that they are far easier to create than with "plain TGE" and as TGEA frees CPU (which we will most likely need for the AI ideas we have in mind) we would really like to incorperate this great effect system to give the designer more flexibility, power and less timewaste when creating new stunning effects (or when just toying around while searching new effects)
02/18/2007 (2:45 pm)
Couldn't agree more.While our design is more an RTS like approach, the effects shown in AFX TGE were fantastic and the docs indicate that they are far easier to create than with "plain TGE" and as TGEA frees CPU (which we will most likely need for the AI ideas we have in mind) we would really like to incorperate this great effect system to give the designer more flexibility, power and less timewaste when creating new stunning effects (or when just toying around while searching new effects)
#25
The main restriction I had to work around was the requirement that each particle emitter be rendered in a single batch. This means that each particle emitter can use only one texture and it can't change the blend function in the middle of a render batch. Without customizations, these restrictions break emitters using multiple particles, emitters using animated particles, and emitters that need to mix blend styles. By adding the ability to set per-particle texture coordinates and by offering a complete set of blend factors, these broken capabilities can be restored without violating the restrictions, and this is what I did. The end result requires a little special preparation of the particle assets, but the particles should render very efficiently.
Here's a brief summary of new features:
For particles, you can now explicitly set the UV values of the four corners of each particle quad. The idea here is that you can tile multiple particle textures into a single texture and configure different particles to show different areas of the same texture. Then you can have an emitter with different particles as long as the particles share the same texture. This approach is very flexible in that, although particles themselves are square, the texture regions they display don't have to be. This is handy for maximizing possible tiling arrangements for sharing a texture between particles.
For animated particles, the texture region specified can be further divided into a grid of tiles that can be indexed as animated frames. You specify dimensions of the tile grid, a frame rate, and an arbitrarily ordered list of frame numbers, and the particle animates by showing these particles one at a time, adjusting UVs on the fly. Again, the UV specification is very flexible so you can mix animated with non-animated particles in a single texture.
When designing fire particles, you can find yourself wanting to mix bright additive blended flame particles with dark normal blended smoke particles. In TGE, this is usually the circumstance where you find yourself mixing particles with useInvAlpha=true with particles setting useInvAlpha=false. This won't work in TGEA, but Ben Garney pointed me to this link, which describes how you can use an alternative blend style combined with textures with pre-multiplied alpha to achieve similar results without switching blends midstream. Making this possible required a new blend style, so I went ahead and made it possible to specify any kind of blend using separate source and destination blend factors. This is already possible in TGB and I implemented it a way that is consistent with how it works there.
Finally, in order to get the most out of the new blend options, I implemented optional per-emitter particle sorting. For some blend styles, particle ordering is irrelevant and even in cases
where the ordering does matter, many particle emitters still look acceptable when rendered with unsorted particles. But for those cases where the particles just won't look right unless sorted, you now have the option of turning sorting on.
Next Up: I'll adapt the current AFX/TGEA port to using this enhanced version of the particle system and then go through the process of migrating all the AFX particle effects to the new approach. I'll report back on how smooth that goes. In theory, TGEA particles with these enhancements should do the trick.
02/27/2007 (11:34 am)
I just finished up some customizations of the TGEA particle system that are intended for inclusion with a future release of TGEA, not just AFX. The goal here was to restore some capabilities that were lost when the particle system was migrated to TGEA, not to add any fancy new features. Still, I did end up adding a couple of enhancements that fit right in with the required changes. While these changes don't achieve transparent backwards compatibility with particles designed for TGE, they do implement parallel capabilities and a fairly minimal migration path between the two. (These customizations still need to be filtered by the TGEA developers so they may not all get included or they may go through some changes.) The main restriction I had to work around was the requirement that each particle emitter be rendered in a single batch. This means that each particle emitter can use only one texture and it can't change the blend function in the middle of a render batch. Without customizations, these restrictions break emitters using multiple particles, emitters using animated particles, and emitters that need to mix blend styles. By adding the ability to set per-particle texture coordinates and by offering a complete set of blend factors, these broken capabilities can be restored without violating the restrictions, and this is what I did. The end result requires a little special preparation of the particle assets, but the particles should render very efficiently.
Here's a brief summary of new features:
For particles, you can now explicitly set the UV values of the four corners of each particle quad. The idea here is that you can tile multiple particle textures into a single texture and configure different particles to show different areas of the same texture. Then you can have an emitter with different particles as long as the particles share the same texture. This approach is very flexible in that, although particles themselves are square, the texture regions they display don't have to be. This is handy for maximizing possible tiling arrangements for sharing a texture between particles.
For animated particles, the texture region specified can be further divided into a grid of tiles that can be indexed as animated frames. You specify dimensions of the tile grid, a frame rate, and an arbitrarily ordered list of frame numbers, and the particle animates by showing these particles one at a time, adjusting UVs on the fly. Again, the UV specification is very flexible so you can mix animated with non-animated particles in a single texture.
When designing fire particles, you can find yourself wanting to mix bright additive blended flame particles with dark normal blended smoke particles. In TGE, this is usually the circumstance where you find yourself mixing particles with useInvAlpha=true with particles setting useInvAlpha=false. This won't work in TGEA, but Ben Garney pointed me to this link, which describes how you can use an alternative blend style combined with textures with pre-multiplied alpha to achieve similar results without switching blends midstream. Making this possible required a new blend style, so I went ahead and made it possible to specify any kind of blend using separate source and destination blend factors. This is already possible in TGB and I implemented it a way that is consistent with how it works there.
Finally, in order to get the most out of the new blend options, I implemented optional per-emitter particle sorting. For some blend styles, particle ordering is irrelevant and even in cases
where the ordering does matter, many particle emitters still look acceptable when rendered with unsorted particles. But for those cases where the particles just won't look right unless sorted, you now have the option of turning sorting on.
Next Up: I'll adapt the current AFX/TGEA port to using this enhanced version of the particle system and then go through the process of migrating all the AFX particle effects to the new approach. I'll report back on how smooth that goes. In theory, TGEA particles with these enhancements should do the trick.
#26
I'm happy to hear that the removed capabilities did not prevent you from getting the best effect system further up the way to TGEA :-)
Can't wait to see how it works out (performance and visual quality wise)
02/27/2007 (11:49 am)
That are great news Jeff.I'm happy to hear that the removed capabilities did not prevent you from getting the best effect system further up the way to TGEA :-)
Can't wait to see how it works out (performance and visual quality wise)
#27
I'm excited for those changes alone.
I will definately be purchasing this pack.
Thanks for all of the work.
Todd
02/27/2007 (12:49 pm)
That is awesome.I'm excited for those changes alone.
I will definately be purchasing this pack.
Thanks for all of the work.
Todd
#28
02/27/2007 (12:52 pm)
Just wanted to add my endorsement that I will very seriously examine your pack once it is released for TGEA. It could give my project a serious boost in special effects that I probably wouldn't otherwise have the time to create. Good work, and keep it up!
#29
02/27/2007 (2:20 pm)
Glad to hear that the AFX port to TGEA is a step closer!
#30
02/27/2007 (6:31 pm)
Sounds great, really looking forward to this one. =)
#31
02/28/2007 (2:05 am)
Hoody hooo!!!
#32
02/28/2007 (1:09 pm)
Fantastic. Thanks for the update.
#33
Since then, I've merged in the AFX particle system enhancements on top of the base enhancements and adapted all of the existing AFX particle effects to the new system.
The TGE particle system allows particle emitters to mix particles referring to completely independent textures. In contrast, the TGEA particle system only allows one texture per emitter, but you can get a mix of particles by combining textures into a single texture and configuring each particle type to show only one section of the tiled texture. So, to adapt existing AFX particle effects to the new system, my primary task was to take all particle textures used in each mixed-particle emitter and tile them together into a single texture. This often involved textures of varying sizes and in arbitrary numbers, so a perfect translation was not possible, but after making careful compromises in size, I was able to recreate particle effects in TGEA that appear very close to the way they looked in TGE. I had to be careful about the tile boundaries between separate particle areas of the tiled textures to avoid any texture bleeding between tiles, but generally this is not overly difficult with particle textures.
This process was an excellent test for the new per-particle texture-coords settings and I think they performed well and proved very flexible. This is illustrated in this example texture from the spell Insectoplasm:

Note how tiles C and D are not only anamorphic but also have overlapping blank areas. Some of these tiles are smaller than the originals but I was able to preserve as much detail as possible with careful placement of the tile boundaries.
The TGE particle system allows emitters to mix particles with two different blend operations. In TGE, the default blend is an additive-alpha style, while useInvAlpha=true produces a lerp-alpha style. These blends often get mixed when creating fire with dark smoke. For the fire you want a bright additive blend, and for the smoke you want a darker interpolated blend. The TGEA particle system only allows one blend style per emitter, so you cannot create this kind of effect the same way as in TGE. Instead you can use TGEA's more flexible particle blend system to choose a more appropriate blend style.
As I mentioned in my last post, this link describes how you can use an alternative blend style combined with textures with pre-multiplied alpha to achieve similar results without switching blends midstream. In the AFX bonfire spell, Light My Fire, there are several emitters that mix fire and smoke in this way. The link above makes it sound like changing to a pre-multiplied-alpha is easy, but in practice it's very tricky and extremely non-intuitive if the original particle emitters are varying color and alpha on top of everything else. Still, after much fiddling with particle parameters, and experimental adjustment of the alpha and color channels in the texture, I was able to achieve emitter behavior and appearance that is pretty close to the originals. The screenshot below shows particles from the Light My Fire bonfire effect running under TGEA. Other aspects of the effect, such as lighting and zodiacs are disabled here:

It was a lot more work and took a lot longer than originally anticipated but the particle effects portion of AFX for TGEA is mostly finished and working well.
03/18/2007 (11:02 am)
In my last post in this thread, I described some enhancements I had implemented for the TGEA particle system. Although these enhancements are intended for inclusion with the main codebase of TGEA, my main motivation was to restore important functionality to the particle system in order to prop up the port of AFX to TGEA that I'm working on. Since then, I've merged in the AFX particle system enhancements on top of the base enhancements and adapted all of the existing AFX particle effects to the new system.
The TGE particle system allows particle emitters to mix particles referring to completely independent textures. In contrast, the TGEA particle system only allows one texture per emitter, but you can get a mix of particles by combining textures into a single texture and configuring each particle type to show only one section of the tiled texture. So, to adapt existing AFX particle effects to the new system, my primary task was to take all particle textures used in each mixed-particle emitter and tile them together into a single texture. This often involved textures of varying sizes and in arbitrary numbers, so a perfect translation was not possible, but after making careful compromises in size, I was able to recreate particle effects in TGEA that appear very close to the way they looked in TGE. I had to be careful about the tile boundaries between separate particle areas of the tiled textures to avoid any texture bleeding between tiles, but generally this is not overly difficult with particle textures.
This process was an excellent test for the new per-particle texture-coords settings and I think they performed well and proved very flexible. This is illustrated in this example texture from the spell Insectoplasm:

Note how tiles C and D are not only anamorphic but also have overlapping blank areas. Some of these tiles are smaller than the originals but I was able to preserve as much detail as possible with careful placement of the tile boundaries.
The TGE particle system allows emitters to mix particles with two different blend operations. In TGE, the default blend is an additive-alpha style, while useInvAlpha=true produces a lerp-alpha style. These blends often get mixed when creating fire with dark smoke. For the fire you want a bright additive blend, and for the smoke you want a darker interpolated blend. The TGEA particle system only allows one blend style per emitter, so you cannot create this kind of effect the same way as in TGE. Instead you can use TGEA's more flexible particle blend system to choose a more appropriate blend style.
As I mentioned in my last post, this link describes how you can use an alternative blend style combined with textures with pre-multiplied alpha to achieve similar results without switching blends midstream. In the AFX bonfire spell, Light My Fire, there are several emitters that mix fire and smoke in this way. The link above makes it sound like changing to a pre-multiplied-alpha is easy, but in practice it's very tricky and extremely non-intuitive if the original particle emitters are varying color and alpha on top of everything else. Still, after much fiddling with particle parameters, and experimental adjustment of the alpha and color channels in the texture, I was able to achieve emitter behavior and appearance that is pretty close to the originals. The screenshot below shows particles from the Light My Fire bonfire effect running under TGEA. Other aspects of the effect, such as lighting and zodiacs are disabled here:

It was a lot more work and took a lot longer than originally anticipated but the particle effects portion of AFX for TGEA is mostly finished and working well.
#34
03/18/2007 (11:13 am)
Looks great and definitely good to hear that it works :)
#35
03/18/2007 (11:27 am)
Sounds great I can't wait until it's ready. It will save me a lot of time. It's going to fit perfectly with my current side project.
#37
03/19/2007 (4:00 am)
Why not make a shader constant that you can pass into the pixel shader and allow a per particle texture region "blendfunc" value to pass into it? Read that value in the PS and do the blending accordingly?
#38

I'm sure it's pretty hard to tell that the above image is from TGEA, but it demonstrates the results of my first serious stab at making zodiacs work in the advanced engine.
So far, it's only interior zodiacs that are working, which I took on first because TGEA implementation of interiors seems to have undergone less overall change than the changes with legacy terrain. Still, I had to do an awful lot of study and experimentation with TGEA to begin to sort out and understand how the new rendering pipeline works. That makes this is a significant milestone, as it demonstrates that I've finally learned enough to make TGEA render some new things.
At this point, interior zodiacs appear to be fully functioning and all the zodiacs used in existing effects look just like they do under AFX for TGE. This includes layered zodiacs, an area I was nervous about getting to look the same in both engines. I'm still not certain if I've got the zodiac rendering in the best place in the overall rendering pipeline and plan to do some experimentation with alternative placements, but it's a great relief to see these effects rendering correctly in the new engine.
04/02/2007 (9:16 am)
Finally... AFX zodiacs make an appearance in TGEA.
I'm sure it's pretty hard to tell that the above image is from TGEA, but it demonstrates the results of my first serious stab at making zodiacs work in the advanced engine.
So far, it's only interior zodiacs that are working, which I took on first because TGEA implementation of interiors seems to have undergone less overall change than the changes with legacy terrain. Still, I had to do an awful lot of study and experimentation with TGEA to begin to sort out and understand how the new rendering pipeline works. That makes this is a significant milestone, as it demonstrates that I've finally learned enough to make TGEA render some new things.
At this point, interior zodiacs appear to be fully functioning and all the zodiacs used in existing effects look just like they do under AFX for TGE. This includes layered zodiacs, an area I was nervous about getting to look the same in both engines. I'm still not certain if I've got the zodiac rendering in the best place in the overall rendering pipeline and plan to do some experimentation with alternative placements, but it's a great relief to see these effects rendering correctly in the new engine.
#39
04/02/2007 (9:24 am)
Excellent news Jeff. Here's hoping you get Zodiacs going on Atlas terrain!
#40
04/02/2007 (9:40 am)
Wow.... it's like a dream slowly turning into reality :)


Torque 3D Owner Ashley Leach
I appreciate your response, and the difficulty of the task (i'm glad it isnt my job :) )
The game is designed around new uses of AI :) so it should port nicely.
I dont imagine the project would extend past 1st quarter 2008. I would need to have finalised the engine and prototype well before then regardless.
TGE is still a great engine, and with AFX things should be great for us, but shaders and atlas are pretty :)
Still keep us all posted on progress with all aspects of AFX, its really really great tech :)
Kind Regards,
Ashley Leach
www.silhouette-studios.com.au