--[[--/* AnotherDayAnotherGlowmarcher.fuse Based on https://www.shadertoy.com/view/t3GfDd a WebGL shader created by mrange. 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]; bool Tex; float View[4]; float Color[4]; float ViewXY[2]; float ViewZ; float AOff[2]; float sOff[2]; float Level0; float Level1; float Level2; float Level3; float BrightnessTex; float TexXY[2]; float TexScale; 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 float3 mul_mat3_f3( mat3 B, float3 A) { return (B*A); } __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 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__ 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_f2(i) sin(i) #define sin_f4(i) sin(i) #define cos_f2(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_f2(i) sin(i) #define sin_f4(i) sin(i) #define cos_f2(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_f2(i) to_float2( _sinf((i).x), _sinf((i).y)) #define sin_f4(i) to_float4( _sinf((i).x), _sinf((i).y), _sinf((i).z), _sinf((i).w)) #define cos_f2(i) to_float2( _cosf((i).x), _cosf((i).y)) #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 = [[ // ---------------------------------------------------------------------------------- // - Common - // ---------------------------------------------------------------------------------- #define texture(ch,uv) _tex2DVecN(ch, (uv).x, (uv).y, 15) #define texelFetch(ch, uv, a) texture(ch, (make_float2((uv).x,(uv).y)+0.5f)/iResolution) #define pi 3.1415926535897f __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; } __DEVICE__ float4 Blending( __TEXTURE2D__ channel, float2 uv, float4 Q, float Blend, float2 Par, float2 MulOff, int Modus, float2 U, float2 R) { //Modus *= 2; // for Fusination if (Blend > 0.0f) { //float2 tuv = U/R; float4 tex = texture(channel,uv); if (tex.w > 0.0f) { if ((int)Modus&2) //swi2S(Q,x,y, _mix(swi2(Q,x,y),(swi2(tex,x,y)+MulOff.y)*MulOff.x,Blend)); Q = _mix(Q,(tex+MulOff.y)*MulOff.x,Blend); //swi3S(Q,x,y,w, _mix(swi3(Q,x,y,w),(swi3(tex,x,y,z)+MulOff.y)*MulOff.x,Blend)); if ((int)Modus&4) //swi2S(Q,x,y, _mix( swi2(Q,x,y), Par , Blend)); //swi2S(Q,x,y, _mix( swi2(Q,x,y), Par, Blend)); //swi3S(Q,x,y,z, _mix(swi3(Q,x,y,z), (swi3(tex,x,y,z)+MulOff.y)*MulOff.x, Blend)); Q = _mix(Q,to_float4(Par.x,Par.y,(tex.x+MulOff.y)*MulOff.x,(tex.y+MulOff.y)*MulOff.x),Blend); if ((int)Modus&8) //swi2S(Q,x,y, _mix( swi2(Q,x,y), Par, Blend)); Q = _mix(Q,to_float4((tex.x+MulOff.y)*MulOff.x,(tex.y+MulOff.y)*MulOff.x,Par.x,Par.y),Blend); //swi2S(Q,z,w, _mix( swi2(Q,z,w), swi2(tex,x,y)*Par, Blend)); if ((int)Modus&16) //swi2S(Q,z,w, _mix(swi2(Q,z,w), swi2(tex,x,y)*Par, Blend)); Q = _mix(Q,to_float4(Par.x,Par.y,MulOff.x,MulOff.y),Blend); } else if ((int)Modus&32) //Special //swi2S(Q,x,y, _mix(swi2(Q,x,y),(swi2(tex,x,y)+MulOff.y)*MulOff.x,Blend)); Q = _mix(Q,(tex+MulOff.y)*MulOff.x,Blend); } return Q; } // ---------------------------------------------------------------------------------- // - Image - // ---------------------------------------------------------------------------------- // Connect Image 'Texture: Picture' to iChannel0 // CC0: Another day, another glowmarcher // Twigl link: https://twigl.app?ol=true&ss=-OmZSyy0GfTTuMjy66sJ #define N normalize __KERNEL__ void AnotherDayAnotherGlowmarcherFuse(__CONSTANTREF__ Params* params, __TEXTURE2D__ iChannel0, __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 o = to_float4_s(0.0f); float2 C = to_float2(fusion_x,fusion_y); bool Tex = params->Tex; float4 View = to_float4(params->View[0], params->View[1], params->View[2], params->View[3]); float4 Color = to_float4(params->Color[0], params->Color[1], params->Color[2], params->Color[3]); float2 ViewXY = to_float2(params->ViewXY[0], params->ViewXY[1]); float ViewZ = params->ViewZ; float2 AOff = to_float2(params->AOff[0], params->AOff[1]); float2 sOff = to_float2(params->sOff[0], params->sOff[1]); float Level0 = params->Level0; float Level1 = params->Level1; float Level2 = params->Level2; float Level3 = params->Level3; float BrightnessTex = params->BrightnessTex; float2 TexXY = to_float2(params->TexXY[0], params->TexXY[1]); float TexScale = params->TexScale; // -------- float ratio = iResolution.y/iResolution.x; float3 p , Z , I=to_float3_aw(iResolution,1.0f) , S; float2 A=to_float2(0.4f,0.3f) + AOff , s=to_float2(0.0f,0.0f) , uv = C / iResolution; C-=0.5f*swi2(I,x,y); s=sin_f2(A*iTime) + sOff; S=N(cross(swi3(View,x,y,z)+to_float3_aw(A*A*s,0),Z=N(to_float3_aw(A*cos_f2(A*iTime),1)))); //to_float3(0,1,0) I=N(C.y*cross(S,Z)+I.y*Z-C.x*S); S=to_float3_aw(s,iTime); float4 O = to_float4_s(0.0f); for ( float i=0.0f,d=0.0f,z=0.0f; ++i<77.0f; O+=o.w/d*o) { p=z*I+S + to_float3_aw(ViewXY,ViewZ); s=sin_f2(A*p.z); swi2S(p,x,y, swi2(p,x,y)-s); Z=N(to_float3_aw(A*cos_f2(A*p.z),-1)); //############### 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); Z = mul_mat3_f3(m , Z); } //############################################################# p-=dot(swi2(p,x,y),swi2(Z,x,y))*Level0*Z; //0.5f swi2S(p,x,y, mul_f2_mat2(swi2(p,x,y) , to_mat2_f4(cos_f4(to_float4(0,11,33,0)-(A*A*s).x)))); //to_float4(0,11,33,0) if (Tex) { //float2 tuv = ((uv+TexXY))*TexScale; //*to_float2(ratio,1.0f) float2 tuv = ((swi2(p,x,y)*to_float2(ratio,1.0f)+TexXY))*TexScale; //*to_float2(ratio,1.0f) Color = texture(iChannel0, tuv) * BrightnessTex; } o=Tex ? Color : Level1+sin_f4(2.0f*_fabs(p.x)+Color);//to_float4(8,3,4,2)); //0.9f p-=round(p); z+=d=1e-3f+Level2*_fabs(Level3-_sqrtf(length(p*p))); //0.7f //0.53f } o=tanh_f4(O/2E4f); o.w = 1.0f; //o = Color; _tex2DVec4Write(destinationTexture, fusion_x, fusion_y, o); } ]] -- /* -- // ------------------------------------------------------------------------ -- // 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, }) InTexCheckbox = self:AddInput("Tex", "Tex", { LINKID_DataType = "Number", INPID_InputControl = "CheckboxControl", INP_Integer = true, INP_Default = 0, }) self:BeginControlNest("View", "View", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "View", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InViewColorR = self:AddInput("Red", "ViewRed", { INP_Default = 0.0, IC_ControlID = 0, attrs}) InViewColorG = self:AddInput("Green", "ViewGreen", { INP_Default = 0.0, IC_ControlID = 1, attrs}) InViewColorB = self:AddInput("Blue", "ViewBlue", { INP_Default = 0.0, IC_ControlID = 2, attrs}) InViewColorA = self:AddInput("Alpha", "ViewAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Color", "Color", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Color", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InColorColorR = self:AddInput("Red", "ColorRed", { INP_Default = 8.0, IC_ControlID = 0, attrs}) InColorColorG = self:AddInput("Green", "ColorGreen", { INP_Default = 3.0, IC_ControlID = 1, attrs}) InColorColorB = self:AddInput("Blue", "ColorBlue", { INP_Default = 4.0, IC_ControlID = 2, attrs}) InColorColorA = self:AddInput("Alpha", "ColorAlpha", { INP_Default = 2.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, }) InAOffPoint = self:AddInput("AOff", "AOff", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INPID_PreviewControl = "CrosshairControl", INP_DefaultX = 0.0, INP_DefaultY = 0.0, }) InsOffPoint = self:AddInput("sOff", "sOff", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INPID_PreviewControl = "CrosshairControl", INP_DefaultX = 0.0, INP_DefaultY = 0.0, }) InLevel0Slider = self:AddInput("Level0", "Level0", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 2.0, INP_Default = 0.5, }) InLevel1Slider = self:AddInput("Level1", "Level1", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 2.0, INP_Default = 0.9, }) InLevel2Slider = self:AddInput("Level2", "Level2", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 2.0, INP_Default = 0.7, }) InLevel3Slider = self:AddInput("Level3", "Level3", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 2.0, INP_Default = 0.53, }) InBrightnessTexSlider = self:AddInput("BrightnessTex", "BrightnessTex", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 10.0, INP_Default = 1.0, }) InTexXYPoint = self:AddInput("TexXY", "TexXY", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INPID_PreviewControl = "CrosshairControl", INP_DefaultX = 0.0, INP_DefaultY = 0.0, }) InTexScaleSlider = self:AddInput("TexScale", "TexScale", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -10.0, INP_MaxScale = 10.0, INP_Default = 1.0, }) 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, }, }) ----- 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 InChannel0 = self:AddInput( "iChannel0", "iChannel0", { LINKID_DataType = "Image", LINK_Main = 1, INP_Required = false }) OutImage = self:AddOutput("Output", "Output", { LINKID_DataType = "Image", LINK_Main = 1, }) ShaderFuse.end_create() end -- // ------------------------------------------------------------------------ -- // Process -- // ------------------------------------------------------------------------ function DefineEdges(edges, nodeX) --This gets the value of our input image for us to modify inside the kernel if edges == 0 then nodeX:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_BORDER, TEX_NORMALIZED_COORDS_TRUE) elseif edges == 1 then nodeX:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_WRAP, TEX_NORMALIZED_COORDS_TRUE) elseif edges == 2 then nodeX:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_DUPLICATE, TEX_NORMALIZED_COORDS_TRUE) elseif edges == 3 then nodeX:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_MIRROR, TEX_NORMALIZED_COORDS_TRUE) elseif edges == 4 then --print("Sampler 4") end end 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, "AnotherDayAnotherGlowmarcherFuse", ShaderCompatibilityCode..ShaderKernelCode, "Params", ShaderParameters ) -- Extern texture or create a new one iChannel0 = InChannel0:GetValue(req) if iChannel0==nil then iChannel0 = Image(imgattrs) iChannel0:Fill(black) end -- 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.Tex = InTexCheckbox:GetValue(req).Value params.View = { InViewColorR:GetValue(req).Value, InViewColorG:GetValue(req).Value, InViewColorB:GetValue(req).Value,InViewColorA:GetValue(req).Value } params.Color = { InColorColorR:GetValue(req).Value, InColorColorG:GetValue(req).Value, InColorColorB:GetValue(req).Value,InColorColorA:GetValue(req).Value } params.ViewXY = {InViewXYPoint:GetValue(req).X,InViewXYPoint:GetValue(req).Y} params.ViewZ = InViewZSlider:GetValue(req).Value params.AOff = {InAOffPoint:GetValue(req).X,InAOffPoint:GetValue(req).Y} params.sOff = {InsOffPoint:GetValue(req).X,InsOffPoint:GetValue(req).Y} 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.BrightnessTex = InBrightnessTexSlider:GetValue(req).Value params.TexXY = {InTexXYPoint:GetValue(req).X,InTexXYPoint:GetValue(req).Y} params.TexScale = InTexScaleSlider:GetValue(req).Value -- Resolution params.width = dst.Width params.height = dst.Height -- Per channel time and resolution local edges = InEdges:GetValue(req).Value -- Set parameters and add I/O node:SetParamBlock(params) --node:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_MIRROR, TEX_NORMALIZED_COORDS_TRUE) DefineEdges(edges, node) node:AddInput("iChannel0",iChannel0) -- TODO: add a better channel name 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 -- */