Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
disketflu committed Mar 24, 2022
1 parent 51e6c86 commit 092e8bf
Show file tree
Hide file tree
Showing 361 changed files with 12,935 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/__pycache__
/assets_compiled
/works
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/snooker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Snooker

**Snooker** is a game that was programmed in Python using the HARFANG 3D framework.

*Become a pool player and test out our physics engine.*

![Snooker Banner](https://github.com/harfang3d/snooker-python-hg2/raw/master/screenshots/scene0.png)

## How to run Snooker

### Python
1. Get [Python 3](https://www.python.org/downloads/)
1. Get HARFANG 3D
1. Either download it from the [HARFANG website](https://www.harfang3d.com/releases/3.2.0/) and follow the [install instructions](https://www.harfang3d.com/docs/3.2.0/man.cpython/)
1. Or, using PIP in the command line, type '*pip install -Iv harfang==3.2.0*'
1. Clone/download this repository
1. run *main.py*

## Credits
* Python programming : François Gutherz, Eric Kernin
* Release : Clément Beudot

## Screenshots
84 changes: 84 additions & 0 deletions animations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Animations

import harfang as hg
from math import cos, pi


class Animations:
animations = []

TWEEN_COS = 0
TWEEN_EASEINQUAD = 1

@staticmethod
def interpolation_lineaire(a, b, t):
return a * (1 - t) + b * t

@staticmethod
def interpolation_cosinusoidale(a, b, t):
return Animations.interpolation_lineaire(a, b, (-cos(pi * t) + 1) / 2)

@staticmethod
def easeInQuad(t, b, c, d):
t /= d
return c * t * t + b

@staticmethod
def minimize_angle_delta(angle_strt, angle_dest):
delta = angle_dest - angle_strt
if abs(delta) > pi:
delta_min = 2*pi - abs(delta)
if angle_strt > angle_dest:
return angle_strt + delta_min
else:
return angle_strt - delta_min
return angle_dest

@classmethod
def minimize_rotation_vec3(cls, rot_start, rot_dest):
rot_dest.x = cls.minimize_angle_delta(rot_start.x, rot_dest.x)
rot_dest.y = cls.minimize_angle_delta(rot_start.y, rot_dest.y)
rot_dest.z = cls.minimize_angle_delta(rot_start.z, rot_dest.z)

@classmethod
def update_animations(cls, t):
flag_end = True
for anim in cls.animations:
flag_end &= anim.update(t)
return flag_end

@classmethod
def clear_animations(cls):
cls.animations = []

@classmethod
def is_running(cls):
if len(cls.animations) == 0:
return False
return True


class Animation:

def __init__(self, t_start, delay, v_start, v_end, tween_type=Animations.TWEEN_COS):
self.t_start = t_start
self.delay = delay
self.v_start = v_start
self.v_end = v_end
self.v = v_start
self.tween_type = tween_type
self.flag_end = False
Animations.animations.append(self)

def update(self, t):
if t > self.t_start + self.delay:
self.v = self.v_end
self.flag_end = True
elif t >= self.t_start:
if self.tween_type == Animations.TWEEN_COS:
self.v = Animations.interpolation_cosinusoidale(self.v_start, self.v_end, (t - self.t_start) / self.delay)
elif self.tween_type == Animations.TWEEN_EASEINQUAD:
self.v = Animations.easeInQuad((t - self.t_start), self.v_start, self.v_end-self.v_start, self.delay)
else:
self.v = self.v_start
return self.flag_end
7 changes: 7 additions & 0 deletions assets.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"default": {
"generate-probe": true
}
}
}
23 changes: 23 additions & 0 deletions assets/_meta/fbx_importer_cfg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"anim_policy":"1"
"anim_simplify_color_tolerance":"0.001000"
"anim_simplify_rotation_tolerance":"0.100000"
"anim_simplify_scale_tolerance":"0.001000"
"anim_simplify_translation_tolerance":"0.001000"
"detect_geometry_instances":"1"
"fbx_file_path":"c:/WORKS/harfang/hg2/website-tutorials_hg2/game-snooker-hg2/works/table_hole.fbx"
"finalizer_script":""
"fix_geometry_orientation":"1"
"frames_per_second":"24"
"geometry_policy":"1"
"geometry_scale":"1.000000"
"import_animations":"0"
"material_policy":"1"
"max_smoothing_angle":"70.000000"
"output_folder":"pool/table_hole"
"profile":"1"
"recalculate_normals":"0"
"recalculate_tangents":"0"
"scale":"1.000000"
"scene_policy":"1"
"texture_policy":"1"
"use_finalizer_script":"0"
5 changes: 5 additions & 0 deletions assets/_meta/prod.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"c:/WORKS/harfang/hg2/website-tutorials_hg2/game-snooker-hg2/works/ground_shadow.fbx":"_prod/c292a3f5-4353-6542-9ecf-a69c61add993"
"c:/WORKS/harfang/hg2/website-tutorials_hg2/game-snooker-hg2/works/table_hole.fbx":"_prod/d4a354c6-7ded-864d-9d6f-2d03ac73dd04"
"d:/Movida/gits/eric/website-tutorials_hg2/game-snooker-hg2/work/light_model/light_model_export.fbx":"_prod/5f5e2591-618f-405b-fed5-f7ee56d11a11"
"d:/Movida/gits/eric/website-tutorials_hg2/game-snooker-hg2/work/pool_col_shape.fbx":"_prod/2726ed59-2957-4823-c69d-bfb61e99e2d9"
"d:/Movida/gits/eric/website-tutorials_hg2/game-snooker-hg2/work/pool_v2.fbx":"_prod/c09ff16d-9f46-4aa1-bb6c-b9df1a822a96"
Binary file not shown.
Binary file added assets/_prod/5f5e2591-618f-405b-fed5-f7ee56d11a11
Binary file not shown.
Binary file added assets/_prod/c09ff16d-9f46-4aa1-bb6c-b9df1a822a96
Binary file not shown.
Binary file added assets/_prod/c292a3f5-4353-6542-9ecf-a69c61add993
Binary file not shown.
Binary file added assets/_prod/d4a354c6-7ded-864d-9d6f-2d03ac73dd04
Binary file not shown.
Binary file added assets/core/noise/64/HDR_L_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/core/noise/64/HDR_L_31.png
Binary file added assets/core/noise/64/HDR_L_32.png
Binary file added assets/core/noise/64/HDR_L_33.png
Binary file added assets/core/noise/64/HDR_L_34.png
Binary file added assets/core/noise/64/HDR_L_35.png
Binary file added assets/core/noise/64/HDR_L_36.png
Binary file added assets/core/noise/64/HDR_L_37.png
Binary file added assets/core/noise/64/HDR_L_38.png
Binary file added assets/core/noise/64/HDR_L_39.png
Binary file added assets/core/noise/64/HDR_L_4.png
Binary file added assets/core/noise/64/HDR_L_40.png
Binary file added assets/core/noise/64/HDR_L_41.png
Binary file added assets/core/noise/64/HDR_L_42.png
Binary file added assets/core/noise/64/HDR_L_43.png
Binary file added assets/core/noise/64/HDR_L_44.png
Binary file added assets/core/noise/64/HDR_L_45.png
Binary file added assets/core/noise/64/HDR_L_46.png
Binary file added assets/core/noise/64/HDR_L_47.png
Binary file added assets/core/noise/64/HDR_L_48.png
Binary file added assets/core/noise/64/HDR_L_49.png
Binary file added assets/core/noise/64/HDR_L_5.png
Binary file added assets/core/noise/64/HDR_L_50.png
Binary file added assets/core/noise/64/HDR_L_51.png
Binary file added assets/core/noise/64/HDR_L_52.png
Binary file added assets/core/noise/64/HDR_L_53.png
Binary file added assets/core/noise/64/HDR_L_54.png
Binary file added assets/core/noise/64/HDR_L_55.png
Binary file added assets/core/noise/64/HDR_L_56.png
Binary file added assets/core/noise/64/HDR_L_57.png
Binary file added assets/core/noise/64/HDR_L_58.png
Binary file added assets/core/noise/64/HDR_L_59.png
Binary file added assets/core/noise/64/HDR_L_6.png
Binary file added assets/core/noise/64/HDR_L_60.png
Binary file added assets/core/noise/64/HDR_L_61.png
Binary file added assets/core/noise/64/HDR_L_62.png
Binary file added assets/core/noise/64/HDR_L_63.png
Binary file added assets/core/noise/64/HDR_L_7.png
Binary file added assets/core/noise/64/HDR_L_8.png
Binary file added assets/core/noise/64/HDR_L_9.png
Binary file added assets/core/noise/HDR_L_0.png
Binary file added assets/core/noise/HDR_L_1.png
Binary file added assets/core/noise/HDR_L_2.png
Binary file added assets/core/noise/HDR_L_3.png
Binary file added assets/core/noise/HDR_L_4.png
Binary file added assets/core/noise/HDR_L_5.png
Binary file added assets/core/noise/HDR_L_6.png
Binary file added assets/core/noise/HDR_L_7.png
Binary file added assets/core/noise/LDR_RGBA_0.png
Binary file added assets/core/noise/LDR_RGBA_1.png
Binary file added assets/core/noise/LDR_RGBA_10.png
Binary file added assets/core/noise/LDR_RGBA_11.png
Binary file added assets/core/noise/LDR_RGBA_12.png
Binary file added assets/core/noise/LDR_RGBA_13.png
Binary file added assets/core/noise/LDR_RGBA_14.png
Binary file added assets/core/noise/LDR_RGBA_15.png
Binary file added assets/core/noise/LDR_RGBA_16.png
Binary file added assets/core/noise/LDR_RGBA_17.png
Binary file added assets/core/noise/LDR_RGBA_18.png
Binary file added assets/core/noise/LDR_RGBA_19.png
Binary file added assets/core/noise/LDR_RGBA_2.png
Binary file added assets/core/noise/LDR_RGBA_20.png
Binary file added assets/core/noise/LDR_RGBA_21.png
Binary file added assets/core/noise/LDR_RGBA_22.png
Binary file added assets/core/noise/LDR_RGBA_23.png
Binary file added assets/core/noise/LDR_RGBA_24.png
Binary file added assets/core/noise/LDR_RGBA_25.png
Binary file added assets/core/noise/LDR_RGBA_26.png
Binary file added assets/core/noise/LDR_RGBA_27.png
Binary file added assets/core/noise/LDR_RGBA_28.png
Binary file added assets/core/noise/LDR_RGBA_29.png
Binary file added assets/core/noise/LDR_RGBA_3.png
Binary file added assets/core/noise/LDR_RGBA_30.png
Binary file added assets/core/noise/LDR_RGBA_31.png
Binary file added assets/core/noise/LDR_RGBA_32.png
Binary file added assets/core/noise/LDR_RGBA_33.png
Binary file added assets/core/noise/LDR_RGBA_34.png
Binary file added assets/core/noise/LDR_RGBA_35.png
Binary file added assets/core/noise/LDR_RGBA_36.png
Binary file added assets/core/noise/LDR_RGBA_37.png
Binary file added assets/core/noise/LDR_RGBA_38.png
Binary file added assets/core/noise/LDR_RGBA_39.png
Binary file added assets/core/noise/LDR_RGBA_4.png
Binary file added assets/core/noise/LDR_RGBA_40.png
Binary file added assets/core/noise/LDR_RGBA_41.png
Binary file added assets/core/noise/LDR_RGBA_42.png
Binary file added assets/core/noise/LDR_RGBA_43.png
Binary file added assets/core/noise/LDR_RGBA_44.png
Binary file added assets/core/noise/LDR_RGBA_45.png
Binary file added assets/core/noise/LDR_RGBA_46.png
Binary file added assets/core/noise/LDR_RGBA_47.png
Binary file added assets/core/noise/LDR_RGBA_48.png
Binary file added assets/core/noise/LDR_RGBA_49.png
Binary file added assets/core/noise/LDR_RGBA_5.png
Binary file added assets/core/noise/LDR_RGBA_50.png
Binary file added assets/core/noise/LDR_RGBA_51.png
Binary file added assets/core/noise/LDR_RGBA_52.png
Binary file added assets/core/noise/LDR_RGBA_53.png
Binary file added assets/core/noise/LDR_RGBA_54.png
Binary file added assets/core/noise/LDR_RGBA_55.png
Binary file added assets/core/noise/LDR_RGBA_56.png
Binary file added assets/core/noise/LDR_RGBA_57.png
Binary file added assets/core/noise/LDR_RGBA_58.png
Binary file added assets/core/noise/LDR_RGBA_59.png
Binary file added assets/core/noise/LDR_RGBA_6.png
Binary file added assets/core/noise/LDR_RGBA_60.png
Binary file added assets/core/noise/LDR_RGBA_61.png
Binary file added assets/core/noise/LDR_RGBA_62.png
Binary file added assets/core/noise/LDR_RGBA_63.png
Binary file added assets/core/noise/LDR_RGBA_7.png
Binary file added assets/core/noise/LDR_RGBA_8.png
Binary file added assets/core/noise/LDR_RGBA_9.png
Binary file added assets/core/pbr/brdf.dds
Binary file not shown.
7 changes: 7 additions & 0 deletions assets/core/pbr/brdf.dds.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"default": {
"generate-probe": true
}
}
}
Binary file added assets/core/pbr/fireplace_1k.hdr
Binary file not shown.
7 changes: 7 additions & 0 deletions assets/core/pbr/fireplace_1k.hdr.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"default": {
"generate-probe": true
}
}
}
Binary file added assets/core/pbr/night_sky.hdr
Binary file not shown.
7 changes: 7 additions & 0 deletions assets/core/pbr/night_sky.hdr.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"default": {
"generate-probe": true
}
}
}
Binary file added assets/core/pbr/probe.hdr
Binary file not shown.
9 changes: 9 additions & 0 deletions assets/core/pbr/probe.hdr.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"default": {
"generate-probe": true,
"max-probe-size": 256,
"radiance-edge-fixup": true
}
}
}
68 changes: 68 additions & 0 deletions assets/core/shader/a_trous_fs.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <forward_pipeline.sh>

SAMPLER2D(u_color, 0);
SAMPLER2D(u_attr0, 1);

uniform vec4 u_dir;
uniform vec4 u_sigma; // x: pos, y: normal, z: depth, w: depth weight cutoff

void main() {
const float epsilon = 1.e-6;

ivec2 p0 = ivec2(gl_FragCoord.xy);
ivec2 offset = ivec2(u_dir.xy);

vec4 c0 = texelFetch(u_color, p0, 0);
vec4 v0 = texelFetch(u_attr0, p0, 0);

float w = 3.0 / 8.0;
vec4 c = w * c0;

float falloff = 1.0 / (sqrt(2.0) * u_sigma.x);

int i;
float ws;

ws = 1.0 / 4.0;
for(i=1; i<=2; i++) {
ivec2 p1;
vec4 v1;
float wn, dz, wz, wp, w1, d;

ivec2 delta = offset * i;
float d2 = dot(vec2(delta), vec2(delta));
wp = exp(-d2 * falloff);

// right
p1 = p0 + delta;
v1 = texelFetch(u_attr0, p1, 0);

dz = abs(v1.w - v0.w);
wz = exp(-dz / u_sigma.z);
wz *= step(u_sigma.w, wz);

wn = pow(max(0.0, dot(v1.xyz, v0.xyz)), u_sigma.y);
w1 = ws * wn * wz * wp;

w += w1;
c += w1 * texelFetch(u_color, p1, 0);

// left
p1 = p0 - delta;
v1 = texelFetch(u_attr0, p1, 0);

dz = abs(v1.w - v0.w);
wz = exp(-dz / u_sigma.z);
wz *= step(u_sigma.w, wz);

wn = pow(max(0.0, dot(v1.xyz, v0.xyz)), u_sigma.y);
w1 = ws * wn * wz * wp;

w += w1;
c += w1 * texelFetch(u_color, p1, 0);

ws *= ws;
}

gl_FragColor = c / w;
}
1 change: 1 addition & 0 deletions assets/core/shader/a_trous_varying.def
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vec3 a_position : POSITION;
7 changes: 7 additions & 0 deletions assets/core/shader/a_trous_vs.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$input a_position

#include <forward_pipeline.sh>

void main() {
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
}
70 changes: 70 additions & 0 deletions assets/core/shader/aaa_downsample_fs.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <forward_pipeline.sh>

SAMPLER2D(u_color, 0);
SAMPLER2D(u_attr0, 1);
SAMPLER2D(u_depth, 2);

void main() {
ivec2 pos = ivec2(gl_FragCoord.xy) * 2;

vec4 v0 = texelFetchOffset(u_attr0, pos, 0, ivec2(0,0));
vec4 v1 = texelFetchOffset(u_attr0, pos, 0, ivec2(1,0));
vec4 v2 = texelFetchOffset(u_attr0, pos, 0, ivec2(0,1));
vec4 v3 = texelFetchOffset(u_attr0, pos, 0, ivec2(1,1));

vec4 c0 = texelFetchOffset(u_color, pos, 0, ivec2(0,0));
vec4 c1 = texelFetchOffset(u_color, pos, 0, ivec2(1,0));
vec4 c2 = texelFetchOffset(u_color, pos, 0, ivec2(0,1));
vec4 c3 = texelFetchOffset(u_color, pos, 0, ivec2(1,1));

vec4 z0 = texelFetchOffset(u_depth, pos, 0, ivec2(0,0));
vec4 z1 = texelFetchOffset(u_depth, pos, 0, ivec2(1,0));
vec4 z2 = texelFetchOffset(u_depth, pos, 0, ivec2(0,1));
vec4 z3 = texelFetchOffset(u_depth, pos, 0, ivec2(1,1));

vec2 tmp = floor(mod(gl_FragCoord.xy, 2.0));
#if AAA_DOWNSAMPLE_CHECKERBOARD
float checkerboard = tmp.x + tmp.y - 2.0*tmp.x*tmp.y;

vec4 v_min = (v0.w < v1.w) ? v0 : v1;
vec4 c_min = (v0.w < v1.w) ? c0 : c1;
vec4 z_min = (v0.w < v1.w) ? z0 : z1;
vec4 v_max = (v0.w > v1.w) ? v0 : v1;
vec4 c_max = (v0.w > v1.w) ? c0 : c1;
vec4 z_max = (v0.w > v1.w) ? z0 : z1;

v_min = (v_min.w < v2.w) ? v_min : v2;
c_min = (v_min.w < v2.w) ? c_min : c2;
z_min = (v_min.w < v2.w) ? z_min : z2;
v_max = (v_max.w > v2.w) ? v_max : v2;
c_max = (v_max.w > v2.w) ? c_max : c2;
z_max = (v_max.w > v2.w) ? z_max : z2;

v_min = (v_min.w < v3.w) ? v_min : v3; // mix(v_min, v3, step(v_min.w, v3.w));
c_min = (v_min.w < v3.w) ? c_min : c3;
z_min = (v_min.w < v3.w) ? z_min : z3;
v_max = (v_max.w > v3.w) ? v_max : v3; // mix(v_max, v3, step(v3.w, v_max.w));
c_max = (v_max.w > v3.w) ? c_max : c3;
z_max = (v_max.w > v3.w) ? z_max : z3;

gl_FragData[0] = mix(c_min, c_max, checkerboard);
gl_FragData[1] = mix(v_min, v_max, checkerboard);
gl_FragData[2] = mix(z_min, z_max, checkerboard);
#else
vec4 v_min = (v0.w < v1.w) ? v0 : v1;
vec4 c_min = (v0.w < v1.w) ? c0 : c1;
vec4 z_min = (v0.w < v1.w) ? z0 : z1;

v_min = (v_min.w < v2.w) ? v_min : v2;
c_min = (v_min.w < v2.w) ? c_min : c2;
z_min = (v_min.w < v2.w) ? z_min : z2;

v_min = (v_min.w < v3.w) ? v_min : v3;
c_min = (v_min.w < v3.w) ? c_min : c3;
z_min = (v_min.w < v3.w) ? z_min : z3;

gl_FragData[0] = c_min;
gl_FragData[1] = v_min;
gl_FragData[2] = z_min;
#endif
}
1 change: 1 addition & 0 deletions assets/core/shader/aaa_downsample_varying.def
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vec3 a_position : POSITION;
7 changes: 7 additions & 0 deletions assets/core/shader/aaa_downsample_vs.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$input a_position

#include <forward_pipeline.sh>

void main() {
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
}
Loading

0 comments on commit 092e8bf

Please sign in to comment.