AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Color modulation with light_environment/skybox (https://forums.alliedmods.net/showthread.php?t=343424)

1xAero 07-22-2023 19:19

Color modulation with light_environment/skybox
 


Actually this is might be useful for someone. You can modulate players color, weapon, viewmodel.
But, one thing you need to know, the model should be with specific flag to make this work even in dark areas, where light is not exists. Without model editing, this will only work where the skybox illuminates the surface of the map.
So, you can decompile model and add into .qc file line with:

$flags 1024

Example of .qc file after editing:

Spoiler


This flag forces lights the model directly from light_environment, no matter where it is in the map.
Also this flag makes model always with maximum light level (lambert).

Spoiler

meTaLiCroSS 09-25-2023 16:47

Re: Color modulation with light_environment/skybox
 
You can just set directly cvar's values without handling entities. Replicate this code:

Code:
void CEnvLight::KeyValue(KeyValueData *pkvd) {     if (FStrEq(pkvd->szKeyName, "_light"))     {         int r, g, b, v, j;         j = sscanf(pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v);         if (j == 1)             g = b = r;         else if (j == 4)         {             r = r * (v / 255.0);             g = g * (v / 255.0);             b = b * (v / 255.0);         }         // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling         r = Q_pow(r / 114.0, 0.6) * 264;         g = Q_pow(g / 114.0, 0.6) * 264;         b = Q_pow(b / 114.0, 0.6) * 264;         pkvd->fHandled = TRUE;         char szColor[64];         Q_sprintf(szColor, "%d", r);         CVAR_SET_STRING("sv_skycolor_r", szColor);         Q_sprintf(szColor, "%d", g);         CVAR_SET_STRING("sv_skycolor_g", szColor);         Q_sprintf(szColor, "%d", b);         CVAR_SET_STRING("sv_skycolor_b", szColor);     }     else     {         CLight::KeyValue(pkvd);     } }

You can assume j = 4 and v = 255, handle cvar's pointers separately and use floatpower.

rtxa 12-09-2023 12:40

Re: Color modulation with light_environment/skybox
 
Thanks, I didn't know how to make it work in dark areas :)

I was experimenting with this feature in the past when porting Vampire-Slayer to HL but unfortunately I couldn't get to set this to individual players (e.g. only one type of vampires have nightvision). Any ideas?

https://i.imgur.com/41Mvrhb.jpg

The only solution I could thing off is to hook SVC_NEWMOVEVARS https://wiki.alliedmods.net/Half-Lif...VC_NEWMOVEVARS which is the message that contains the sky color values, but that probably requires Orpheu, not sure if there's a simpler solution, maybe using ReAPI move vars or AddToFullPack?


All times are GMT -4. The time now is 15:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.