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

有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top