- Home /
How to create a shader for a dynamic linear gradient
TLDR; How do I create a linear gradient in Shader Graph with dynamic color segments (dynamic in both quantity and color)?
Hello! I'm working on a project where I am literally attempting to create the effect of a linear RGBW LED strip light. I already have dynamic color data being generated for the individual diodes in a C# script. This data is being used by actual light objects in the scene. Now, I'm struggling to create a physical lens to visually represent the diffused light emission. For simplicity sake, think of a long skinny rectangle/plane object. I'd like to create a shader for this lens object which would take in the color data of the diodes. This would, effectively, be a linear gradient with many color segments that are changing over time (per the diode color data).
I am very new at creating shaders with Shader Graph, so this has been very challenging for me..
I understand that I can create exposed Color variables in the shader and then update those colors from my C# script, however, per the requirements of the project the quantity of diodes must also be dynamic to change the overall length of the LED strip. So, initializing these Color variables in the Shader Graph is obviously not an option.
I thought about creating a Texture2D, which would contain a 1 dimensional array of pixels representing the color data per diode, and then could possibly blend those colors together somehow in the shader logic? I just don't know how to actually do that..
Any suggestions or thoughts would be incredibly helpful.. Please keep in mind that I am very new to shaders. Thanks!
Your answer
Follow this Question
Related Questions
Converting c# function to shader. 0 Answers
perform action on shader compilation/update 0 Answers
Shader Problem 0 Answers
Shader tiling error 0 Answers
Retrieving information from texture not working in shader graph 0 Answers