diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg new file mode 100644 index 0000000..f351bc4 --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg @@ -0,0 +1,354 @@ +{ + "$schema": "gigischema.json", + "name": "Explosion", + "version": "0.99b", + "variables": [ + { + "name": "AnimateRadius", + "type": "Bool", + "dflt": "true" + }, + { + "name": "Rotate", + "type": "Bool", + "dflt": "false" + }, + { + "name": "RotationSpeed", + "type": "Float", + "dflt": "0.25" + }, + { + "name": "iTime", + "type": "Float", + "dflt": "0.0", + "visibility": "Host" + }, + { + "name": "iResolution", + "type": "Float3" + }, + { + "name": "SphereRadius", + "type": "Float", + "dflt": "1.5" + }, + { + "name": "Color1", + "type": "Float3", + "dflt": "1.7, 1.3, 1.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color2", + "type": "Float3", + "dflt": "1.0, 0.6, 0.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color3", + "type": "Float3", + "dflt": "1.0, 0.0, 0.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color4", + "type": "Float3", + "dflt": "0.2, 0.2, 0.2", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color5", + "type": "Float3", + "dflt": "0.4, 0.4, 0.4", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "ColorThresholds", + "type": "Float3", + "dflt": "0.25, 0.5, 0.75" + }, + { + "name": "NoiseFreq1", + "type": "Float", + "dflt": "2.0" + }, + { + "name": "NoiseFreq2", + "type": "Float", + "dflt": "4.0" + }, + { + "name": "NoiseFreq3", + "type": "Float", + "dflt": "8.0" + }, + { + "name": "NoiseFreq4", + "type": "Float", + "dflt": "16.0" + }, + { + "name": "NoiseWeights", + "type": "Float4", + "dflt": "0.5, 0.25, 0.125, 0.0625" + }, + { + "name": "NoiseAmplitude", + "type": "Float", + "dflt": "1.0", + "UISettings": { + "UIHint": "Slider", + "min": "0.0", + "max": "5.0" + } + }, + { + "name": "NoiseBias", + "type": "Float", + "dflt": "-0.05", + "UISettings": { + "UIHint": "Slider", + "min": "-1.0", + "max": "1.0" + } + } + ], + "shaders": [ + { + "name": "Explosion", + "fileName": "ExplosionCS.hlsl", + "entryPoint": "csmain", + "resources": [ + { + "name": "input", + "type": "Texture", + "access": "SRV", + "buffer": { + "PODAsStructuredBuffer": false + } + }, + { + "name": "output", + "type": "Texture", + "access": "UAV", + "buffer": { + "PODAsStructuredBuffer": false + } + }, + { + "name": "perlin1", + "type": "Texture", + "access": "UAV", + "buffer": { + "PODAsStructuredBuffer": false + } + }, + { + "name": "perlin2", + "type": "Texture", + "access": "UAV", + "buffer": { + "PODAsStructuredBuffer": false + } + }, + { + "name": "perlin3", + "type": "Texture", + "access": "UAV", + "buffer": { + "PODAsStructuredBuffer": false + } + }, + { + "name": "perlin4", + "type": "Texture", + "access": "UAV", + "buffer": { + "PODAsStructuredBuffer": false + } + } + ] + } + ], + "nodes": [ + { + "resourceTexture": { + "name": "Input", + "editorPos": [ + -17.0, + -5.0 + ], + "visibility": "Imported" + } + }, + { + "resourceTexture": { + "name": "Output", + "editorPos": [ + -21.0, + 50.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "actionComputeShader": { + "name": "Explosion", + "editorPos": [ + 149.0, + -1.0 + ], + "linkProperties": [ + {}, + {}, + {}, + {}, + {}, + {}, + {} + ], + "connections": [ + { + "srcPin": "output", + "dstNode": "Output", + "dstPin": "resource" + }, + { + "srcPin": "input", + "dstNode": "Input", + "dstPin": "resource" + }, + { + "srcPin": "perlin1", + "dstNode": "Perlin1", + "dstPin": "resource" + }, + { + "srcPin": "perlin2", + "dstNode": "Perlin2", + "dstPin": "resource" + }, + { + "srcPin": "perlin3", + "dstNode": "Perlin3", + "dstPin": "resource" + }, + { + "srcPin": "perlin4", + "dstNode": "Perlin4", + "dstPin": "resource" + } + ], + "shader": { + "name": "Explosion" + }, + "dispatchSize": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin1", + "editorPos": [ + -21.0, + 178.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin2", + "editorPos": [ + -21.0, + 226.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin3", + "editorPos": [ + -21.0, + 274.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin4", + "editorPos": [ + -21.0, + 322.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + } + ] +} \ No newline at end of file diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg.bak b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg.bak new file mode 100644 index 0000000..ebf967f --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gg.bak @@ -0,0 +1,382 @@ +{ + "$schema": "gigischema.json", + "name": "Explosion", + "version": "0.97b", + "variables": [ + { + "name": "AnimateRadius", + "type": "Bool", + "dflt": "true" + }, + { + "name": "Rotate", + "type": "Bool", + "dflt": "false" + }, + { + "name": "RotationSpeed", + "type": "Float", + "dflt": "0.25" + }, + { + "name": "iTime", + "type": "Float", + "dflt": "0.0", + "visibility": "Host" + }, + { + "name": "iResolution", + "type": "Float3" + }, + { + "name": "SphereRadius", + "type": "Float", + "dflt": "1.5" + }, + { + "name": "Color1", + "type": "Float3", + "dflt": "1.7, 1.3, 1.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color2", + "type": "Float3", + "dflt": "1.0, 0.6, 0.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color3", + "type": "Float3", + "dflt": "1.0, 0.0, 0.0", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color4", + "type": "Float3", + "dflt": "0.2, 0.2, 0.2", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "Color5", + "type": "Float3", + "dflt": "0.4, 0.4, 0.4", + "UISettings": { + "UIHint": "Color" + } + }, + { + "name": "ColorThresholds", + "type": "Float3", + "dflt": "0.25, 0.5, 0.75" + }, + { + "name": "NoiseFreq1", + "type": "Float", + "dflt": "2.0" + }, + { + "name": "NoiseFreq2", + "type": "Float", + "dflt": "4.0" + }, + { + "name": "NoiseFreq3", + "type": "Float", + "dflt": "8.0" + }, + { + "name": "NoiseFreq4", + "type": "Float", + "dflt": "16.0" + }, + { + "name": "NoiseWeights", + "type": "Float4", + "dflt": "0.5, 0.25, 0.125, 0.0625" + }, + { + "name": "NoiseAmplitude", + "type": "Float", + "dflt": "1.0", + "UISettings": { + "UIHint": "Slider", + "min": "0.0", + "max": "5.0" + } + }, + { + "name": "NoiseBias", + "type": "Float", + "dflt": "-0.05", + "UISettings": { + "UIHint": "Slider", + "min": "-1.0", + "max": "1.0" + } + } + ], + "shaders": [ + { + "name": "Explosion", + "fileName": "ExplosionCS.hlsl", + "entryPoint": "csmain", + "resources": [ + { + "name": "input", + "type": "Texture", + "access": "SRV" + }, + { + "name": "output", + "type": "Texture", + "access": "UAV" + }, + { + "name": "perlin1", + "type": "Texture", + "access": "UAV" + }, + { + "name": "perlin2", + "type": "Texture", + "access": "UAV" + }, + { + "name": "perlin3", + "type": "Texture", + "access": "UAV" + }, + { + "name": "perlin4", + "type": "Texture", + "access": "UAV" + } + ] + } + ], + "nodes": [ + { + "resourceTexture": { + "name": "Input", + "editorPos": [ + -17.0, + -5.0 + ], + "visibility": "Imported" + } + }, + { + "resourceTexture": { + "name": "Output", + "editorPos": [ + -21.0, + 50.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "actionComputeShader": { + "name": "Explosion", + "editorPos": [ + 149.0, + -1.0 + ], + "linkProperties": [ + {}, + {}, + {}, + {}, + {}, + {}, + {} + ], + "shader": { + "name": "Explosion" + }, + "dispatchSize": { + "node": { + "name": "Input" + } + }, + "connections": [ + { + "srcPin": "output", + "dstNode": "Output", + "dstPin": "resource" + }, + { + "srcPin": "input", + "dstNode": "Input", + "dstPin": "resource" + }, + { + "srcPin": "perlin1", + "dstNode": "Perlin1", + "dstPin": "resource" + }, + { + "srcPin": "perlin2", + "dstNode": "Perlin2", + "dstPin": "resource" + }, + { + "srcPin": "perlin3", + "dstNode": "Perlin3", + "dstPin": "resource" + }, + { + "srcPin": "perlin4", + "dstNode": "Perlin4", + "dstPin": "resource" + } + ] + } + }, + { + "resourceTexture": { + "name": "Perlin1", + "editorPos": [ + -21.0, + 178.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin2", + "editorPos": [ + -21.0, + 226.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin3", + "editorPos": [ + -21.0, + 274.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "resourceTexture": { + "name": "Perlin4", + "editorPos": [ + -21.0, + 322.0 + ], + "visibility": "Exported", + "format": { + "node": { + "name": "Input" + } + }, + "size": { + "node": { + "name": "Input" + } + } + } + }, + { + "actionSubGraph": { + "name": "Blur", + "editorPos": [ + 327.0, + 18.0 + ], + "linkProperties": [ + {}, + {} + ], + "fileName": "..\\BoxBlur\\BoxBlur.gg", + "connections": [ + { + "srcPin": "Input", + "dstNode": "Explosion", + "dstPin": "output" + }, + { + "srcPin": "Output" + } + ], + "subGraphData": { + "importedResources": [ + "Input" + ], + "exportedResources": [ + "Output" + ], + "variables": [ + { + "name": "BlurRadius", + "type": "Int", + "dflt": "1", + "visibility": "User" + } + ] + }, + "variableSettings": [ + { + "name": "BlurRadius", + "visibility": "User" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gguser b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gguser new file mode 100644 index 0000000..2ca17d6 --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/Explosion.gguser @@ -0,0 +1,89 @@ +{ + "systemVars": { + "iResolution_textureName": "Input" + }, + "resourceViewNodeIndex": 2, + "resourceViewResourceIndex": 7, + "importedResources": [ + { + "nodeName": "Input", + "texture": { + "size": [ + 1280, + 960, + 1 + ] + } + } + ], + "savedVariables": [ + { + "name": "AnimateRadius", + "value": "true" + }, + { + "name": "Rotate", + "value": "false" + }, + { + "name": "RotationSpeed", + "value": "0.250000" + }, + { + "name": "SphereRadius", + "value": "1.500000" + }, + { + "name": "Color1", + "value": "1.700000,1.300000,1.000000" + }, + { + "name": "Color2", + "value": "1.000000,0.600000,0.000000" + }, + { + "name": "Color3", + "value": "1.000000,0.000000,0.000000" + }, + { + "name": "Color4", + "value": "0.200000,0.200000,0.200000" + }, + { + "name": "Color5", + "value": "0.400000,0.400000,0.400000" + }, + { + "name": "ColorThresholds", + "value": "0.250000,0.500000,0.750000" + }, + { + "name": "NoiseFreq1", + "value": "2.000000" + }, + { + "name": "NoiseFreq2", + "value": "4.000000" + }, + { + "name": "NoiseFreq3", + "value": "8.000000" + }, + { + "name": "NoiseFreq4", + "value": "16.000000" + }, + { + "name": "NoiseWeights", + "value": "0.500000,0.250000,0.125000,0.062500" + }, + { + "name": "NoiseAmplitude", + "value": "1.000000" + }, + { + "name": "NoiseBias", + "value": "-0.050000" + } + ] +} \ No newline at end of file diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/ExplosionCS.hlsl b/Techniques/GigiJamJune2024/tcalderbank_explosion/ExplosionCS.hlsl new file mode 100644 index 0000000..b0e3900 --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/ExplosionCS.hlsl @@ -0,0 +1,259 @@ +// Explosion technique, shader DoBlur +/*$(ShaderResources)*/ + +// Credit +// Based on these 2 tutorials +// https://github.com/ssloy/tinykaboom/wiki/KABOOM!-in-180-lines-of-code +// https://www.youtube.com/watch?v=welK2U7UkzE + +// constants +static const float c_time = /*$(Variable:iTime)*/; +static const float3 c_resolution = /*$(Variable:iResolution)*/; +static const float c_pi = 3.14159; +static const float c_fov = c_pi / 3.0f; // 60 degrees +static const float3 c_cameraOrigin = float3(0.0f, 0.0f, 3.0f); + +static const int c_rayMarchIterations = 128; +static const float c_rayMarchStepPercent = 0.1f; +static const float c_rayMarchMinStepSize = 0.01f; +static const float4 c_backgroundColor = float4(0.0f, 0.0f, 0.0f, 1.0f); +static const float4 c_hitColor = float4(1.0f, 1.0f, 1.0f, 1.0f); +static const float3 c_lightPosition = float3(10.0f, 10.0f, 10.0f); + +static const float c_sphereRadius = /*$(Variable:SphereRadius)*/; + +static const float c_freq1 = /*$(Variable:NoiseFreq1)*/; +static const float c_freq2 = /*$(Variable:NoiseFreq2)*/; +static const float c_freq3 = /*$(Variable:NoiseFreq3)*/; +static const float c_freq4 = /*$(Variable:NoiseFreq4)*/; + +static const float4 c_noiseWeights = /*$(Variable:NoiseWeights)*/; +static const float c_noiseAmp = /*$(Variable:NoiseAmplitude)*/; +static const float c_noiseBias = /*$(Variable:NoiseBias)*/; + +static const float3 c_color1 = /*$(Variable:Color1)*/; +static const float3 c_color2 = /*$(Variable:Color2)*/; +static const float3 c_color3 = /*$(Variable:Color3)*/; +static const float3 c_color4 = /*$(Variable:Color4)*/; +static const float3 c_color5 = /*$(Variable:Color5)*/; + +static const float3 c_colorThreshholds = /*$(Variable:ColorThresholds)*/; + +static const bool c_animateRadius = /*$(Variable:AnimateRadius)*/; +static const bool c_rotate = /*$(Variable:Rotate)*/; +static const float c_rotationSpeed = /*$(Variable:RotationSpeed)*/; + +// Perlin Noise +// Source: https://github.com/gegamongy/3DPerlinNoiseGodot/blob/main/3DPerlinNoise.gdshader +float3 random3D(float3 uvw){ + + uvw = float3( dot(uvw, float3(127.1,311.7, 513.7) ), + dot(uvw, float3(269.5,183.3, 396.5) ), + dot(uvw, float3(421.3,314.1, 119.7) ) ); + + return -1.0 + 2.0 * frac(sin(uvw) * 43758.5453123); +} + +float noise3D(float3 uvw){ + //uvw *= noise_scale; + //uvw += noise_transform; + + float3 gridIndex = floor(uvw); + float3 gridFract = frac(uvw); + + float3 blur = smoothstep(0.0, 1.0, gridFract); + //blur = gridFract; + + float3 blb = gridIndex + float3(0.0, 0.0, 0.0); + float3 brb = gridIndex + float3(1.0, 0.0, 0.0); + float3 tlb = gridIndex + float3(0.0, 1.0, 0.0); + float3 trb = gridIndex + float3(1.0, 1.0, 0.0); + float3 blf = gridIndex + float3(0.0, 0.0, 1.0); + float3 brf = gridIndex + float3(1.0, 0.0, 1.0); + float3 tlf = gridIndex + float3(0.0, 1.0, 1.0); + float3 trf = gridIndex + float3(1.0, 1.0, 1.0); + + float3 gradBLB = random3D(blb); + float3 gradBRB = random3D(brb); + float3 gradTLB = random3D(tlb); + float3 gradTRB = random3D(trb); + float3 gradBLF = random3D(blf); + float3 gradBRF = random3D(brf); + float3 gradTLF = random3D(tlf); + float3 gradTRF = random3D(trf); + + float3 distToPixelFromBLB = gridFract - float3(0.0, 0.0, 0.0); + float3 distToPixelFromBRB = gridFract - float3(1.0, 0.0, 0.0); + float3 distToPixelFromTLB = gridFract - float3(0.0, 1.0, 0.0); + float3 distToPixelFromTRB = gridFract - float3(1.0, 1.0, 0.0); + float3 distToPixelFromBLF = gridFract - float3(0.0, 0.0, 1.0); + float3 distToPixelFromBRF = gridFract - float3(1.0, 0.0, 1.0); + float3 distToPixelFromTLF = gridFract - float3(0.0, 1.0, 1.0); + float3 distToPixelFromTRF = gridFract - float3(1.0, 1.0, 1.0); + + float dotBLB = dot(gradBLB, distToPixelFromBLB); + float dotBRB = dot(gradBRB, distToPixelFromBRB); + float dotTLB = dot(gradTLB, distToPixelFromTLB); + float dotTRB = dot(gradTRB, distToPixelFromTRB); + float dotBLF = dot(gradBLF, distToPixelFromBLF); + float dotBRF = dot(gradBRF, distToPixelFromBRF); + float dotTLF = dot(gradTLF, distToPixelFromTLF); + float dotTRF = dot(gradTRF, distToPixelFromTRF); + + return lerp( + lerp( + lerp(dotBLB, dotBRB, blur.x), + lerp(dotTLB, dotTRB, blur.x), blur.y + ), + lerp( + lerp(dotBLF, dotBRF, blur.x), + lerp(dotTLF, dotTRF, blur.x), blur.y + ), blur.z + ) + 0.5; +} + +float3 rotateAroundYAxis(float3 p, float angle) +{ + float3x3 mat = { + cos(angle), 0, sin(angle), + 0, 1, 0, + -sin(angle), 0, cos(angle) + }; + + return mul(mat, p); +} + +// calculate noise at multiple frequencies and do a weighted sum of the results +float noise3DMultipleFreq(float3 p) +{ + float noiseVal1 = noise3D(p * c_freq1); + float noiseVal2 = noise3D(p * c_freq2); + float noiseVal3 = noise3D(p * c_freq3); + float noiseVal4 = noise3D(p * c_freq4); + + float4 noise = float4(noiseVal1, noiseVal2, noiseVal3, noiseVal4); + + return dot(noise, c_noiseWeights) * c_noiseAmp + c_noiseBias; +} + +// negative if inside sphere, positive otherwise +float calculateSignedDistance(float3 pos, float sphereRadius) +{ + float displacement = -noise3DMultipleFreq(pos); + + float radius = sphereRadius + displacement; + + return length(pos) - radius; +}; + +float3 calculateHitColor(float displacement) +{ + float x = clamp(displacement, 0.0f, 1.0f); + + if (x < c_colorThreshholds[0]) + return lerp(c_color5, c_color4, x * 4.0f); + else if (x < c_colorThreshholds[1]) + return lerp(c_color4, c_color3, x * 4.0f - 1.0f); + else if (x < c_colorThreshholds[2]) + return lerp(c_color3, c_color2, x * 4.0f - 2.0f); + + return lerp(c_color2, c_color1, x * 4.0f - 3.0f); +} + +/*$(_compute:csmain)*/(uint3 DTid : SV_DispatchThreadID) +{ + float sphereRadius = c_sphereRadius; + + if (c_animateRadius) + { + sphereRadius = abs(sin(c_time / 4.0f)) * 3.0f; + } + + // add +0.5 to get middle of pixel + // subtract half width/height to get distance from center of image + float directionX = (float(DTid.x) + 0.5f) - (float(c_resolution.x) / 2.0f); + + float directionY = (float(DTid.y) + 0.5f) - (float(c_resolution.y) / 2.0f); + directionY *= -1.0f; // flip it so that positive is up + + float directionZ = -(float(c_resolution.y) / (2.0f * tan(c_fov / 2.0f))); + + float3 direction = normalize(float3(directionX, directionY, directionZ)); + + float widthPercent = float(DTid.x) / float(c_resolution.x); + float heightPercent = float(DTid.y) / float(c_resolution.y); + + float brightness = (widthPercent + heightPercent) / 2.0f; + + float3 position = c_cameraOrigin; + + float4 outColor = c_backgroundColor; + + for (int i = 0; i < c_rayMarchIterations; i++) + { + float3 posRotated = position; + + if (c_rotate) + { + posRotated = rotateAroundYAxis(position, c_time * c_rotationSpeed); + } + + float distanceFromOrigin = length(posRotated); + + float signedDistance = calculateSignedDistance(posRotated, sphereRadius); + + float displacement = distanceFromOrigin - signedDistance - sphereRadius; + + bool hitBool = (signedDistance < 0.0f); + + if (hitBool) + { + // calculate normal vector + float epsilon = 0.1f; + + float dx = calculateSignedDistance(posRotated + float3(epsilon, 0.0f, 0.0f), sphereRadius) - signedDistance; + float dy = calculateSignedDistance(posRotated + float3(0.0f, epsilon, 0.0f), sphereRadius) - signedDistance; + float dz = calculateSignedDistance(posRotated + float3(0.0f, 0.0f, epsilon), sphereRadius) - signedDistance; + + float3 n = normalize(float3(dx, dy, dz)); + + // calculate diffuse lighting + float3 l = normalize(c_lightPosition - posRotated); + + float intensity = max(dot(l, n), 0.4f); // clamp to avoid pure black + + float3 hitColor = calculateHitColor((-displacement - 0.08f) * 2.0f) * intensity; + + outColor = float4(hitColor, 1.0f); + + break; + } + + position += direction * max(signedDistance * c_rayMarchStepPercent, c_rayMarchMinStepSize); + } + + direction.z = 0.0f; + + // These are just for debug purposes + perlin1[DTid.xy] = float4(float3(1.0f, 1.0f, 1.0f) * noise3D(direction * c_freq1), 1.0f); + perlin2[DTid.xy] = float4(float3(1.0f, 1.0f, 1.0f) * noise3D(direction * c_freq2), 1.0f); + perlin3[DTid.xy] = float4(float3(1.0f, 1.0f, 1.0f) * noise3D(direction * c_freq3), 1.0f); + perlin4[DTid.xy] = float4(float3(1.0f, 1.0f, 1.0f) * noise3D(direction * c_freq4), 1.0f); + + float sphereMax = (c_sphereRadius * 3.0f) - sphereRadius; + float sphereS = (sphereRadius - c_sphereRadius) / sphereMax; + + float fadeToWhite = lerp(0.0f, 1.0f, sphereS); + + outColor.x += fadeToWhite; + outColor.y += fadeToWhite; + outColor.z += fadeToWhite; + + output[DTid.xy] = outColor; +} + +/* +Shader Resources: + Texture intput (as SRV) + Texture output (as UAV) +*/ diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/_Screenshot.gif b/Techniques/GigiJamJune2024/tcalderbank_explosion/_Screenshot.gif new file mode 100644 index 0000000..942508d Binary files /dev/null and b/Techniques/GigiJamJune2024/tcalderbank_explosion/_Screenshot.gif differ diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/_Submission.txt b/Techniques/GigiJamJune2024/tcalderbank_explosion/_Submission.txt new file mode 100644 index 0000000..54d55eb --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/_Submission.txt @@ -0,0 +1,4 @@ +Title: Explosion +Name: Tristan Calderbank (tcalderbank@ea.com) +Description: +First a sphere is ray marched as an SDF in a compute shader. Then a normal is calculated with finite differences and lambert diffuse lighting is added. The surface is then displaced using 4 stacked frequencies of 3D Perlin noise. Color is then blended in based on displacement value and animation of the radius is added. \ No newline at end of file diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/explosion.gif b/Techniques/GigiJamJune2024/tcalderbank_explosion/explosion.gif new file mode 100644 index 0000000..942508d Binary files /dev/null and b/Techniques/GigiJamJune2024/tcalderbank_explosion/explosion.gif differ diff --git a/Techniques/GigiJamJune2024/tcalderbank_explosion/instructions.txt b/Techniques/GigiJamJune2024/tcalderbank_explosion/instructions.txt new file mode 100644 index 0000000..7c531e5 --- /dev/null +++ b/Techniques/GigiJamJune2024/tcalderbank_explosion/instructions.txt @@ -0,0 +1,17 @@ +Description + +First a sphere is ray marched as an SDF in a compute shader. Then a normal is calculated with finite differences and lambert diffuse lighting is added. +The surface is then displaced using 4 stacked frequencies of 3D Perlin noise. Color is then blended in based on displacement value. + +Instructions + +Open Explosion.gg in GigiViewer + +Under Render Graph select Explosion.output + +Credit: + +Based on these guides: + +https://github.com/ssloy/tinykaboom/wiki/KABOOM!-in-180-lines-of-code +https://www.youtube.com/watch?v=welK2U7UkzE \ No newline at end of file