Assortment of VKDoom-related shader fixes.

This commit is contained in:
Mari the Deer 2025-02-09 16:17:53 +01:00
commit 9a9c419dc1
5 changed files with 19 additions and 147 deletions

View file

@ -29,15 +29,9 @@ void SetupMaterial( inout Material mat )
envcol = (envcol+grad)*.25;
#endif
mat.Base = vec4(envcol,1.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}
vec4 ProcessLight( Material mat, vec4 color )
{
#ifdef AMBIENT_GLOW
float glow = .75+.25*sin(timer*8.);
return vec4(vec3(glow),color.a);
#else
return color;
mat.Glow = vec4(vec3(glow),1.);
#endif
mat.Normal = ApplyNormalMap(vTexCoord.st);
}

View file

@ -41,40 +41,37 @@ vec3 GradientMap( in vec3 color )
{
float gray = dot(color,vec3(.333333));
vec2 pos = vec2(gray/2.+.25,0.);
return textureLod(gradtex,pos,0.).rgb;
return texture(gradtex,pos,0.).rgb;
}
void SetupMaterial( inout Material mat )
{
// store these to save some time
vec2 size = vec2(textureSize(Layer1,0));
vec2 pxsize = 1./size;
// y'all ready for this multilayered madness?
vec2 uv = vTexCoord.st;
// base blank layer
vec4 base = vec4(1.);
// first layer, warp then multiply red
base.rgb *= textureLod(Layer1,warpcoord(uv),0.).x;
base.rgb *= texture(Layer1,warpcoord(uv)).x;
// first layer, multiply green
base.rgb *= textureLod(Layer1,uv,0.).y;
base.rgb *= texture(Layer1,uv).y;
// first layer, add blue
base.rgb += textureLod(Layer1,uv,0.).zzz;
base.rgb += texture(Layer1,uv).zzz;
// multiply by red fade
base.rgb *= textureLod(fadetex,vec2(.5),0.).x;
base.rgb *= texture(fadetex,vec2(.5)).x;
// gradient map result
base.rgb = GradientMap(base.rgb);
// color to alpha
base = blacktoalpha(base);
// second layer, alpha blend
vec4 tmp = textureLod(Layer2,uv,0.);
vec4 tmp = texture(Layer2,uv);
vec4 tmp2;
tmp2.a = tmp.a+base.a*(1.-tmp.a);
tmp2.rgb = (tmp.rgb*tmp.a+base.rgb*base.a*(1.-tmp.a))/tmp2.a;
base = tmp2;
// third layer, hard light with two multiplied masks
tmp.xy = textureLod(Layer3,uv,0.).xy;
tmp.z = textureLod(fadetex,vec2(.5),0.).y;
tmp.y *= textureLod(Layer3,clamp(uv+vec2(1.-tmp.z*2.,0.),vec2(0.),vec2(1.)),0.).z;
tmp.xy = texture(Layer3,uv).xy;
tmp.z = texture(fadetex,vec2(.5)).y;
tmp.y *= texture(Layer3,clamp(uv+vec2(1.-tmp.z*2.,0.),vec2(0.),vec2(1.))).z;
tmp2.r = hardlight(base.r,tmp.x);
tmp2.g = hardlight(base.g,tmp.x);
tmp2.b = hardlight(base.b,tmp.x);

View file

@ -3,16 +3,13 @@
void SetupMaterial( inout Material mat )
{
mat.Base = getTexel(vTexCoord.st);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}
vec4 ProcessLight( Material mat, vec4 color )
{
float mixfct = mix(1.,.5,floor(abs(vTexCoord.s-.5)*2.133333));
mixfct = mix(mixfct,.5,floor(abs(vTexCoord.t-.5)*2.13333));
mat.Base.rgb *= mixfct;
vec3 light = vec3(-.6,.7,.8);
float val = max(dot(normalize(vEyeNormal.xyz),light),.25);
val += .2*pow(max(dot(normalize(vEyeNormal.xyz),light),0.),4.);
float mixfct = mix(1.,.5,floor(abs(vTexCoord.s-.5)*2.133333));
mixfct = mix(mixfct,.5,floor(abs(vTexCoord.t-.5)*2.13333));
val *= mixfct;
return vec4(vec3(val),color.a);
mat.Base.rgb *= val;
mat.Bright = vec4(1.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}