I’m not sure if this is possible, but I’d like to make a material with an emmissive texture that’s brighter closer to the player and gets dimmer with distance. I imagine this would involve scripting a custom shader, but I dont really know where to start with this (or, again, if it’s possible to do this).
The closest thing I can think of would be to have several gameobjects with different textures and to adjust each material separately, but that would mean that each block shares one alpha and it would be a hard transition between each block. Hardly seems efficient, so if I can avoid doing that, that would be great.
It’s possible if you compute a fragment world position position with a fixed world position passed to the shader, if possibly you compute it on per vertex first and pass the interpolated result to the fragment, then mask it with a texture channel as you see fit. I’m not sure but you might also get object position then compute per vertex color.
The difference between all 3 is that it’s different scale,
per fragment will have a nice gradient on the entire object with closer pixel being brighter
per vertex will do the same but the brightness will accumulate around closest vertex
per object will have the entire object glow uniformly based on distance, so each object will have it’s own uniform glow based on distance, but it depend as if object position is a key parameter passed to shader …