Jump to content

Change color of scattered and packed grass


Recommended Posts

Hi everyone! I am very new in Houdini and I hope you could help me solving this problem.

I have a grass which is made of 60 long grids (photo attached), they are packed and scattered over a big grid.  I would like to add random color not only on each grass but on each long grid of grass. But I am stuck because I don't know how to apply random color on something inside a packed primitive. Can anyone please advice? Thank you! 

image.png

image.png

Link to comment
Share on other sites

Just apply v@Cd to the points that represent the packed primitives. Then in your shader, you either need to tell the material to "Use Packed Color" if you're using a prefab shader like the Classic Shader or Principled Shader, or if you're building it yourself, you need to include a RenderState VOP that loads the attribute packed:Cd and multiply that against the base color of the material.

Link to comment
Share on other sites

Here's another example file: there's one example material using the built-in Use Packed Color switch that's found on the classic shader. The other example material is a constant material doing the packed color multiplication from scratch.

packed_color_example_toadstorm.hip

Edited by toadstorm
misread earlier post
Link to comment
Share on other sites

Thank you all for your prompt reply! I tried your suggestion and examples but I am not able to do what I need:

This is the grass that I was mentioned, it's made of 60+ long grid. I applied material (shader with texture on diffuse) to it and packed.

image.thumb.png.b5cfc8b5869a94d7acb0bbced0dde94f.png

I created a grid and scatter points on it, gave it random color.

image.thumb.png.14997a43b53ef12d67ee419c5a132192.png

I use copy to point to distribute the grass on the grid, the grass will collect the Cd from the scattered points.

image.thumb.png.1f1f2175ddda4811e80dc11131fb268f.png

And I will use the Cd to multiply the mapping in the shader to have a better variation on grass.

image.thumb.png.3f5fe02f1d04d816d968d440e5621b01.png

But I want to variation not only on each grass but on each grid of grass. (This is using the method provided by Midasssilver, it do the trick but it's not packed. I want to use pack to make the setup light and fast.)

image.thumb.png.a06df0be83a4eda268e7fdf43fc2dc97.png

Sorry that I am not clear enough to describe my question before. And I hope I am not too stupid to find out the solution was already in the example that you guys provided...

Thank you guys!!

Link to comment
Share on other sites

You probably just need to re-pack it after it gets the right color, and make sure you promote the color when you re-pack it. Also, getting your color from the points that you are copying the instances of the plants onto doesn't help you, because you will need to overwrite it again with random color that takes every leaf into account.

Edited by Midasssilver
updated explanation
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...