I’m wanting to do something similar to how Google handles the elevation rules in their Material Design stuff. Using the following image, I’d like to be able to apply a drop shadow to my rectangles when I render them, based on their elevation.
Initially I was thinking of just using a texture, but I’m not sure I can pull off the scaling of the texture right as the elevation changed. Meaning the shadow becoming harder as the rectangle gets closer to the “bottom” and softer as it gets higher.
I would like to do this using a shader, but I’m not sure if that’s the right approach. If it is the correct approach, I don’t really know where to begin with that. I’ve never used a shader before and the MonoGame docs on how to create one and consume one is a little sparse I assumed I would apply this shader to a secondary rectangle that was scaled up/down beneath the real rectangle. The only thing I’m just not sure of is handling the changing in the shadow softness as the underlying shadow Rectangle size, gets closer to the bounds of its parent. Do shaders expose properties that I can use to determine how my shader is rendered? Basically letting me tweak the shader at runtime while the rectangle elevation changes. Like I said, I’m not familiar with shaders at all, so any input/advice or help would be massively appreciated.
What do you guys recommend?