Jump to content
  • 0
havenphillip

How can I get the area where two objects intersect?

Question

45 answers to this question

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.

Link to post
  • 0

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

Link to post
  • 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

 

Link to post
  • 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.

Boolean-Ven.jpg

  • Like 1
Link to post
  • 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.

Link to post
  • 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.

shaderforcefieldsimple.png

Link to post
  • 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?

Link to post
  • 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.

Link to post
  • 0

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

You might have to convert to a depth value.

Link to post
  • 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?

Link to post
  • 0

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

  • Like 1
Link to post
  • 0

@havenphillip

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

Maybe you could ask Shadmar to help with this?

Link to post

Join the conversation

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

Guest
Answer this question...

×   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.

×
×
  • Create New...