forked from OctaForge/OctaCore
76 lines
1.8 KiB
INI
76 lines
1.8 KiB
INI
////////////////////////////////////////////////
|
|
//
|
|
// stain shaders
|
|
//
|
|
////////////////////////////////////////////////
|
|
|
|
// staintype:
|
|
// o -> overbright
|
|
// t -> transparent
|
|
// f -> fogged
|
|
|
|
stainopt = [ >= (strstr $staintype $arg1) 0 ]
|
|
|
|
stainvariantshader = [
|
|
local staintype
|
|
staintype = $arg2
|
|
variantshader 0 $arg1 (? (stainopt "t") 0 -1) (if (! (stainopt "t")) [result [
|
|
@(? (stainopt "f") [
|
|
//:fog
|
|
])
|
|
attribute vec4 vvertex, vcolor;
|
|
attribute vec2 vtexcoord0;
|
|
uniform mat4 camprojmatrix;
|
|
uniform vec4 colorscale;
|
|
varying vec4 color;
|
|
varying vec2 texcoord0;
|
|
void main(void)
|
|
{
|
|
gl_Position = camprojmatrix * vvertex;
|
|
color = vcolor * colorscale;
|
|
texcoord0 = vtexcoord0;
|
|
}
|
|
]]) [
|
|
uniform sampler2D tex0;
|
|
varying vec4 color;
|
|
varying vec2 texcoord0;
|
|
fragdata(0) vec4 fragcolor;
|
|
@(? (stainopt "t") [
|
|
fragdata(1) vec4 gglow;
|
|
])
|
|
void main(void)
|
|
{
|
|
vec4 diffuse = texture2D(tex0, texcoord0);
|
|
@(if (stainopt "o") [result [
|
|
diffuse.rgb = mix(vec3(0.5), diffuse.rgb, color.rgb);
|
|
fragcolor.rgb = diffuse.rgb;
|
|
fragcolor.a = 0.5;
|
|
@(? (stainopt "t") [
|
|
gglow.rgb = diffuse.rgb;
|
|
gglow.a = 0.5;
|
|
])
|
|
]] [result [
|
|
diffuse *= color;
|
|
fragcolor = diffuse;
|
|
@(? (stainopt "t") [
|
|
gglow.rgb = vec3(0.0);
|
|
gglow.a = diffuse.a;
|
|
])
|
|
]])
|
|
}
|
|
]
|
|
]
|
|
|
|
stainshader = [
|
|
staintype = $arg2
|
|
stainvariantshader $arg1 $arg2
|
|
if (! (stainopt "f")) [
|
|
stainvariantshader $arg1 (concatword $arg2 "t")
|
|
]
|
|
]
|
|
|
|
stainshader "stain" ""
|
|
stainshader "overbrightstain" "o"
|
|
stainshader "foggedstain" "f"
|
|
|