Skip to content

Commit

Permalink
Merge pull request #42 from ErkMkd/main
Browse files Browse the repository at this point in the history
update to Harfang 3.2.4
  • Loading branch information
ErkMkd committed Sep 21, 2022
2 parents c1a13e9 + 97a55f8 commit fe1cd41
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 1,185 deletions.
4 changes: 2 additions & 2 deletions source/1-Window2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

hgui.info_text("info1", "Simple Window2D")

if hgui.button("Button 0"):
print("Click btn 0")
if hgui.button("Button"):
print("Click btn")

_, flag_check_box0 = hgui.check_box("Check box", flag_check_box0)

Expand Down
10 changes: 6 additions & 4 deletions source/2-Window3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@

hgui.info_text("info1", "Simple Window3D")

if hgui.button("Button 0##1"):
print("Click btn 0 ##1")
if hgui.button("Button 0##2"):
print("Click btn 0 ##2")
# You can display same widgets names, using "##" prefixe to differenciate widgets ids.

if hgui.button("Button##1"):
print("Click btn ##1")
if hgui.button("Button##2"):
print("Click btn ##2")

_, flag_check_box0 = hgui.check_box("Check box", flag_check_box0)

Expand Down
27 changes: 17 additions & 10 deletions source/6-Full_widgets_2D_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

if hgui.begin_window_2D("My window", hg.Vec2(50, 50), hg.Vec2(1124, 600), 1):

hgui.set_line_space_size(10)

if hgui.button("Hello button 0"):
print("Click btn 0")
f, d = hgui.check_box("Check test", flag_check_box0)
Expand All @@ -61,29 +63,34 @@

hgui.same_line()

hgui.image("img1", "textures/logo.png", hg.Vec2(221, 190))
hgui.image("img1", "textures/logo.png", hg.Vec2(221/2, 190/2))

f, my_text = hgui.input_text("Input text")

align = hgui.HGUIAF_CENTER
if hgui.button("Hello button 1", align):
hgui.set_inner_line_space_size(1)
hgui.set_line_space_size(1)

if hgui.button("Hello button 1", align = hgui.HGUIAF_BOTTOMRIGHT ):
print("Click btn 1")
hgui.same_line()
if hgui.button("Hello button 2", align):
if hgui.button("Hello button 2", align = hgui.HGUIAF_BOTTOM):
print("Click btn 2")
hgui.same_line()
if hgui.button("Hello button 22", align):
if hgui.button("Hello button 22", align = hgui.HGUIAF_BOTTOMLEFT):
print("Click btn 22")

if hgui.button("Hello button 3", align):
if hgui.button("Hello button 3", align = hgui.HGUIAF_TOPRIGHT):
print("Click btn 3")
hgui.same_line()
if hgui.button("Hello button 4", align):
if hgui.button("Hello button 4", align = hgui.HGUIAF_TOP):
print("Click btn 4")
hgui.same_line()
if hgui.button("Hello button 23", align):
print("Click btn 23")

hgui.set_inner_line_space_size(10)
hgui.set_line_space_size(20)

if hgui.button("Hello button 23", align = hgui.HGUIAF_TOPLEFT):
print("Click btn 23")

_, current_rib = hgui.radio_image_button("rib_0","textures/cube_1.png", current_rib, 0, hg.Vec2(64, 64))
hgui.same_line()
Expand All @@ -100,7 +107,7 @@

hgui.set_cursor_pos(hg.Vec3(400,200,0))

if hgui.button_image("image_1", "textures/logo.png", hg.Vec2(221, 190) / 6, hgui.HGUI_LABEL_HIDE, align):
if hgui.button_image("image_1", "textures/logo.png", hg.Vec2(221, 190) / 6, show_label = True):
print("click image button")

if hgui.begin_window_2D("my_window_2", hg.Vec2(650, 100), hg.Vec2(400, 400), 1, hgui.HGUIWF_NoPointerMove ):
Expand Down
2 changes: 1 addition & 1 deletion source/assets/core/shader/default.hps
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"features": ["OptionalDiffuseMap", "OptionalSpecularMap", "OptionalNormalMap", "OptionalSelfMap", "OptionalSkinning"]
"features": ["OptionalDiffuseMap", "OptionalSkinning"]
}
4 changes: 2 additions & 2 deletions source/assets/core/shader/font_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ uniform vec4 u_color;
SAMPLER2D(u_tex, 0);

void main() {
float opacity = texture2D(u_tex, v_texcoord0).a * u_color.a;
gl_FragColor = vec4(u_color.rgb, opacity);
float opacity = texture2D(u_tex, v_texcoord0).w * u_color.w;
gl_FragColor = vec4(u_color.xyz, opacity);
}
20 changes: 10 additions & 10 deletions source/assets/core/shader/hiz_trace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ uniform vec4 u_depthTexInfos; // width(x) heigh(y) start mipmap level(z) max mip

//
vec3 ray_step_cell(vec3 ray, vec3 dir, float step, vec2 z_range) {
float t_ = 100000000.0; // [EJ] any large value is ok
float t = 100000000.0; // [EJ] any large value is ok

if (dir.x > 0.0)
t_ = min(t_, (floor(ray.x / step + 1.0) * step - ray.x) / dir.x);
t = min(t, (floor(ray.x / step + 1.0) * step - ray.x) / dir.x);
else if (dir.x < 0.0)
t_ = min(t_, (ceil(ray.x / step - 1.0) * step - ray.x) / dir.x);
t = min(t, (ceil(ray.x / step - 1.0) * step - ray.x) / dir.x);

if (dir.y > 0.0)
t_ = min(t_, (floor(ray.y / step + 1.0) * step - ray.y) / dir.y);
t = min(t, (floor(ray.y / step + 1.0) * step - ray.y) / dir.y);
else if (dir.y < 0.0)
t_ = min(t_, (ceil(ray.y / step - 1.0) * step - ray.y) / dir.y);
t = min(t, (ceil(ray.y / step - 1.0) * step - ray.y) / dir.y);

if (dir.z > 0.0) {
if (ray.z < z_range.x)
t_ = min(t_, (z_range.x - ray.z) / dir.z);
t = min(t, (z_range.x - ray.z) / dir.z);
} else if (dir.z < 0.0) {
if (ray.z > z_range.y)
t_ = min(t_, (z_range.y - ray.z) / dir.z);
t = min(t, (z_range.y - ray.z) / dir.z);
}

return ray + dir * t_;
return ray + dir * t;
}

float hiz_trace(vec3 ray_o, vec3 ray_d, mat4 proj, float z_near, int max_iterations, out vec3 ray) {
Expand Down Expand Up @@ -87,8 +87,8 @@ float hiz_trace(vec3 ray_o, vec3 ray_d, mat4 proj, float z_near, int max_iterati
}
}

vec2 k_fade = saturate((ray.xy - viewport_min) / (u_viewRect.zw * 0.1));
k_fade *= saturate(vec2(1.0, 1.0) - (ray.xy - viewport_max * 0.9) / (u_viewRect.zw * 0.1));
vec2 k_fade = saturate((ray.xy - viewport_min.xy) / (u_viewRect.zw * 0.1));
k_fade *= saturate(vec2(1.0, 1.0) - (ray.xy - viewport_max.xy * 0.9) / (u_viewRect.zw * 0.1));

ray.xy /= u_depthTexInfos.xy;

Expand Down
16 changes: 8 additions & 8 deletions source/assets/core/shader/pbr_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ float SampleShadowPCF(sampler2DShadow map, vec4 coord, float inv_pixel_size, flo
float k = 0.0;

#if FORWARD_PIPELINE_AAA
#define PCF_SAMPLE_COUNT 2.0 // 3x3
#define PCF_SAMPLE_COUNT 2 // 3x3

// float weights[9] = {0.024879, 0.107973, 0.024879, 0.107973, 0.468592, 0.107973, 0.024879, 0.107973, 0.024879};
float weights[9] = {0.011147, 0.083286, 0.011147, 0.083286, 0.622269, 0.083286, 0.011147, 0.083286, 0.011147};
// ARRAY_BEGIN(float, weights, 9) 0.024879, 0.107973, 0.024879, 0.107973, 0.468592, 0.107973, 0.024879, 0.107973, 0.024879 ARRAY_END();
ARRAY_BEGIN(float, weights, 9) 0.011147, 0.083286, 0.011147, 0.083286, 0.622269, 0.083286, 0.011147, 0.083286, 0.011147 ARRAY_END();

for (float j = 0.0; j <= PCF_SAMPLE_COUNT; ++j) {
float v = 6.0 * (j + jitter.y) / PCF_SAMPLE_COUNT - 1.0;
for (float i = 0.0; i <= PCF_SAMPLE_COUNT; ++i) {
float u = 6.0 * (i + jitter.x) / PCF_SAMPLE_COUNT - 1.0;
for (int j = 0; j <= PCF_SAMPLE_COUNT; ++j) {
float v = 6.0 * (float(j) + jitter.y) / float(PCF_SAMPLE_COUNT) - 1.0;
for (int i = 0; i <= PCF_SAMPLE_COUNT; ++i) {
float u = 6.0 * (float(i) + jitter.x) / float(PCF_SAMPLE_COUNT) - 1.0;
k += SampleHardShadow(map, coord + vec4(vec2(u, v) * k_pixel_size, 0.0, 0.0), bias) * weights[j * 3 + i];
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ void main() {
vec4 ss_radiance = texture2D(uSSRadianceMap, gl_FragCoord.xy / uResolution.xy);

irradiance = ss_irradiance.xyz; // mix(irradiance, ss_irradiance, ss_irradiance.w);
radiance = mix(radiance, ss_radiance, ss_radiance.w);
radiance = mix(radiance, ss_radiance.xyz, ss_radiance.w);
#endif

vec3 diffuse = irradiance * base_opacity.xyz;
Expand Down
6 changes: 3 additions & 3 deletions source/assets/core/shader/ssgi_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ void main() {
vec4 jitter = texture2D(u_noise, mod(gl_FragCoord.xy, vec2(64, 64)) / vec2(64, 64));

// sample normal/depth
vec2 uv = GetAttributeTexCoord(vTexCoord0, textureSize(u_attr0, 0).xy);
vec2 uv = GetAttributeTexCoord(vTexCoord0, vec2(textureSize(u_attr0, 0).xy));
vec4 attr0 = texture2D(u_attr0, uv);

vec3 n = normalize(attr0.xyz);
if (isNan(n.x) || isNan(n.y) |isNan(n.z))
if (isNan(n.x) || isNan(n.y) || isNan(n.z))
n = vec3(0, 1, 0);

// compute ray origin & direction
Expand All @@ -45,7 +45,7 @@ void main() {
float cos_spread = cos(spread), sin_spread = sin(spread);

for (int j = 0; j < int(sample_count); ++j) {
float angle = float(j + jitter.w) / sample_count * 2. * 3.141592;
float angle = (float(j) + jitter.w) / sample_count * 2.0 * 3.141592;
float cos_angle = cos(angle), sin_angle = sin(angle);
vec3 ray_d_spread = (right * cos_angle + up * sin_angle) * sin_spread + n * cos_spread;

Expand Down
13 changes: 7 additions & 6 deletions source/assets/core/shader/ssr_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ void main() {
vec4 jitter = texture2D(u_noise, mod(gl_FragCoord.xy, vec2(64, 64)) / vec2(64, 64));

// sample normal/depth
vec2 uv = GetAttributeTexCoord(vTexCoord0, textureSize(u_attr0, 0).xy);
vec2 uv = GetAttributeTexCoord(vTexCoord0, vec2(textureSize(u_attr0, 0).xy));
vec4 attr0 = texture2D(u_attr0, uv);

vec3 n = normalize(attr0.xyz);
if (isNan(n.x) || isNan(n.y) |isNan(n.z))
if (isNan(n.x) || isNan(n.y) || isNan(n.z))
n = vec3(0, 1, 0);

// compute ray origin & direction
Expand Down Expand Up @@ -66,7 +66,7 @@ void main() {
float cos_spread = cos(spread), sin_spread = sin(spread);

for (int j = 0; j < int(sample_count); ++j) {
float angle = float(j + jitter.w) / sample_count * 2. * 3.141592;
float angle = (float(j) + jitter.w) / sample_count * 2.0 * 3.141592;
vec3 ray_d_spread = (right * cos(angle) + up * sin(angle)) * sin_spread + ray_d * cos_spread;

vec3 world_ray_d = mul(uMainInvView, vec4(ray_d_spread, 0.0)).xyz;
Expand All @@ -85,18 +85,19 @@ void main() {

float log_depth = ComputeRayLogDepth(uMainProjection, hit_point);

vec4 output = vec4(0.0, 0.0, 0.0, 1.0); // assume backface hit
vec4 ss_output = vec4(0.0, 0.0, 0.0, 1.0); // assume backface hit
if (dot(attr0.xyz, ray_d_spread) < 0.0 && hit_point.z <= log_depth)
output = vec4(texture2D(u_color, uv - vel * uv_ratio).xyz, 1.0); // front face hit
ss_output = vec4(texture2D(u_color, uv - vel * uv_ratio).xyz, 1.0); // front face hit

color += mix(fallback, output, k);
color += mix(fallback, ss_output, k);
} else {
color += fallback;
}
}
}

color /= sample_count * sample_count;
color = clamp(color, 0.0, 32.0); // [FG] Avoid high intensity HDR probes from saturating the SSR buffer.
#endif

gl_FragColor = color;
Expand Down
2 changes: 1 addition & 1 deletion source/assets/core/shader/temporal_accumulation_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
vec2 uv = gl_FragCoord.xy / input_size;
vec2 dt = GetVelocityVector(uv, uResolution.xy / input_size.xy);

vec2 uv_curr = GetAttributeTexCoord(vTexCoord0, textureSize(u_current, 0).xy);
vec2 uv_curr = GetAttributeTexCoord(vTexCoord0, vec2(textureSize(u_current, 0).xy));
vec4 current = texture2D(u_current, uv_curr);

vec4 c0 = texture2DLodOffset(u_current, uv_curr, 0, ivec2(0, 1));
Expand Down
Loading

0 comments on commit fe1cd41

Please sign in to comment.