• Alpha-based Color Tinting on LightmappedGeneric Textures
    4 replies, posted
So similar to how Garry's Mod colors the clothes on player models, I'm implementing a system that changes the color of certain world textures for a gamemode I'm working on depending on which two teams are decided to play for the map (red, blue, green and orange). I'm able to get said textures to change color after the teams have been chosen (directly setting the $color parameter in lua), but the only downside is it ignores the alpha mask of the base texture, which means the entire texture gets colored ($blendTintByBaseAlpha is being ignored in the material file, despite it being set to 1). This is pretty undesirable and ultimately limits the system to have entire textures become tinted. One thing to note is that changing the material's shader to VertexLitGeneric fixes this coloring issue, but of course it completely screws up the shading, and recompiling the map with this change will result in the material not calculating the lightmaps. Here's a comparison of the two shaders - the first image is what I have, but don't want, and the second is what I want, but can't have: LightmappedGeneric (prefer not to have) https://files.facepunch.com/forum/upload/111825/2f59dbf6-bd06-4fa4-9965-1b4196d35588/temp1.PNG VertexLitGeneric (prefer to have, but unreliable and broken) https://files.facepunch.com/forum/upload/111825/c80f47a6-f42b-442a-b083-5560a17fd82e/temp2.PNG Any help on the subject is greatly appreciated.
You gotta remember that valve material system is pretty limited and lots of features disables other features, like phong and transparency, can you compare by using a playermodel vmt and trying to adapt it? My bets are that you have to use $basemapalphaphongmask 1
It is also very possible that the lightmapped shader just doesnt support that material parameter.
$blendTintByBaseAlpha is only supported by VertexLitGeneric, UnlitGeneric, and Skin. Since no shader exists to do what you want, and gmod doesn't support custom shaders, you will have to improvise. You can change the material texture to a render target at runtime, and render whatever you need to the render target.
Thanks for the replies so far. @Rubat and @Jcw87 , seems like you're right in that the LightmappedGeneric shader just simply doesn't use the parameter at all. After tinkering more a few hours ago, I managed to get a much more pleasant result with the use of a detail texture, which gets colored instead of the base texture itself. The detail texture generally looks something like a specular map, with darker areas being less affected by the tint color than the lighter ones. Here's an example of a regular albedo texture: https://files.facepunch.com/forum/upload/111825/597e1a5a-763d-43d7-b79e-334f9efaa272/image.png with its "color map" that gets used as a detail texture: https://files.facepunch.com/forum/upload/111825/de136e61-bf29-413c-a6d1-d81ed28a4104/image.png I currently have it so that the material's detail texture multiplies its tint color by a lot to mitigate the darkening of parts that shouldn't be colored ASAP, so $detailblendfactor ends up being closer to 0.01 and still remain very colorful. Here's a demonstration video showing the real-time changing of side teams, and how the textures now change accordingly and how they look now! https://www.youtube.com/watch?v=aATnBM7ecOY&feature=youtu.be So for now this should work. Only tedious thing about it is having to create a separate material when you really shouldn't have to, but it certainty beats the alternative so far.
Sorry, you need to Log In to post a reply to this thread.