Commit c3e5e3b5 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

HDR lighting

parent 3b3d797a
Pipeline #1141 passed with stages
in 54 minutes and 28 seconds
......@@ -769,13 +769,13 @@
<key>RenderToneMapType</key>
<map>
<key>Comment</key>
<string>Tonemapping type 0 - None, 1 - Linear, 2 - Reinhard, 3 - Reinhard2, 4 - Filmic, 5 - Unreal, 6 - ACES, 7 - Uchimura, 8 - Lottes, 9 - Uncharted</string>
<string>Tonemapping type 0 - HDR Debug, 1 - Linear, 2 - Reinhard, 3 - Reinhard2, 4 - Filmic, 5 - Unreal, 6 - ACES, 7 - Uchimura, 8 - Lottes, 9 - Uncharted</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>0</integer>
<integer>7</integer>
</map>
<key>RenderToneMapUchimuraA</key>
<map>
......@@ -803,7 +803,7 @@
<key>Value</key>
<array>
<real>0.4</real>
<real>1.33</real>
<real>1.13</real>
<real>0.0</real>
</array>
</map>
......
......@@ -46,7 +46,7 @@ vec3 linear_to_srgb(vec3 cl);
vec3 reinhard(vec3 x)
{
return x/(1+x);
return x/(1+x);
}
vec3 reinhard2(vec3 x) {
......@@ -56,9 +56,9 @@ vec3 reinhard2(vec3 x) {
vec3 filmic(vec3 color)
{
color = max(vec3(0.), color - vec3(0.004));
color = (color * (6.2 * color + .5)) / (color * (6.2 * color + 1.7) + 0.06);
return color;
color = max(vec3(0.), color - vec3(0.004));
color = (color * (6.2 * color + .5)) / (color * (6.2 * color + 1.7) + 0.06);
return color;
}
vec3 unreal(vec3 x)
......@@ -178,8 +178,9 @@ void main()
#if TONEMAP_METHOD == 0 // None, Gamma Correct Only
#define NEEDS_GAMMA_CORRECT 1
#elif TONEMAP_METHOD == 1 // Linear
#elif TONEMAP_METHOD == 1 // Linear
#define NEEDS_GAMMA_CORRECT 1
diff.rgb = clamp(diff.rgb, 0, 1);
#elif TONEMAP_METHOD == 2 // Reinhard method
#define NEEDS_GAMMA_CORRECT 1
diff.rgb = reinhard(diff.rgb);
......@@ -212,25 +213,25 @@ void main()
#if COLOR_GRADE_LUT
// Invert coord for compat with DX-style LUT
diff.y = 1.0 - diff.y;
diff.y = 1.0 - diff.y;
// Convert to texel coords
vec3 lutRange = diff.rgb * ( colorgrade_lut_size.w - 1);
// Convert to texel coords
vec3 lutRange = diff.rgb * ( colorgrade_lut_size.w - 1);
// Calculate coords in texel space
vec2 lutX = vec2(floor(lutRange.z)*colorgrade_lut_size.w+lutRange.x, lutRange.y);
vec2 lutY = vec2(ceil(lutRange.z)*colorgrade_lut_size.w+lutRange.x, lutRange.y);
vec2 lutX = vec2(floor(lutRange.z)*colorgrade_lut_size.w+lutRange.x, lutRange.y);
vec2 lutY = vec2(ceil(lutRange.z)*colorgrade_lut_size.w+lutRange.x, lutRange.y);
// texel to ndc
lutX = (lutX+0.5)*colorgrade_lut_size.xy;
lutY = (lutY+0.5)*colorgrade_lut_size.xy;
// texel to ndc
lutX = (lutX+0.5)*colorgrade_lut_size.xy;
lutY = (lutY+0.5)*colorgrade_lut_size.xy;
// LUT interpolation
diff.rgb = mix(
// LUT interpolation
diff.rgb = mix(
texture2D(colorgrade_lut, lutX).rgb,
texture2D(colorgrade_lut, lutY).rgb,
fract(lutRange.z)
);
);
#endif
frag_color = diff;
......
......@@ -158,7 +158,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt / (nh*da);
vec3 speccol = lit*scol*light_col.rgb*spec.rgb;
speccol = clamp(speccol, vec3(0), vec3(1));
speccol = max(speccol, vec3(0));
col += speccol;
float cur_glare = max(speccol.r, speccol.g);
......
......@@ -229,8 +229,9 @@ void main()
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
col += dlit*scol*spec.rgb;
//col += spec.rgb;
vec3 speccol = dlit*scol*spec.rgb;
speccol = max(speccol, vec3(0));
col += speccol;
}
}
......
......@@ -229,8 +229,9 @@ void main()
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
col += dlit*scol*spec.rgb;
//col += spec.rgb;
vec3 speccol = dlit*scol*spec.rgb;
speccol = max(speccol, vec3(0));
col += speccol;
}
}
......
......@@ -43,7 +43,6 @@ vec3 srgb_to_linear(vec3 cs)
vec3 linear_to_srgb(vec3 cl)
{
cl = clamp(cl, vec3(0), vec3(1));
vec3 low_range = cl * 12.92;
vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055;
bvec3 lt = lessThan(cl,vec3(0.0031308));
......
......@@ -225,9 +225,10 @@ void main()
vec4 spec = texture2DRect(specularRect, frag.xy);
if (spec.a > 0.0)
{
vec3 npos = -normalize(pos);
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
vec3 h = normalize(lv+npos);
float nh = dot(norm, h);
......@@ -243,7 +244,7 @@ void main()
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
vec3 speccol = dlit*scol*spec.rgb*shadow;
speccol = clamp(speccol, vec3(0), vec3(1));
speccol = max(speccol, vec3(0));
col += speccol;
}
}
......
......@@ -225,6 +225,7 @@ void main()
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
......@@ -242,7 +243,7 @@ void main()
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
vec3 speccol = dlit*scol*spec.rgb*shadow;
speccol = clamp(speccol, vec3(0), vec3(1));
speccol = max(speccol, vec3(0));
col += speccol;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment