Jump to content
juleslin

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
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!!

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

I tried repack them after the variation process, it works, just that it would took longer time to "prepare" before render. 

Thank you!

Share this post


Link to post
Share on other sites

which Houdini version you are using? I remember 15 (?) did not support Cd on top of packed geo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×