Raised This Month: $51 Target: $400
 12% 

Color modulation with light_environment/skybox


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
1xAero
Member
Join Date: Feb 2018
Location: Sakha, Russia
Old 07-22-2023 , 19:19   Color modulation with light_environment/skybox
Reply With Quote #1



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
1xAero is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-25-2023 , 16:47   Re: Color modulation with light_environment/skybox
Reply With Quote #2

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.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 12-09-2023 , 12:40   Re: Color modulation with light_environment/skybox
Reply With Quote #3

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?



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?
__________________

Last edited by rtxa; 12-10-2023 at 11:59.
rtxa is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:29.


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