General Category > ASL Scripts
PHUR v1.4
Raxx:
I didn't use any known algorithms for it (known to me anyway), so my method is probably not the most efficient, nor is the distribution perfect. But here goes:
* Find the midpoint of the polygon. Put that and the vertices of that polygon into an array
* Divide each edge of the polygon into subsections the same length as the spacing you desire. Toss those into the array as well
* Now loop through each edge point (including the subsections) and do this:
* Create an imaginary edge from the midpoint to the edge point
* Divide that edge into subsections the same length as the spacing desired
* At each subsection, compare its distance to all of the points in the array so far
* If none of the distances are less than the desired spacing, push that imaginary point into the array
* Do this for each polygon, but ignore shared edges when pushing into the array
* All of those points in the array are now the origins for the grass
A flaw with this is that regardless of how small the polygon is, there is guaranteed to be an origin at every original vertex and midpoint of every polygon. Also, like I said, the distribution won't be perfect. But they will be spaced pretty consistently, as you can see if you test out tiny spacing on a single quad. You probably don't have to use the midpoint and can instead pick any point on the edge for the second step -- I just preferred to make sure the midpoint was always in there.
I'm not a huge fan of that method, but it worked well enough, and I'm a pragmatic person :P For a game engine, if everything is triangulated you end up having a higher concentration of edges and midpoints, and therefore more origins regardless of what kind of spacing you desire.
Attached is an image that shows how my distribution looks on a quad that gets divided multiple times. As you can see, there's a pattern on each polygon that you can make out, when the spacing is very low -- this pattern probably won't be noticeable at all on terrain, however. To help reduce the pattern, you can loop through all of the origins and randomly take out a number of them, prior to generating the grass.
cooldude234:
Thanks, this will help me get an understanding of how to implement something like this into the engine.
Will try to take a crack at it sometime in the next day or two.
captaindrewi:
"Make my own PHUR Strands?
To implement your own strands, take note of these things:
When modeling a strand
It must have STRAND_PHUR at the beginning of its name
It must have the same material as the PHUR and base".
Where would i put a strand [model]?
have 1.3 but console says 1.2.
Raxx:
Oops, forgot to update that little header. Shame on me.
You can place the strand anywhere, the script doesn't use its location in world space. So long as it has "STRAND_PHUR" in front of its name, and has the same material as the PHUR and base mesh, it'll work.
[edit]Note that you can't delete it, or else PHUR won't be able to use it. You can just tuck it away somewhere out of sight.
cooldude234:
It seems to not be idiot proofed.
If I accidentally click on one spot with the
Oh wait, I was clicking a broken script not even related to any of yours raxx XD
However I cannot change the amount of stands without subdividing the mesh. I don't if I'm just being an idiot again or if it's something else but I made this pic :D
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version