Skip to content

Commit

Permalink
Update to Harfang 3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ErkMkd committed Jun 17, 2022
1 parent 82de89e commit 0723f7e
Show file tree
Hide file tree
Showing 58 changed files with 553 additions and 978 deletions.
7 changes: 0 additions & 7 deletions assets/core/pbr/brdf.dds.meta

This file was deleted.

Binary file removed assets/core/pbr/night_sky.hdr
Binary file not shown.
7 changes: 0 additions & 7 deletions assets/core/pbr/night_sky.hdr.meta

This file was deleted.

1 change: 1 addition & 0 deletions assets/core/shader/a_trous_fs.sc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_color, 0);
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/a_trous_vs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input a_position

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

void main() {
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/aaa_downsample_fs.sc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_color, 0);
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/aaa_downsample_vs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input a_position

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

void main() {
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/aaa_upsample_fs.sc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_input, 0);
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/aaa_upsample_vs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input a_position

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

void main() {
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/aaa_utils.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#ifndef AAA_UTILS_SH_HEADER_GUARD
#define AAA_UTILS_SH_HEADER_GUARD

Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/bloom_combine_fs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_source, 0);
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/bloom_combine_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <bgfx_shader.sh>

void main() {
Expand Down
36 changes: 23 additions & 13 deletions assets/core/shader/bloom_downsample_fs.sc
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_source, 0);
uniform vec4 u_source_rect;

vec2 compute_texel(vec2 uv, vec2 center, vec4 bounds) {
vec4 w = vec4(step(bounds.xy, uv), step(uv, bounds.zw));
return mix(center, uv, vec2(w.x*w.z, w.y*w.w));
}

void main() {
vec2 uv = v_texcoord0.xy;
vec4 offset = vec4(-1., 1., 1., 0.) / uResolution.xxyy;

vec4 s0 = texture2D(u_source, uv - offset.yz);
vec4 s1 = texture2D(u_source, uv - offset.wz);
vec4 s2 = texture2D(u_source, uv - offset.xz);
vec2 center = (floor(v_texcoord0.xy * uResolution.xy) + vec2_splat(0.5)) / uResolution.xy;
vec4 bounds = (floor(u_source_rect.xyzw) + vec4(1.,1.,-1.,-1.)) / uResolution.xyxy;

vec4 s0 = texture2D(u_source, compute_texel(uv - offset.yz, center, bounds)); // -1,-1
vec4 s1 = texture2D(u_source, compute_texel(uv - offset.wz, center, bounds)); // 0,-1
vec4 s2 = texture2D(u_source, compute_texel(uv - offset.xz, center, bounds)); // 1,-1

vec4 s3 = texture2D(u_source, uv + offset.xw);
vec4 s4 = texture2D(u_source, uv);
vec4 s5 = texture2D(u_source, uv + offset.yw);
vec4 s3 = texture2D(u_source, compute_texel(uv + offset.xw, center, bounds)); // -1, 0
vec4 s4 = texture2D(u_source, compute_texel(uv, center, bounds)); // 0, 0
vec4 s5 = texture2D(u_source, compute_texel(uv + offset.yw, center, bounds)); // 1, 0

vec4 s6 = texture2D(u_source, uv + offset.xz);
vec4 s7 = texture2D(u_source, uv + offset.wz);
vec4 s8 = texture2D(u_source, uv + offset.yz);
vec4 s6 = texture2D(u_source, compute_texel(uv + offset.xz, center, bounds)); // -1, 1
vec4 s7 = texture2D(u_source, compute_texel(uv + offset.wz, center, bounds)); // 0, 1
vec4 s8 = texture2D(u_source, compute_texel(uv + offset.yz, center, bounds)); // 1, 1

offset = 0.5 * offset;

vec4 t0 = texture2D(u_source, uv - offset.yz);
vec4 t1 = texture2D(u_source, uv - offset.xz);
vec4 t2 = texture2D(u_source, uv + offset.xz);
vec4 t3 = texture2D(u_source, uv + offset.yz);
vec4 t0 = texture2D(u_source, compute_texel(uv - offset.yz, center, bounds)); // -1,-1
vec4 t1 = texture2D(u_source, compute_texel(uv - offset.xz, center, bounds)); // 1,-1
vec4 t2 = texture2D(u_source, compute_texel(uv + offset.xz, center, bounds)); // -1, 1
vec4 t3 = texture2D(u_source, compute_texel(uv + offset.yz, center, bounds)); // 1, 1

vec4 v0 = s0 + s1 + s3 + s4;
vec4 v1 = s1 + s2 + s4 + s5;
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/bloom_downsample_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

uniform vec4 u_source_rect;
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/bloom_threshold_fs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

uniform vec4 u_params;
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/bloom_threshold_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <bgfx_shader.sh>

void main() {
Expand Down
29 changes: 19 additions & 10 deletions assets/core/shader/bloom_upsample_fs.sc
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_source, 0);

uniform vec4 u_source_rect;
uniform vec4 u_params;

vec2 compute_texel(vec2 uv, vec2 center, vec4 bounds) {
vec4 w = vec4(step(bounds.xy, uv), step(uv, bounds.zw));
return mix(center, uv, vec2(w.x*w.z, w.y*w.w));
}

void main() {
vec2 uv = v_texcoord0.xy;
vec4 offset = vec4(-1., 1., 1., 0.) / uResolution.xxyy;

vec4 t0 = texture2D(u_source, uv - offset.yz);
vec4 t1 = texture2D(u_source, uv - offset.wz);
vec4 t2 = texture2D(u_source, uv - offset.xz);
vec2 center = (floor(v_texcoord0.xy * uResolution.xy) + vec2_splat(0.5)) / uResolution.xy;
vec4 bounds = (floor(u_source_rect.xyzw) + vec4(1.,1.,-1.,-1.)) / uResolution.xyxy;

vec4 t0 = texture2D(u_source, compute_texel(uv - offset.yz, center, bounds)); // -1,-1
vec4 t1 = texture2D(u_source, compute_texel(uv - offset.wz, center, bounds)); // 0,-1
vec4 t2 = texture2D(u_source, compute_texel(uv - offset.xz, center, bounds)); // 1,-1

vec4 t3 = texture2D(u_source, uv + offset.xw);
vec4 t4 = texture2D(u_source, uv);
vec4 t5 = texture2D(u_source, uv + offset.yw);
vec4 t3 = texture2D(u_source, compute_texel(uv + offset.xw, center, bounds)); // -1, 0
vec4 t4 = texture2D(u_source, compute_texel(uv, center, bounds));
vec4 t5 = texture2D(u_source, compute_texel(uv + offset.yw, center, bounds)); // 1, 0

vec4 t6 = texture2D(u_source, uv + offset.xz);
vec4 t7 = texture2D(u_source, uv + offset.wz);
vec4 t8 = texture2D(u_source, uv + offset.yz);
vec4 t6 = texture2D(u_source, compute_texel(uv + offset.xz, center, bounds)); // -1, 1
vec4 t7 = texture2D(u_source, compute_texel(uv + offset.wz, center, bounds)); // 0, 1
vec4 t8 = texture2D(u_source, compute_texel(uv + offset.yz, center, bounds)); // 1, 1

gl_FragColor = u_params.z * (t0 + t2 + t6 + t8 + 2. * (t1 + t3 + t5 + t7) + 4. * t4) / 16.;
}
1 change: 1 addition & 0 deletions assets/core/shader/bloom_upsample_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

uniform vec4 u_source_rect;
Expand Down
51 changes: 35 additions & 16 deletions assets/core/shader/compositing_fs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <forward_pipeline.sh>

SAMPLER2D(u_copyColor, 0);
Expand All @@ -9,49 +10,42 @@ SAMPLER2D(u_copyDepth, 1);
tone-mapping operators implementation taken from https://www.shadertoy.com/view/lslGzl
*/

vec3 LinearToneMapping(vec3 color, float exposure) // 1.
{
vec3 LinearToneMapping(vec3 color, float exposure) { // 1.
color = clamp(exposure * color, 0., 1.);
return color;
}

vec3 SimpleReinhardToneMapping(vec3 color, float exposure) // 1.5
{
vec3 SimpleReinhardToneMapping(vec3 color, float exposure) { // 1.5
color *= exposure / (1. + color / exposure);
return color;
}

vec3 LumaBasedReinhardToneMapping(vec3 color)
{
vec3 LumaBasedReinhardToneMapping(vec3 color) {
float luma = dot(color, vec3(0.2126, 0.7152, 0.0722));
float toneMappedLuma = luma / (1. + luma);
color *= toneMappedLuma / luma;
return color;
}

vec3 WhitePreservingLumaBasedReinhardToneMapping(vec3 color, float white) // 2.
{
vec3 WhitePreservingLumaBasedReinhardToneMapping(vec3 color, float white) { // 2.
float luma = dot(color, vec3(0.2126, 0.7152, 0.0722));
float toneMappedLuma = luma * (1. + luma / (white * white)) / (1. + luma);
color *= toneMappedLuma / luma;
return color;
}

vec3 RomBinDaHouseToneMapping(vec3 color)
{
vec3 RomBinDaHouseToneMapping(vec3 color) {
color = exp(-1. / (2.72 * color + 0.15));
return color;
}

vec3 FilmicToneMapping(vec3 color)
{
vec3 FilmicToneMapping(vec3 color) {
color = max(vec3(0., 0., 0.), color - vec3(0.004, 0.004, 0.004));
color = (color * (6.2 * color + .5)) / (color * (6.2 * color + 1.7) + 0.06);
return color;
}

vec3 Uncharted2ToneMapping(vec3 color, float exposure)
{
vec3 Uncharted2ToneMapping(vec3 color, float exposure) {
float A = 0.15;
float B = 0.50;
float C = 0.10;
Expand All @@ -66,8 +60,31 @@ vec3 Uncharted2ToneMapping(vec3 color, float exposure)
return color;
}

void main()
{
vec4 Sharpen(vec2 uv, float strength) {
vec4 up = texture2D(u_copyColor, uv + vec2(0, 1) / uResolution.xy);
vec4 left = texture2D(u_copyColor, uv + vec2(-1, 0) / uResolution.xy);
vec4 center = texture2D(u_copyColor, uv);
vec4 right = texture2D(u_copyColor, uv + vec2(1, 0) / uResolution.xy);
vec4 down = texture2D(u_copyColor, uv + vec2(0, -1) / uResolution.xy);

float exposure = uAAAParams[1].x;
up.xyz = SimpleReinhardToneMapping(up.xyz, exposure);
left.xyz = SimpleReinhardToneMapping(left.xyz, exposure);
center.xyz = SimpleReinhardToneMapping(center.xyz, exposure);
right.xyz = SimpleReinhardToneMapping(right.xyz, exposure);
down.xyz = SimpleReinhardToneMapping(down.xyz, exposure);

vec4 res = (1.0 + 4.0 * strength) * center - strength * (up + left + right + down);
return vec4(res.xyz, center.w);
}

void main() {
#if 1
vec4 in_sample = Sharpen(v_texcoord0, uAAAParams[2].y);

vec3 color = in_sample.xyz;
float alpha = in_sample.w;
#else
vec4 in_sample = texture2D(u_copyColor, v_texcoord0);

vec3 color = in_sample.xyz;
Expand All @@ -78,7 +95,9 @@ void main()
//color = lumaBasedReinhardToneMapping(color);
//color = FilmicToneMapping(color);
//color = Uncharted2ToneMapping(color, exposure);
#endif

// gamma correction
float inv_gamma = uAAAParams[1].y;
color = pow(color, vec3_splat(inv_gamma));

Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/compositing_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <bgfx_shader.sh>

void main() {
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/copy_fs.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$input v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <bgfx_shader.sh>

SAMPLER2D(u_copyColor, 0);
Expand Down
1 change: 1 addition & 0 deletions assets/core/shader/copy_vs.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$input a_position, a_texcoord0
$output v_texcoord0

// HARFANG(R) Copyright (C) 2022 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
#include <bgfx_shader.sh>

void main() {
Expand Down
Loading

0 comments on commit 0723f7e

Please sign in to comment.