sabresaurus / SabreCSG

Level design tools for Unity
MIT License
1.38k stars 136 forks source link

Terrain / Displacement Editor #99

Open Henry00IS opened 6 years ago

Henry00IS commented 6 years ago

Due to an ongoing discussion on Twitter and a quick proof of concept:

Terrain using a single brush

This proof of concept only uses a single concave brush.

I am considering to actually go ahead and add displacement / terrain to SabreCSG.

Because I am using a single concave brush the CSG algorithm can't process it properly (although it does work well if a subtractive brush goes through the brush completely but it's better to use NoCSG). Optimize Geometry breaks the surface but I think it may be possible to exclude the brush from the optimization process (edit: confirmed, this is easy to do).

It may also be possible to, similar to the 2D Shape Editor, have multiple small convex brushes so that you are able to subtract it- or from it for special level design cases. Just to have the option.

Henry00IS commented 6 years ago

Here is some recent news from Discord, why aren't you on our Discord yet?

I found a way to build convex terrain with planar polygons, I believe this mspaint.exe image is the key to success:

image

Imagine these are 4 convex brushes (top-down view). No matter how you move any of these 5 vertices up or down the faces will remain planar (imagine a quad that gets cracked into two triangles, that's non-planar and very bad for CSG and the tools).

image

As this solution is convex it means SabreCSG can cut holes into it with subtractive brushes, you can make caves and such unlike Unity's terrain system.

Henry00IS commented 6 years ago

The convex terrain theory has been tested and does indeed work well:

image

(this uses the new subtractive brush fix PR)