Alpha
This commit is contained in:
parent
bce746ca01
commit
b265a62e9f
|
@ -6,5 +6,5 @@ layout(location = 0) out vec4 color;
|
|||
in vec4 Color;
|
||||
|
||||
void main(){
|
||||
color = vec4(Color.xyz, .5);
|
||||
color = Color;
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
#version 330 core
|
||||
|
||||
// Ouput data
|
||||
layout(location = 0) out vec3 color;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
uniform sampler2DArray TextureAtlas;
|
||||
uniform sampler2DArray NormalAtlas;
|
||||
uniform sampler2DArray HOSAtlas;
|
||||
|
||||
uniform mat4 View;
|
||||
uniform vec3 FogColor;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
#ifdef GEOMETRY
|
||||
in GeometryData
|
||||
|
@ -62,10 +62,10 @@ vec4 getTexture(sampler2DArray sample, vec2 UV) {
|
|||
#endif
|
||||
}
|
||||
|
||||
vec3 getTriTexture(sampler2DArray sample, vec2 crdx, vec2 crdy, vec2 crdz, vec3 weights) {
|
||||
return getTexture(sample, crdx).rgb * weights.x +
|
||||
getTexture(sample, crdy).rgb * weights.y +
|
||||
getTexture(sample, crdz).rgb * weights.z;
|
||||
vec4 getTriTexture(sampler2DArray sample, vec2 crdx, vec2 crdy, vec2 crdz, vec3 weights) {
|
||||
return getTexture(sample, crdx) * weights.x +
|
||||
getTexture(sample, crdy) * weights.y +
|
||||
getTexture(sample, crdz) * weights.z;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -82,7 +82,7 @@ void main() {
|
|||
vec2 UVy = vs.Position_modelspace.zx * texScale;
|
||||
vec2 UVz = vs.Position_modelspace.xy * texScale;
|
||||
|
||||
vec3 tex = getTriTexture(TextureAtlas, UVx, UVy, UVz, blendWeights);
|
||||
vec4 tex = getTriTexture(TextureAtlas, UVx, UVy, UVz, blendWeights);
|
||||
|
||||
#ifdef PBR
|
||||
// Whiteout normal blend
|
||||
|
@ -96,7 +96,7 @@ void main() {
|
|||
// Swizzle tangent normals to match world orientation and triblend
|
||||
vec3 worldNormal = normalize(texNx.zyx * blendWeights.x + texNy.xzy * blendWeights.y +texNz.xyz * blendWeights.z);
|
||||
|
||||
vec3 texHOS = getTriTexture(HOSAtlas, UVx, UVy, UVz, blendWeights);
|
||||
vec3 texHOS = getTriTexture(HOSAtlas, UVx, UVy, UVz, blendWeights).rgb;
|
||||
#endif
|
||||
#else
|
||||
// Cheap planar
|
||||
|
@ -104,7 +104,7 @@ void main() {
|
|||
vec3 nrm = normalize(pow(blendWeights, vec3(80)));
|
||||
vec2 UV = (vec2(vs.Position_modelspace.xy * nrm.z) + vec2(vs.Position_modelspace.yz * nrm.x) + vec2(vs.Position_modelspace.zx * nrm.y)) * texScale;
|
||||
|
||||
vec3 tex = getTexture(TextureAtlas, UV).rgb;
|
||||
vec4 tex = getTexture(TextureAtlas, UV);
|
||||
#ifdef PBR
|
||||
vec3 texN = expand(getTexture(NormalAtlas, UV).rgb);
|
||||
// Swizzle world normals into tangent space and apply Whiteout blend
|
||||
|
@ -120,7 +120,7 @@ void main() {
|
|||
// Colors
|
||||
#ifdef PBR
|
||||
// Material properties
|
||||
vec3 MaterialDiffuseColor = tex;
|
||||
vec3 MaterialDiffuseColor = tex.rgb;
|
||||
vec3 MaterialAmbientColor = vec3(.1) * MaterialDiffuseColor * texHOS.y;
|
||||
vec3 MaterialSpecularColor = vec3(.8) * texHOS.z;
|
||||
|
||||
|
@ -158,18 +158,21 @@ void main() {
|
|||
// MAYBE: shadow
|
||||
|
||||
color =
|
||||
// Ambient : simulates indirect lighting
|
||||
MaterialAmbientColor +
|
||||
// Diffuse : "color" of the object
|
||||
visibility * MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance * distance) +
|
||||
// Specular : reflective highlight, like a mirror
|
||||
visibility * MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance * distance);
|
||||
vec4(
|
||||
// Ambient : simulates indirect lighting
|
||||
MaterialAmbientColor +
|
||||
// Diffuse : "color" of the object
|
||||
visibility * MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance * distance) +
|
||||
// Specular : reflective highlight, like a mirror
|
||||
visibility * MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance * distance),
|
||||
tex.a
|
||||
);
|
||||
#else
|
||||
color = tex;
|
||||
#endif
|
||||
#if FOG
|
||||
float ratio = exp(vs.Depth * 0.69)-1;
|
||||
color = mix(color, pow(FogColor, vec3(2.2)), clamp(ratio, 0, 1));
|
||||
color = mix(color, pow(FogColor, vec4(2.2)), clamp(ratio, 0, 1));
|
||||
#endif
|
||||
color = pow(color, vec3(1.0 / 2.2));
|
||||
color = pow(color, vec4(1.0 / 2.2));
|
||||
}
|
|
@ -79,6 +79,9 @@ GLFWwindow* createWindow(int samples) {
|
|||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
GLint smp;
|
||||
glGetIntegerv(GL_SAMPLES, &smp);
|
||||
if(smp > 0) {
|
||||
|
|
Loading…
Reference in New Issue