How to detect collision with plane with an account of transparency?

Greetings!

I’m working for remake of game Might & Magic 7. It uses art from original game archives. Monsters are presented as textured billboards (screen-oriented planes) and animated by manipulations with texture.

The problem is to detect collision of billboard and perpendicular ray with regard of texture transparency. What is the most efficient way to solve it?

The problem is to check transparency at point of intersection between the plane and ray.

@nikolayplekhanov said:
...The problem is to detect collision of billboard and perpendicular ray

Do you mean specifically that the ray is perpendicular to the billboard or, put differently, that the ray is parallel to the surface normal of the billlboard?
@nikolayplekhanov said: with regard of texture transparency.

Again, just to clarify, do you mean that you need to differentiate between the ray passing through a transparent part of the billboard versus passing through an opaque part?

Hm do the yray, then calculate the texturecoordinate for every hit, and discard the ones with a alpha of zero (by getting the amterial and the triangle you hit , you can calcualte where on the texture your ray hit)

Sorry if I’m not clear enough. The primary problem is to check color/transparency in particular point of texture. Is there a way to get it without analyzing raw image data? …for example via shaders?


@jonathan-pikalek said:
Do you mean specifically that the ray is perpendicular to the billboard or, put differently, that the ray is parallel to the surface normal of the billlboard?

The solution for this particular case will good, but the cases when ray is not perpendicular are insteresting too.

@jonathan-pikalek said:
Again, just to clarify, do you mean that you need to differentiate between the ray passing through a transparent part of the billboard versus passing through an opaque part?

Exactly.

You get a hit location and you know where the vertices of your quad are… So you can compute the texture coordinate. As empire said, then its just about checking the alpha value at that spot.

How to check the alpha value at that spot?

I know how to do it by analyzing an underlying ByteBuffers, but I suppose it’s not a best solution.

Yes it is “a best solution”.

1 Like

While it could be done with shaders, reading back the data from the graficcard has a extremly overhead, nullifying any performance gain you could have possible gain.

1 Like

How to compute texture coordinate at hit location?

I was looking for a valid transformation matrix to convert world coordinates into texture, but failed in attempts to calculate matrix which does desired transformation.

Well you can get the triangle you hit, now you need to get the texture coordinates for each from the buffer of the mesh, then interpolate them to get the correct position in the texture

The trouble is just about interpolate them