• 0

How can I get the area where two objects intersect?

Question

...or where can I find out how to do this? What's the term I should look up?

Recommended Posts

• 0

You can detect if two objects collide with Collision but I don't think it'll give you the shape of the collision.  Might be able to do it with Newton somehow.

• 0

Shaders or game code? I think there is a plane intersect function but not sure if it's exposed in Lua

• 0

I was thinking shaders but I'm not entirely opposed to Lua if I could get it to work. I'm looking at the forcefield shader I keep seeing all around the internet. It draws a line where the two intersect.

• 0

You could use aabb commands and convert the intersections to 2D space and pass the intersection points from the script to the shader.

• 0

You can pass things back from the script to the shader?

• 0

You should but I'm not sure if it's exposed to Lua. I can take a look at the headers tonight for you.

• 0

I just need to be pointed in the right direction is all. What's the term I should look up? Depth intersection? Something like that?

• 0

AABB and these commands are what I had in-mind.

```virtual bool IntersectsPoint(const Vec3& p, const float radius=0);//lua
virtual bool IntersectsAABB(const AABB& aabb, const float overlap=0);//lua
virtual int IntersectsPlane(Plane plane);//lua
virtual bool IntersectsLine(const Vec3& p0, const Vec3& p1, const float radius=0.0);//lua
virtual float DistanceToPoint(const Vec3& point, const float radius=0);//lua```

• 0

Ok bounding boxes. Perfect. I'll start reading up on them.

• 0

Depends on the object. For boxes, the math is pretty simple.

• 0

An "AND" operation would be cool to have in the AABB class. I guess this could create a bounding box from the intersecting volume of two AABBs.

• 0

What I really want is to make a plane on the ground and find all the objects that are intersecting it by the space they're occupying or the "hole" they're making in the plane. Ultimately I'm trying to develop a pixel depth offset effect like Unreal has but all their tutorials are using that goofyass node system. Some of them are doing this weird thing with that force field shader where they're using a depth buffer as a texture like "texture(depthbuffer, fragcoords);" What's the LE equivalent of that? Bounding boxes are probably good for finding the area but seems like a lot to do just to discard that space.

• 0

• 0

If this is what you are trying to do, it looks to me like it is a combination of:

• Apply a color when the Z component of the normal is near zero (edges).
• Apply a color when underlying depth value is near the current draw Z position. It looks like a screenspace depth effect, which is why the effect is abruptly cut off on the left side of the box in the foreground.

• 0

Man I'm always in over my head. Sounds like what you're saying is a fresnel and using the DepthToZPosition that is in your water shader with vec3 screencoord?

That's what I think I want. The problem I'm having is with the parallax shader. When I set things on it they look like they're floating above it. The rock highs and lows don't interact with like a box or tree model. So if you recall you can just cut the parallax texcoords and they appear to have a 3d "beyond the geometry" look. So if I can find all the intersections of items set on the parallaxed surface I can then discard those areas to give that impression on everything. UE's Pixel Depth Offset is the closest thing I've seen to accomplish this though I'm not entirely sure this is what they're actually doing. What approach do you recommend for solving that?

• 0

You could manually write the pixel depth. Stalker did this for their shadowmaps. However this means you will lose early Z discard, which will make the shader more expensive.

• 0

I don't suppose you have a snippet that shows how to do this?

• 0

I think you just o this:
gl_FragCoord.z = z position

You might have to convert to a depth value.

• 0

I'll keep trying. Thanks.

• 0

What about this? The foam around the rocks suggests to me that there is a way for the plane to "know" the shape of the things intersecting it. The question is what part of the shader knows that?

http://fire-face.com/personal/water/

• 0

Same thing our water shader does.

• 0

I've been meaning to pull the water shader apart to see how it works. I guess now is as good a time as any. Anything I should take note of specifically to get what I'm looking for like the fog or the amplitude or something?

• 0

I think the shader compares the current depth to the stored one to control the transparency.

• 0

I (and for sure many others) would pay for such a water shader to use commercially if there was one in the marketplace...

• 0

Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×

• Pages

• Support

• Projects
×
• Create New...