Issue with multiple trimmed surfaces

Hi
I have a icosphere made up of a lot of trimmed surfaces.
Now I am trying to reflect light rays of this object using the mosquito plugin
but somehow it is having issues with the trimmed surfaces

→ when use the component untrimm you can see the issue very clearly

is there a solution for this?

thanks in advance

If that M thing is using the RayShoot Method, that’s expected since trims are NOT supported (see SDK comments on geometry). However you can do that with other ways (Notify if you need a C# that does it).

2 Likes

Hi
yes what would be the other way to do this?
and would this other way also work for refractions and not just reflections? as seen in image bewlow (has the same issue with trimmed surfaces)

thanks for your reply

Well … the bad news are:

1, I have related stuff (classic ccx + normal at closest point + reflection + …) but I’m not in the practice right now (and since there’s a critical F1 race in Japan this w/e [and MotoGP] … ).

2, I don’t use components (or add-ons) for baking by beans: just C# code. But you can pretend that this is some sort of add-on.

Until Monday … and staying on that RayShoot theme get this and have fun: Random (even or not) points are created on a Sphere (center at t on track curve) and then rays are shooted from the center to every point.

RayShoot_VS_Object_V23.gh (126.1 KB)
RayShoot_VS_Object_V23.3dm (278.1 KB)

See the trim issue: ray reflects on the BrepFace hole (because it doesn’t take into account the trim info).

On the other hand if a given BrepFace is NOT a Surface (meaning there’s trim around) one can use the BrepFace.IsPointOnFace Method and thus filter the results.

Not sure if it’s of some help to you, anyway attached is a demo using vanilla gh including IsoVist Ray.

RayReflections_re.gh (25.6 KB)

1 Like

Well … other than Kim’s native thingy … I’ve found at home a C# that does RayShoot stuff (without RayShoot) meaning that he respects trims and multi reflections (obviously: recursion at work here). For a refraction option it requires some lines of code more.

Anyway is 100% code and thus may not be your cap of tea (if not drop a word).

1 Like

Can’t you just convert your trimmed surfaces into a non-trimmed triangular surfaces?
(surface from 4 point with 2 consecutive point equal each-other)

Hi
i gues that solution works :slight_smile: I just tried it for one triangle and seems to be a good solution. Do you know if there is a fast way to do a large amount of trimmed surfaces at the same time (and not doing them manually)

I am very knew to GH (about 3weeks of use)
I thought of this but I am sure there is a better solution :rofl:

thanks for the tip :smiley:

Hi
I Just took a look at this. This looks promising. I have a script using mosquito components (see my long comment bellow). but this only works with surfaces. no breps meshes or untrimmed surfaces. this would be a good solution in changing that without having to have any knowladge of C#.
:smile:
Your help is very much appriciated
thanks

Hi
wow you are so helpfull. Thank you :smiley:
I have absolutly no knowledge of c# or any programming for that matter ^^

I am trying to create a little script that will simulate how light interacts with transparent opbjects and simulate CAUSTICS

I have already managed to make a script that works with simple surfaces but the script is having issues with trimmed surfaces and doesn’t work with meshes at all.

caustics are mad up of diffrent amount of bounces on the inside of the geometry as seen here:

i can manage on simple objects like a sphere. Each color is one part of the image above. just reflection. refraction refraction and then so.
I always culled away the rays that don’t end up hitting the ground plane because these don’t end up as caustics:

my goal is just to achive a script that can do exactly this with any tipe of geometry.

something I also had to concider was what happens when light rays exit the geometry (getting refracted) and are heading for the geometry again (getting refracted again)
as seen here

just as an insight to what I am doing :smiley:

You are very kind but I don’t think so: since your beans (native stuff) and mine (code) have nothing in common … I can hardly see any practical help from my side.

Anyway:

  1. The C# things (about 5 on that matter) that I have they don’t do business with meshes because I hate meshes. Meaning that some lines of code more are required. Since the general approach is “kinda” a RayShoot one (In fact is using classic Curve/Brep ccx events via a recursive Method) this is not a big deal. That said by Brep think any combo (solid or not) of trimmed BrepFaces or untrimmed ones. Like :

  1. As I said refraction requires also some lines of code more most notably ways to monitor a given ray segment (Snell matters: is it inside a brep? is it in free air?) .

I can’t promise any ETA … but maybe at some future time I could add the MIA capabilities 1/2 as above.

You are a wise man.

Anyway I’ve found 10 minutes to write a basic refraction Method: amuse yourself with these freaky lines that do freaky/ominous things (used in other freaky things) for computing the refraction of a given ray (inside or outside a solid).

1 Like

Thanks :slight_smile:
I will give it a try! I will let you know how I am doing and what I managed :sunglasses:
:crazy_face:

You can’t do that (general case: anything around [open, closed Breps] + multi ray bending with regard all present Breps) without some sort of loop technique (in coding the most efficient is recursion). Anyway, found 15 minutes more to continue on that.

2 modes would be available: Multi Reflection or Multi Refraction (on solids) + Multi Reflection (BrepFaces). See some WIP results here: (either reflection or refraction):

BTW: A critical angle filter is obviously a must (when a refraction becomes reflection):

BTW: I must manage far shorter times: 13 milliseconds are a lot for such a simple task (blame the Brep Normal Method).

Here’s a very simple demo thingy on that Snell law. You can do it obviously witth native components (but the other things that the forthcoming C# does … well … er … you can’t).

BTW: angleIn is the Vector3d angle between the Brep Normal (inversed if ray is inside) and the rayDirection (always inversed) with respect a plane defined from the hit point (origin) and the CrossProduct (rayDirection, Normal). Google: CrossProduct and given the opportunity do the DotProduct search as well. There’s native GH stuff on these I believe.

RayShoot_SnellLawDemo.gh (9.1 KB)

Observe that going from air to some material (with some R) is OK … but the other thing MAY or MAY NOT yield an “escaped ray”. If the ray is trapped inside we have a reflection (life sucks).

This means that the critical angle is related with the rayState (in/out) AND the angleIN AND the R value … meaning that there’s no need to include it as var (if the NaN test is considered an “elegant” way to cut the mustard) - NaN means Not a Number.

After all these Greek things here’s the general algo (Mode 1: Reflections, Mode 2: Refractions and Reflections):

  1. For a given ray segment (last element on a Polyline describing the ray) get the hitPoint: sample all the ccxPts (ray segment as LineCurve VS a BrepList) and sort them against the ray start point distance. Get the first on the sorted List that IS NOT the hit point.
  2. Get the hitBrepIndex: what is the Brep that bends the ray?
  3. If Mode = 1 do a Reflection.
  4. if Mode = 2
    4.0 if the Brep is not a solid do a Reflection.
    4.1. if the Brep is solid.
    4.1.1 get the outAngle (taking into account the ray segment state [is inside/outside : this is where the hitBrepIndex comes to play]).
    4.1.2 If the outAngle is valid (not Nan) do a Refraction.
    4.1.3.If the outAngle is NaN do a Reflection (case: ray inside trying to go outside)

BTW: Reflection: rotate the ray segment Math.PI with respect the Brep Normal plane at the hit point. Reverse the new segment.
BTW: Refraction: rotate the ray segment (angleIn+ Math.PI-angleOut) with respect the plane defined via the CrossProduct as above. Reverse the new segment.

Put all the above into a loop (controlled via a loopCount var) and deal with any Brep List VS any ray List.

Here’s a visual demo on that trapped inside (Refraction) ray matter. Shooting from the inside of a Sphere that has R values (see overrideR) from 1.31 (Ice) to 2.41 (diamond). As the R grows less and less rays can escape … and for these values/settings captured and for that emit Topology diamond yields the same results as Mode 1 (Reflection).

That’s why girls like diamonds meaning that we should work overnight in order to offer them the best of the best.

Hi again.
sorry for replying so late. but I was super busy :frowning:

Uptill now i haven’t even taken the critical angle into acount. I knew at some point I had to but not sure how.
Your small C# component just took care of that. I don’t really know about coding but I managed to modify it slightly for it to be usefull to me :slight_smile:
thank you for that!!

With your help and the tipp of:

I am already so much further than expected

thank you again! :sunglasses:

OK … try to do it with components (+ some Loop thingy the likes of Anemone) and if you fail: drop a word for the salvation.

Some tips more:

  1. ALWAYS deal with any challenge having the general case in mind: For this thread this means any collection of Breps (open, closed, valid, invalid, good, bad, whatever) VS any collection of Rays.
  2. DO NOT assume that if a given ray segment is inside in some Brep then the next one is outside: because you may have overlapping solids (that’s not possible in real-life but we are not living in real-life anyway). Take into account the direction of the Normal as well (for a closed Brep this points outwards - unless you Flip the Brep (LOL)) for reversing it (case: segment inside) etc etc.
  3. Thus (at the expense of a few milliseconds more) test a segment by using a Point for inclusion (using say Curve.PointAtNormalizedLength (0.95)) for every ray segment.
  4. DO NOT exclude any Brep (hitted previously) in any loop stage: because a blob type of Brep may intersect with a ray segment many times.

As a challenge try to mastermind a connectivity thingy as well: for any node of any final polyline ray … compute the index of the Brep that caused the bending (that’s a classic connectivity Tree - A MUST for any engineer worth the name).

Anyway … since you asked for it I’m posting the salvation (or the torture ?) here instead on a PM basis (because maybe others could find it useful).

Brep_ReflectionsRefractions_V1.gh (141.1 KB)
Brep_ReflectionsRefractions_V1.3dm (2.2 MB)

Info panel informs you about some basic stuff:

Some tips:

  1. You can assign different R values for any valid solid Brep present in the bList. geomRList samples these values. If is empty (as delivered) the 1.31 is assosiated to every solid. If geomRList has less values than the solids present then these are consumed in order and the last is assosiated with the remaining solids. If overrideR is != 0 then that value is assosiated with every solid. You can add any R value (but avoid R > 2.5).
  2. The total Ray length (the length of the polyline, that is) is managed via the RL parameter. If some segment length is < document tolerance => segment is discarded.
  3. The max hits is managed via the reflections parameter (should be named: hits or bounces, but anyway). So if you see some weird results increase that limit.
  4. 2 Modes are available: Reflection or Refraction (solids) + Reflection (non solids). If a given ray segment can’t escape then a Reflection is made.
  5. Rays are either grid like or radial. They are made internally (that’s not very user friendly … I could add a few lines more in order to accept any user collection).
  6. The critical angle is auto managed internally (acc the angleIn, the state of ray (in/out) and the R value per Brep).
  7. Connectivity (as explained above) is also made: what Brep caused the bounce per node (ordered) per polyline ray.
  8. R values are in fact complex numbers (real + imaginary) … but … let’s deal with the entry level case first.
  9. Nurbs type of Breps yield bigger Elapsed times (for obvious reasons).
  10. Use the best quality of espresso (and cigars) when playing with the thing.

All in all: you can pretend that this is some kind of add-on … or … learn C#, double click it and discover the big rabbit hole called coding. But why bother? in a few years from now an AI computer could do it for you (rendering you obsolete - no pain no gain).

1 Like