godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.25k stars 21.04k forks source link

CSG shapes textures are mapped different than normal meshes #19143

Open Plopsiskopsis opened 6 years ago

Plopsiskopsis commented 6 years ago

Godot version: 3.1.dev.5b11d16

OS/device including version: Win10 64 bit. Geforce gtx 950M

Issue description: added texture to a CSGcube and it did not align as you would expect. Works fine if you create a CSGmesh image

Steps to reproduce: Create a mesh and a CSGshape of same type. add texture to both and see.

madmiraal commented 4 years ago

I'm not sure this is a bug. The way a texture maps to a mesh depends on the UV mapping. AFIK there is no standard expected mapping. It's also worth remembering that all of these shapes should only be used for prototyping and the actual objects to be used in a game should be created outside of Godot and imported along with the desired UV mappings and textures.

For me the question is not why the textures are mapped differently, but: why do we have two different ways of creating basic CSG shapes? CSGShapes In the front row we have the CSG shapes: CSGBox, CSGCylinder, CSGSphere and CSGTorus. In the back row we have CSGMesh shapes: Capsule, Cube, Cylinder, Sphere, Prism, Plane and Quad. In addition, to create custom shapes, we have the CSGPolygon and within CSGMesh we have ArrayMesh and PointMesh. How useful all of these are is, of course, a separate question.

My suggestion would be to get rid of the CSGBox, CSGCylinder, CSGSphere and CSGTorus. I know CSGTorus doesn't have a CSGMesh equivalent, but is it really going to be missed? If we also got rid of CSGPolygon then the CSG module could be drastically simplified into just a CSGMesh object and a CSGContainer object.

Zireael07 commented 4 years ago

CSG Polygon is super useful! Point taken on the others, does anyone use the Torus?

FeatherAntennae commented 4 years ago

@Zireael07 I used it to prototype some hexagonal door frames and to cut arches into other things. It's also used in the demo .gif in the doc page for CSG.

https://docs.godotengine.org/en/latest/tutorials/3d/csg_tools.html

Plopsiskopsis commented 4 years ago

Could the torus be added to CSGMesh? Polygon is super great. The other ones just confuse.

The-Cyber-Captain commented 6 days ago

Though I - personally - agree with @Plopsiskopsis that a sort of shared codebase between mesh and CSG 'feels' the right approach that would require something of a more major reworking under the hood to maintain the efficiencies of the current distinct approaches. IE, entirely new primitive-generation code with Mesh and CSG sending different default flags.

As @reduz himself states, the distinction is 100% intended. https://github.com/godotengine/godot/pull/59077#issuecomment-1204288075

So, to recap this 6y+ ongoing issue now, in that context, this issue is purely about the unexpected discrepancy between the UV mappings of mesh primitives and CSG versions; which includes

boxCSG cylinderCSG

Yes, these CSGs are supposed to only be used for prototyping. But the lack of consistency within our own software is guaranteed to throw a number of end-users; especially those new to / adopting Godot who don't know why two different approaches have been taken. Furthermore, I suspect the inconsistency is likely to give anyone who does export the CSGs as a base to remodel / retop extra head-scratching - and time lost - if they expect the textures to line up for reference at all there!

IMHO it's definitely worth us addressing this issue so the CSGs feature of the engine can confidently be touted.

The-Cyber-Captain commented 6 days ago

NB: though the 3,2,1 UV map of BoxMesh primitive is very smart, I can pretty much guarantee that rolling out any work to have CSGBox match that will itself result in a flurry of issues from users reporting it as broken. //facepalm

It's.... unexpected.

boxMesh

For BoxMesh it is, at least, documented; one of the few primitives which currently mentions the UV map approach taken. That would need to be reflected in the similar CSGBox documentation. In reality, we should either

or

The-Cyber-Captain commented 6 days ago

PS: trying to actually action any code change here might be outside my wheelhouse / actual skills. It would certainly take me away from the game I'm trying to develop using the engine! Similarly, any tangential architecture discussions.

But I'll keep an eye on any pull requests - or proposals and discussions it spawns again if it comes to that - for this. And can definitely update the associated docs off the back of whatever the outcome is. [salutes y'all]