Skip to content

Commit 7a93006

Browse files
committed
this adds opacity support to stock shaders
1 parent 4e520db commit 7a93006

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

per-fragment-phong.fs.glsl

+7-11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ in VS_OUT
2323
uniform vec3 diffuse_albedo;
2424
uniform vec3 specular_albedo;
2525
uniform float specular_power;
26+
uniform float opacity = 1.0;
2627
uniform vec3 ambient;
2728

2829
uniform sampler2D base_texture;
@@ -35,7 +36,7 @@ vec3 light_position = vec3(0.0, 0.0, 100.0);
3536
subroutine(color_t)
3637
vec4 Constant()
3738
{
38-
return vec4(ambient, 1.0);
39+
return vec4(ambient, opacity);
3940
}
4041

4142
subroutine(color_t)
@@ -56,19 +57,14 @@ vec4 PerPixelLighting()
5657
vec3 diffuse = max(dot(s, n), 0.0) * diffuse2;
5758
vec3 specular = pow(max(dot(r, v), 0.0), specular_power) * specular_albedo;
5859

59-
return vec4(ambient + diffuse + specular, 1.0);
60-
}
61-
62-
subroutine(color_t)
63-
vec4 PPLWithTextureAndVignette()
64-
{
65-
return texture(base_texture, fs_in.T);
60+
return vec4(ambient + diffuse + specular, opacity);
6661
}
6762

6863
subroutine(color_t)
6964
vec4 PPLWithTexture()
7065
{
71-
vec3 diffuse2 = vec3(texture(base_texture, fs_in.T));
66+
vec4 t = texture(base_texture, fs_in.T);
67+
vec3 diffuse2 = vec3(t);
7268
vec3 N2 = fs_in.N;
7369

7470
if (!gl_FrontFacing)
@@ -82,8 +78,8 @@ vec4 PPLWithTexture()
8278
vec3 diffuse = max(dot(s, n), 0.0) * diffuse2;
8379
vec3 specular = pow(max(dot(r, v), 0.0), specular_power) * specular_albedo;
8480

85-
return vec4(ambient + diffuse + specular, 1.0);
86-
//vec4(fs_in.T.t, fs_in.T.t, fs_in.T.t, 0); //
81+
return vec4(vec3(ambient + diffuse + specular), t.a * opacity);
82+
//vec4(fs_in.T.t, fs_in.T.t, fs_in.T.t, 0); //
8783
}
8884

8985
subroutine(color_t)

0 commit comments

Comments
 (0)