RangerMcFriendly@Posted: Mon Dec 20, 2010 10:52 am :
Hello everyone, it is I again. The last time I was here browsing the forums someone mentioned that one of the Doom 3 engine's limitations was its lack of ability for the unified lighting to interact with particles. This is something I have not really investigated until recently. While looking at the stock particle textures, I did notice that the hellmaggot texture also has its own specular and normal map. If the particles don't interact with light, what would be the use? Well, they can, but not very well. This probably isn't news, as it may have been discussed here before. I did a modest search and found nothing so I apologize if this old news and there is another topic.

However, even if this isn't news, I'd still like to discuss this. I used one of my own cloud textures and made it a specular and normal map and tested to see if it would work. It did and I'm impressed, though not without its faults. If you haven't tried it you should. Here is an example.

Code:
textures/particles/TEST/TEST_4
{
   noSelfShadow
   noshadows
   translucent
   discrete
   twosided
   nonsolid
   noimpact

   qer_editorimage      textures/particles/LIGHTTEST/cloud_test.tga

   {
       blend  diffusemap
       map    textures/particles/LIGHTTEST/cloud_test.tga
          vertexcolor
   }
   {
       blend  bumpmap
       map    textures/particles/LIGHTTEST/cloud_test_local.tga
      vertexcolor

   }
   {
       blend  specularmap
       map    textures/particles/LIGHTTEST/cloud_test_s.tga
      vertexcolor

   }
   
}


Image Image Image Image

Diffusemap, bumpmap, and specularmap all react to light, so you can actually just have one layer instead of three to get this to work without having to have 3 different textures. I've tested to see how they render individually and the particles seem to have more issues rendering when done individually, however there are a lot of issues anyways and I will explain that later. If you want to use one layer, I would suggest using any texture with a black background using either diffusemap or specularmap blend methods. Bumpmap will just render extremely white and diffusemap with an alpha background renders a bit odd like a blend texture being blended using the "add" method (very sensitive).

Rendering with 3 layers does not seem to reduce performance anymore than you would with just one layer. In fact, the textures seem to be a bit more reliable with 3 layers and better looking unless you don't want your fog to look bumpy shiny, but this is just my observation. Maybe it is just my system. The real issue is that the Doom 3 engine does not like rendering particles that react to light very well and it can be very demanding on the system. The particles will only be rendered at certain angles or when viewed at a certain position. I can't "technically" explain this, but when Doom 3 doesn't want to render particles for me it is typically due to using larger textures, too many particles on screen, or particles being stretched too big. It could also possibly be an issue with my GPU. The Doom 3 dev site says to use bounds expansion and increase it to a high value when particles don't get rendered when they should, but it has never worked for me. Bug?

http://www.youtube.com/watch?v=j8LInFS6Fdo

Download the test particle room here!

Anyways, I made a video demonstrating these particles in practice. You'll see exactly what I am talking about. I don't know what potential this has because particles interacting with light is very expensive and they are very buggy. How much of this can be optimized or corrected through coding is beyond me, but if anyone could post some insight, that would be great. The only thing I seem to be good at is particles so whatever I can contribute through this avenue would make me feel like I have not wasted so much time haha. Currently I am giving all the weapon particles a good face lift and right now I am almost done. No gameplay changes like my greenplasma skin, just particle, decal, and light effects.

A few other things I should mention is that I noticed that disabling the materials "twosided" actually hurts performance. Odd. The video mentions this, but it seems the only way these particles will render is like the "add" method, and no "blend" method. Also, decals render on top and is very noticeable, especially large burn marks. :P Well anyways if anyone wants me to pack the test map and particles I used for this I can do that, though it wasn't hard to do this myself. Take care. Bye.



rich_is_bored@Posted: Mon Dec 20, 2010 12:24 pm :
This...

Code:
textures\mytexture
{
   bumpmap   textures\custom\image1.tga
   diffusemap   textures\custom\image2.tga
   specularmap   textures\custom\image3.tga
}


... is shorthand for this...

Code:
textures\mytexture
{
   {
      blend   bumpmap
      map   textures\custom\image1.tga
   }
   {
      blend   diffusemap
      map   textures\custom\image2.tga
   }
   {
      blend   specularmap
      map   textures\custom\image3.tga
   }
}


It's three stages either way. Also if any light interaction stage (diffuse, bump, specular) is used, all three will be calculated. When a stage is missing, the engine simply falls back to a set of internal images like _black, _white, or _flat.

The additive effect you see is a result of using the translucent keyword. All it does is average the color with what's already in the frame buffer. So when you have a large number of particles overlapping you end up with something like this...

Code:
Source   Destination   Average
White   Black      50% Grey
White   50% Grey   25% Grey
White   25% Grey   12.5% Grey
...


I don't quite understand the use of vertexcolor in your material shader. I don't think particles have a vertex color so that's probably not doing anything.



RangerMcFriendly@Posted: Mon Dec 20, 2010 1:00 pm :
Thanks for that tip. That will make my material shaders less cluttered :b

You have to have translucent or it won't render the black as transparent for some reason. No fade in or out either. Maybe just using a transparent texture alone it may render as blend but I have not tested that yet. Vertexcolor allows it to be colored in the particle editor, or else it will just appear colored as is. Checking "entity color" in the particle editor is essentially the same as disabling vertexcolor anyways.

I just copied over hell maggots material shading and modified it btw.



RipOutTheWings@Posted: Mon Dec 20, 2010 4:26 pm :
can you upload the textures you use?



RipOutTheWings@Posted: Mon Dec 20, 2010 8:21 pm :
Quote:
anyone wants me to pack the test map and particles

man, it would be great
please :D



RangerMcFriendly@Posted: Mon Dec 20, 2010 9:13 pm :
Okay I'll pack it. Let me make a new map real quick to combine the 3 I made.



RipOutTheWings@Posted: Mon Dec 20, 2010 11:00 pm :
ok man :D



RangerMcFriendly@Posted: Mon Dec 20, 2010 11:08 pm :
Okay, I've made the map and attached it to this post. It was essentially 3 test maps I had merged into 1. You will spawn in a hallway that leads to three rooms. The first room has a rotating orange light with fog, the second room has no light with fog, and the last room has a projected light hitting the floor with fog streaming through it. Hope you enjoy it.

The map name is lightparticle_test.



RipOutTheWings@Posted: Mon Dec 20, 2010 11:45 pm :
hm
it looks sharp and strange =/ bugs?
in your video it looks amazing



RipOutTheWings@Posted: Mon Dec 20, 2010 11:49 pm :
the problem is in diffuse texture



gavavva@Posted: Tue Dec 21, 2010 12:36 am :
The other problem is your not using power of two textures, but thats not a major thing, it will just result in ugly visuals.



RangerMcFriendly@Posted: Tue Dec 21, 2010 1:12 am :
RipOutTheWings wrote:
hm
it looks sharp and strange =/ bugs?
in your video it looks amazing


Hmm. I emptied out my base folder and tested out this pack to see if everything works and I didn't have any issues. It looks like only the diffuse stage is rendering. If you modify it to render with only diffuse, the diffuse texture needs a black background. The one I packed is transparent. You could use the specular texture though. Hopefully you get it to work, it looks great.

gavavva wrote:
The other problem is your not using power of two textures, but thats not a major thing, it will just result in ugly visuals.


What do you mean not using power of two textures?



BNA!@Posted: Tue Dec 21, 2010 1:27 am :
RangerMcFriendly wrote:
gavavva wrote:
The other problem is your not using power of two textures, but thats not a major thing, it will just result in ugly visuals.


What do you mean not using power of two textures?


He likely means 2x2, 128x128, 256x256 or 512x512... and so on.



RangerMcFriendly@Posted: Tue Dec 21, 2010 1:39 am :
Ahh I see. I usually make my textures 256 or 512 in size. I'll try the particles in 256 and see what that does.



New Horizon@Posted: Tue Dec 21, 2010 4:33 am :
Yeah, your textures in the test folder are 350 x 350....the game engine doesn't like that.



RangerMcFriendly@Posted: Tue Dec 21, 2010 6:02 am :
I scaled the textures to 256. There isn't any noticeable difference. Plus, those lovely plasma and bfg particles you see are 350x350 and they perform magically as well but that was an error on my part for basing those textures on an older nebula texture I made at 350x350 and never bothered to scale it.



gavavva@Posted: Tue Dec 21, 2010 3:54 pm :
Oh, but there IS a difference :p You will be forcing the GPU to downscale the texture to its nearest neighbour which in this case would be 256x256. That means not only will you get some pretty poor blurred textures, but it will also be slower to call them into memory. Its much better to make them the correct size right off the bat, because then what you see is what you get. It may not seem like it makes a HUGE difference in a case like this, but it all adds up.



RangerMcFriendly@Posted: Tue Dec 21, 2010 4:48 pm :
You're right, I learned my lesson :>



RipOutTheWings@Posted: Tue Dec 21, 2010 6:29 pm :
How to optimize the perfomance? cuz its not all right (its strange, cuz crysis on ultra - 30-40fps)



rebb@Posted: Tue Dec 21, 2010 7:30 pm :
Crysis came after Doom3 - and has many more optimizations and tricks going on under the hood that weren't known or widespread when Doom3 was in development. Not to mention being able to use specialized shaders with access to lighting information.

Rendering lots of overlapping translucent surfaces in Doom3 where each one uses full light/bump interactions is just bound to cripple performance.
Standard opaque/alphatested surfaces use the early-Z test to prevent useless calculations, translucent ones don't.



RipOutTheWings@Posted: Tue Dec 21, 2010 7:48 pm :
I understand it
but it must be a way



New Horizon@Posted: Tue Dec 21, 2010 11:53 pm :
Editing the particle file from a count of 100 to 50 particles helped and still looked good. It could be a nice effect for a dusty room.



Serpentine@Posted: Wed Dec 22, 2010 3:49 am :
gavavva wrote:
Oh, but there IS a difference :p You will be forcing the GPU to downscale the texture to its nearest neighbour which in this case would be 256x256. That means not only will you get some pretty poor blurred textures, but it will also be slower to call them into memory. Its much better to make them the correct size right off the bat, because then what you see is what you get. It may not seem like it makes a HUGE difference in a case like this, but it all adds up.


Well kinda, it will usually just pad to the next highest POT x POT and adjust UV's the the expected area, so you get a padded uncompressed texture. However it also tries to use the opengl extension for hardware support for NPOT textures. If this happens to be a texture that's DXT compressed and not diffuse... it get's all kind of retarded about things as it will pad the texture and then use the incorrect mapping. Nvidia seems to have worked around this but gives a lot of banding. AMD seems to accept that doom3 knows what its doing, but since the logic is all kinds of wrong it results in doom3 falling over on some hardware/driver combos and on others will just skip the stage.

In short : it's the worst thing ever, always, always make sure you're power of two :)

Back on topic : a fun trick to make completely opaque and alpha blended materials (you still cant get light on the stage tho), you can use map add (map1, map1), were map1 is a half depth version of the texture you want, aka you only have 0-127 per channel. This then isnt 50% opaque and isnt fullbright :)
Might be fun to use for these particles so that they have some diffuse without the specular.

You can mix that with a normal diffuse stage to give softened edges(ignorealphatest) and still get some light on the diffuse section(alphatest)... but it's somewhat limited :(



RipOutTheWings@Posted: Tue Dec 21, 2010 7:48 pm :
I understand it
but it must be a way



New Horizon@Posted: Tue Dec 21, 2010 11:53 pm :
Editing the particle file from a count of 100 to 50 particles helped and still looked good. It could be a nice effect for a dusty room.



Serpentine@Posted: Wed Dec 22, 2010 3:49 am :
gavavva wrote:
Oh, but there IS a difference :p You will be forcing the GPU to downscale the texture to its nearest neighbour which in this case would be 256x256. That means not only will you get some pretty poor blurred textures, but it will also be slower to call them into memory. Its much better to make them the correct size right off the bat, because then what you see is what you get. It may not seem like it makes a HUGE difference in a case like this, but it all adds up.


Well kinda, it will usually just pad to the next highest POT x POT and adjust UV's the the expected area, so you get a padded uncompressed texture. However it also tries to use the opengl extension for hardware support for NPOT textures. If this happens to be a texture that's DXT compressed and not diffuse... it get's all kind of retarded about things as it will pad the texture and then use the incorrect mapping. Nvidia seems to have worked around this but gives a lot of banding. AMD seems to accept that doom3 knows what its doing, but since the logic is all kinds of wrong it results in doom3 falling over on some hardware/driver combos and on others will just skip the stage.

In short : it's the worst thing ever, always, always make sure you're power of two :)

Back on topic : a fun trick to make completely opaque and alpha blended materials (you still cant get light on the stage tho), you can use map add (map1, map1), were map1 is a half depth version of the texture you want, aka you only have 0-127 per channel. This then isnt 50% opaque and isnt fullbright :)
Might be fun to use for these particles so that they have some diffuse without the specular.

You can mix that with a normal diffuse stage to give softened edges(ignorealphatest) and still get some light on the diffuse section(alphatest)... but it's somewhat limited :(



RipOutTheWings@Posted: Tue Dec 21, 2010 7:48 pm :
I understand it
but it must be a way



New Horizon@Posted: Tue Dec 21, 2010 11:53 pm :
Editing the particle file from a count of 100 to 50 particles helped and still looked good. It could be a nice effect for a dusty room.



Serpentine@Posted: Wed Dec 22, 2010 3:49 am :
gavavva wrote:
Oh, but there IS a difference :p You will be forcing the GPU to downscale the texture to its nearest neighbour which in this case would be 256x256. That means not only will you get some pretty poor blurred textures, but it will also be slower to call them into memory. Its much better to make them the correct size right off the bat, because then what you see is what you get. It may not seem like it makes a HUGE difference in a case like this, but it all adds up.


Well kinda, it will usually just pad to the next highest POT x POT and adjust UV's the the expected area, so you get a padded uncompressed texture. However it also tries to use the opengl extension for hardware support for NPOT textures. If this happens to be a texture that's DXT compressed and not diffuse... it get's all kind of retarded about things as it will pad the texture and then use the incorrect mapping. Nvidia seems to have worked around this but gives a lot of banding. AMD seems to accept that doom3 knows what its doing, but since the logic is all kinds of wrong it results in doom3 falling over on some hardware/driver combos and on others will just skip the stage.

In short : it's the worst thing ever, always, always make sure you're power of two :)

Back on topic : a fun trick to make completely opaque and alpha blended materials (you still cant get light on the stage tho), you can use map add (map1, map1), were map1 is a half depth version of the texture you want, aka you only have 0-127 per channel. This then isnt 50% opaque and isnt fullbright :)
Might be fun to use for these particles so that they have some diffuse without the specular.

You can mix that with a normal diffuse stage to give softened edges(ignorealphatest) and still get some light on the diffuse section(alphatest)... but it's somewhat limited :(



RipOutTheWings@Posted: Tue Dec 21, 2010 7:48 pm :
I understand it
but it must be a way



New Horizon@Posted: Tue Dec 21, 2010 11:53 pm :
Editing the particle file from a count of 100 to 50 particles helped and still looked good. It could be a nice effect for a dusty room.



Serpentine@Posted: Wed Dec 22, 2010 3:49 am :
gavavva wrote:
Oh, but there IS a difference :p You will be forcing the GPU to downscale the texture to its nearest neighbour which in this case would be 256x256. That means not only will you get some pretty poor blurred textures, but it will also be slower to call them into memory. Its much better to make them the correct size right off the bat, because then what you see is what you get. It may not seem like it makes a HUGE difference in a case like this, but it all adds up.


Well kinda, it will usually just pad to the next highest POT x POT and adjust UV's the the expected area, so you get a padded uncompressed texture. However it also tries to use the opengl extension for hardware support for NPOT textures. If this happens to be a texture that's DXT compressed and not diffuse... it get's all kind of retarded about things as it will pad the texture and then use the incorrect mapping. Nvidia seems to have worked around this but gives a lot of banding. AMD seems to accept that doom3 knows what its doing, but since the logic is all kinds of wrong it results in doom3 falling over on some hardware/driver combos and on others will just skip the stage.

In short : it's the worst thing ever, always, always make sure you're power of two :)

Back on topic : a fun trick to make completely opaque and alpha blended materials (you still cant get light on the stage tho), you can use map add (map1, map1), were map1 is a half depth version of the texture you want, aka you only have 0-127 per channel. This then isnt 50% opaque and isnt fullbright :)
Might be fun to use for these particles so that they have some diffuse without the specular.

You can mix that with a normal diffuse stage to give softened edges(ignorealphatest) and still get some light on the diffuse section(alphatest)... but it's somewhat limited :(