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