0

I'm diving into CG shaders. I'm baking a vertex shader that needs one random constant (computed just once at start time). I know that in Unity it's pretty easy to pass a value from a script to the shader, but I'd like to know if there is any way to have the shader create this random constant for me. Searching for this didn't help me that much so far. So thanks for any help!

Steak

Steak Overflow
  • 7,041
  • 1
  • 37
  • 59

1 Answers1

1

not really. You can use some other parameter (like time, or x location for the model) and run frac() or something to get a cgheesy random value, but no direct way in the shader (that's remotely efficient).

bjorke
  • 3,295
  • 1
  • 16
  • 20
  • Thanks for the answer. I realized this myself recently and I see the efficiency reasons. With your help I'm totally sure of what I'm doing now. Thanks – Steak Overflow Feb 20 '13 at 16:00