bplist00*u_inputParameters^virtualPatches_frameworkVersion^portAttributesYrootPatch_editorViewerWindow [QuaternionX[QuaternionZUeye_Y_FeedBack_Amount[QuaternionW[QuaternionYUeye_X#?ѭѭ##AA #?p'p'#?Ӂ88#AA #@ V156.10  #W_enable[descriptionTname_The input port.UInput$%&'Tname[descriptionVEnable_ Controls execution of the patch.+,-.UclassUstateWQCPatch/01234[connectionsXtimebase_publishedInputPortsXuserInfoUnodes56789:;<=>?@ABCDEFOSW\_aehjmpsvy{~]connection_14\connection_7]connection_10\connection_8]connection_15\connection_1\connection_9]connection_11\connection_2]connection_16]connection_48\connection_3]connection_12\connection_4\connection_5]connection_13\connection_6GHIJKLMNZsourceNode_destinationPortZsourcePort_destinationNodeZSplitter_5Tmu_YVoutputXOpenCL_1GHIJNPQRZinputImageXdstImage]ImageResize_1GHIJTUMVZSplitter_1SMixWPatch_1GHIJXYZ[WPatch_3ZinputScaleZUnit_Width[Billboard_1GHIJ]^MNZSplitter_6Tmu_ZGHIJVP`[__protocolOutput_ImageGHIJbcdVWBloom_1__protocolInput_Image[outputImageGHIJfgMNZSplitter_2Ueye_XGHIJRPib[outputImageGHIJklMNZSplitter_7Tmu_WGHIJnoMX[Splitter_23]SupersamplingGHIJXqrRZinputWidth[Pixels_WideGHIJtuMNZSplitter_3Ueye_YGHIJXwxR[inputHeight[Pixels_HighGHIJXzrV[Pixels_WideGHIJ|}MNZSplitter_4Tmu_XGHIJXxV[Pixels_HighVparent,T TnodeSkeyTport2Oz streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+nameFeedBack AmountUinput,f2Or streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+nameeye (X),t 2Or streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+nameeye (Y),|2Ox streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(X),K 2Ox streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Y),] 2Ox streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Z),k 2Ox streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(W)O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+positionNSValue* {CGPoint=dd} scrolling5pf@ zoomFactorNSNumberf#q{&3:AN[h+,WQCClear2_ivarInputPortStates_clearColorBuffer_systemInputPortStates_clearDepthBufferZinputColorUvalueSredUalphaTblueUgreen####  O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+positionNSValue* {CGPoint=dd}ц WClear_1+,NXQCOpenCL2Wversion_customPixelFormat^useLocalKernel]useBestDevice_settingsVisible^selectedKernel\sampleString_automaticOutputDimensions_automaticThreadDimensionsZsourceCode_customInputPortStates[deviceIndex\Unknown msec_// //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef WIDTH #define WIDTH (256) #endif #ifndef HEIGHT #define HEIGHT (256) #endif #define ASPECT ((float)WIDTH / (float)HEIGHT) #define SQR(x) ((x)*(x)) #define BOUNDING_RADIUS (2.0f) #define BOUNDING_RADIUS_SQR (SQR(BOUNDING_RADIUS)) #define ESCAPE_THRESHOLD (BOUNDING_RADIUS * 1.5f) #define DELTA (1e-5f) #define ITERATIONS (5) #define EPSILON (0.003f) #define SHADOWS (0) #define __float3 float4 #define make_float3 (float4) __float3 cross3(__float3 b, __float3 c) { return make_float3(mad(b.y, c.z, -b.z * c.y), mad(b.z, c.x, -b.x * c.z), mad(b.x, c.y, -b.y * c.x), 0); } __float3 normalize3(__float3 v) { return v * half_rsqrt(dot(v, v)); } //////////////////////////////////////////////////////////////////////////////////////////////////// float4 qmult( float4 q1, float4 q2 ) { float4 r; __float3 t; __float3 q1yzw = make_float3(q1.y, q1.z, q1.w, 0); __float3 q2yzw = make_float3(q2.y, q2.z, q2.w, 0); __float3 c = cross3( q1yzw, q2yzw ); t = q2yzw * q1.x + q1yzw * q2.x + c; r.x = q1.x * q2.x - dot( q1yzw, q2yzw ); r.yzw = t.xyz; return r; } float4 qsqr( float4 q ) { float4 r; __float3 t; __float3 qyzw = make_float3(q.y, q.z, q.w, 0); t = 2.0f * q.x * qyzw; r.x = q.x * q.x - dot( qyzw, qyzw ); r.yzw = t.xyz; return r; } //////////////////////////////////////////////////////////////////////////////////////////////////// __float3 EstimateNormalQJulia( __float3 p, float4 c, int iterations ) { float4 qp = (float4)( p.x, p.y, p.z, 0.0f ); float4 gx1 = qp - (float4)( DELTA, 0.0f, 0.0f, 0.0f ); float4 gx2 = qp + (float4)( DELTA, 0.0f, 0.0f, 0.0f ); float4 gy1 = qp - (float4)( 0.0f, DELTA, 0.0f, 0.0f ); float4 gy2 = qp + (float4)( 0.0f, DELTA, 0.0f, 0.0f ); float4 gz1 = qp - (float4)( 0.0f, 0.0f, DELTA, 0.0f ); float4 gz2 = qp + (float4)( 0.0f, 0.0f, DELTA, 0.0f ); for ( int i = 0; i < iterations; i++ ) { gx1 = qsqr( gx1 ) + c; gx2 = qsqr( gx2 ) + c; gy1 = qsqr( gy1 ) + c; gy2 = qsqr( gy2 ) + c; gz1 = qsqr( gz1 ) + c; gz2 = qsqr( gz2 ) + c; } float nx = fast_length(gx2) - fast_length(gx1); float ny = fast_length(gy2) - fast_length(gy1); float nz = fast_length(gz2) - fast_length(gz1); __float3 normal = normalize3(make_float3( nx, ny, nz, 0 )); return normal; } //////////////////////////////////////////////////////////////////////////////////////////////////// float4 IntersectQJulia( __float3 rO, __float3 rD, float4 c, float epsilon, float escape) { float rd = 0.0f; float dist = epsilon; while ( dist >= epsilon && rd < escape) { float4 z = (float4)( rO.x, rO.y, rO.z, 0.0f ); float4 zp = (float4)( 1.0f, 0.0f, 0.0f, 0.0f ); float zd = 0.0f; uint count = 0; while(zd < escape && count < ITERATIONS) { zp = 2.0f * qmult(z, zp); z = qsqr(z) + c; zd = dot(z, z); count++; } float normZ = fast_length( z ); dist = 0.5f * normZ * half_log( normZ ) / fast_length( zp ); rO += rD * dist; rd = dot(rO, rO); } return (float4)(rO.x, rO.y, rO.z, dist); } //////////////////////////////////////////////////////////////////////////////////////////////////// __float3 Phong( __float3 light, __float3 eye, __float3 pt, __float3 normal, __float3 base) { const float SpecularExponent = 10.0f; const float Specularity = 0.45f; __float3 light_dir = normalize3( light - pt ); __float3 eye_dir = normalize3( eye - pt ); float NdotL = dot( normal, light_dir ); __float3 reflect_dir = light_dir - 2.0f * NdotL * normal; base += fabs(normal) * 0.5f; __float3 diffuse = base * fmax(NdotL, 0.0f); __float3 specular = Specularity * half_powr( fmax( dot(eye_dir, reflect_dir), 0.0f), SpecularExponent ); return diffuse + specular; } //////////////////////////////////////////////////////////////////////////////////////////////////// float IntersectSphere( __float3 rO, __float3 rD, float radius ) { float fB = 2.0f * dot( rO, rD ); float fB2 = fB * fB; float fC = dot( rO, rO ) - radius; float fT = (fB2 - 4.0f * fC); if (fT <= 0.0f) return 0.0f; float fD = half_sqrt( fT ); float fT0 = ( -fB + fD ) * 0.5f; float fT1 = ( -fB - fD ) * 0.5f; fT = fmin(fT0, fT1); return fT; } //////////////////////////////////////////////////////////////////////////////////////////////////// float4 RaytraceQJulia( __float3 rO, __float3 rD, float4 mu, float epsilon, __float3 eye, __float3 light, __float3 diffuse, float radius, bool shadows, int iterations ) { const float4 background = (float4)( 0.f, 0.f, 0.f, 0.0f ); float4 color = background; rD = normalize3( rD ); float t = IntersectSphere( rO, rD, radius ); if ( t <= 0.0f ) return color; rO += rD * t; float4 hit = IntersectQJulia( rO, rD, mu, epsilon, ESCAPE_THRESHOLD ); float dist = hit.w; if (dist >= epsilon) return color; rO.xyz = hit.xyz; __float3 normal = EstimateNormalQJulia( rO, mu, iterations ); __float3 rgb = Phong( light, rD, rO, normal, diffuse ); color.xyz = rgb.xyz; color.w = 1.0f; if (SHADOWS) { __float3 light_dir = normalize3( light - rO ); rO += normal * epsilon * 2.0f; hit = IntersectQJulia( rO, light_dir, mu, epsilon, ESCAPE_THRESHOLD ); dist = hit.w; color.xyz *= (dist < epsilon) ? (0.4f) : (1.0f); } return color; } /////////////////////////////////////////////////////////////////////////////////////////// float4 QJulia( float4 coord, float4 mu, float3 eye, float4 diffuse, float epsilon, float iterations, int shadows, uint width, uint height) { float zoom = BOUNDING_RADIUS_SQR; float radius = BOUNDING_RADIUS_SQR; float2 size = (float2)((float)width, (float)height); float scale = max(size.x, size.y); float2 half = (float2)(0.5f, 0.5f); float2 position = (coord.xy - half * size) / scale; float2 frame = (position) * zoom; __float3 light = make_float3(0.f, 0.f, 8.0f, 0.0f); //__float3 eye = make_float3(0.0f, 0.0f, 4.0f, 0.0f); __float3 ray = make_float3(frame.x, frame.y, 0.0f, 0.0f); __float3 base = make_float3(diffuse.x, diffuse.y, diffuse.z, 0.0f); __float3 rO = eye; __float3 rD = (ray - rO); float4 color = RaytraceQJulia( rO, rD, mu, epsilon, eye, light, base, radius, shadows, iterations); return color; } //////////////////////////////////////////////////////////////////////////////////////////////////// __kernel void QJuliaKernel( __wr image2d_t dstImage, const float4 mu, const float3 eye, const float4 diffuse, const float epsilon) { int tx = get_global_id(0); int ty = get_global_id(1); int index = ty * WIDTH + tx; int2 coords = (int2)(tx, ty); bool valid = (tx < WIDTH) && (ty < HEIGHT); float4 coord = (float4)((float)tx, (float)ty, 0.0f, 0.0f); if(valid) { float4 color = QJulia(coord, mu,eye ,diffuse, epsilon,ITERATIONS, SHADOWS, WIDTH, HEIGHT); write_imagef(dstImage, coords, color); } } //////////////////////////////////////////////////////////////////////////////////////////////////// Ydiffuse_X_dstImage-Argument-Dim_XWepsilon\Global-Dim_XUeye_Z[Local-Dim_X[Local-Dim_YYdiffuse_Y[Local-Dim_Z\Global-Dim_Y_dstImage-Argument-Dim_Y\Global-Dim_ZYdiffuse_ZYdiffuse_W##?htj~#@#?С#?#?O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name"QJuliaKernel"positionNSValue* {CGPoint=dd}%+,[[QCBillboard2[CIRendering_optimizedRenderingXsizeMode\pixelAligned   VinputYZinputColor]inputRotation]inputBlendingVinputX_inputPixelAligned# #?#?#?#? ##ZautoHeight O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+positionNSValue* {CGPoint=dd}+,R]QCImageResize2O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+positionNSValue* {CGPoint=dd} !"^inputConditionYinputMode+,$%XWQCPatch/1&23'9>JK_publishedOutputPorts()*+,058\connection_4\connection_1\connection_2\connection_3GHIJ-.M/]Multiplexer_1ZinputValueVMath_2GHIJ1234\ScreenInfo_1Yoperand_1_outputPixelsWideVMath_1GHIJ167/Yoperand_1_outputPixelsHighGHIJ-.M4:,;-o=2?@\QCNumberPort#@ # O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+nameeye (Y)positionNSValue* {CGPoint=dd}D+,BC|ZQCSplittergt2DGJKLMME2FOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(X)H2IOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(X)#\QCNumberPort#?O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(X)positionNSValue* {CGPoint=dd}C4+,OPKZQCSplittergt2QTWXYZMR2SOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Y)U2VOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Y)#\QCNumberPort#?O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Y)positionNSValue* {CGPoint=dd}AX+,\]]ZQCSplittergt2^adefgM_2`Ox streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Z)b2cOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Z)#\QCNumberPort#?O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(Z)positionNSValue* {CGPoint=dd}C|+,ijkZQCSplittergt2knqrstMl2mOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(W)o2pOx streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(W)#\QCNumberPort#?O streamtyped@NSMutableDictionary NSDictionaryNSObjectiNSString+name Quaternion(W)positionNSValue* {CGPoint=dd}E_-9 431 800 446 0 0 1440 878 !3BUdn $-.5V^gsx '<HQgpv)6DR_mz )2@Q\`hy):EK\hy'8DU`ev9?PUUfk w    r   ! & , = A G L R [ d m v w |    * 3 h p *68:G--L-V-p-x----------.......%.*.-.2.;.@.E.J.S.X.].`.e.h.m.r.{../7/ >!>->>>J>X>i>t>>>>>>>>>>?? ???@3@D@M@@@@@@A A AA#ABBBBBC CCC$CCCD DDDDEEEEEFFFFFFGGG)G;GNG`GtGGGGGGGGGGGGGGHaHnH|HHHHJJJJJJJJKcKhKmKKKKLLLLLLM[M`MiMMMNN NNNNNNOO O OOO"O+O2OEOJOjOoOP{PPPPPQ7Q