View Full Version : Unity grass problems.
02-07-2012, 03:54 PM
So I'm trying to make grass from 3d motive tutorial. After lots of messing with coord system I finally made it work... kinda... I don't know why but they are rendered with vertex colour. I painted the terrain with detail painting. If I change the tint colour of grass in the terrain settings only the value changes anything and it changes 'opacity' of vertex colours. I painted mesh with red like in tutorial so I could make it move depending on vertex colour. Any one knows how to fix it ? Any idea how to make it move with vertex colour ? ;p (I just didn't google it yet. Maybe some one here did something like that ?)
02-08-2012, 02:26 AM
I'm unfamiliar with the tutorial, but you should definitely be able to animate the grass in the vertex shader according to vertex colour, if that's what you're after.
Although, all of the grass vertex animations I've seen use the UVs to control which parts of the grass are affected, and you could probably use your vertex colours to control the direction or something. Could be pretty cool. :)
If you haven't written such a shader before, I think that a similar shader is included in the built-in shader source (http://unity3d.com/support/resources/assets/built-in-shaders.html) (although those might be using Shaderlab, rather than the more standard -- and more understandable in my opinion -- standard vertex and fragment shaders).
If you get really stuck I can look at whipping one up when I've got some time.
02-08-2012, 02:36 AM
Thx! I will try to do it. I never messed with the shaders code though. Must ...useeee....my.... brains! Since when You paint terrain with detail mesh it responds to wind (making this wavy movement) it should be possible. Still have the vertex paint issue though :/ The tutorial uses red channel of vertex paint to move grass. The part closest to ground is black and as it goes up its brighter red. Having this you can make upper parts move more than those near the ground.... my problem is that Unity keeps showing vertex paint when I paint with detail mesh. I found out that only detail mesh painting makes sense with creating grass since it lets you easliy control the density. I could delete vertex colours and maybe use built in responsivness on wind but I would like to have more control over it. First I need to solve this vertex paint issue.
02-08-2012, 02:51 AM
Wait, you can do vertex painting from within Unity?
I... have never done that, but it would be pretty handy if I could do that on non-terrain objects too... I'll have to check that out!
Whether you're using vertex colours, or UVs, and what they do, is really dependent on how the shader is written. If you're not getting the result you're looking for, I think there's a good chance the shader's just expecting different information to what you're providing. Maybe posting the shader code could help.
02-08-2012, 02:54 AM
I'm not writing the shader yet ;] Problem with vertex colours is :
- I painted vertices in max
- imported as fbx to unity
- painted terrain with detail mesh painting
- all detail mesh is tinted with vertex colours ( == grass is red ;])
As far as I know there is a plugin for Unity to vertex paint but I wasn't talking about it ;p I'm sorry if its hard to understand me sometimes. My eng is bit rusty.
I will try to write the shader when I'm done with this issue ;p
Thats how it looks.
02-08-2012, 03:05 AM
What you see in your Unity scene is what your shader gives you. If your vertex colours are influencing the output in your shader, that's what you'll see. If you switch the grass to use another material and a different shader (say, ordinary diffuse for example), you probably won't see the red any more -- but then you'll probably lose your grass blowing animation too.
Does that make sense?
02-08-2012, 03:17 AM
Even If I change material the vertex colour shows up. Maybe its mesh detail thingy that it uses vertex colours (always).
02-08-2012, 03:23 AM
Ah. I haven't worked with the Terrain engine, as it's not supported on mobile. :/
02-08-2012, 03:27 AM
Maybe I shouldn't use terrain properties since I want to try to sell those in asset store... people making mobile games could use them better then.
02-13-2012, 01:52 AM
IT'S THE RED WEED FROM MARS!!1!
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.