--[[--/* GlassOrigin.fuse Based on https://www.shadertoy.com/view/scS3Wy a WebGL shader created by Frostbyte_. Converted to DCTL and embeddet into a Lua Fuse by JiPi (https://www.youtube.com/c/JiPi_YT). Place this file in your Fusion's and/or DaVinci Resolve's 'Fuses/' folder to use it. */--]]-- -- /* local ShaderFuse = require("Shaderfuse/ShaderFuse") ShaderFuse.init() -- // ------------------------------------------------------------------------ -- // Registry declaration -- // ------------------------------------------------------------------------ FuRegisterClass(ShaderFuse.FuRegister.Name, CT_SourceTool, { ShaderFuse.FuRegister.Attributes, REG_NoObjMatCtrls = true, REG_NoMotionBlurCtrls = true, REG_Source_GlobalCtrls = false, REG_Source_SizeCtrls = true, REG_Source_AspectCtrls = true, REG_Source_DepthCtrls = true, REG_OpNoMask = true, REG_TimeVariant = true, }) -- // ------------------------------------------------------------------------ -- // DCTL kernel parameters -- // ------------------------------------------------------------------------ -- */ ShaderParameters = [[ float iResolution[2]; float iTime; float iMouse[4]; float Color1[4]; float Color2[4]; float Color3[4]; float Color4[4]; float ViewXY[2]; float ViewZ; float Level0; float Level1; float Level2; float Level3; float Level4; float Level5; float Level6; int width,height; int compOrder; ]] -- /* -- // ------------------------------------------------------------------------ -- DCTL kernel compatibility code -- // ------------------------------------------------------------------------ -- */ ShaderCompatibilityCode = [[ #if defined(DEVICE_IS_METAL) #define in #define out thread #define inout thread #else #define in #define out #define inout #endif #undef USE_NATIVE_METAL_IMPL #undef USE_NATIVE_CUDA_IMPL #undef USE_NATIVE_OPENCL_IMPL // 0 to use the generic implementations; 1 for Metal, OpenCL, Cuda specific code if existing #if 1 #if defined(DEVICE_IS_METAL) #define USE_NATIVE_METAL_IMPL 1 #elif defined(DEVICE_IS_CUDA) #define USE_NATIVE_CUDA_IMPL 1 #elif defined(DEVICE_IS_OPENCL) #define USE_NATIVE_OPENCL_IMPL 1 #endif #endif #if defined(USE_NATIVE_METAL_IMPL) #define swi2(A,a,b) (A).a##b #define swi3(A,a,b,c) (A).a##b##c #define swi2S(a,b,c,d) a.b##c = d #define swi3S(a,b,c,d,e) a.b##c##d = e #else #define swi2(A,a,b) to_float2((A).a,(A).b) #define swi3(A,a,b,c) to_float3((A).a,(A).b,(A).c) #define swi2S(a,b,c,d) {float2 tmp = d; (a).b = tmp.x; (a).c = tmp.y;} #define swi3S(a,b,c,d,e) {float3 tmp = e; (a).b = tmp.x; (a).c = tmp.y; (a).d = tmp.z;} #define swi4S(a,b,c,d,e,f) {float4 tmp = f; (a).b = tmp.x; (a).c = tmp.y; (a).d = tmp.z; (a).e = tmp.w;} #endif // ---------------------------------------------------------------------------------------------------------- // mat2 implementation // ---------------------------------------------------------------------------------------------------------- #if defined(USE_NATIVE_METAL_IMPL) typedef float2x2 mat2; #define mul_f2_mat2(A,B) ((A)*(B)) #else typedef struct { float2 r0; float2 r1; } mat2; __DEVICE__ inline float2 mul_f2_mat2( float2 v, mat2 m ) { float2 t; t.x = v.x*m.r0.x + v.y*m.r0.y; t.y = v.x*m.r1.x + v.y*m.r1.y; return t; } #endif // end of mat2 implementation // ---------------------------------------------------------------------------------------------------------- // mat3 implementation // ---------------------------------------------------------------------------------------------------------- #if defined(USE_NATIVE_METAL_IMPL) typedef float3x3 mat3; __DEVICE__ inline mat3 to_mat3( float a, float b, float c, float d, float e, float f, float g, float h, float i) { return mat3(a,b,c,d,e,f,g,h,i); } __DEVICE__ inline mat3 to_mat3_f3( float3 a, float3 b, float3 c ) { return mat3(a,b,c); } __DEVICE__ inline float3 mul_mat3_f3( mat3 B, float3 A) { return (B*A); } __DEVICE__ inline float3 mul_f3_mat3( float3 A, mat3 B) { return (A*B); } __DEVICE__ inline mat3 mul_mat3_mat3( mat3 A, mat3 B) { return (A*B); } #else typedef struct { float3 r0; float3 r1; float3 r2; } mat3; __DEVICE__ inline mat3 to_mat3( float a, float b, float c, float d, float e, float f, float g, float h, float i) { mat3 t; t.r0.x = a; t.r0.y = b; t.r0.z = c; t.r1.x = d; t.r1.y = e; t.r1.z = f; t.r2.x = g; t.r2.y = h; t.r2.z = i; return t; } __DEVICE__ inline mat3 to_mat3_f3( float3 A, float3 B, float3 C) { mat3 D; D.r0 = A; D.r1 = B; D.r2 = C; return D; } __DEVICE__ inline float3 mul_mat3_f3( mat3 B, float3 A) { float3 C; C.x = A.x * B.r0.x + A.y * B.r1.x + A.z * B.r2.x; C.y = A.x * B.r0.y + A.y * B.r1.y + A.z * B.r2.y; C.z = A.x * B.r0.z + A.y * B.r1.z + A.z * B.r2.z; return C; } __DEVICE__ inline float3 mul_f3_mat3( float3 A, mat3 B) { float3 C; C.x = A.x * B.r0.x + A.y * B.r0.y + A.z * B.r0.z; C.y = A.x * B.r1.x + A.y * B.r1.y + A.z * B.r1.z; C.z = A.x * B.r2.x + A.y * B.r2.y + A.z * B.r2.z; return C; } __DEVICE__ mat3 mul_mat3_mat3( mat3 B, mat3 A) { float r[3][3]; float a[3][3] = {{A.r0.x, A.r0.y, A.r0.z}, {A.r1.x, A.r1.y, A.r1.z}, {A.r2.x, A.r2.y, A.r2.z}}; float b[3][3] = {{B.r0.x, B.r0.y, B.r0.z}, {B.r1.x, B.r1.y, B.r1.z}, {B.r2.x, B.r2.y, B.r2.z}}; for( int i = 0; i < 3; ++i) { for( int j = 0; j < 3; ++j) { r[i][j] = 0.0f; for( int k = 0; k < 3; ++k) { r[i][j] = r[i][j] + a[i][k] * b[k][j]; } } } mat3 R = to_mat3(r[0][0], r[0][1], r[0][2], r[1][0], r[1][1], r[1][2], r[2][0], r[2][1], r[2][2]); return R; } #endif // end of mat3 implementation #if defined(USE_NATIVE_METAL_IMPL) #define sin_f3(i) sin(i) #define cos_f3(i) cos(i) #define cos_f4(i) cos(i) #define tanh_f4(i) tanh(i) #else #if defined(USE_NATIVE_OPENCL_IMPL) #define reflect(I,N) (I-2.0f*dot(N,I)*N) #define fract(a) ((a)-_floor(a)) // oder Pointer bauen: gentype fract(gentype x, gentype *itpr) #define sin_f3(i) sin(i) #define cos_f3(i) cos(i) #define cos_f4(i) cos(i) #define tanh_f4(i) tanh(i) #else // Generic #define fract(a) ((a)-_floor(a)) #define sin_f3(i) to_float3( _sinf((i).x), _sinf((i).y), _sinf((i).z)) #define cos_f3(i) to_float3( _cosf((i).x), _cosf((i).y), _cosf((i).z)) #define cos_f4(i) to_float4( _cosf((i).x), _cosf((i).y), _cosf((i).z), _cosf((i).w)) #define tanh_f4(i) to_float4(_tanhf((i).x), _tanhf((i).y), _tanhf((i).z), _tanhf((i).w)) #endif #endif ]] -- /* -- // ------------------------------------------------------------------------ -- DCTL kernel implementation -- // ------------------------------------------------------------------------ -- */ ShaderKernelCode = [[ // ---------------------------------------------------------------------------------- // - Image - // ---------------------------------------------------------------------------------- __DEVICE__ inline mat2 to_mat2_f4 (float4 a) { mat2 t; t.r0.x = a.x; t.r0.y = a.y; t.r1.x = a.z; t.r1.y = a.w; return t; } // SPDX-License-Identifier: CC-BY-NC-SA-4.0 // Copyright (c) 2026 @Frostbyte //[LICENSE] https://creativecommons.org/licenses/by-nc-sa/4.0f/ // Credit: @Frostbyte (https://fragcoord.xyz/u/Frostbyte) // Original shader: https://fragcoord.xyz/s/tbe1g319 #define pi 3.1415926535897f #define T iTime //Path #define P(z) (to_float3(_cosf((z) * 0.02f) *20.0f, _cosf((z) * 0.05f) * 3.0f+0.0f, (z))) // 2d rotation matrix golfed #define R(a) to_mat2_f4(cos_f4(a+to_float4(0,33,11,0))) //Xor's Dot Noise golfed by Fabrice: https://fragcoord.xyz/s/pf29h2wz #define n(p) dot( cos_f3(mul_mat3_f3(G , (p))), sin_f3(mul_f3_mat3(1.6f*(p) , G)) ) // Inigo Quilez (MIT) https://www.shadertoy.com/view/ll2GD3 __DEVICE__ float3 c(float t, float3 Colors[4]) { //return clamp(to_float3(0.455f, 0.322f, 0.216f) + to_float3(-0.073f, 0.119f, 0.150f) * cos_f3(6.28318f * (to_float3(20.000f, 1.000f, 1.000f) * t + to_float3(0.100f, -0.256f, -0.231f))), 0.0f, 1.0f); // sRGB return clamp(Colors[0] + Colors[1] * cos_f3(6.28318f * (Colors[2] * t + Colors[3])), 0.0f, 1.0f); // sRGB } __KERNEL__ void GlassOriginFuse(__CONSTANTREF__ Params* params, __TEXTURE2D_WRITE__ destinationTexture) { DEFINE_KERNEL_ITERATORS_XY(fusion_x, fusion_y); if (fusion_x >= params->width || fusion_y >= params->height) return; float2 iResolution = to_float2(params->iResolution[0], params->iResolution[1]); float iTime = params->iTime; float4 iMouse = to_float4(params->iMouse[0],params->iMouse[1],params->iMouse[2],params->iMouse[3]); float4 fragColor = to_float4_s(0.0f); float2 fragCoord = to_float2(fusion_x,fusion_y); float4 Color1 = to_float4(params->Color1[0], params->Color1[1], params->Color1[2], params->Color1[3]); float4 Color2 = to_float4(params->Color2[0], params->Color2[1], params->Color2[2], params->Color2[3]); float4 Color3 = to_float4(params->Color3[0], params->Color3[1], params->Color3[2], params->Color3[3]); float4 Color4 = to_float4(params->Color4[0], params->Color4[1], params->Color4[2], params->Color4[3]); float2 ViewXY = to_float2(params->ViewXY[0], params->ViewXY[1]); float ViewZ = params->ViewZ; float Level0 = params->Level0; float Level1 = params->Level1; float Level2 = params->Level2; float Level3 = params->Level3; float Level4 = params->Level4; float Level5 = params->Level5; float Level6 = params->Level6; // -------- float3 Colors[4] = {swi3(Color1,x,y,z), swi3(Color2,x,y,z), swi3(Color3,x,y,z), swi3(Color4,x,y,z)}; mat3 G = to_mat3(-0.57f,0.81f,0.1f, -0.28f,-0.3f,0.9f, 0.77f, 0.49f, 0.4f); float i=0.0f,y=0.0f,d=0.0f,s=0.0f; float3 g, p = P(T*1e1f) + to_float3_aw(ViewXY, ViewZ), Z = normalize( P(T*1e1f+1.0f) - p), X = normalize(to_float3(Z.z,0,-Z.x)), rd = mul_f3_mat3(to_float3_aw((fragCoord - 0.5f * iResolution) / iResolution.y, 2) , to_mat3_f3(-X, cross(X, Z), Z)); //############### 3D Mouse-Rotation des Objektes ############## float crz = (iMouse.x - iResolution.x / 2.0f) / iResolution.x * pi; float crx = (iMouse.y - iResolution.y / 2.0f) / iResolution.y * pi; mat3 m = mul_mat3_mat3(to_mat3(_cosf(crz), 0.0f, _sinf(crz), 0.0f, 1.0f, 0.0f, -_sinf(crz), 0.0f, _cosf(crz)) , to_mat3(1.0f, 0.0f, 0.0f, 0.0f, _cosf(crx), _sinf(crx), 0.0f, -_sinf(crx), _cosf(crx))); if(iMouse.z > 0.0f) { p = mul_mat3_f3(m , p); rd = mul_mat3_f3(m , rd); } //############################################################# float4 o = to_float4_s(0.0f); for (;i++ < 150.0f;) { s = 0.001f + _fabs(s) * Level0;//0.1f; d += s; swi3S(o,x,y,z, swi3(o,x,y,z) + c(p.z*0.1f+i*2.0f, Colors) / s ); p = rd*d+P(T*1e1f); g = p; swi2S(p,x,y, mul_f2_mat2(swi2(p,x,y) , R(length(swi2(P(T),x,y))*0.05f ))); //s =(_sinf(p.z + (p.y)) * 0.1f)-0.2f; s =(_sinf(p.z + (p.y)) * Level1)-Level2; y = _fabs(n(p)+n(p/8.0f)*Level3);//4.0f); s += y+y*0.2f; //s = _fmaxf(1.5f+_sinf(p.z*0.2f+p.y*0.4f)-length(swi2((g-P(p.z)),x,y)), s); s = _fmaxf(1.5f+_sinf(p.z*Level4+p.y*Level5)-length(swi2((g-P(p.z)),x,y)), s); } fragColor = tanh_f4(o * o /2e8f)*Level6;//1.5f; fragColor.w = 1.0f; _tex2DVec4Write(destinationTexture, fusion_x, fusion_y, fragColor); } ]] -- /* -- // ------------------------------------------------------------------------ -- // Create -- // ------------------------------------------------------------------------ function Create() ShaderFuse.begin_create() ----- Inspector Panel Controls -- Speed Slider InFrequency = self:AddInput("Speedup", "speed", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_Default = 1.0, INP_MinScale = 0.0, INP_MaxScale = 5.0, SLCS_LowName = "stop", SLCS_HighName = "5x", }) -- iMouse Controls InMouseXY = self:AddInput("iMouse.xy", "iMouseXY", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INP_DoNotifyChanged = false, --INP_Passive = true, INPID_PreviewControl = "CrosshairControl", }) InMouseZW = self:AddInput("iMouse.zw", "iMouseZW", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INP_DoNotifyChanged = false, --INP_Passive = true, INPID_PreviewControl = "CrosshairControl", INP_Disabled = true, }) InMouseDrag = self:AddInput("Mouse Button Pressed", "iMouseClick", { LINKID_DataType = "Number", INPID_InputControl = "CheckboxControl", INP_DoNotifyChanged = false, --INP_Passive = true, INP_MinScale = 0, INP_MaxScale = 1, INP_Default = 0, }) self:BeginControlNest("Color1", "Color1", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Color1", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InColor1ColorR = self:AddInput("Red", "Color1Red", { INP_Default = 0.455, IC_ControlID = 0, attrs}) InColor1ColorG = self:AddInput("Green", "Color1Green", { INP_Default = 0.322, IC_ControlID = 1, attrs}) InColor1ColorB = self:AddInput("Blue", "Color1Blue", { INP_Default = 0.216, IC_ControlID = 2, attrs}) InColor1ColorA = self:AddInput("Alpha", "Color1Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Color2", "Color2", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Color2", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InColor2ColorR = self:AddInput("Red", "Color2Red", { INP_Default = -0.073, IC_ControlID = 0, attrs}) InColor2ColorG = self:AddInput("Green", "Color2Green", { INP_Default = 0.119, IC_ControlID = 1, attrs}) InColor2ColorB = self:AddInput("Blue", "Color2Blue", { INP_Default = 0.150, IC_ControlID = 2, attrs}) InColor2ColorA = self:AddInput("Alpha", "Color2Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Color3", "Color3", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Color3", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InColor3ColorR = self:AddInput("Red", "Color3Red", { INP_Default = 20.000, IC_ControlID = 0, attrs}) InColor3ColorG = self:AddInput("Green", "Color3Green", { INP_Default = 1.000, IC_ControlID = 1, attrs}) InColor3ColorB = self:AddInput("Blue", "Color3Blue", { INP_Default = 1.000, IC_ControlID = 2, attrs}) InColor3ColorA = self:AddInput("Alpha", "Color3Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Color4", "Color4", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Color4", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InColor4ColorR = self:AddInput("Red", "Color4Red", { INP_Default = 0.100, IC_ControlID = 0, attrs}) InColor4ColorG = self:AddInput("Green", "Color4Green", { INP_Default = -0.256, IC_ControlID = 1, attrs}) InColor4ColorB = self:AddInput("Blue", "Color4Blue", { INP_Default = -0.231, IC_ControlID = 2, attrs}) InColor4ColorA = self:AddInput("Alpha", "Color4Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() InViewXYPoint = self:AddInput("ViewXY", "ViewXY", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INPID_PreviewControl = "CrosshairControl", INP_DefaultX = 0.0, INP_DefaultY = 0.0, }) InViewZSlider = self:AddInput("ViewZ", "ViewZ", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -10.0, INP_MaxScale = 10.0, INP_Default = 0.0, }) InLevel0Slider = self:AddInput("Level0", "Level0", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 1.0, INP_Default = 0.1, }) InLevel1Slider = self:AddInput("Level1", "Level1", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 1.0, INP_Default = 0.1, }) InLevel2Slider = self:AddInput("Level2", "Level2", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 1.0, INP_Default = 0.2, }) InLevel3Slider = self:AddInput("Level3", "Level3", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 10.0, INP_Default = 4.0, }) InLevel4Slider = self:AddInput("Level4", "Level4", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 1.0, INP_Default = 0.2, }) InLevel5Slider = self:AddInput("Level5", "Level5", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 2.0, INP_Default = 0.4, }) InLevel6Slider = self:AddInput("Level6", "Level6", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 5.0, INP_Default = 1.5, }) Sep3 = self:AddInput(string.rep("_", 152), "Separator3", { LINKID_DataType = "Text", INPID_InputControl = "LabelControl", INP_External = false, INP_Passive = true, IC_Visible = true, INP_DoNotifyChanged = true, IC_NoLabel = true, }) InEdges = self:AddInput("Edges", "Edges", { LINKID_DataType = "Number", INPID_InputControl = "MultiButtonControl", INP_Default = 3.0, INP_Integer = true, INP_DoNotifyChanged = true, INP_External = false, MBTNC_ForceButtons = true, INP_MinScale = 0, INP_MaxScale = 3, INP_MinAllowed = 0, INP_MaxAllowed = 3, MBTNC_ShowBasicButton = true, MBTNC_StretchToFit = false, --true, MBTNC_ShowToolTip = true, { MBTNC_AddButton = "Canvas", MBTNCD_ButtonWidth = 4/16, }, { MBTNC_AddButton = "Wrap",MBTNCD_ButtonWidth = 3/16, }, { MBTNC_AddButton = "Duplicate", MBTNCD_ButtonWidth = 5/16, }, { MBTNC_AddButton = "Mirror", MBTNCD_ButtonWidth = 4/16, }, }) InDebugImage = self:AddInput("DebugImage", "DebugImage", { LINKID_DataType = "Number", INPID_InputControl = "ComboControl", INP_Default = 0.0, INP_Integer = true, ICD_Width = 1, { CCS_AddString = "Final", }, { CCS_AddString = "BufferA", }, { CCS_AddString = "BufferB", }, { CCS_AddString = "BufferC", }, { CCS_AddString = "BufferD", }, CC_LabelPosition = "Horizontal", }) ----- Size & Depth InSize = self:AddInput("Size", "Size_Fuse", { LINKID_DataType = "Number", INPID_InputControl = "ComboControl", INP_DoNotifyChanged = true, INP_Default = 0, INP_Integer = true, ICD_Width = 1, { CCS_AddString = "Default", }, { CCS_AddString = "Manually", }, { CCS_AddString = "Image0", }, { CCS_AddString = "1920x1080", }, { CCS_AddString = "1200x675", }, { CCS_AddString = "800x450", }, { CCS_AddString = "640x360", }, CC_LabelPosition = "Horizontal", ICS_ControlPage = "Image", }) InWidth = self:AddInput("Width", "_Width", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_Default = 1920, INP_Integer = true, INP_MinScale = 0, INP_MaxScale = 4096, }) InHeight = self:AddInput("Height", "_Height", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_Default = 1080, INP_Integer = true, INP_MinScale = 0, INP_MaxScale = 4096, }) InDepth = self:AddInput("Depth_Fuse", "Depth_Fuse", { LINKID_DataType = "Number", INPID_InputControl = "ComboControl", INP_DoNotifyChanged = true, INP_Default = 0, INP_Integer = true, ICD_Width = 1, { CCS_AddString = "Default", }, { CCS_AddString = "int8", }, { CCS_AddString = "int16", }, { CCS_AddString = "float16", }, { CCS_AddString = "float32", }, CC_LabelPosition = "Horizontal", ICS_ControlPage = "Image", }) InMyWidth = self:FindInput("Width") InMyWidth:SetAttrs({ IC_Visible = false }) InMyHeight = self:FindInput("Height") InMyHeight:SetAttrs({ IC_Visible = false }) InMyDepth = self:FindInput("Depth") InMyDepth:SetAttrs({ IC_Visible = false }) ----- In/Out OutImage = self:AddOutput("Output", "Output", { LINKID_DataType = "Image", LINK_Main = 1, }) ShaderFuse.end_create() end -- // ------------------------------------------------------------------------ -- // Process -- // ------------------------------------------------------------------------ function Process(req) -- Imagesize and Depth if (InSize:GetValue(req).Value >= 1) then if (InSize:GetValue(req).Value == 2) then if (InChannel0:GetValue(req) ~= nil) then Width = InChannel0:GetValue(req).Width Height = InChannel0:GetValue(req).Height end else Width = InWidth:GetValue(req).Value Height = InHeight:GetValue(req).Value end end -- Alle ( int und float ) if (InDepth:GetValue(req).Value > 0) then if InDepth:GetValue(req).Value == 1 then SourceDepth = 5 else if InDepth:GetValue(req).Value == 2 then SourceDepth = 6 else if InDepth:GetValue(req).Value == 3 then SourceDepth = 7 else SourceDepth = 8 end end end end local imgattrs = { IMG_Document = self.Comp, { IMG_Channel = "Red", }, { IMG_Channel = "Green", }, { IMG_Channel = "Blue", }, { IMG_Channel = "Alpha", }, IMG_Width = Width, IMG_Height = Height, IMG_XScale = XAspect, IMG_YScale = YAspect, IMAT_OriginalWidth = realwidth, -- nil !?! IMAT_OriginalHeight = realheight, -- nil !?! IMG_Quality = not req:IsQuick(), IMG_MotionBlurQuality = not req:IsNoMotionBlur(), IMG_DeferAlloc = true, IMG_ProxyScale = ( (not req:IsStampOnly()) and 1 or nil), IMG_Depth = ( (SourceDepth~=0) and SourceDepth or nil ) } local dst = Image(imgattrs) local black = Pixel({R=0,G=0,B=0,A=0}) dst:Fill(black) if req:IsPreCalc() then local out = Image({IMG_Like = dst, IMG_NoData = true}) OutImage:Set(req, out) return end node = DVIPComputeNode(req, "GlassOriginFuse", ShaderCompatibilityCode..ShaderKernelCode, "Params", ShaderParameters ) -- Extern texture or create a new one -- DCTL parameters local framerate = self.Comp:GetPrefs("Comp.FrameFormat.Rate") local params = {} params = node:GetParamBlock(ShaderParameters) params.iResolution[0] = dst.Width params.iResolution[1] = dst.Height params.iTime = (req.Time / framerate) * InFrequency:GetValue(req).Value -- iMouse local mouse_xy = InMouseXY:GetValue(req) local mouse_zw = InMouseZW:GetValue(req) params.iMouse[0] = mouse_xy.X params.iMouse[1] = mouse_xy.Y params.iMouse[2] = mouse_zw.X params.iMouse[3] = mouse_zw.Y if InMouseDrag:GetValue(req).Value ~= 0 then if params.iMouse[2]==-1 and params.iMouse[3]==-1 then params.iMouse[2]=params.iMouse[0] params.iMouse[3]=params.iMouse[1] end else params.iMouse[2] = -1 params.iMouse[3] = -1 end if mouse_zw.X ~= params.iMouse[2] or mouse_zw.Y ~= params.iMouse[3] then InMouseZW:SetAttrs({INP_Disabled=false}) InMouseZW:SetSource(Point(params.iMouse[2],params.iMouse[3]),0,0) InMouseZW:SetAttrs({INP_Disabled=true}) end params.iMouse[0] = params.iMouse[0] * Width params.iMouse[1] = params.iMouse[1] * Height if params.iMouse[2] == -1 and params.iMouse[3] == -1 then params.iMouse[2] = 0 params.iMouse[3] = 0 else params.iMouse[2] = params.iMouse[2] * Width params.iMouse[3] = params.iMouse[3] * Height end params.Color1 = { InColor1ColorR:GetValue(req).Value, InColor1ColorG:GetValue(req).Value, InColor1ColorB:GetValue(req).Value,InColor1ColorA:GetValue(req).Value } params.Color2 = { InColor2ColorR:GetValue(req).Value, InColor2ColorG:GetValue(req).Value, InColor2ColorB:GetValue(req).Value,InColor2ColorA:GetValue(req).Value } params.Color3 = { InColor3ColorR:GetValue(req).Value, InColor3ColorG:GetValue(req).Value, InColor3ColorB:GetValue(req).Value,InColor3ColorA:GetValue(req).Value } params.Color4 = { InColor4ColorR:GetValue(req).Value, InColor4ColorG:GetValue(req).Value, InColor4ColorB:GetValue(req).Value,InColor4ColorA:GetValue(req).Value } params.ViewXY = {InViewXYPoint:GetValue(req).X,InViewXYPoint:GetValue(req).Y} params.ViewZ = InViewZSlider:GetValue(req).Value params.Level0 = InLevel0Slider:GetValue(req).Value params.Level1 = InLevel1Slider:GetValue(req).Value params.Level2 = InLevel2Slider:GetValue(req).Value params.Level3 = InLevel3Slider:GetValue(req).Value params.Level4 = InLevel4Slider:GetValue(req).Value params.Level5 = InLevel5Slider:GetValue(req).Value params.Level6 = InLevel6Slider:GetValue(req).Value -- Resolution params.width = dst.Width params.height = dst.Height -- Per channel time and resolution -- Set parameters and add I/O node:SetParamBlock(params) node:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_MIRROR, TEX_NORMALIZED_COORDS_TRUE) node:AddOutput("dst", dst) local ok = node:RunSession(req) if (not ok) then dst = nil dump(node:GetErrorLog()) end OutImage:Set(req,dst) collectgarbage(); end -- // ------------------------------------------------------------------------ -- // Callback -- // ------------------------------------------------------------------------ function NotifyChanged(inp, param, time) if (param ~= nil) then if inp == InSize then if param.Value == 1 then InWidth:SetAttrs({ IC_Visible = true }) InHeight:SetAttrs({ IC_Visible = true }) else InWidth:SetAttrs({ IC_Visible = false }) InHeight:SetAttrs({ IC_Visible = false }) end if param.Value == 3 then --1920x1080 InWidth:SetSource(Number(1920),0,0) InHeight:SetSource(Number(1080),0,0) end if param.Value == 4 then --1200x675 InWidth:SetSource(Number(1200),0,0) InHeight:SetSource(Number(675),0,0) end if param.Value == 5 then --800x450 InWidth:SetSource(Number(800),0,0) InHeight:SetSource(Number(450),0,0) end if param.Value == 6 then --640x360 InWidth:SetSource(Number(640),0,0) InHeight:SetSource(Number(360),0,0) end end end end -- */