From 772283a0c624560ff5b0ab3520d3efde84613746 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 20 Mar 2020 15:16:46 +0100 Subject: [PATCH] Remove seconds property from PerspectivePlane --- orx-fx/src/main/kotlin/distort/Raycast.kt | 27 +++++++++---------- .../fx/gl3/distort/perspective-plane.frag | 17 ++++++------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/orx-fx/src/main/kotlin/distort/Raycast.kt b/orx-fx/src/main/kotlin/distort/Raycast.kt index 212cb0d1..7ed43e25 100644 --- a/orx-fx/src/main/kotlin/distort/Raycast.kt +++ b/orx-fx/src/main/kotlin/distort/Raycast.kt @@ -10,36 +10,33 @@ import org.openrndr.math.transforms.transform @Description("Perspective plane") class PerspectivePlane : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("distort/perspective-plane.frag"))) { - -// @DoubleParameter("camera x", -1.0, 1.0, order = 0) - var cameraX : Double = 0.0 -// @DoubleParameter("camera y", -1.0, 1.0, order = 1) - var cameraY : Double = 0.0 -// @DoubleParameter("camera z", -1.0, 1.0, order = 2) - var cameraZ : Double = 1.0 + // @DoubleParameter("camera x", -1.0, 1.0, order = 0) + var cameraX: Double = 0.0 + // @DoubleParameter("camera y", -1.0, 1.0, order = 1) + var cameraY: Double = 0.0 + // @DoubleParameter("camera z", -1.0, 1.0, order = 2) + var cameraZ: Double = 1.0 @DoubleParameter("plane x", -1.0, 1.0, order = 3) - var planeX : Double = 0.0 + var planeX: Double = 0.0 @DoubleParameter("plane y", -1.0, 1.0, order = 4) - var planeY : Double = 0.0 + var planeY: Double = 0.0 @DoubleParameter("plane z", -1.0, 1.0, order = 5) - var planeZ : Double = 0.5 + var planeZ: Double = 0.5 @DoubleParameter("plane yaw", -180.0, 180.0, order = 6) - var planeYaw : Double = 0.0 + var planeYaw: Double = 0.0 @DoubleParameter("plane pitch", -180.0, 180.0, order = 7) - var planePitch : Double = 0.0 + var planePitch: Double = 0.0 @DoubleParameter("plane roll", -180.0, 180.0, order = 8) - var planeRoll : Double = 0.0 + var planeRoll: Double = 0.0 @BooleanParameter("tile input") var tile: Boolean by parameters - var seconds:Double by parameters init { - seconds = 0.0 tile = false } diff --git a/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/distort/perspective-plane.frag b/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/distort/perspective-plane.frag index 9b568514..1c3663ad 100644 --- a/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/distort/perspective-plane.frag +++ b/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/distort/perspective-plane.frag @@ -6,7 +6,6 @@ uniform sampler2D tex0; in vec2 v_texCoord0; uniform vec3 cameraPosition; uniform vec3 planePosition; -uniform float seconds; uniform mat4 planeMatrix; uniform bool tile; uniform vec2 targetSize; @@ -22,25 +21,25 @@ void main() { vPlaneUp *= m; vPlaneRight *= m; - vec3 vPlaneNormal = normalize(cross(vPlaneRight,vPlaneUp)); - float fPlaneDeltaNormalDistance = dot(vPlanePos,vPlaneNormal) - dot(vPlaneNormal,vCamPos); + vec3 vPlaneNormal = normalize(cross(vPlaneRight, vPlaneUp)); + float fPlaneDeltaNormalDistance = dot(vPlanePos, vPlaneNormal) - dot(vPlaneNormal, vCamPos); vec4 color = vec4(0.); for (int m = 0; m < 2; m++) { for (int n = 0; n < 2; n++) { vec2 s = (v_texCoord0 - vec2(0.5)) * 2.0; s*= vec2(1.0, targetSize.y / targetSize.x); vec3 vRayDir = normalize(vec3(s, -1.0)); - float t = fPlaneDeltaNormalDistance / dot(vPlaneNormal,vRayDir); - vec3 hitPos = vCamPos + vRayDir*t; + float t = fPlaneDeltaNormalDistance / dot(vPlaneNormal, vRayDir); + vec3 hitPos = vCamPos + vRayDir * t; vec3 delta = hitPos - vPlanePos; - vec2 bary = vec2(dot(delta, vPlaneRight),dot(delta, vPlaneUp)); + vec2 bary = vec2(dot(delta, vPlaneRight), dot(delta, vPlaneUp)); - bary /= vec2(1.0, targetSize.y/targetSize.x); + bary /= vec2(1.0, targetSize.y / targetSize.x); bary += vec2(0.5); - if ( (tile || (bary.x >= 0.0 && bary.x <= 1.0 && bary.y >=0.0 && bary.y <= 1.0)) && t > 0.0) { + if ((tile || (bary.x >= 0.0 && bary.x <= 1.0 && bary.y >=0.0 && bary.y <= 1.0)) && t > 0.0) { color += texture(tex0, bary); } } } - o_color = color*0.25; + o_color = color * 0.25; }