YouTube2Text

Godot 3/4 Particle Shader to Make 'Wandering' Grass With (Or Other Foliage) — Transcript

by devmar · 1,526 words · 223 segments · language en · Watch on YouTube

Full transcript

  1. 0:00good day to you all it's me again
  2. 0:01bringing you another episode of making
  3. 0:03stuff in godot 4.
  4. 0:05today i wanted to present the progress
  5. 0:07on my foliage system by using a particle
  6. 0:10shader a bit of a disclaimer up front it
  7. 0:13is far from finished i'm sure it could
  8. 0:15be optimized some more but since we're
  9. 0:18working in alpha it's probably too soon
  10. 0:20to worry about optimization anyway
  11. 0:23i am planning to put it on dropbox if
  12. 0:25you want to give it a try but remember
  13. 0:27it may be very short-lived given how
  14. 0:30things change from one of iteration to
  15. 0:33another it simply may not work
  16. 0:35anymore by the time you get to try it
  17. 0:37out okay so just saying and by the way
  18. 0:39in case you do try it out
  19. 0:42it would be a display of good manners if
  20. 0:44you liked the video and subscribe to the
  21. 0:46channel again just saying anyway to the
  22. 0:49point um here is something that remotely
  23. 0:52resembles a uh a patch of grass and if
  24. 0:55you grab it and move it around the scene
  25. 0:57it follows the shape of the terrain
  26. 1:00the terrain itself has no collision by
  27. 1:02the way it's all smoke and mirrors
  28. 1:04it's a flat mesh with a vertex shader on
  29. 1:06it and you can watch some of my previous
  30. 1:09videos to see how it was made now for
  31. 1:11demonstration purposes i am going to
  32. 1:13replace my grass mesh with a simple box
  33. 1:16mesh i'm going to set its height to
  34. 1:19something noticeable like 12
  35. 1:21and i'm going to reset all these
  36. 1:23parameters here on the shader so that we
  37. 1:25can start from a clean slate all right
  38. 1:29a few ground rules to begin with the
  39. 1:31shader is to be used on a gpu particles
  40. 1:353d node inside a process material the
  41. 1:38amount setting is kind of obvious is how
  42. 1:41many instances we're going to have i've
  43. 1:44got 10 000
  44. 1:45as you can see
  45. 1:47lifetime is how quick you want your
  46. 1:49particles to respawn if you set it to a
  47. 1:51minimum which is equivalent to 10
  48. 1:53milliseconds they will respawn in almost
  49. 1:55real time as you move the node around
  50. 1:57the scene i'm keeping it like this for
  51. 1:59demonstration but in an actual game it
  52. 2:01will depend on you know how vast your
  53. 2:04grass field is going to be and how fast
  54. 2:06your player is moving maybe you don't
  55. 2:08need to refresh the particles so quickly
  56. 2:11it's important to set the explosiveness
  57. 2:13to one and randomness to zero otherwise
  58. 2:16they will flicker when they refresh let
  59. 2:18me show you see what's going on
  60. 2:20so if you set explosiveness to maximum
  61. 2:22with zero randomness they will be drawn
  62. 2:25all at once and that will help you avoid
  63. 2:27this issue okay so
  64. 2:29let's look at some of the uh fundamental
  65. 2:32shader parameters first before we do
  66. 2:34anything let's make sure we have our
  67. 2:36height map image in this map height map
  68. 2:39parameter this of course should be the
  69. 2:41same image you're using to deform your
  70. 2:44terrain in the vertex shader assuming
  71. 2:46you want your grass to snap onto your
  72. 2:47terrain of course
  73. 2:49optionally you can put in the normal map
  74. 2:51of your terrain as well and you will see
  75. 2:52what for in just a moment next instance
  76. 2:55rose this is crucial because it controls
  77. 2:58the emission shape
  78. 2:59if you set the particle count to 10 000
  79. 3:02like i did
  80. 3:03it will just emit a single file row of
  81. 3:0610 000 particles starting from the
  82. 3:08emitter using this spacing parameter to
  83. 3:11space them out but that's not what we
  84. 3:12want we don't want single file we want a
  85. 3:15patch of grass with the emitter point in
  86. 3:17the center of it so we need to tell the
  87. 3:20shader how many times we want to divide
  88. 3:23this row of particles and this is
  89. 3:25exactly what this setting does instance
  90. 3:27rows
  91. 3:28and the rows will be offset by the same
  92. 3:30spacing parameter okay so if you set it
  93. 3:32to 100 you're going to get a hundred
  94. 3:35rows each with 100 particles totaling to
  95. 3:3810 000. so you'll get a nice square uh
  96. 3:41patch uh you can see what happens when i
  97. 3:43scroll the instance rows value uh our
  98. 3:46square patch is kind of morphing into a
  99. 3:48rectangle if i got it all the way down
  100. 3:50to one it would be a single row uh again
  101. 3:53but i want a square so i'm going to
  102. 3:54leave it at 100. one important thing to
  103. 3:56remember is that
  104. 3:58instance rows must be an integer
  105. 4:00otherwise if it's a float the particles
  106. 4:02will behave erratically when you move
  107. 4:04the node around finally terrain
  108. 4:06amplitude is the height value that you
  109. 4:09have in your terrain vertex shader in my
  110. 4:11case it's 100 so i've put 100 here to
  111. 4:14make sure that my foliage matches the
  112. 4:17shape of the terrain underneath
  113. 4:19okay so with the basic settings out of
  114. 4:21the way uh let's take a look at some of
  115. 4:23the more interesting parameters coverage
  116. 4:25altitude is the maximum altitude at
  117. 4:28which your foliage will grow it's now
  118. 4:31set to 20 but if i dial it in you will
  119. 4:34see that the particles that cover the
  120. 4:36higher parts the mountains uh begin to
  121. 4:38disappear and they're not really
  122. 4:39disappearing though they're just they're
  123. 4:41still being emitted only way off screen
  124. 4:44so we don't have to render them coverage
  125. 4:46range is the height range within which
  126. 4:48your grass will grow if i set it to
  127. 4:50something much smaller like 10 and then
  128. 4:53scroll the altitude up and down you'll
  129. 4:55see how the particles are moving up and
  130. 4:56down the mountain this could be useful
  131. 4:58when you want to have like different
  132. 5:00types of vegetation at different heights
  133. 5:02which happens in nature
  134. 5:04slope coverage decides on the extent to
  135. 5:07which the grass will grow on slopes so
  136. 5:09if i dial it in you'll see that the
  137. 5:10particles are starting to disappear from
  138. 5:13the areas where the slope is steeper
  139. 5:16clamping strength this one is
  140. 5:18interesting but before we make sense of
  141. 5:20it we need to create a clump map that is
  142. 5:23a map that will control where the grass
  143. 5:26grows within your patch the easiest way
  144. 5:29to go about this one is to create a
  145. 5:30noise texture so let's go ahead and do
  146. 5:32that i'll create a fast
  147. 5:35noise light and i'll give it a type of
  148. 5:37ping pong that's what i found works best
  149. 5:40for this purpose and i'm going to create
  150. 5:42a color ramp to give me some more
  151. 5:43control
  152. 5:44over the clumping so now if i play
  153. 5:47around with the sliders on the color
  154. 5:48ramp and noise frequency you'll see that
  155. 5:51i'm starting to get some pretty cool
  156. 5:52looking uh irregularities so clumping
  157. 5:56strength is basically the extent to
  158. 5:58which the clump map uh affects the
  159. 6:00particles it's like if you are
  160. 6:02increasing the contrast on the clamp map
  161. 6:04more or less
  162. 6:05now we can also orient the particles to
  163. 6:08the terrain normal with this checkbox
  164. 6:10here
  165. 6:11that's what we needed the normal map for
  166. 6:14if you remember hopefully you can see
  167. 6:15the effect it's not perfect because it's
  168. 6:17using an 8-bit normal map image to build
  169. 6:20the transform matrix from rgb values of
  170. 6:23the pixels if it was a 32-bit normal map
  171. 6:25it would probably be more accurate but
  172. 6:27still it's kind of okay you can also
  173. 6:30adjust the strength of the influence
  174. 6:32that the normal map has on the transform
  175. 6:34matrix
  176. 6:35better yet if you scroll down you'll see
  177. 6:38this terrain normal basis parameter with
  178. 6:40this you can manipulate the transform
  179. 6:43matrix of the normals and you can
  180. 6:45achieve some pretty freaky effects with
  181. 6:46this like if you wanted to create a
  182. 6:49windswept environment for example you
  183. 6:50could lay your grass down with the
  184. 6:53setting okay moving on instance position
  185. 6:55randomize this is going to allow us to
  186. 6:57make this rig look more organic as in
  187. 7:00more natural you can randomize the
  188. 7:02position of the particles we can also
  189. 7:05randomize their rotation like so we can
  190. 7:07randomize the scale of the particles by
  191. 7:10setting a minimum and maximum scale this
  192. 7:13alone will randomize their scale but we
  193. 7:15can further amplify the randomization
  194. 7:17effect with this setting instance scale
  195. 7:19randomize okay we can also set the scale
  196. 7:22of each of the three axis separately
  197. 7:24like if you wanted the instances to be
  198. 7:26taller or thicker or whatever and
  199. 7:28finally spacing which we discussed in
  200. 7:31the beginning controls the scattering of
  201. 7:33the individual instances and that my
  202. 7:35friends is it so using this shader with
  203. 7:38some really simple grass blades that i
  204. 7:40made in blender i was able to create
  205. 7:43these environments in qatar which
  206. 7:45performed quite well while arguably
  207. 7:47looking fairly decently in my personal
  208. 7:49opinion and that is before any
  209. 7:51optimization work has been done on godot
  210. 7:534 because remember this is still early
  211. 7:56alpha alpha 10 in this particular case
  212. 7:58anyway let me know what you think in the
  213. 8:00comments
  214. 8:01like the video if you enjoyed it find me
  215. 8:03on twitter for more frequent updates and
  216. 8:05i guess i'll see you in the next episode
  217. 8:08peace in the world
  218. 8:11[Music]
  219. 8:40[Music]
  220. 8:45so
  221. 8:51[Music]
  222. 9:20[Music]
  223. 10:27you

About this transcript

This page contains the full transcript of Godot 3/4 Particle Shader to Make 'Wandering' Grass With (Or Other Foliage) by devmar, generated from the public captions YouTube serves with the video. The transcript has 1,526 words across 223 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.