Add the support for emit map. For the moment it's only for solid objects
This commit is contained in:
@@ -18,7 +18,7 @@ varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -31,5 +31,5 @@ void main(void)
|
||||
vec4 detail = texture(Detail, uv_bis);
|
||||
color *= detail;
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -42,6 +42,6 @@ void main(void)
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap);
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -30,5 +30,5 @@ void main(void)
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
#endif
|
||||
color *= detail;
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -48,6 +48,6 @@ void main(void)
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
|
||||
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap);
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
||||
|
||||
@@ -11,20 +11,23 @@ in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef GL_ARB_bindless_texture
|
||||
vec4 col = texture(handle, uv);
|
||||
float specmap = texture(secondhandle, uv).g;
|
||||
float emitmap = texture(secondhandle, uv).b;
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(Albedo, uv);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
#endif
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
|
||||
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ out vec4 FragColor;
|
||||
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main() {
|
||||
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
@@ -30,5 +30,5 @@ void main() {
|
||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||
#endif
|
||||
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -27,5 +27,5 @@ void main(void)
|
||||
#endif
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -24,5 +24,5 @@ void main(void)
|
||||
#endif
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ varying vec3 nor;
|
||||
#endif
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main() {
|
||||
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
@@ -31,5 +31,5 @@ void main() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -23,5 +23,5 @@ void main(void)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
void main() {
|
||||
// Splatting part
|
||||
@@ -46,5 +46,5 @@ void main() {
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
|
||||
FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0.), 1.);
|
||||
FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@ uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue)
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue;
|
||||
return tmp * ao;
|
||||
}
|
||||
vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.;
|
||||
return tmp * ao + (emitMapValue * emitCol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user