Skip to content

Instantly share code, notes, and snippets.

@xDShot
Last active October 12, 2020 18:16
Show Gist options
  • Save xDShot/03076a981fec9870a1e1924d8fd23383 to your computer and use it in GitHub Desktop.
Save xDShot/03076a981fec9870a1e1924d8fd23383 to your computer and use it in GitHub Desktop.
Source HSV to RGB material proxy
"VertexLitGeneric"
{
$baseTexture "models/shadow_warrior/sword/reskins/z45_rgb"
$bumpmap "models/shadow_warrior/sword/katana_energetic_n"
$blendtintbybasealpha 1
$color "[1 .3 0]"
// BEGIN OF HSV2RGB
$Hue 1.00
$Saturate 1.00
$Value 1.00
$_ONE 1
$_ZERO 0
$_STEP0 .00
$_STEP1 .16
$_STEP2 .33
$_STEP3 .5
$_STEP4 .66
$_STEP5 .83
$_STEP6 1.00
$_r_fadein 0.00
$_r_fadeout 1.00
$_g_fadein 0.00
$_g_fadeout 1.00
$_b_fadein 0.00
$_b_fadeout 1.00
$_tmp 0.00
$_saturate 0.00
$_r 0
$_g 0
$_b 0
// END OF HSV2RGB
"Proxies"
{
// BEGIN OF HSV2RGB
// --* RED *--
//Fadein
Subtract
{
srcVar1 $_STEP5
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_r_fadein
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_r_fadein
resultVar $_r_fadein
}
//Fadeout
Subtract
{
srcVar1 $_STEP2
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_r_fadeout
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP1 // > srcVar2
resultVar $_r // { resultVar =
greaterVar $_r_fadeout // greaterVar }
LessEqualVar $_ONE // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP2 // > srcVar2
resultVar $_r // { resultVar =
greaterVar $_ZERO // greaterVar }
LessEqualVar $_r // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP4 // > srcVar2
resultVar $_r // { resultVar =
greaterVar $_r_fadein // greaterVar }
LessEqualVar $_r // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP5 // > srcVar2
resultVar $_r // { resultVar =
greaterVar $_ONE // greaterVar }
LessEqualVar $_r // else { resultVar = LessEqualVar }
}
// --* GREEN *--
//Fadein
Subtract
{
srcVar1 $_STEP1
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_g_fadein
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_g_fadein
resultVar $_g_fadein
}
//Fadeout
Subtract
{
srcVar1 $_STEP4
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_g_fadeout
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP0 // > srcVar2
resultVar $_g // { resultVar =
greaterVar $_g_fadein // greaterVar }
LessEqualVar $_ZERO // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP1 // > srcVar2
resultVar $_g // { resultVar =
greaterVar $_ONE // greaterVar }
LessEqualVar $_g // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP3 // > srcVar2
resultVar $_g // { resultVar =
greaterVar $_g_fadeout // greaterVar }
LessEqualVar $_g // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP4 // > srcVar2
resultVar $_g // { resultVar =
greaterVar $_ZERO // greaterVar }
LessEqualVar $_g // else { resultVar = LessEqualVar }
}
// --* BLUE *--
//Fadein
Subtract
{
srcVar1 $_STEP3
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_b_fadein
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_b_fadein
resultVar $_b_fadein
}
//Fadeout
Subtract
{
srcVar1 $_STEP6
srcVar2 $Hue
resultVar $_tmp
}
Divide
{
srcVar1 $_tmp
srcVar2 $_STEP1
resultVar $_b_fadeout
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP2 // > srcVar2
resultVar $_b // { resultVar =
greaterVar $_b_fadein // greaterVar }
LessEqualVar $_ZERO // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP3 // > srcVar2
resultVar $_b // { resultVar =
greaterVar $_ONE // greaterVar }
LessEqualVar $_b // else { resultVar = LessEqualVar }
}
LessOrEqual
{
srcVar1 $Hue // if srcVar1
srcVar2 $_STEP5 // > srcVar2
resultVar $_b // { resultVar =
greaterVar $_b_fadeout // greaterVar }
LessEqualVar $_b // else { resultVar = LessEqualVar }
}
//Clamp values 0-1
Clamp
{
min $_ZERO
max $_ONE
srcVar1 $_r
resultVar $_r
}
Clamp
{
min $_ZERO
max $_ONE
srcVar1 $_g
resultVar $_g
}
Clamp
{
min $_ZERO
max $_ONE
srcVar1 $_b
resultVar $_b
}
// Saturate
Subtract
{
srcVar1 $_ONE
srcVar2 $Saturate
resultVar $_saturate
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_r
resultVar $_tmp
}
Multiply
{
srcVar1 $_tmp
srcVar2 $_saturate
resultVar $_tmp
}
Add
{
srcVar1 $_r
srcVar2 $_tmp
resultVar $_r
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_g
resultVar $_tmp
}
Multiply
{
srcVar1 $_tmp
srcVar2 $_saturate
resultVar $_tmp
}
Add
{
srcVar1 $_g
srcVar2 $_tmp
resultVar $_g
}
Subtract
{
srcVar1 $_ONE
srcVar2 $_b
resultVar $_tmp
}
Multiply
{
srcVar1 $_tmp
srcVar2 $_saturate
resultVar $_tmp
}
Add
{
srcVar1 $_b
srcVar2 $_tmp
resultVar $_b
}
// Value
Multiply
{
srcVar1 $_r
srcVar2 $Value
resultVar $_r
}
Multiply
{
srcVar1 $_g
srcVar2 $Value
resultVar $_g
}
Multiply
{
srcVar1 $_b
srcVar2 $Value
resultVar $_b
}
//Return values
Equals
{
srcVar1 $_r
resultVar "$color[0]"
}
Equals
{
srcVar1 $_g
resultVar "$color[1]"
}
Equals
{
srcVar1 $_b
resultVar "$color[2]"
}
// END OF HSV2RGB
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment