Jump to content
The Dark Mod Forums

Particle Collisions and Cutoff Feature


Recommended Posts

I just recently became aware of this feature: https://wiki.thedarkmod.com/index.php?title=Particle_collisions_and_cutoff

Unfortunately I completely missed it, as when I went to create weather effects in my FMs I just followed this (which doesn't mention it): https://wiki.thedarkmod.com/index.php?title=A_-_Z_Beginner_Full_Guide_Page_3#Rain_and_Snow

The point of this thread is to a) make people aware of it and b) gather feedback from any mappers that have used it so we can get some mapper-focused documentation in the Wiki.  The page above is great for background information about how it works, but as a mapper I really just want to know:

  • What are the limitations of this (i.e. when should it be used and when shouldn't it be used)?
  • Why isn't it the default behaviour?  Why all this work to get it into the map?
  • What built-in support for it exists (particle definitions, materials, etc). Do I need to create all this stuff myself?
  • Texture layout vs. Linear layout: what's the difference in the end, pros/cons, why would I use one over the other...
  • Why does it need a separate command (runParticle)? Can this just not be bundled in with dmap?
  • A clear, step-by-step instruction on how to implement it in a map from beginning to end using a simple use case.

Tagging some users who have relevant experience with this: @stgatilov @Goldwell @Amadeus

Edited by Frost_Salamander
Link to comment
Share on other sites

So, I do have some experience using the particle collisions for Written in Stone. At the time of development, I had to make custom weather particle and material defs in order to get it to work properly. Honestly, while the system is nice when it does work, it is complicated, quite a lot of work on part of the mapper, and can be very finicky. A minor change to the map can break the system (to which, the runParticle command needs to be run again after mapping).

One thing I don't get is why TDM doesn't have core materials that support particle collision right out of the box. There is a small handful of rain materials that support this, but most of the core weather textures, and particularly snow textures, all use "deform particle2" even though that is not supported by particle collision; "deform particle" is the correct keyword for this (as per the article here

I can't imagine why a mapper would ever want rain and snow to pierce through brushwork, like a ceiling in a house. And even if the mapper did want that, they could simply place a weather patch on the ceiling to make that happen.

Edited by Amadeus
  • Like 1
Link to comment
Share on other sites

I also did find one interesting issue this morning when going through Written in Stone. It seems like the snow particles got cut off at a visportal, which I imagine is a bug:
 

tbc (2024-01-04 08-22-03) (-3233.6 -1950.25 139.84).jpg

  • Like 1
Link to comment
Share on other sites

Particle collisions cannot be computed in realtime, particles are purely graphical effect which cannot interact with collisions. So the collisions have to be precomputed beforehand, just like dmap precomputes triangulations of brushes. Most of the nuances grow from here.

Quote

Why does it need a separate command (runParticle)? Can this just not be bundled in with dmap?

It was possible in theory to run it automatically during dmap (just like e.g. you never have to run aas tool directly, because dmap calls it automatically), but I'm afraid it would annoy everyone because it may take quite a lot of time depending on settings.

Now that some people have some practice with this, should we change it?

Quote

What are the limitations of this (i.e. when should it be used and when shouldn't it be used)?

Most importantly, collisions are precomputed statically.

If you move the emitter, the collision information becomes wrong.
All objects which seem dynamic are automatically excluded from precomputation, so the particles will still go straight through all the guards and moveables.

Quote

Why isn't it the default behaviour?

What do you mean by "default" behavior?
Default behavior of what? particles?

Like make all particle emitters stop on collisions automatically?
What about cases when mapper wanted particles to pierce walls?
What about moving particle emitters?

Quote

  Why all this work to get it into the map?

The goal was to reduce amount of work actually.
As soon as you are able to set one huge particle emitter over the whole map, I think you don't have to mess with it any more, just remember to execute runParticle occasionally when you want up-to-date collisions.

Before that, mapper had to split the rain patch into many patches and manually tweak every patch so that it stops at proper height. As far as I understand, it was very time-consuming and painful.

As for areaLock, it does not restrict particles to single area. It only disables the whole system if renderer proves player does not see the specified area. As long as the door is open, you should still see rain falling indoors, no?

Quote

Texture layout vs. Linear layout: what's the difference in the end, pros/cons, why would I use one over the other...

Yeah, this is a tough question.

Texture layout:

  • Only works properly if particle evolves exactly the same way if emitted from the same location.
  • Interacts with texturing: requires you to set non-overlapping texcoords in 0..1 range on the emitting surface.
  • The only option in TDM 2.08. Ok for straight-falling rain, but snow is out of question.

Linear layout:

  • Only works for a periodic system, i.e. the whole system exactly repeats itself after some time.
  • Precomputation might take a lot of time, especially if you insist on a large period.
  • [problem for maintainers like me] If particle code is changed in TDM engine, the collisions must be recomputed.
  • Was added in TDM 2.09. Supports pretty much any kind of particles, although snow was the main goal.
  • Like 3
Link to comment
Share on other sites

2 minutes ago, stgatilov said:

What about cases when mapper wanted particles to pierce walls?

This does seem like it would be an edge case mostly. I know I wouldn't want to see smoke break geometry, sparks, etc., but I'm happy to be corrected on this. But at the very least, I think the weather particles (like snow and rain) should support particle collision right out of the gate, and it currently doesn't.

  • Like 1
Link to comment
Share on other sites

19 minutes ago, Amadeus said:

One thing I don't get is why TDM doesn't have core materials that support particle collision right out of the box. There is a small handful of rain materials that support this, but most of the core weather textures, and particularly snow textures, all use "deform particle2" even though that is not supported by particle collision; "deform particle" is the correct keyword for this

Because that we would have to copy/paste all rain materials to introduce "deform particle" version. Note that we cannot delete "deform particle2" versions because they are already used, and they cannot be replaced that easily.

Then we would have to copy everything again in order to add versions with collisions.
But I'm sure mappers might want to create rain patches of different size, so we'll probably have to have versions with layout texture 1024 1024, layout texture 512 512, layout texture 256 256, etc.
And then different mappers might have different feelings about the balance between quality and waiting time in case of layout linear, so we'll have many versions of snow too.

All of this causes combinatorial explosion, and we'll get at least ten times more materials and particle decls than we have now, causing a lot of confusion.

Perhaps combinatorial explosion can be avoided if these settings are specified in another file. I guess at that moment I was not brave enough to introduce a new type of decl files.

  • Like 2
Link to comment
Share on other sites

Posted (edited)
1 hour ago, stgatilov said:

It was possible in theory to run it automatically during dmap (just like e.g. you never have to run aas tool directly, because dmap calls it automatically), but I'm afraid it would annoy everyone because it may take quite a lot of time depending on settings.

Now that some people have some practice with this, should we change it?

I haven't personally run it so not sure how long it actually takes.  @Amadeus how long did it take for WIS?

@stgatilov To make runParticle part of dmap,  is there a way to check if runParticle needs to be run or not first?  For example, if there are no particles present with 'collisionStatic' keyword than just skip it.  I wouldn't say this is big deal, but it's a manual step that the mapper could easily forget to run on release day...

 

1 hour ago, stgatilov said:

What do you mean by "default" behavior?
Default behavior of what? particles?

I meant the default weather materials - but Amadeus covered that in his question - thanks.

1 hour ago, stgatilov said:

As for areaLock, it does not restrict particles to single area. It only disables the whole system if renderer proves player does not see the specified area. As long as the door is open, you should still see rain falling indoors, no?

Actually this doesn't seem to be the case.  The rain seems to stay outside the visleaf if the door is open. In the example screenshot from inside the Inn in In Plain Sight, the rain patch actually extends over the roof of this building.  With the door open, the rain 'stays outside'.  However, you're right and still with this method you need to use individual patches and place them carefully (although I didn't have to worry about the height).  It's not perfect because rain will still poke through awnings and stuff outside.

 

ips-rain.jpg

Edited by Frost_Salamander
Link to comment
Share on other sites

2 hours ago, Frost_Salamander said:

Unfortunately I completely missed it, as when I went to create weather effects in my FMs I just followed this (which doesn't mention it): https://wiki.thedarkmod.com/index.php?title=A_-_Z_Beginner_Full_Guide_Page_3#Rain_and_Snow

IMO there should be a warning of some sorts on this page. This tutorial was written by Fidcal ages ago, and there are possibly tons of things that might be severely outdated, and practices that would better be discouraged.

  • Like 2
Link to comment
Share on other sites

Just now, peter_spy said:

IMO there should be a warning of some sorts on this page. This tutorial was written by Fidcal ages ago, and there are possibly tons of things that might be severely outdated, and practices that would better be discouraged.

yeah totally.  One of the outputs of this discussion will be to update that page.

Link to comment
Share on other sites

16 minutes ago, Frost_Salamander said:

Actually this doesn't seem to be the case.  The rain seems to stay outside the visleaf if the door is open. In the example screenshot from inside the Inn in In Plain Sight, the rain patch actually extends over the roof of this building.  With the door open, the rain 'stays outside'.

I'm not sure you are right. It seems that it is limited by area scissor.
Basically, take axis-aligned 2D bounding box of the door visportal: that would be the scissor of the outer area. The particles should be limited to this rectangle only.

If you move around, this rectangle will change of course.

Link to comment
Share on other sites

20 minutes ago, Frost_Salamander said:

I haven't personally run it so not sure how long it actually takes.  @Amadeus how long did it take for WIS?

 

so, "runParticle written" took 26 seconds... yeah, that's no small amount of time. Granted, WIS is a large map

Edited by Amadeus
  • Like 1
Link to comment
Share on other sites

27 minutes ago, Frost_Salamander said:

yeah totally.  One of the outputs of this discussion will be to update that page.

And hopefully update the particle collision page to provide clear step-by-step instructions for mappers on how to set up rain and snow particle collisions. In my opinion, it seems like weather effects will be the most common use case for this collision system, so simple instructions on how to prevent rain/snow from falling through an interior ceiling will be useful for most mappers 

Link to comment
Share on other sites

1 hour ago, stgatilov said:

I'm not sure you are right. It seems that it is limited by area scissor.
Basically, take axis-aligned 2D bounding box of the door visportal: that would be the scissor of the outer area. The particles should be limited to this rectangle only.

If you move around, this rectangle will change of course.

Well, if you say so.  If I remove the 'areaLock' spawnarg from the rain patches, it falls through the roof and it looks the same whether the door is open or closed.  I'm just saying that opening the door doesn't seem to make the rain appear inside as you suggested above.

Regardless, I'm not advocating the areaLock method, just reporting observations.

Link to comment
Share on other sites

  • 2 weeks later...

@Frost_SalamanderIt has been a good minute since i've played with particle collisions with rain, however I decided to revisit it after seeing your post and I can't seem to get it working.

 

@stgatilov could you please confirm if this is the right flow as it doesn't seem to be working in my map:

 

1) Create a .prt file containing:

   particle rain2_heavy2024 {
       {
           count               100
           material            textures/particles/drop2
           time                0.500
           cycles              0.000
           bunching            1.000
           distribution        rect 0.000 0.000 0.000
           direction           cone "0.000"
           orientation         aimed 0.000 0.040
           speed               "1000.000"
           size                "0.500" 
           aspect              "1.000" 
           randomDistribution  0.000
           fadeIn              0.200
           fadeOut             0.000
           color               0.040 0.040 0.040 1.000
           fadeColor           0.000 0.000 0.000 1.000
           offset              0.000 0.000 0.000
           gravity             0.000

		   collisionStatic
		   mapLayout			texture 512 512
       }
   }

 

2) Create a .mtr file containing:

   textures/darkmod/weather/rain2_heavy2024mtr
   {
       deform particle rain2_heavy2024
       qer_editorimage textures/editor/rain
       nonsolid
       noshadows
       {  //needed to emit particles
           blend   filter
           map      _white
       }
   }

3) Create the appropriate patch in game applying the above texture to it (with the texture fit to it and it facing down)

4) dmap missionname.map

5) runparticle missionname.map

 

But ingame the rain just ignores the brushes and falls right through:

NaggJnc.png

 

Even using "particle_collision_static_blocker" "1" on this water entity, had no impact

oNn87wR.png

  • Like 1
Link to comment
Share on other sites

On 1/13/2024 at 6:10 AM, Goldwell said:

3) Create the appropriate patch in game applying the above texture to it (with the texture fit to it and it facing down)

4) dmap missionname.map

5) runparticle missionname.map

Any warning during dmap?

Does your patch have [0..1] non-overlapping texcoords?

Link to comment
Share on other sites

1 hour ago, stgatilov said:

Any warning during dmap?

Does your patch have [0..1] non-overlapping texcoords?

No warnings during dmap

 

re: the patch, how do I check if a patch has a "[0..1] non-overlapping texcoords"?

Is it correct in interpreting that to mean the texture has been fit to the patch? If so then yes.

image.png.7819a7a2662b9bdfb39908131a0f6f97.png

 

This is the patch copied from DR if that helps:

 

<?xml version="1.0" encoding="utf-8"?>
<map version="1" format="portable">
  <layers>
    <layer id="0" name="Default" parentId="-1" active="true" hidden="false"/>
  </layers>
  <selectionGroups>
    <selectionGroup id="415" name=""/>
    <selectionGroup id="416" name=""/>
    <selectionGroup id="417" name=""/>
    <selectionGroup id="418" name=""/>
    <selectionGroup id="420" name=""/>
    <selectionGroup id="421" name=""/>
    <selectionGroup id="423" name=""/>
    <selectionGroup id="424" name=""/>
  </selectionGroups>
  <selectionSets/>
  <properties>
    <property key="EditTimeInSeconds" value="20837"/>
    <property key="LastCameraAngle" value="69 332.186 0"/>
    <property key="LastCameraPosition" value="20.0088 1653.64 531.677"/>
    <property key="LastShaderClipboardMaterial" value="textures/darkmod/nature/snow/snow_rough01"/>
  </properties>
  <entity number="0">
    <primitives>
      <patch number="0" width="3" height="3" fixedSubdivisions="false">
        <material name="textures/darkmod/weather/rain2_heavy2024mtr"/>
        <controlVertices>
          <controlVertex row="0" column="0" x="-448.000000" y="1712.000000" z="720.000000" u="0" v="0"/>
          <controlVertex row="1" column="0" x="-448.000000" y="1568.000000" z="720.000000" u="0" v="0.500000"/>
          <controlVertex row="2" column="0" x="-448.000000" y="1424.000000" z="720.000000" u="0" v="1.000000"/>
          <controlVertex row="0" column="1" x="-76.000000" y="1712.000000" z="720.000000" u="0.500000" v="0"/>
          <controlVertex row="1" column="1" x="-76.000000" y="1568.000000" z="720.000000" u="0.500000" v="0.500000"/>
          <controlVertex row="2" column="1" x="-76.000000" y="1424.000000" z="720.000000" u="0.500000" v="1.000000"/>
          <controlVertex row="0" column="2" x="296.000000" y="1712.000000" z="720.000000" u="1.000000" v="0"/>
          <controlVertex row="1" column="2" x="296.000000" y="1568.000000" z="720.000000" u="1.000000" v="0.500000"/>
          <controlVertex row="2" column="2" x="296.000000" y="1424.000000" z="720.000000" u="1.000000" v="1.000000"/>
        </controlVertices>
        <layers>
          <layer id="0"/>
        </layers>
        <selectionGroups/>
        <selectionSets/>
      </patch>
    </primitives>
    <keyValues>
      <keyValue key="classname" value="worldspawn"/>
      <keyValue key="difficulty0Name" value="easy"/>
      <keyValue key="difficulty1Name" value="medium"/>
      <keyValue key="difficulty2Name" value="hard"/>
      <keyValue key="shop_skip" value="1"/>
    </keyValues>
    <layers>
      <layer id="0"/>
    </layers>
    <selectionGroups/>
    <selectionSets/>
  </entity>
</map>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...