Make sure specular highlights from punctual lights don't fall off of polished surfaces
parent
54e6c554c5
commit
13ac0f77ff
|
|
@ -351,23 +351,6 @@ vec3 hue_to_rgb(float hue)
|
|||
|
||||
// PBR Utils
|
||||
|
||||
// ior Index of Refraction, normally 1.5
|
||||
// returns reflect0
|
||||
float calcF0(float ior)
|
||||
{
|
||||
float f0 = (1.0 - ior) / (1.0 + ior);
|
||||
return f0 * f0;
|
||||
}
|
||||
|
||||
vec3 fresnel(float vh, vec3 f0, vec3 f90 )
|
||||
{
|
||||
float x = 1.0 - abs(vh);
|
||||
float x2 = x*x;
|
||||
float x5 = x2*x2*x;
|
||||
vec3 fr = f0 + (f90 - f0)*x5;
|
||||
return fr;
|
||||
}
|
||||
|
||||
vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh)
|
||||
{
|
||||
return reflect0 + (reflect90 - reflect0) * pow(clamp(1.0 - vh, 0.0, 1.0), 5.0);
|
||||
|
|
@ -682,6 +665,9 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
|
|||
vec3 v, // surface point to camera
|
||||
vec3 l) //surface point to light
|
||||
{
|
||||
// make sure specular highlights from punctual lights don't fall off of polished surfaces
|
||||
perceptualRoughness = max(perceptualRoughness, 8.0/255.0);
|
||||
|
||||
float alphaRoughness = perceptualRoughness * perceptualRoughness;
|
||||
|
||||
// Compute reflectance.
|
||||
|
|
|
|||
|
|
@ -111,9 +111,6 @@ void main()
|
|||
float depth = texture2DRect(depthMap, tc.xy).r;
|
||||
vec4 pos = getPositionWithDepth(tc, depth);
|
||||
vec4 norm = texture2DRect(normalMap, tc);
|
||||
float envIntensity = norm.z;
|
||||
norm.xyz = getNorm(tc);
|
||||
|
||||
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
|
||||
float light_gamma = 1.0 / 1.3;
|
||||
|
||||
|
|
@ -147,6 +144,7 @@ void main()
|
|||
bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR);
|
||||
if (hasPBR)
|
||||
{
|
||||
norm.xyz = getNorm(tc);
|
||||
vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
|
||||
float perceptualRoughness = orm.g;
|
||||
float metallic = orm.b;
|
||||
|
|
@ -164,6 +162,10 @@ void main()
|
|||
vec3 f0 = vec3(0.04);
|
||||
vec3 baseColor = diffuse.rgb;
|
||||
|
||||
//baseColor.rgb = vec3(0,0,0);
|
||||
//colorEmissive = srgb_to_linear(norm.xyz*0.5+0.5);
|
||||
|
||||
|
||||
vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
|
||||
diffuseColor *= 1.0 - metallic;
|
||||
|
||||
|
|
@ -187,6 +189,9 @@ void main()
|
|||
}
|
||||
else
|
||||
{
|
||||
float envIntensity = norm.z;
|
||||
norm.xyz = getNorm(tc);
|
||||
|
||||
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
|
||||
da = pow(da, light_gamma);
|
||||
|
||||
|
|
@ -249,5 +254,6 @@ void main()
|
|||
frag_color.rgb = srgb_to_linear(color.rgb);
|
||||
}
|
||||
|
||||
|
||||
frag_color.a = bloom;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue