Raised This Month: $ Target: $400
 0% 

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 , 20: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 , 17: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
Reply


Thread Tools
Display Modes

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 04:29.


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