Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

Allow $vertexcolor on VertexLitGeneric (or create new shader with that ability) with additive blending with dynamic lights #28

Open knah opened 11 years ago

knah commented 11 years ago

My request is to add support for $vertexcolor to VertexLitGeneric, or if that isn't possible, create a new shader to accomplish that. I'd also like this to be additive with dynamic lighting (or better, controllable whether it's additive or not), so that dynamic lights can actually add to vertex color instead of just multiplying it. Why additive? Imagine a situation where vertex is pitch black. With non-additive lights, it will be impossible to light it up. Obviously, normal models can't have vertex colors in them, and that's why VertexLitGeneric doesn't support this. But meshes can have colors and alpha specified per-vertex. One more possibility, if implementing this into VertexLitGeneric shader, would be adding another parameter, that acts like $color, but in the same additive manner. This way, it would be possible to shadow models inside of mesh easier using material proxies.

Why I need this? While experimenting with meshes recently, I came to a situation where I would want to add some custom lighting on mesh, as it was somewhat big and won't cast shadows on itself. This could be done by setting "color" attribute for each vertex, but here comes the problem: this attribute works only with UnlitGeneric shader, which, as the name says, ignores any dynamic light. If I manually darken areas of mesh that should be in shadow using UnlitGeneric, players won't be able to light it up with light sources such as lamps or lights. Technically it is possible to rebuild mesh with new vertex colors, but once the mesh gets big enough, rebuilding it would be way too slow to have any real application.

I have looked into different ways of accomplishing this task, and so far this seems to be the best one. Splitting mesh into lit and unlit parts and rendering them with overridden lighting is not an option because of visible sews, and that probably will override dynamic lighting too. Making whole map dark and using only dynamic lights is also not an option, as that would be a huge hit on performance on lower-end users. Also consider how limited dynamic lights are - not directional, no control over quadratic/linear falloff, no shadows, etc.

ghost commented 11 years ago

Agreed - we've needed something like this for a while now

AlexCSDev commented 11 years ago

Yep, need this.

Caskoo commented 5 years ago

Very interesting suggestion.

cannon commented 4 years ago

Bump, I would really like this for my block-building addon. I want $vertexcolor on VertexLitGeneric to multiply the colors of blocks. Right now I'm trying to combine different block textures, different lighting styles, and different colors, and it's really tough to do it all with textures.

theomonnom commented 3 years ago

Bump ?

garryspins commented 11 months ago

Bump