WARNING : This site is outdated and the PopcornFX team will no longer answer your questions here.
For all support questions please go to our Discord server
0 like 0 dislike

I'm attempting to create a rain particle effect and I have most of it set up. The issue I'm having is that the collision system I have set up does not seem to hit objects accurately, for example; I have a mesh of a car and the rain particle effect is intended to hit the roof of the car and die. This does not happen, what instead happens is the rain will pass through the roof of the car and hit the bottom where it will then be destroyed. 

Rather than using the normal physics collision that is provided in the physics & Collision nodes, I use this script in the evolvers script node; 

function void    Eval()
    float3    raycastStart = StartPosition;
    float3    raycastStop = Position;
    float3    raycastVec = raycastStop - raycastStart;
    float3    raycastDir = safe_normalize(raycastVec, raycastVec);
    float    raycastDist = length(raycastVec);
    int4    hit = scene.intersectExt(raycastStart,
    float    hitDist = scene.unpackDist(hit);
    int     SurfaceTypeID = scene.unpackSurfaceType(hit);
    float3    hitPosition = raycastStart + raycastDir * hitDist;
    float3    hitUp = scene.unpackNormal(hit);
    float3    hitForward = cross(float3suf(0, -hit.f, hit.+ 0.01), hitUp);
    int con = isfinite(hitDist);

is there anything else I can do to improve the accuracy of the collisions or am I missing something that is required for this to work effectively? 

by Jamesking96 (960 points)

1 Answer

0 like 0 dislike

Hi James,

You can have a look at CollisionSurfaceTypes.pkfx example file in the ReleaseHighlights project pack, this will show an example of extracting surface types and doing manual scene intersection queries.

Now if you do not need to extract the colliding surface type, just use the regular scene.intersect() function. There are other effects showing its usage.

Does your effect have a correct behaviour in PK-Editor ? You can bring your car model inside the editor, then add it as a 3D model backdrop and see how your rain effect reacts to the car.

Depending on how it behaves it will help you/us better identify the problem.


by HugoPKFX (17.7k points)
Hi Hugo,

Sorry for the late reply but I had a look at the examples and they proved useful. Though I didn't end up using the approaches used in these examples as with the model I am working with the particles that collide have an issue where they slip through the model allowing for you to see them before they are destroyed. My *fix* for this was to just increase the raycastDist value so that the particles would register the collision sooner.

Thanks for your support anyway the examples are still very useful to look at.