Created
July 28, 2021 00:30
-
-
Save dreness/2463f7679d4682ee43e7180a0cdaba02 to your computer and use it in GitHub Desktop.
basic compute kernel Kodelife project XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<klxml v='16' a='MTL'> | |
<document><properties><creator><![CDATA[net.hexler.KodeLife]]></creator><creatorVersion><![CDATA[1.0.1.153]]></creatorVersion><versionMajor>1</versionMajor><versionMinor>1</versionMinor><versionPatch>1</versionPatch><author><![CDATA[]]></author><comment><![CDATA[]]></comment><enabled>1</enabled><size><x>500</x><y>500</y></size><clearColor><x>0</x><y>0</y><z>0</z><w>1</w></clearColor><selectedRenderPassIndex>1</selectedRenderPassIndex><selectedKontrolPanelIndex>0</selectedKontrolPanelIndex><uiExpandedPreviewDocument>0</uiExpandedPreviewDocument><uiExpandedPreviewRenderPass>1</uiExpandedPreviewRenderPass><uiExpandedProperties>1</uiExpandedProperties></properties><params><uiExpanded>1</uiExpanded><param type='CLOCK'><displayName><![CDATA[Clock]]></displayName><variableName><![CDATA[time]]></variableName><uiExpanded>0</uiExpanded><running>1</running><direction>1</direction><speed>1</speed><loop>0</loop><loopStart>0</loopStart><loopEnd>6.28319</loopEnd></param><param type='FRAME_RESOLUTION'><displayName><![CDATA[Frame Resolution]]></displayName><variableName><![CDATA[resolution]]></variableName><uiExpanded>0</uiExpanded></param><param type='INPUT_MOUSE_SIMPLE'><displayName><![CDATA[Mouse]]></displayName><variableName><![CDATA[mouse]]></variableName><uiExpanded>0</uiExpanded><variant>1</variant><normalize>0</normalize><invert><x>0</x><y>1</y></invert></param><param type='CONSTANT_FLOAT1'><displayName><![CDATA[Float]]></displayName><variableName><![CDATA[size]]></variableName><uiExpanded>1</uiExpanded><value>6.19576</value><range><x><x>3</x><y>15</y></x></range></param><param type='CONSTANT_FLOAT1'><displayName><![CDATA[Float]]></displayName><variableName><![CDATA[gloop]]></variableName><uiExpanded>1</uiExpanded><value>4.0318</value><range><x><x>3</x><y>6</y></x></range></param></params><passes><pass type='RENDER'><properties><label><![CDATA[A]]></label><enabled>1</enabled><selectedShaderStageIndex>4</selectedShaderStageIndex><primitiveIndex>0</primitiveIndex><primitiveType><![CDATA[TRIANGLES]]></primitiveType><instanceCount>1</instanceCount><uiExpanded>0</uiExpanded><renderstate><colormask><r>1</r><g>1</g><b>1</b><a>1</a><uiExpanded>0</uiExpanded></colormask><blendstate><enabled>0</enabled><srcBlendRGB><![CDATA[SRC_ALPHA]]></srcBlendRGB><dstBlendRGB><![CDATA[ONE_MINUS_SRC_ALPHA]]></dstBlendRGB><srcBlendA><![CDATA[ONE]]></srcBlendA><dstBlendA><![CDATA[ONE_MINUS_SRC_ALPHA]]></dstBlendA><equationRGB><![CDATA[ADD]]></equationRGB><equationA><![CDATA[ADD]]></equationA><uiExpanded>1</uiExpanded></blendstate><cullstate><enabled>1</enabled><ccw>1</ccw><uiExpanded>1</uiExpanded></cullstate><depthstate><enabled>1</enabled><write>1</write><func><![CDATA[LESS]]></func><uiExpanded>0</uiExpanded></depthstate></renderstate><rendertarget><size><x>500</x><y>500</y></size><resolutionMode><![CDATA[PROJECT]]></resolutionMode><uiExpanded>1</uiExpanded><color><clear><x>0</x><y>0</y><z>0</z><w>1</w></clear><uiExpanded>1</uiExpanded></color><depth><clear>0</clear><uiExpanded>1</uiExpanded></depth></rendertarget><transform><uiExpanded>0</uiExpanded><projection><type>0</type><perspective><fov>60</fov><z><x>1</x><y>1000</y></z></perspective><orthographic><bounds><x>-1</x><y>1</y><z>-1</z><w>1</w></bounds><z><x>0</x><y>10</y></z></orthographic><uiExpanded>0</uiExpanded></projection><view><eye><x>0</x><y>0</y><z>3</z></eye><center><x>0</x><y>0</y><z>0</z></center><up><x>0</x><y>1</y><z>0</z></up><uiExpanded>1</uiExpanded></view><model><scale><x>0.868</x><y>0.868</y><z>1</z></scale><rotate><x>0</x><y>0</y><z>0</z></rotate><translate><x>0</x><y>0</y><z>0</z></translate><uiExpanded>1</uiExpanded></model></transform></properties><params><uiExpanded>1</uiExpanded></params><stages><stage type='VERTEX'><properties><enabled>1</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded><param type='TRANSFORM_MVP'><displayName><![CDATA[Model View Projection Matrix]]></displayName><variableName><![CDATA[mvp]]></variableName><uiExpanded>1</uiExpanded></param></params><shader><source profile='GL2'><![CDATA[uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
attribute vec4 a_position; | |
attribute vec3 a_normal; | |
attribute vec2 a_texcoord; | |
varying vec3 v_normal; | |
varying vec2 v_texcoord; | |
void main(void) | |
{ | |
gl_Position = mvp * a_position; | |
v_normal = a_normal; | |
v_texcoord = a_texcoord; | |
} | |
]]></source><source profile='GL3'><![CDATA[#version 150 | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
in vec4 a_position; | |
in vec3 a_normal; | |
in vec2 a_texcoord; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
void main(void) | |
{ | |
// Some drivers don't like position being written here | |
// with the tessellation stages enabled also. | |
// Comment next line when Tess.Eval shader is enabled. | |
gl_Position = mvp * a_position; | |
outData.v_position = a_position; | |
outData.v_normal = a_normal; | |
outData.v_texcoord = a_texcoord; | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 300 es | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
in vec4 a_position; | |
in vec3 a_normal; | |
in vec2 a_texcoord; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
void main(void) | |
{ | |
// Some drivers don't like position being written here | |
// with the tessellation stages enabled also. | |
// Comment next line when Tess.Eval shader is enabled. | |
gl_Position = mvp * a_position; | |
outData.v_position = a_position; | |
outData.v_normal = a_normal; | |
outData.v_texcoord = a_texcoord; | |
} | |
]]></source><source profile='DX9'><![CDATA[struct VS_INPUT | |
{ | |
float4 a_position : POSITION; | |
float3 a_normal : NORMAL; | |
float2 a_texcoord : TEXCOORD0; | |
}; | |
struct VS_OUTPUT | |
{ | |
float4 v_position : POSITION; | |
float3 v_normal : NORMAL; | |
float2 v_texcoord : TEXCOORD0; | |
}; | |
float time; | |
float2 resolution; | |
float2 mouse; | |
float3 spectrum; | |
float4x4 mvp; | |
VS_OUTPUT vs_main(in VS_INPUT In) | |
{ | |
VS_OUTPUT Out; | |
Out.v_position = mul(mvp, In.a_position); | |
Out.v_normal = In.a_normal; | |
Out.v_texcoord = In.a_texcoord; | |
return Out; | |
} | |
]]></source><source profile='MTL'><![CDATA[#include <metal_stdlib> | |
using namespace metal; | |
struct VS_INPUT | |
{ | |
float4 a_position [[attribute(0)]]; | |
float3 a_normal [[attribute(1)]]; | |
float2 a_texcoord [[attribute(2)]]; | |
}; | |
struct VS_OUTPUT | |
{ | |
float4 v_position [[position]]; | |
float3 v_normal; | |
float2 v_texcoord; | |
}; | |
struct VS_UNIFORM | |
{ | |
float time; | |
float2 resolution; | |
float2 mouse; | |
float3 spectrum; | |
float4x4 mvp; | |
}; | |
vertex | |
VS_OUTPUT vs_main( | |
VS_INPUT input [[stage_in]], | |
constant VS_UNIFORM& uniform [[buffer(16)]]) | |
{ | |
VS_OUTPUT out; | |
out.v_position = uniform.mvp * input.a_position; | |
out.v_normal = input.a_normal; | |
out.v_texcoord = input.a_texcoord; | |
return out; | |
} | |
]]></source></shader></stage><stage type='TESS_CONTROL'><properties><enabled>0</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded></params><shader><source profile='MTL'><![CDATA[ | |
]]></source><source profile='GL3'><![CDATA[#version 400 | |
layout(vertices = 3) out; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData[]; | |
const float TessLevelInner = 1; | |
const float TessLevelOuter = 1; | |
#define ID gl_InvocationID | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
void main() | |
{ | |
outData[ID].v_position = inData[ID].v_position; | |
outData[ID].v_normal = inData[ID].v_normal; | |
outData[ID].v_texcoord = inData[ID].v_texcoord; | |
if(ID == 0) | |
{ | |
gl_TessLevelInner[0] = TessLevelInner; | |
gl_TessLevelOuter[0] = TessLevelOuter; | |
gl_TessLevelOuter[1] = TessLevelOuter; | |
gl_TessLevelOuter[2] = TessLevelOuter; | |
} | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 310 es | |
#extension GL_EXT_shader_io_blocks: enable | |
#extension GL_EXT_tessellation_shader: enable | |
layout(vertices = 3) out; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData[]; | |
const float TessLevelInner = 1.; | |
const float TessLevelOuter = 1.; | |
#define ID gl_InvocationID | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
void main() | |
{ | |
outData[ID].v_position = inData[ID].v_position; | |
outData[ID].v_normal = inData[ID].v_normal; | |
outData[ID].v_texcoord = inData[ID].v_texcoord; | |
if(ID == 0) | |
{ | |
gl_TessLevelInner[0] = TessLevelInner; | |
gl_TessLevelOuter[0] = TessLevelOuter; | |
gl_TessLevelOuter[1] = TessLevelOuter; | |
gl_TessLevelOuter[2] = TessLevelOuter; | |
} | |
} | |
]]></source></shader></stage><stage type='TESS_EVAL'><properties><enabled>0</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded><param type='TRANSFORM_MVP'><displayName><![CDATA[Model View Projection Matrix]]></displayName><variableName><![CDATA[mvp]]></variableName><uiExpanded>1</uiExpanded></param></params><shader><source profile='MTL'><![CDATA[ | |
]]></source><source profile='GL3'><![CDATA[#version 400 | |
layout(triangles, equal_spacing, ccw) in; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
void main() | |
{ | |
outData.v_position = | |
gl_TessCoord[0] * inData[0].v_position + | |
gl_TessCoord[1] * inData[1].v_position + | |
gl_TessCoord[2] * inData[2].v_position; | |
outData.v_normal = | |
gl_TessCoord[0] * inData[0].v_normal + | |
gl_TessCoord[1] * inData[1].v_normal + | |
gl_TessCoord[2] * inData[2].v_normal; | |
outData.v_texcoord = | |
gl_TessCoord[0] * inData[0].v_texcoord + | |
gl_TessCoord[1] * inData[1].v_texcoord + | |
gl_TessCoord[2] * inData[2].v_texcoord; | |
gl_Position = mvp * outData.v_position; | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 310 es | |
#extension GL_EXT_shader_io_blocks: enable | |
#extension GL_EXT_tessellation_shader: enable | |
layout(triangles, equal_spacing, ccw) in; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
void main() | |
{ | |
outData.v_position = | |
gl_TessCoord[0] * inData[0].v_position + | |
gl_TessCoord[1] * inData[1].v_position + | |
gl_TessCoord[2] * inData[2].v_position; | |
outData.v_normal = | |
gl_TessCoord[0] * inData[0].v_normal + | |
gl_TessCoord[1] * inData[1].v_normal + | |
gl_TessCoord[2] * inData[2].v_normal; | |
outData.v_texcoord = | |
gl_TessCoord[0] * inData[0].v_texcoord + | |
gl_TessCoord[1] * inData[1].v_texcoord + | |
gl_TessCoord[2] * inData[2].v_texcoord; | |
gl_Position = mvp * outData.v_position; | |
} | |
]]></source></shader></stage><stage type='GEOMETRY'><properties><enabled>0</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded><param type='TRANSFORM_MVP'><displayName><![CDATA[Model View Projection Matrix]]></displayName><variableName><![CDATA[mvp]]></variableName><uiExpanded>1</uiExpanded></param></params><shader><source profile='MTL'><![CDATA[ | |
]]></source><source profile='GL3'><![CDATA[#version 150 | |
layout(triangles) in; | |
layout(triangle_strip, max_vertices = 3) out; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
void main() | |
{ | |
outData.v_texcoord = inData[0].v_texcoord; | |
outData.v_normal = inData[0].v_normal; | |
gl_Position = gl_in[0].gl_Position; | |
EmitVertex(); | |
outData.v_texcoord = inData[1].v_texcoord; | |
outData.v_normal = inData[1].v_normal; | |
gl_Position = gl_in[1].gl_Position; | |
EmitVertex(); | |
outData.v_texcoord = inData[2].v_texcoord; | |
outData.v_normal = inData[2].v_normal; | |
gl_Position = gl_in[2].gl_Position; | |
EmitVertex(); | |
EndPrimitive(); | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 310 es | |
#extension GL_EXT_shader_io_blocks: enable | |
#extension GL_EXT_geometry_shader: enable | |
layout(triangles) in; | |
layout(triangle_strip, max_vertices = 3) out; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData[]; | |
out VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} outData; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform mat4 mvp; | |
void main() | |
{ | |
outData.v_texcoord = inData[0].v_texcoord; | |
outData.v_normal = inData[0].v_normal; | |
gl_Position = gl_in[0].gl_Position; | |
EmitVertex(); | |
outData.v_texcoord = inData[1].v_texcoord; | |
outData.v_normal = inData[1].v_normal; | |
gl_Position = gl_in[1].gl_Position; | |
EmitVertex(); | |
outData.v_texcoord = inData[2].v_texcoord; | |
outData.v_normal = inData[2].v_normal; | |
gl_Position = gl_in[2].gl_Position; | |
EmitVertex(); | |
EndPrimitive(); | |
} | |
]]></source></shader></stage><stage type='FRAGMENT'><properties><enabled>1</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded><param type='CONSTANT_FLOAT1'><displayName><![CDATA[Float]]></displayName><variableName><![CDATA[size]]></variableName><uiExpanded>1</uiExpanded><value>0</value><range></range></param></params><shader><source profile='GL2'><![CDATA[#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform sampler2D texture0; | |
uniform sampler2D texture1; | |
uniform sampler2D texture2; | |
uniform sampler2D texture3; | |
uniform sampler2D prevFrame; | |
uniform sampler2D prevPass; | |
varying vec3 v_normal; | |
varying vec2 v_texcoord; | |
void main(void) | |
{ | |
vec2 uv = -1. + 2. * v_texcoord; | |
gl_FragColor = vec4( | |
abs(sin(cos(time+3.*uv.y)*2.*uv.x+time)), | |
abs(cos(sin(time+2.*uv.x)*3.*uv.y+time)), | |
spectrum.x * 100., | |
1.0); | |
} | |
]]></source><source profile='GL3'><![CDATA[#version 150 | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform sampler2D texture0; | |
uniform sampler2D texture1; | |
uniform sampler2D texture2; | |
uniform sampler2D texture3; | |
uniform sampler2D prevFrame; | |
uniform sampler2D prevPass; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData; | |
out vec4 fragColor; | |
void main(void) | |
{ | |
vec2 uv = -1. + 2. * inData.v_texcoord; | |
fragColor = vec4( | |
abs(sin(cos(time+3.*uv.y)*2.*uv.x+time)), | |
abs(cos(sin(time+2.*uv.x)*3.*uv.y+time)), | |
spectrum.x * 100., | |
1.0); | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 300 es | |
precision highp float; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform sampler2D texture0; | |
uniform sampler2D texture1; | |
uniform sampler2D texture2; | |
uniform sampler2D texture3; | |
uniform sampler2D prevFrame; | |
uniform sampler2D prevPass; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData; | |
out vec4 fragColor; | |
void main(void) | |
{ | |
vec2 uv = -1. + 2. * inData.v_texcoord; | |
fragColor = vec4( | |
abs(sin(cos(time+3.*uv.y)*2.*uv.x+time)), | |
abs(cos(sin(time+2.*uv.x)*3.*uv.y+time)), | |
spectrum.x * 100., | |
1.0); | |
} | |
]]></source><source profile='DX9'><![CDATA[struct PS_INPUT | |
{ | |
float3 v_normal : NORMAL; | |
float2 v_texcoord : TEXCOORD0; | |
}; | |
struct PS_OUTPUT | |
{ | |
float4 color : COLOR0; | |
}; | |
float time; | |
float2 resolution; | |
float2 mouse; | |
float3 spectrum; | |
sampler2D texture0; | |
sampler2D texture1; | |
sampler2D texture2; | |
sampler2D texture3; | |
sampler2D prevFrame; | |
sampler2D prevPass; | |
PS_OUTPUT ps_main(in PS_INPUT In) | |
{ | |
PS_OUTPUT Out; | |
float2 uv = -1. + 2. * In.v_texcoord; | |
Out.color = float4( | |
abs(sin(cos(time+3.*uv.y)*2.*uv.x+time)), | |
abs(cos(sin(time+2.*uv.x)*3.*uv.y+time)), | |
spectrum.x * 100., | |
1.0); | |
return Out; | |
} | |
]]></source><source profile='MTL'><![CDATA[#include <metal_stdlib> | |
using namespace metal; | |
struct FS_INPUT | |
{ | |
float3 v_normal; | |
float2 v_texcoord; | |
}; | |
struct FS_UNIFORM | |
{ | |
float time; | |
float2 resolution; | |
float4 mouse; | |
float gloop; | |
float size; | |
}; | |
fragment | |
float4 fs_main( | |
FS_INPUT In [[stage_in]], | |
constant FS_UNIFORM& uniform [[buffer(16)]], | |
texture2d<float> prevFrame [[texture(0)]]) | |
{ | |
float4 col = float4(0); | |
return col; | |
} | |
]]></source></shader></stage></stages></pass><pass type='COMPUTE'><properties><label><![CDATA[B]]></label><enabled>1</enabled><selectedShaderStageIndex>5</selectedShaderStageIndex><groups><x>64</x><y>64</y><z>1</z></groups><threads><x>8</x><y>8</y><z>1</z></threads></properties><params><uiExpanded>1</uiExpanded></params><stages><stage type='COMPUTE'><properties><enabled>1</enabled><hidden>0</hidden><locked>0</locked><fileWatch>0</fileWatch><fileWatchPath><![CDATA[]]></fileWatchPath><uiExpanded>1</uiExpanded></properties><params><uiExpanded>1</uiExpanded><param type='FRAME_PREV_PASS'><displayName><![CDATA[Previous Pass]]></displayName><variableName><![CDATA[o]]></variableName><uiExpanded>1</uiExpanded><attachment>1</attachment><variant>0</variant><samplerState><minFilter><![CDATA[LINEAR]]></minFilter><magFilter><![CDATA[LINEAR]]></magFilter><wrapS><![CDATA[REPEAT]]></wrapS><wrapT><![CDATA[CLAMP]]></wrapT></samplerState><imageParams><accessMode><![CDATA[READ_WRITE]]></accessMode></imageParams></param></params><shader><source profile='GL3'><![CDATA[#version 430 | |
precision highp float; | |
precision highp int; | |
precision highp image2D; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
layout(local_size_x = LOCAL_SIZE_X, | |
local_size_y = LOCAL_SIZE_Y, | |
local_size_z = LOCAL_SIZE_Z) in; | |
layout(binding = 0) uniform writeonly image2D prevPass; | |
void main() | |
{ | |
ivec2 uv = ivec2(gl_GlobalInvocationID.xy); | |
} | |
]]></source><source profile='ES3'><![CDATA[#version 310 es | |
precision highp float; | |
precision highp int; | |
precision highp image2D; | |
layout(local_size_x = LOCAL_SIZE_X, | |
local_size_y = LOCAL_SIZE_Y, | |
local_size_z = LOCAL_SIZE_Z) in; | |
layout(binding = 0, rgba8) uniform writeonly image2D prevPass; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
void main() | |
{ | |
ivec2 uv = ivec2(gl_GlobalInvocationID.xy); | |
} | |
]]></source><source profile='MTL'><![CDATA[// Converted from github.com:dejager/oxford-comma to Kodelife 1.0.1.153 | |
// by [email protected] | |
// set threadgroups based on total pixel count, so that | |
// Groups [x,y,z] * Threads [x,y,z] >= resolution.[x,y,z] | |
// input sliders are on the project, inherited by both stages | |
#include <metal_stdlib> | |
#include <simd/simd.h> | |
using namespace metal; | |
#define smoothIntersect(a, b, k) smoothUnion(a, b, -k) | |
#define sphereField(center, radius, position) ( length(center - position) - radius) | |
#define halfField(position) (position.y - res.y / 2.0) | |
#define CS(a) float2(cos(a*1.3), sin(a*1.7)) | |
struct CS_UNIFORM | |
{ | |
float time; | |
float2 resolution; | |
float4 mouse; | |
float gloop; | |
float size; | |
}; | |
float smoothUnion(float a, float b, float k){ | |
float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0); | |
return mix(b, a, h) - k * h * (1.0 - h); | |
} | |
kernel void cs_main( | |
constant CS_UNIFORM& uniform [[buffer(16)]], | |
ushort2 gid [[thread_position_in_grid]], | |
texture2d<float, access::write> o [[texture(0)]] | |
) { | |
float2 res = uniform.resolution; | |
float2 p = float2(gid.xy); | |
float2 uv = (res.xy - 0.5 * res.xy) / max(res.x, res.y); | |
float2 P = 0.0; | |
if (uniform.mouse.z > 0) { | |
P.x = 1.0 + (uniform.mouse.x); | |
P.y = uniform.mouse.y; | |
} else { | |
P = (res / (2.0 - uv * (0.5 - CS(uniform.time)))); | |
} | |
float size = sphereField(P, res.y / (25.0/uniform.size), p); | |
float3 sfield = float3(halfField(p), size, res.x / uniform.gloop); | |
float a = smoothUnion(sfield.x, sfield.y, sfield.z); | |
float b = smoothIntersect(sfield.x, sfield.y, sfield.z); | |
float clampedA = clamp(a, 0., 1.0); | |
float clampedB = clamp(b, 0., 1.0); | |
float4 color = float4(mix(1, clampedA, clampedB), 0.02, 0, 1); | |
o.write(color, ushort2(p)); | |
} | |
]]></source></shader></stage></stages></pass></passes></document> | |
</klxml> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment