- Home /
Make a Texture2D gradient during run-time
I'm wondering if it is possible to create a gradient based on several colors without using shaders? What I want is to generate it during runtime and have it be a 2*256 texture. The reason I don't just make a few gradients in photoshop and import them is that i want to randomize their looks from a few parameters.
Since these gradients never will be applied to a mesh i cant use shaders to get this effect. What would be the easiest way to do this, if it's even possible?
Arden, Eric has a superb explanation of this here:
http://answers.unity3d.com/questions/445898/how-to-gradeintly-fill-a-bitmap-programmically.html
it may help
Answer by Eric5h5 · Jul 11, 2011 at 06:23 PM
Everything is possible, you just code it. Make an appropriate texture by creating a Color array, then use SetPixels and Apply. (Although you don't need 2x256, since 1x2 is sufficient due to bilinear filtering creating a gradient for you from two colors. You still need a Color array, but it only really needs two entries.)
say @Eric!
Let me ask you something. Did you recently change the spelling of your screen-name from Eric5x5 to Eric5h5 ? ("X" becomes "H")
For two years ... I could swear it was Eric5x5.
(ie, it's a reference to the military aviation slang "5x5" -- "received with great clarity" "all clear")
If not, i..e if I "mis-saw" it for two years, thousands of times ... that is freaky :O
Cheers :)
$$anonymous$$y screen name has remained unchanged for untold eons. In the beginning, there was Eric5h5, and it has been so ever since.
That is amazing. I can only apologise for all the times I typed "5x5". (I have eye problems.)
I'm truly sorry!
As I say I read it as "5x5" - military jargon for "perfect reception, clarity." (Which seemed very apt!) Again, sorry!!! $$anonymous$$akes me think of that website, cantbeunseen.com
Eric5h5 !
I don't remember you typing "5x5" actually. If the Google search I did just now is accurate, you only did it twice. So, I suppose I can forgive that. Possibly. $$anonymous$$aybe.
Your answer
Follow this Question
Related Questions
Create a custom texture from code? 1 Answer
Changing Part Of Texture/Material 1 Answer
Changing terrain texture at runtime 1 Answer