Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Unityverse · Oct 11, 2015 at 03:09 PM · terraingrasstexturingvolumetric

Technique for volumetric grass. Texturing question.

I'm working on generated, volumetric grass tiles. They are created during runtime from layers of quads with transparent textures :

(Ignore rear tiles, they are a different type of grass) alt text

Right now just using a single quad prefab that gets generated multiple times vertically, for each tile. Each layer texture is identical, with alpha cutoff decreasing based on height.


The problem:

Limited to two dimensions of detail. A plan for 3D grass is to use layers of different textures to create a false 3D object.

A grass model sliced into 100 layers :

alt text

This code is attached to the root tile object and generates the layers :

     // Input values
     public GameObject grassLayer;
     public float patchHeight;
     public int layerCount;
     public float cutoffMin;
     public float cutoffMax;
 
     private float x, y, z;
     private float layerSep;
     private Renderer rend;
     
     void Start() {
         layerSep = patchHeight / layerCount;
         for (int i = 0; i < layerCount; i++) {
             x = transform.position.x;
             y = layerSep + i/(1/layerSep);
             z = transform.position.z;
 
             // Create/name/inherit grass layers
             GameObject go = (GameObject) Instantiate (grassLayer,
                                                   new Vector3 (x, y, z),
                                                   Quaternion.Euler (90, 0, 0));
             go.name = string.Format ("layer{0}", i);
             go.transform.parent = transform;
 
             // Set material parameters
             rend = go.GetComponent<Renderer>();
             rend.material.shader = Shader.Find("Legacy Shaders/Transparent/Cutout/Diffuse");
             rend.material.SetFloat("_Cutoff", (cutoffMax/layerCount) * i + cutoffMin);
             
         }
     }

What is a good method for creating 100 materials with unique texture that can be using for all grass tiles generated?

jpg1.jpg (472.2 kB)
jpg2.jpg (377.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eudaimonium · Oct 11, 2015 at 04:39 PM

Your approach would be absolutely horrible, performance wise - each material is a seperate shader pass in the final render which has it's own CPU and GPU overhead. It's a good performance practice to keep the material layer as down as possible - it's why the new physically based shading is so popular, it's a way to generate nearly every surface you need with one material.

If you wish to go with layer generation technique, you want to generate them using shaders (so you basically have one plane in the game with one material, which is rendered as a dozen or so layers), this is a technique more commonly referred to as "fur shader", google that and see what comes up.

But in total I believe the final result will not be satisfactory for displaying Grass on terrain, especially if this is a third or first person perspective which allows the camera to get close to it.

Currently there's really no rock solid and high performance way to actually render out real blades of grass like that. Crysis 3 had an approach where each blade of grass is tessellated set of several long thin triangles, connected by joints that behave with realistic physics but the scene where that was heavily used was notorious for bringing down even the highest end PCs to it's knees.

nVidia has a few tech demos demonstrating realistic grass turf rendering but the complete toolset is still experimental as far as I know.

I think you'd be best to sticking with standard Terrain grass painting tools.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Unityverse · Oct 11, 2015 at 06:32 PM 0
Share

Thanks for the advice. I'll look further into physical based shading, since I haven't learned much about it yet. I'll take a look at the Crysis technique as well, sounds interesting. BTW, I probably should have mentioned that this isn't for anything where serious scrutiny or performance is needed. It's just an experiment I'm messing with. It's essentially based on an article I'd read about fur shading. I've used standard poly-grass techniques before, as seen in the first image, and agree it's a good option today. So, from what I understand generating ~100 materials for every unique type of foliage is going to be a nightmare. Thanks again.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Gras Dissapears in build 1 Answer

Unity terrain grass extremely weird 0 Answers

Plant grass or tree with an image 0 Answers

Hide Grass and Trees applied to terrain? 2 Answers

Swapping terrain lightmaps does not affect grass? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges