23
2014
Grass Maker for Mesh Terrain (wip)
Trying to make some basic grass/plants generator for mesh terrain.. (not terrain object).
(This is part of Mesh Terrain/Splatmap Tool)
FEATURES
– Editor plugin: Generates grass billboard planes(quads) over mesh surface (using raycast..)
– Checks splatmap color, if its over certain threshold, then add grass here..
– Atlas texture support for grass
—
TODO
– Find: Better / realistic looking way to distribute grass/plants around terrain.. (Ideas: using splatmask? terrain surface angles? or just fill the whole scene randomly? or floodfill?)
– Fix: floating meshes (maybe can take raycast hit normal, then adjust border vertices using that..?)
– Add: position randomness
– Add: multiple grass/plant types (using atlas now)
– Add: grass options (scale, main color, variation, …)
– Add: billboard options (how many quad planes, what group shape: single, cross, …)
– Add: take vertex color from terrain, use in shader : done
– Grass islands/patches should also have less/shorter grass on patch borders..if that looks nicer.
– Could add trees, rocks into this later also..
– Optimized Quad plane > Use single triangle instead?
– Lawnmover script, why not! (just move vertices down or change atlas image to cut grass)
– Bending grass near player (shader: move vertices by player distance)
– Add probability percentage option for each grass type (now there are too many white flowers..) *Random weighted selection..
– Optimize far away grass (hide it if too far, fade in or show when closer)
– Distribution: less grass if lower mask threshold : Before: “if (maskC.g>0.75f)”, After: “if (Random.value>1-maskColor.g)”
– Fix shader: some problems with lights? (too dark in some areas/angles) : added custom surface shader lighting using this
PROBLEMS
– Cannot use GetPixel() to get pixel color from that position, with raycast & hit.textureCoord, if the mesh texture material is set tiled? : Just had to multiply hit.textureCoord with tiling value.
– Webplayer demo build would be 44 megabytes! Have to check whats happening there..
—
IDEAS
– Raycast floodfill : Shoot raycast on terrain, if suitable mask color for grass, shoot more rays nearby and place grass (with scale based on original startpoint), until hit different mask color..
—
INSPIRATION
– Grassy terrain/hill photo
– Grass/sand terrain render
– Outerra grass
RESOURCES
– Nvidia grass (some quad shapes here)
– Free skyboxes
—
Image#2: Problems > Floating meshes (since the quad centerpoint is taken from single raycast hit..)
AFTER (26.6.2014).. floating shadow still quite annoying here..
—
Image#3-4-5: Trying to get quad aligned with surface, without distorting texture.. argh, why I didnt do my maths homework at school ><
Almost solved (by a friend with some mathemagic), now there are those color lines to indicate end vertex positions on surface.. not yet sure what happens to texture when quad is stretched over there..
—
Image#6: Added perlin noise to grass positions, looks ok from nearby:
—
Image#7: Taking grass color/tint from current texture under it
—
Image#8: Using sprite shader, looks nice also (no shadows or waving though..and forgot to set bottom vertex alpha to 1) *click images for full size
—
Image#9: Using texture atlas for grass (*btw. these plant textures are from : https://www.assetstore.unity3d.com/en/#!/content/6
—
Image#10: 2 Sided lighting shader, added skybox and fog. (around 560 drawcalls, almost 2.5million tri’s)
—
Image#11: New random distribution probability threshold & height scale from mask color. It gives those random smaller grasses nearby the normal grass area
Related Posts
13 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
These links might be helpful
http://mollyrocket.com/casey/stream_0015.html
http://www.crydev.net/newspage.php?news=91597
thanks, now testing with just adding some perlin noise to the grass position, not too bad so far (most likely just random would work also, in image#7 can still see lines..)
Vegetation generator algorithm (page 62) :
http://twvideo01.ubm-us.net/o1/vault/GDC2014/Presentations/Gollent_Marcin_Landscape_Creation_and.pdf
This might work for the grass type probability, WeightedRandomPool.cs:
http://www.simplypointless.net/building-pools-on-the-shoulders-of-giants/
selection based on percentage weighting in C# (sources)
http://forum.unity3d.com/threads/selection-based-on-percentage-weighting-in-c.274680/
Looks greate!
looks like this one creates grass on the fly and using heightmap as reference (i’m using raycasts..) :
http://grassonmeshgenerator.blogspot.fr/
nice looking grass shader:
http://forum.unity3d.com/threads/shader-forge-a-visual-node-based-shader-editor.222049/page-39#post-1740963
[Free] Random Distribution Script:
http://forum.unity3d.com/threads/free-random-distribution-script.277516/
Procedural mesh grash beta:
http://forum.unity-community.de/topic/7048-procedural-mesh-grass-beta/
moving grass shader:
http://forum.unity3d.com/threads/shader-moving-trees-grass-in-wind-outside-of-terrain.230911/
nice looking free mesh plants
http://opengameart.org/content/free-plant-pack
geometry shader for grass
https://github.com/toninhoPinto/GrassProject