--[[--/* ReactorDeNCleoDeCristal.fuse Based on https://www.shadertoy.com/view/NXf3Rf a WebGL shader created by gus78. 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 BGColor[4]; float FinalColor[4]; float Base1Color[4]; float Base2Color[4]; float BeamXY[2]; float Beam; float ViewXY[2]; float ViewZ; float Edge; 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 #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;} #endif // ---------------------------------------------------------------------------------------------------------- // mat2 implementation // ---------------------------------------------------------------------------------------------------------- #if defined(USE_NATIVE_METAL_IMPL) typedef float2x2 mat2; #define to_mat2(A,B,C,D) mat2((A),(B),(C),(D)) #define mul_f2_mat2(A,B) ((A)*(B)) #else typedef struct { float2 r0; float2 r1; } mat2; __DEVICE__ inline mat2 to_mat2 ( float a, float b, float c, float d) { mat2 t; t.r0.x = a; t.r0.y = b; t.r1.x = c; t.r1.y = d; return t; } __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 abs_f3(a) _fabs(a) #define pow_f3(a,b) pow(a,b) #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 abs_f3(a) fabs(a) #define pow_f3(a,b) pow(a,b) #else // Generic #if defined(DEVICE_IS_OPENCL) __DEVICE__ float3 reflect(float3 I, float3 N) {return I - 2.0f * dot(N, I) * N;} #endif #define fract(a) ((a)-_floor(a)) #define abs_f3(a) to_float3(_fabs((a).x), _fabs((a).y),_fabs((a).z)) #define pow_f3(a,b) to_float3(_powf((a).x,(b).x),_powf((a).y,(b).y),_powf((a).z,(b).z)) #endif #endif ]] -- /* -- // ------------------------------------------------------------------------ -- DCTL kernel implementation -- // ------------------------------------------------------------------------ -- */ ShaderKernelCode = [[ // ---------------------------------------------------------------------------------- // - Common - // ---------------------------------------------------------------------------------- #define texture(ch,uv) _tex2DVecN(ch, (uv).x, (uv).y, 15) #define pi 3.1415926535897f // ---------------------------------------------------------------------------------- // - Image - // ---------------------------------------------------------------------------------- // "The Quantum Core v2.0" - Visualizador de Grado Profesional ($300 USD) // Geometría de cristal, refracciones reales y reactividad por bandas. // iChannel0: Audio (Indispensable) #define T iTime // --- FUNCIONES DE ALTA PRECISIÓN --- __DEVICE__ mat2 rot(float a) { float c=_cosf(a), s=_sinf(a); return to_mat2(c,s,-s,c); } __DEVICE__ float sdBox(float3 p, float3 b) { float3 q = abs_f3(p) - b; return length(_fmaxf(q, to_float3_s(0.0f))) + _fminf(_fmaxf(q.x,_fmaxf(q.y,q.z)),0.0f); } // Reactividad limpia __DEVICE__ float getBass(__TEXTURE2D__ iChannel0) { return _powf(texture(iChannel0, to_float2(0.05f, 0.25f)).x, 2.0f); } __DEVICE__ float getMid(__TEXTURE2D__ iChannel0) { return texture(iChannel0, to_float2(0.4f, 0.25f)).x; } // --- EL NÚCLEO (Geometría que no genera bloques sólidos) --- __DEVICE__ float map(float3 p, float iTime, __TEXTURE2D__ iChannel0) { float bass = getBass(iChannel0); float3 q = p; // El núcleo: un octaedro que se abre con el audio swi2S(q,x,y, mul_f2_mat2(swi2(q,x,y) , rot(T * 0.5f + bass))); swi2S(q,y,z, mul_f2_mat2(swi2(q,y,z) , rot(T * 0.3f))); // Geometría fractal simple para evitar el "bloque sólido" for(int i=0; i<3; i++) { q = abs_f3(q) - 0.2f - bass * 0.1f; swi2S(q,x,y, mul_f2_mat2(swi2(q,x,y) , rot(0.5f))); swi2S(q,y,z, mul_f2_mat2(swi2(q,y,z) , rot(0.8f))); } return sdBox(q, to_float3(0.1f, 0.5f, 0.1f)); } __KERNEL__ void ReactorDeNCleoDeCristalFuse(__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 fragColor = to_float4_s(0.0f); float2 fragCoord = to_float2(fusion_x,fusion_y); float4 BGColor = to_float4(params->BGColor[0], params->BGColor[1], params->BGColor[2], params->BGColor[3]); float4 FinalColor = to_float4(params->FinalColor[0], params->FinalColor[1], params->FinalColor[2], params->FinalColor[3]); float4 Base1Color = to_float4(params->Base1Color[0], params->Base1Color[1], params->Base1Color[2], params->Base1Color[3]); float4 Base2Color = to_float4(params->Base2Color[0], params->Base2Color[1], params->Base2Color[2], params->Base2Color[3]); float2 BeamXY = to_float2(params->BeamXY[0], params->BeamXY[1]); float Beam = params->Beam; float2 ViewXY = to_float2(params->ViewXY[0], params->ViewXY[1]); float ViewZ = params->ViewZ; float Edge = params->Edge; // -------- float Alpha = BGColor.w; float2 uv = (fragCoord - 0.5f * iResolution) / iResolution.y; float bass = getBass(iChannel0); float mid = getMid(iChannel0); // Cámara cinematográfica (Sin saltos raros) float3 ro = to_float3(0.0f, 0.0f, -3.0f); float3 rd = normalize(to_float3_aw(uv, 1.5f)+to_float3_aw(ViewXY, ViewZ)); //############### 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) { ro = mul_mat3_f3(m , ro); rd = mul_mat3_f3(m , rd); } //############################################################# // Movimiento suave de cámara swi2S(ro,x,z, mul_f2_mat2(swi2(ro,x,z) , rot(T * 0.2f))); swi2S(rd,x,z, mul_f2_mat2(swi2(rd,x,z) , rot(T * 0.2f))); float3 col = swi3(BGColor,x,y,z);//to_float3(0.01f, 0.01f, 0.02f); // Fondo negro de lujo // Raymarching de superficie (No volumétrico para evitar errores de gradiente) float t = 0.0f; for(int i=0; i<100; i++) { float3 p = ro + rd * t; float d = map(p, iTime, iChannel0); if(d < 0.001f || t > 10.0f) break; t += d; } if(t < 10.0f) { float3 p = ro + rd * t; // Cálculo de normales para brillo metálico/cristal float2 e = to_float2(0.001f, 0.0f); float3 n = normalize(map(p, iTime, iChannel0) - to_float3(map(p-swi3(e,x,y,y), iTime, iChannel0), map(p-swi3(e,y,x,y), iTime, iChannel0), map(p-swi3(e,y,y,x), iTime, iChannel0))); // Iluminación: Cian y Magenta (Tu marca registrada) float3 lightPos = to_float3(2.0f, 2.0f, -2.0f); float3 lDir = normalize(lightPos - p); float diff = _fmaxf(dot(n, lDir), 0.0f); float spec = _powf(_fmaxf(dot(reflect(-lDir, n), -rd), 0.0f), 64.0f); // Color reactivo //float3 baseCol = _mix(to_float3(0.0f, 0.8f, 1.0f), to_float3(1.0f, 0.0f, 0.5f), _sinf(p.y * 2.0f + T) * 0.5f + 0.5f); float3 baseCol = _mix(swi3(Base1Color,x,y,z), swi3(Base2Color,x,y,z), _sinf(p.y * 2.0f + T) * 0.5f + 0.5f); col = baseCol * diff + spec * to_float3_s(1.0f); // Efecto de bordes brillantes (Glow) float edge = _powf(1.0f - _fmaxf(dot(n, -rd), 0.0f), 3.0f) * Edge;//3.0f); col += baseCol * edge * 2.0f; Alpha = 1.0f; } //float3 Col = col; // Rayos de luz "God Rays" artificiales (Para el valor de USD 300) float beam = _powf(_fmaxf(0.0f, 1.0f - length(uv * (to_float2(1.0f, 2.0f)+BeamXY))), 4.0f)*Beam;//4.0f); col += swi3(FinalColor,x,y,z) * beam * bass;//to_float3(0.1f, 0.3f, 0.5f) * beam * bass; // Post-procesado premium col = smoothstep(to_float3_s(0.0f), to_float3_s(1.0f), col); col = pow_f3(col, to_float3_s(0.4545f)); // Gamma fragColor = to_float4_aw(col, Alpha); _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("Colors", "Colors", false, {}) self:BeginControlNest("BGColor", "BGColor", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "BGColor", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBGColorColorR = self:AddInput("Red", "BGColorRed", { INP_Default = 0.01, IC_ControlID = 0, attrs}) InBGColorColorG = self:AddInput("Green", "BGColorGreen", { INP_Default = 0.01, IC_ControlID = 1, attrs}) InBGColorColorB = self:AddInput("Blue", "BGColorBlue", { INP_Default = 0.02, IC_ControlID = 2, attrs}) InBGColorColorA = self:AddInput("Alpha", "BGColorAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("FinalColor", "FinalColor", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "FinalColor", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InFinalColorColorR = self:AddInput("Red", "FinalColorRed", { INP_Default = 0.1, IC_ControlID = 0, attrs}) InFinalColorColorG = self:AddInput("Green", "FinalColorGreen", { INP_Default = 0.3, IC_ControlID = 1, attrs}) InFinalColorColorB = self:AddInput("Blue", "FinalColorBlue", { INP_Default = 0.5, IC_ControlID = 2, attrs}) InFinalColorColorA = self:AddInput("Alpha", "FinalColorAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Base1Color", "Base1Color", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Base1Color", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBase1ColorColorR = self:AddInput("Red", "Base1ColorRed", { INP_Default = 0.0, IC_ControlID = 0, attrs}) InBase1ColorColorG = self:AddInput("Green", "Base1ColorGreen", { INP_Default = 0.8, IC_ControlID = 1, attrs}) InBase1ColorColorB = self:AddInput("Blue", "Base1ColorBlue", { INP_Default = 1.0, IC_ControlID = 2, attrs}) InBase1ColorColorA = self:AddInput("Alpha", "Base1ColorAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Base2Color", "Base2Color", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Base2Color", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBase2ColorColorR = self:AddInput("Red", "Base2ColorRed", { INP_Default = 1.0, IC_ControlID = 0, attrs}) InBase2ColorColorG = self:AddInput("Green", "Base2ColorGreen", { INP_Default = 0.0, IC_ControlID = 1, attrs}) InBase2ColorColorB = self:AddInput("Blue", "Base2ColorBlue", { INP_Default = 0.5, IC_ControlID = 2, attrs}) InBase2ColorColorA = self:AddInput("Alpha", "Base2ColorAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:EndControlNest() InBeamXYPoint = self:AddInput("BeamXY", "BeamXY", { LINKID_DataType = "Point", INPID_InputControl = "OffsetControl", INPID_PreviewControl = "CrosshairControl", INP_DefaultX = 0.0, INP_DefaultY = 0.0, }) InBeamSlider = self:AddInput("Beam", "Beam", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -10.0, INP_MaxScale = 10.0, INP_Default = 1.0, }) 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, }) InEdgeSlider = self:AddInput("Edge", "Edge", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_MinScale = -1.0, INP_MaxScale = 3.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, }) ----- 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 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, "ReactorDeNCleoDeCristalFuse", 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.BGColor = { InBGColorColorR:GetValue(req).Value, InBGColorColorG:GetValue(req).Value, InBGColorColorB:GetValue(req).Value,InBGColorColorA:GetValue(req).Value } params.FinalColor = { InFinalColorColorR:GetValue(req).Value, InFinalColorColorG:GetValue(req).Value, InFinalColorColorB:GetValue(req).Value,InFinalColorColorA:GetValue(req).Value } params.Base1Color = { InBase1ColorColorR:GetValue(req).Value, InBase1ColorColorG:GetValue(req).Value, InBase1ColorColorB:GetValue(req).Value,InBase1ColorColorA:GetValue(req).Value } params.Base2Color = { InBase2ColorColorR:GetValue(req).Value, InBase2ColorColorG:GetValue(req).Value, InBase2ColorColorB:GetValue(req).Value,InBase2ColorColorA:GetValue(req).Value } params.BeamXY = {InBeamXYPoint:GetValue(req).X,InBeamXYPoint:GetValue(req).Y} params.Beam = InBeamSlider:GetValue(req).Value params.ViewXY = {InViewXYPoint:GetValue(req).X,InViewXYPoint:GetValue(req).Y} params.ViewZ = InViewZSlider:GetValue(req).Value params.Edge = InEdgeSlider:GetValue(req).Value -- Resolution params.width = dst.Width params.height = dst.Height -- Per channel time and resolution node:SetParamBlock(params) node:AddSampler("RowSampler", TEX_FILTER_MODE_LINEAR,TEX_ADDRESS_MODE_MIRROR, TEX_NORMALIZED_COORDS_TRUE) 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 -- */