From 51b0657629ca0441a7df945992f9361914e0d913 Mon Sep 17 00:00:00 2001 From: paddywwoof Date: Thu, 4 Feb 2021 14:28:01 +0000 Subject: [PATCH 1/2] int division explicit for py3, found by lutz shpi --- pi3d/event/FindDevices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pi3d/event/FindDevices.py b/pi3d/event/FindDevices.py index b2103c2d..4a723278 100644 --- a/pi3d/event/FindDevices.py +++ b/pi3d/event/FindDevices.py @@ -2,7 +2,7 @@ from .Constants import * def test_bit(nlst, b): - index = b / 32 + index = b // 32 bit = b % 32 if len(nlst) <= index: return False From 8f7c6d8967dffca340bb8a1f1023f4475d715534 Mon Sep 17 00:00:00 2001 From: paddywwoof Date: Tue, 9 Feb 2021 15:33:34 +0000 Subject: [PATCH 2/2] only apply bump reduction with distance for 3d camera --- pi3d/shaders/std_bump.inc | 5 ++++- pi3d/shaders/std_head_fs.inc | 1 + pi3d/shaders/std_head_vs.inc | 1 + pi3d/shaders/std_main_vs.inc | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pi3d/shaders/std_bump.inc b/pi3d/shaders/std_bump.inc index 6515874b..e36ef186 100644 --- a/pi3d/shaders/std_bump.inc +++ b/pi3d/shaders/std_bump.inc @@ -7,6 +7,9 @@ bump.y *= -1.0; // unib[3][2] ([11] in python) is used to adjust the strength of normal map textures - float bfact = unib[3][2] * (1.0 - smoothstep(100.0, 600.0, dist)); // ------ attenuate smoothly between 100 and 600 units + float bfact = unib[3][2]; + if (is_3d > 0.0) { + bfact *= (1.0 - smoothstep(100.0, 600.0, dist)); // ------ attenuate smoothly between 100 and 600 units + } float intensity = clamp(dot(lightVector, normalize(vec3(0.0, 0.0, 1.0) + bump * bfact)) * lightFactor, 0.0, 1.0); // ------ adjustment of colour according to combined normal texc.rgb = (texc.rgb * unif[9]) * intensity + (texc.rgb * unif[10]); // ------ directional lightcol * intensity + ambient lightcol diff --git a/pi3d/shaders/std_head_fs.inc b/pi3d/shaders/std_head_fs.inc index 8c6f5ffe..02178d45 100644 --- a/pi3d/shaders/std_head_fs.inc +++ b/pi3d/shaders/std_head_fs.inc @@ -12,5 +12,6 @@ uniform vec3 unif[20]; varying float dist; varying float fog_start; +varying float is_3d; //fragcolor \ No newline at end of file diff --git a/pi3d/shaders/std_head_vs.inc b/pi3d/shaders/std_head_vs.inc index 32854b30..4b7723dc 100644 --- a/pi3d/shaders/std_head_vs.inc +++ b/pi3d/shaders/std_head_vs.inc @@ -17,3 +17,4 @@ uniform vec3 unif[20]; varying float dist; varying float fog_start; +varying float is_3d; diff --git a/pi3d/shaders/std_main_vs.inc b/pi3d/shaders/std_main_vs.inc index ea447740..47951cf4 100644 --- a/pi3d/shaders/std_main_vs.inc +++ b/pi3d/shaders/std_main_vs.inc @@ -28,3 +28,5 @@ uvec.y, vvec.y, -normout.y, 0.0, uvec.z, vvec.z, -normout.z, 0.0, 0.0, 0.0, 0.0, 1.0) * vec4(lightVector, 0.0)); + + is_3d = abs(modelviewmatrix[0][3][3] - modelviewmatrix[1][3][3]);