--[[--/* Staryu.fuse Based on https://www.shadertoy.com/view/s3XGRX a WebGL shader created by noztol. 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]; int iFrame; float BeachCol1[4]; float BeachCol2[4]; float SeaCol1[4]; float SeaCol2[4]; float SkyCol1[4]; float SkyCol2[4]; float BodyCol[4]; float GoldCol[4]; float RubyCol[4]; float Mat3Col1[4]; float Mat3Col2[4]; float FinalCol[4]; float ViewXY[2]; float ViewZ; 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 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 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__ 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 fract_f2(A) fract(A) #define fract_f3(A) fract(A) #define abs_f3(a) _fabs(a) #define sign_f(a) sign(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 fract_f2(A) to_float2(fract((A).x),fract((A).y)) #define fract_f3(A) to_float3(fract((A).x),fract((A).y),fract((A).z)) #define abs_f3(a) fabs(a) #define sign_f(a) sign(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 fract_f2(A) to_float2(fract((A).x),fract((A).y)) #define fract_f3(A) to_float3(fract((A).x),fract((A).y),fract((A).z)) #define abs_f3(a) to_float3(_fabs((a).x), _fabs((a).y),_fabs((a).z)) #define sign_f(a) (a==0.0f?0.0f:a>0.0f?1.0f:-1.0f) #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 = [[ // ---------------------------------------------------------------------------------- // - Image - // ---------------------------------------------------------------------------------- #define pi 3.1415926535897f // Staryu on the Beach // By Noztol // Constants/Uniforms #define ZERO 0 //float uTime; /* NOISE */ // Hash function by David Hoskins, https://www.shadertoy.com/view/4djSRW, MIT license __DEVICE__ float2 hash22(float2 p) { float3 p3 = fract_f3((swi3(p,x,y,x)) * to_float3(0.1031f, 0.1030f, 0.0973f)); p3 += dot(p3, swi3(p3,y,z,x)+33.33f); return fract_f2((swi2(p3,x,x)+swi2(p3,y,z))*swi2(p3,z,y)); } // Gradient noise __DEVICE__ float GradientNoise2D(float2 xy) { float i0 = _floor(xy.x), i1 = i0 + 1.0f; float j0 = _floor(xy.y), j1 = j0 + 1.0f; float v00 = dot(2.0f * hash22(to_float2(i0, j0)) - 1.0f, xy - to_float2(i0, j0)); float v01 = dot(2.0f * hash22(to_float2(i0, j1)) - 1.0f, xy - to_float2(i0, j1)); float v10 = dot(2.0f * hash22(to_float2(i1, j0)) - 1.0f, xy - to_float2(i1, j0)); float v11 = dot(2.0f * hash22(to_float2(i1, j1)) - 1.0f, xy - to_float2(i1, j1)); float xf = xy.x - i0; xf = xf * xf * xf * (10.0f + xf * (-15.0f + xf * 6.0f)); float yf = xy.y - j0; yf = yf * yf * yf * (10.0f + yf * (-15.0f + yf * 6.0f)); return v00 + (v10 - v00)*xf + (v01 - v00)*yf + (v00 + v11 - v01 - v10) * xf*yf; } // sea + beach __DEVICE__ float4 smin(float4 a, float4 b, float k) { // smoothed blending with color float h = clamp(0.5f + 0.5f * (b.x - a.x) / k, 0.0f, 1.0f); float d = _mix(b.x, a.x, h) - k * h * (1.0f - h); float3 tmp = _mix(swi3(b,y,z,w), swi3(a,y,z,w), h); return to_float4(d, tmp.x, tmp.y, tmp.z); } __DEVICE__ float4 mapGround(float3 p, float uTime, float3 Colors[4]) { float time = 0.25f*3.14159265f*uTime; float beach = 0.4f*_tanhf(0.2f*p.y)-0.2f*GradientNoise2D(0.5f*swi2(p,x,y)); beach *= smoothstep(0.0f,1.0f, 0.5f*(1.0f+_expf(0.3f*p.x)) * (length(to_float2(1.4f,1.0f)*swi2(p,x,y)-to_float2(-0.2f,-0.2f))-0.5f)); float sea = -0.2f+0.1f*_expf(sin(time)); if (_fabs(p.z-sea)<0.1f) sea += 0.005f*_tanhf(2.0f*_fmaxf(sea-beach,0.0f)) * _sinf(10.0f*(p.x-uTime-_sinf(p.y)))*_sinf(10.0f*(p.y+uTime-_sinf(p.x))); if (_fabs(p.z-beach)<0.1f) beach += 0.005f*_tanhf(5.0f*_fmaxf(beach-sea,0.0f)) * GradientNoise2D(50.0f*swi2(p,x,y)); // radial displacment sand effect float2 staryuPos = swi2(p,x,y) - to_float2(-0.1f, 0.1f); float r = length(staryuPos); float phi = _atan2f(staryuPos.y, staryuPos.x); // The trench radius matches where Staryu's bottom tips hit the ground float trenchDist = _fabs(r - 0.8f); float carveDepth = 0.12f * smoothstep(0.2f, 0.0f, trenchDist); // Create a trailing decay based on Staryu's rotation float trail = fract((phi + uTime * 0.3f) / 3.14159265f); float drawEffect = 1.0f - trail; // Decay effect: Wash out the trench if the water level hits it float dryness = smoothstep(0.0f, 0.05f, beach - sea); beach -= carveDepth * drawEffect * dryness; // --------------------------------------- //float3 seacol = _mix(to_float3(0.65f,0.85f,0.8f),to_float3(0.2f,0.55f,0.45f), smoothstep(0.0f,1.0f,-0.1f*p.y)); float3 seacol = _mix(Colors[0],Colors[1], smoothstep(0.0f,1.0f,-0.1f*p.y)); seacol = _mix(to_float3_s(1.0f), seacol, clamp(4.0f*(sea-beach),0.0f,1.0f)); seacol = _mix(to_float3_s(1.1f), seacol, clamp(20.0f*(sea-beach),0.0f,1.0f)); //float3 beachcol = _mix(to_float3(0.7f,0.7f,0.6f),to_float3(0.9f,0.85f,0.8f), clamp(5.0f*(beach-sea),0.0f,1.0f)); float3 beachcol = _mix(Colors[2],Colors[3], clamp(5.0f*(beach-sea),0.0f,1.0f)); float4 ground = smin(to_float4(-sea, seacol.x, seacol.y, seacol.z), to_float4(-beach, beachcol.x, beachcol.y, beachcol.z), 0.01f-0.005f*_cosf(time)); float3 tmp = _fminf(swi3(ground,y,z,w),to_float3_s(1.0f)); return to_float4(p.z+ground.x, tmp.x, tmp.y, tmp.z); } __DEVICE__ float3 gradGround(float3 p, float uTime, float3 Colors[4]) { const float h = 0.01f; float3 n = to_float3_s(0.0f); for(int i=ZERO; i<4; i++) { float3 e = 2.0f*to_float3((((i+3)>>1)&1),((i>>1)&1),(i&1))-1.0f; n += e*mapGround(p+e*h, uTime, Colors).x; } return n*(0.25f/h); } __DEVICE__ mat2 rot(float a) { float s = _sinf(a), c = _cosf(a); return to_mat2(c, -s, s, c); } __DEVICE__ float sminFloat(float a, float b, float k) { float h = clamp(0.5f + 0.5f * (b - a) / k, 0.0f, 1.0f); return _mix(b, a, h) - k * h * (1.0f - h); } __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); } __DEVICE__ float2 mapStaryu(float3 p, float uTime) { // Translate Staryu to rest perfectly on the beach (Z lowered to 1.05f to plant feet in sand) p -= to_float3(-0.1f, 0.1f, 1.05f); p = swi3(p,x,z,y); // Convert World Z-up to Staryu Local Y-up // Animation: Gentle hover and global rotation p.y -= _sinf(uTime * 1.5f) * 0.1f; swi2S(p,x,z, mul_f2_mat2(swi2(p,x,z) , rot(uTime * 0.3f))); swi2S(p,x,y, mul_f2_mat2(swi2(p,x,y) , rot(_sinf(uTime * 0.5f) * 0.1f))); float2 res = to_float2(100.0f, 0.0f); // 1.0f Staryu Body float dBody = 100.0f; for(int i = 0; i < 5; i++) { float3 q = p; swi2S(q,x,y, mul_f2_mat2(swi2(q,x,y) , rot((float)(i) * 3.14159265f * 2.0f / 5.0f))); // Organic Movement: Flap & Wiggle float flapAngle = _sinf(uTime * 2.5f + (float)(i) * 1.5f) * 0.12f; swi2S(q,y,z, mul_f2_mat2(swi2(q,y,z) , rot(flapAngle))); float wiggleMask = smoothstep(0.4f, 1.35f, q.y); q.z += _sinf(q.y * 6.0f - uTime * 6.0f + (float)(i)) * 0.05f * wiggleMask; q.y -= 0.65f; float t = clamp((q.y + 0.7f) / 1.4f, 0.0f, 1.0f); float taperX = _mix(0.38f, 0.001f, t); float taperZ = _mix(0.48f, 0.001f, t); // Body remains thick to hide the back of the sphere float rLen = length(to_float2(taperX, taperZ)); float dRhombus = (_fabs(q.x) * taperZ + _fabs(q.z) * taperX - taperX * taperZ) / rLen; float arm = _fmaxf(dRhombus, _fabs(q.y) - 0.7f) - 0.015f; dBody = sminFloat(dBody, arm, 0.08f); } res = to_float2(dBody, 1.0f); // 2.0f Gold Core float3 coreP = p - to_float3(0.0f, 0.0f, 0.15f); float dGoldBase = length(coreP) - 0.40f; float dLines = 100.0f; for(int i = 0; i < 3; i++) { float a = (float)(i) * 3.14159265f / 3.0f; float3 lq = coreP; swi2S(lq,x,y, mul_f2_mat2(swi2(lq,x,y) , rot(a))); dLines = _fminf(dLines, sdBox(lq, to_float3(0.025f, 0.42f, 0.42f))); } dLines = _fmaxf(dLines, length(coreP) - 0.43f); dLines = _fmaxf(dLines, -coreP.z); dLines = _fmaxf(dLines, -(length(swi2(coreP,x,y)) - 0.22f)); float dGold = _fmaxf(min(dGoldBase, dLines), -(length(swi2(coreP,x,y)) - 0.2f)); if (dGold < res.x) res = to_float2(dGold, 2.0f); // 3.0f Ruby Gem float3 rubyPos = p - to_float3(0.0f, 0.0f, 0.35f); float dRuby = _fmaxf(length(rubyPos) - 0.25f, -rubyPos.z); if (dRuby < res.x) res = to_float2(dRuby, 3.0f); res.x *= 0.8f; return res; } __DEVICE__ float3 gradStaryu(float3 p, float uTime) { float2 e = to_float2(0.001f, 0.0f); return normalize(to_float3( mapStaryu(p + swi3(e,x,y,y), uTime).x - mapStaryu(p - swi3(e,x,y,y), uTime).x, mapStaryu(p + swi3(e,y,x,y), uTime).x - mapStaryu(p - swi3(e,y,x,y), uTime).x, mapStaryu(p + swi3(e,y,y,x), uTime).x - mapStaryu(p - swi3(e,y,y,x), uTime).x )); } // staryu intersection __DEVICE__ bool boxIntersection(float offset, float3 ro, float3 rd, out float *tn, out float *tf) { ro -= to_float3(-0.1f, 0.1f, 1.05f); // Match updated Staryu Z translation float3 inv_rd = 1.0f / rd; float3 n = inv_rd*(ro); float3 k = abs_f3(inv_rd)*(to_float3(1.5f, 1.5f, 1.5f)+offset); float3 t1 = -n - k, t2 = -n + k; *tn = _fmaxf(max(t1.x, t1.y), t1.z); *tf = _fminf(min(t2.x, t2.y), t2.z); if (*tn > *tf) return false; return true; } __DEVICE__ bool intersectStaryu(float3 ro, float3 rd, inout float *t, float tf, float eps, out float *mat_id, float uTime) { float t0, t1; if (!boxIntersection(0.0f, ro, rd, &t0, &t1)) return false; t1 = _fminf(t1, tf); if (t1 < t0) return false; *t = _fmaxf(t0, 0.01f); for (int i=ZERO; i<100; i++) { float2 res = mapStaryu(ro+rd* *t, uTime); float v = res.x; if (v < eps) { *mat_id = res.y; return true; } *t += _fmaxf(v, eps); if (*t > t1) return false; } return false; } // Soft shadow __DEVICE__ float calcShadow(float3 ro, float3 rd, float uTime) { float t0, t1; if (!boxIntersection(0.2f, ro, rd, &t0, &t1)) return 1.0f; float sh = 1.0f; float t = _fmaxf(t0, 0.01f) + 0.02f*hash22(swi2(rd,x,y)).x; for (int i=ZERO; i<40; i++) { float h = 0.8f*mapStaryu(ro + rd*t, uTime).x; sh = _fminf(sh, smoothstep(0.0f, 1.0f, 20.0f*h/t)); t += clamp(h, 0.02f, 0.5f); if (h<0.0f) return 0.0f; if (t>t1) break; } return _fmaxf(sh, 0.0f); } __DEVICE__ bool intersectBeach(float3 ro, float3 rd, out float *t, float tf, float uTime, float3 Colors[4]) { *t = 0.01f; float v0 = 0.0f, v = 0.0f, dt = 0.0f; for (int i = (int)(ZERO); i < 50; i++) { if (*t>tf) return false; v = mapGround(ro+rd* *t, uTime, Colors).x; if (v*v0 < 0.0f) break; dt = i==(int)(ZERO)?v:dt*v/_fabs(v-v0); dt = sign_f(dt)*clamp(_fabs(dt), 0.02f, 1.0f); *t += dt; v0 = v; } *t -= dt * clamp(v/(v-v0), 0.0f, 1.0f); return true; } __DEVICE__ float3 getSkyCol(float3 rd, float3 sundir, float3 SkyColor[2]) { rd = normalize(to_float3_aw(swi2(rd,x,y),_fmaxf(rd.z,0.0f))); //float3 sky = _mix(to_float3(0.8f,0.9f,1.0f), to_float3(0.3f,0.6f,0.9f), rd.z); float3 sky = _mix(SkyColor[0], SkyColor[1], rd.z); float3 sun = 1.5f*to_float3(0.95f,0.9f,0.5f)*_powf(_fmaxf(dot(rd,sundir),0.0f), 8.0f); return sky + sun; } __KERNEL__ void StaryuFuse(__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]); int iFrame = params->iFrame; float4 fragColor = to_float4_s(0.0f); float2 fragCoord = to_float2(fusion_x,fusion_y); float4 BeachCol1 = to_float4(params->BeachCol1[0], params->BeachCol1[1], params->BeachCol1[2], params->BeachCol1[3]); float4 BeachCol2 = to_float4(params->BeachCol2[0], params->BeachCol2[1], params->BeachCol2[2], params->BeachCol2[3]); float4 SeaCol1 = to_float4(params->SeaCol1[0], params->SeaCol1[1], params->SeaCol1[2], params->SeaCol1[3]); float4 SeaCol2 = to_float4(params->SeaCol2[0], params->SeaCol2[1], params->SeaCol2[2], params->SeaCol2[3]); float4 SkyCol1 = to_float4(params->SkyCol1[0], params->SkyCol1[1], params->SkyCol1[2], params->SkyCol1[3]); float4 SkyCol2 = to_float4(params->SkyCol2[0], params->SkyCol2[1], params->SkyCol2[2], params->SkyCol2[3]); float4 BodyCol = to_float4(params->BodyCol[0], params->BodyCol[1], params->BodyCol[2], params->BodyCol[3]); float4 GoldCol = to_float4(params->GoldCol[0], params->GoldCol[1], params->GoldCol[2], params->GoldCol[3]); float4 RubyCol = to_float4(params->RubyCol[0], params->RubyCol[1], params->RubyCol[2], params->RubyCol[3]); float4 Mat3Col1 = to_float4(params->Mat3Col1[0], params->Mat3Col1[1], params->Mat3Col1[2], params->Mat3Col1[3]); float4 Mat3Col2 = to_float4(params->Mat3Col2[0], params->Mat3Col2[1], params->Mat3Col2[2], params->Mat3Col2[3]); float4 FinalCol = to_float4(params->FinalCol[0], params->FinalCol[1], params->FinalCol[2], params->FinalCol[3]); float2 ViewXY = to_float2(params->ViewXY[0], params->ViewXY[1]); float ViewZ = params->ViewZ; // -------- float3 Colors[4] = {swi3(BeachCol1,x,y,z), swi3(BeachCol2,x,y,z), swi3(SeaCol1,x,y,z), swi3(SeaCol2,x,y,z)}; float3 SkyColor[2] = {swi3(SkyCol1,x,y,z), swi3(SkyCol2,x,y,z)}; /* SKY */ float3 sundir = normalize(to_float3(0.3f,0.3f,1.0f)); //ZERO = _fminf(iFrame, 0); float uTime = iTime; // set camera float rx = iMouse.z!=0.0f ? 1.65f*(iMouse.y/iResolution.y)-0.05f : 0.12f; float rz = iMouse.z!=0.0f ? -iMouse.x/iResolution.x*4.0f*3.14f : 0.5f; float3 w = to_float3_aw(_cosf(rx)*to_float2(_cosf(rz),_sinf(rz)), _sinf(rx)); float3 u = to_float3(-_sinf(rz),_cosf(rz),0); float3 v = cross(w,u); float3 ro = to_float3(0,0,0.5f)+6.0f*w-0.5f*u+0.2f*v; float2 uv = 2.0f*fragCoord/iResolution - to_float2_s(1.0f); float3 rd = mul_mat3_f3(to_mat3_f3(u,v,-w) , to_float3_aw(uv*iResolution, 2.0f*length(iResolution))); rd = normalize(rd + to_float3_aw(ViewXY*iResolution, ViewZ*iResolution.x)); #ifdef XXX //############### 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); } //############################################################# #endif // ray intersection float t = 0.0f, t1=40.0f; int intersect_id = -1; float staryu_mat = 0.0f; if (intersectBeach(ro, rd, &t, t1, uTime, Colors)) intersect_id=0, t1=t; if (intersectStaryu(ro, rd, &t, t1, 0.005f, &staryu_mat, uTime)) intersect_id=1, t1=t; t = t1; // shading float3 p = ro+rd*t; float3 col; float shadow = calcShadow(p, sundir, uTime); if (intersect_id == -1) { col = to_float3_s(1.0f); } if (intersect_id == 0) { // beach/sea float3 n = normalize(gradGround(p, uTime, Colors)); float3 albedo = swi3(mapGround(p, uTime, Colors),y,z,w); float3 amb = 0.2f*albedo; float3 dif = 0.6f*(0.3f+0.7f*shadow) * _fmaxf(dot(n,sundir),0.0f) * albedo; float dummyMat; float3 spc = intersectStaryu(p,reflect(rd,n),&t1,4.0f,0.05f, &dummyMat, uTime) ? to_float3(0.05f,0.045f,0.04f) : to_float3_s(0.2f-0.1f*_tanhf(0.5f*p.y)) * getSkyCol(reflect(rd,n), sundir, SkyColor); col = amb+dif+spc; } if (intersect_id == 1) { // staryu float3 n = gradStaryu(p, uTime); float3 albedo = to_float3_s(0); float roughness = 1.0f; float metallic = 0.0f; if (staryu_mat == 1.0f) { // Star Body albedo = swi3(BodyCol,x,y,z);//to_float3(0.8f, 0.4f, 0.15f); roughness = 0.8f; } else if (staryu_mat == 2.0f) { // Gold Casing albedo = swi3(GoldCol,x,y,z);//to_float3(1.0f, 0.75f, 0.15f); roughness = 0.2f; metallic = 1.0f; } else if (staryu_mat == 3.0f) { // Ruby albedo = swi3(RubyCol,x,y,z);//to_float3(0.9f, 0.0f, 0.1f); roughness = 0.1f; metallic = 0.8f; } float3 viewDir = -rd; float3 halfVec = normalize(sundir + viewDir); float dif = _fmaxf(dot(n, sundir), 0.0f); float specAngle = _fmaxf(dot(n, halfVec), 0.0f); float specular = _powf(specAngle, _mix(1.0f, 128.0f, 1.0f - roughness)); float fresnel = _powf(1.0f - _fmaxf(dot(n, viewDir), 0.0f), 5.0f); float3 amb = (0.4f - 0.1f * dot(rd, n)) * albedo; float3 diffuseLight = dif * shadow * to_float3(1.0f, 0.9f, 0.8f) * albedo; float3 specLight = specular * to_float3(1.0f, 0.9f, 0.8f) * shadow * _mix(to_float3_s(1.0f), albedo, metallic); col = amb + diffuseLight; if(staryu_mat == 2.0f) { float3 env = getSkyCol(reflect(-viewDir, n), sundir, SkyColor); col += env * albedo * fresnel * 2.0f; col += specLight * 3.0f; } else if (staryu_mat == 3.0f) { col += swi3(Mat3Col1,x,y,z) * (1.0f - dif) * 0.5f;//to_float3(0.8f, 0.0f, 0.2f) * (1.0f - dif) * 0.5f; col += specLight * 5.0f; col += fresnel * swi3(Mat3Col2,x,y,z);//to_float3(1.0f, 0.5f, 0.5f); } else if (staryu_mat == 1.0f) { col += specLight * 0.2f; } } col = _mix(getSkyCol(rd, sundir, SkyColor), col, _expf(-0.04f*_fmaxf(t-5.0f,0.0f))); col += 0.5f*swi3(FinalCol,x,y,z)*_powf(_fmaxf(dot(rd,sundir),0.0f),1.5f);//*_powf(_fmaxf(dot(rd,sundir),0.0f),1.5f); col = pow_f3(0.95f*col, to_float3_s(1.25f)); fragColor = to_float4_aw(col,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("Colors", "Colors", false, {}) self:BeginControlNest("BeachCol1", "BeachCol1", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "BeachCol1", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBeachCol1ColorR = self:AddInput("Red", "BeachCol1Red", { INP_Default = 0.7, IC_ControlID = 0, attrs}) InBeachCol1ColorG = self:AddInput("Green", "BeachCol1Green", { INP_Default = 0.7, IC_ControlID = 1, attrs}) InBeachCol1ColorB = self:AddInput("Blue", "BeachCol1Blue", { INP_Default = 0.6, IC_ControlID = 2, attrs}) InBeachCol1ColorA = self:AddInput("Alpha", "BeachCol1Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("BeachCol2", "BeachCol2", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "BeachCol2", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBeachCol2ColorR = self:AddInput("Red", "BeachCol2Red", { INP_Default = 0.9, IC_ControlID = 0, attrs}) InBeachCol2ColorG = self:AddInput("Green", "BeachCol2Green", { INP_Default = 0.85, IC_ControlID = 1, attrs}) InBeachCol2ColorB = self:AddInput("Blue", "BeachCol2Blue", { INP_Default = 0.8, IC_ControlID = 2, attrs}) InBeachCol2ColorA = self:AddInput("Alpha", "BeachCol2Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("SeaCol1", "SeaCol1", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "SeaCol1", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InSeaCol1ColorR = self:AddInput("Red", "SeaCol1Red", { INP_Default = 0.65, IC_ControlID = 0, attrs}) InSeaCol1ColorG = self:AddInput("Green", "SeaCol1Green", { INP_Default = 0.85, IC_ControlID = 1, attrs}) InSeaCol1ColorB = self:AddInput("Blue", "SeaCol1Blue", { INP_Default = 0.8, IC_ControlID = 2, attrs}) InSeaCol1ColorA = self:AddInput("Alpha", "SeaCol1Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("SeaCol2", "SeaCol2", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "SeaCol2", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InSeaCol2ColorR = self:AddInput("Red", "SeaCol2Red", { INP_Default = 0.2, IC_ControlID = 0, attrs}) InSeaCol2ColorG = self:AddInput("Green", "SeaCol2Green", { INP_Default = 0.55, IC_ControlID = 1, attrs}) InSeaCol2ColorB = self:AddInput("Blue", "SeaCol2Blue", { INP_Default = 0.45, IC_ControlID = 2, attrs}) InSeaCol2ColorA = self:AddInput("Alpha", "SeaCol2Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("SkyCol1", "SkyCol1", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "SkyCol1", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InSkyCol1ColorR = self:AddInput("Red", "SkyCol1Red", { INP_Default = 0.8, IC_ControlID = 0, attrs}) InSkyCol1ColorG = self:AddInput("Green", "SkyCol1Green", { INP_Default = 0.9, IC_ControlID = 1, attrs}) InSkyCol1ColorB = self:AddInput("Blue", "SkyCol1Blue", { INP_Default = 1.0, IC_ControlID = 2, attrs}) InSkyCol1ColorA = self:AddInput("Alpha", "SkyCol1Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("SkyCol2", "SkyCol2", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "SkyCol2", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InSkyCol2ColorR = self:AddInput("Red", "SkyCol2Red", { INP_Default = 0.3, IC_ControlID = 0, attrs}) InSkyCol2ColorG = self:AddInput("Green", "SkyCol2Green", { INP_Default = 0.6, IC_ControlID = 1, attrs}) InSkyCol2ColorB = self:AddInput("Blue", "SkyCol2Blue", { INP_Default = 0.9, IC_ControlID = 2, attrs}) InSkyCol2ColorA = self:AddInput("Alpha", "SkyCol2Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("BodyCol", "BodyCol", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "BodyCol", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InBodyColColorR = self:AddInput("Red", "BodyColRed", { INP_Default = 0.8, IC_ControlID = 0, attrs}) InBodyColColorG = self:AddInput("Green", "BodyColGreen", { INP_Default = 0.4, IC_ControlID = 1, attrs}) InBodyColColorB = self:AddInput("Blue", "BodyColBlue", { INP_Default = 0.15, IC_ControlID = 2, attrs}) InBodyColColorA = self:AddInput("Alpha", "BodyColAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("GoldCol", "GoldCol", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "GoldCol", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InGoldColColorR = self:AddInput("Red", "GoldColRed", { INP_Default = 1.0, IC_ControlID = 0, attrs}) InGoldColColorG = self:AddInput("Green", "GoldColGreen", { INP_Default = 0.75, IC_ControlID = 1, attrs}) InGoldColColorB = self:AddInput("Blue", "GoldColBlue", { INP_Default = 0.15, IC_ControlID = 2, attrs}) InGoldColColorA = self:AddInput("Alpha", "GoldColAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("RubyCol", "RubyCol", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "RubyCol", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InRubyColColorR = self:AddInput("Red", "RubyColRed", { INP_Default = 0.9, IC_ControlID = 0, attrs}) InRubyColColorG = self:AddInput("Green", "RubyColGreen", { INP_Default = 0.0, IC_ControlID = 1, attrs}) InRubyColColorB = self:AddInput("Blue", "RubyColBlue", { INP_Default = 0.1, IC_ControlID = 2, attrs}) InRubyColColorA = self:AddInput("Alpha", "RubyColAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Mat3Col1", "Mat3Col1", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Mat3Col1", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InMat3Col1ColorR = self:AddInput("Red", "Mat3Col1Red", { INP_Default = 0.8, IC_ControlID = 0, attrs}) InMat3Col1ColorG = self:AddInput("Green", "Mat3Col1Green", { INP_Default = 0.0, IC_ControlID = 1, attrs}) InMat3Col1ColorB = self:AddInput("Blue", "Mat3Col1Blue", { INP_Default = 0.2, IC_ControlID = 2, attrs}) InMat3Col1ColorA = self:AddInput("Alpha", "Mat3Col1Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("Mat3Col2", "Mat3Col2", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "Mat3Col2", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InMat3Col2ColorR = self:AddInput("Red", "Mat3Col2Red", { INP_Default = 1.0, IC_ControlID = 0, attrs}) InMat3Col2ColorG = self:AddInput("Green", "Mat3Col2Green", { INP_Default = 0.5, IC_ControlID = 1, attrs}) InMat3Col2ColorB = self:AddInput("Blue", "Mat3Col2Blue", { INP_Default = 0.5, IC_ControlID = 2, attrs}) InMat3Col2ColorA = self:AddInput("Alpha", "Mat3Col2Alpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() self:BeginControlNest("FinalCol", "FinalCol", true, {}) ctrl_grp_cnt = (ctrl_grp_cnt==nil) and 1 or (ctrl_grp_cnt+1) attrs = { ICS_Name = "FinalCol", LINKID_DataType = "Number", INPID_InputControl = "ColorControl", INP_MinScale = 0.0, INP_MaxScale = 1.0, IC_ControlGroup = ctrl_grp_cnt, } InFinalColColorR = self:AddInput("Red", "FinalColRed", { INP_Default = 0.8, IC_ControlID = 0, attrs}) InFinalColColorG = self:AddInput("Green", "FinalColGreen", { INP_Default = 0.5, IC_ControlID = 1, attrs}) InFinalColColorB = self:AddInput("Blue", "FinalColBlue", { INP_Default = 0.6, IC_ControlID = 2, attrs}) InFinalColColorA = self:AddInput("Alpha", "FinalColAlpha", { INP_Default = 1.0, IC_ControlID = 3, attrs}) self:EndControlNest() 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, }) 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 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, "StaryuFuse", 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.iFrame = req.Time params.BeachCol1 = { InBeachCol1ColorR:GetValue(req).Value, InBeachCol1ColorG:GetValue(req).Value, InBeachCol1ColorB:GetValue(req).Value,InBeachCol1ColorA:GetValue(req).Value } params.BeachCol2 = { InBeachCol2ColorR:GetValue(req).Value, InBeachCol2ColorG:GetValue(req).Value, InBeachCol2ColorB:GetValue(req).Value,InBeachCol2ColorA:GetValue(req).Value } params.SeaCol1 = { InSeaCol1ColorR:GetValue(req).Value, InSeaCol1ColorG:GetValue(req).Value, InSeaCol1ColorB:GetValue(req).Value,InSeaCol1ColorA:GetValue(req).Value } params.SeaCol2 = { InSeaCol2ColorR:GetValue(req).Value, InSeaCol2ColorG:GetValue(req).Value, InSeaCol2ColorB:GetValue(req).Value,InSeaCol2ColorA:GetValue(req).Value } params.SkyCol1 = { InSkyCol1ColorR:GetValue(req).Value, InSkyCol1ColorG:GetValue(req).Value, InSkyCol1ColorB:GetValue(req).Value,InSkyCol1ColorA:GetValue(req).Value } params.SkyCol2 = { InSkyCol2ColorR:GetValue(req).Value, InSkyCol2ColorG:GetValue(req).Value, InSkyCol2ColorB:GetValue(req).Value,InSkyCol2ColorA:GetValue(req).Value } params.BodyCol = { InBodyColColorR:GetValue(req).Value, InBodyColColorG:GetValue(req).Value, InBodyColColorB:GetValue(req).Value,InBodyColColorA:GetValue(req).Value } params.GoldCol = { InGoldColColorR:GetValue(req).Value, InGoldColColorG:GetValue(req).Value, InGoldColColorB:GetValue(req).Value,InGoldColColorA:GetValue(req).Value } params.RubyCol = { InRubyColColorR:GetValue(req).Value, InRubyColColorG:GetValue(req).Value, InRubyColColorB:GetValue(req).Value,InRubyColColorA:GetValue(req).Value } params.Mat3Col1 = { InMat3Col1ColorR:GetValue(req).Value, InMat3Col1ColorG:GetValue(req).Value, InMat3Col1ColorB:GetValue(req).Value,InMat3Col1ColorA:GetValue(req).Value } params.Mat3Col2 = { InMat3Col2ColorR:GetValue(req).Value, InMat3Col2ColorG:GetValue(req).Value, InMat3Col2ColorB:GetValue(req).Value,InMat3Col2ColorA:GetValue(req).Value } params.FinalCol = { InFinalColColorR:GetValue(req).Value, InFinalColColorG:GetValue(req).Value, InFinalColColorB:GetValue(req).Value,InFinalColColorA:GetValue(req).Value } params.ViewXY = {InViewXYPoint:GetValue(req).X,InViewXYPoint:GetValue(req).Y} params.ViewZ = InViewZSlider: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: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 -- */