Specifically, I want the band to rotate in one direction indefinitely, whereas by default it will reverse the rotation within a minute or so.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" RenderPasses="2" FileVersion="2">
<OnLoaded>
<ZLibrary Comment="HSV Library">
<Source>
<![CDATA[vec3 hsv(float h, float s, float v)
{
s = clamp(s/100, 0, 1);
v = clamp(v/100, 0, 1);
if(!s)return vector3(v, v, v);
h = h < 0 ? frac(1-abs(frac(h/360)))*6 : frac(h/360)*6;
float c, f, p, q, t;
c = floor(h);
f = h-c;
p = v*(1-s);
q = v*(1-s*f);
t = v*(1-s*(1-f));
switch(c)
{
case 0: return vector3(v, t, p);
case 1: return vector3(q, v, p);
case 2: return vector3(p, v, t);
case 3: return vector3(p, q, v);
case 4: return vector3(t, p, v);
case 5: return vector3(v, p, q);
}
}]]>
</Source>
</ZLibrary>
</OnLoaded>
<OnUpdate>
<ZExpression>
<Expression>
<![CDATA[const int
ALPHA = 0,
HUE = 1,
SATURATION = 2,
LIGHTNESS = 3;
vec3 c=hsv(Parameters[HUE]*360,Parameters[SATURATION]*100,(1-Parameters[LIGHTNESS])*100);
ShaderColor.r=c.r;
ShaderColor.g=c.g;
ShaderColor.b=c.b;]]>
</Expression>
</ZExpression>
</OnUpdate>
<OnRender>
<ZExpression>
<Expression>
<![CDATA[if(App.CurrentRenderPass==0) {
@SetRenderTarget(RenderTarget:FirstPassTarget);
@UseMaterial(Material:ScreenMaterial);
} else {
@SetRenderTarget(RenderTarget:null);
@UseMaterial(Material:PostMaterial);
}
@RenderSprite();]]>
</Expression>
</ZExpression>
</OnRender>
<Content>
<Group>
<Children>
<Array Name="Parameters" SizeDim1="10" Persistent="255">
<Values>
<![CDATA[78DA6360606098F75EDD9681A1C19E0102EC91B1B1B1B13D480E006FA80544]]>
</Values>
</Array>
<Constant Name="ParamHelpConst" Type="2">
<StringValue>
<![CDATA[Alpha
Hue
Saturation
Lightness
Focus
Background
Flameinten
Refract
Twirl
Noise]]>
</StringValue>
</Constant>
<Constant Name="AuthorInfo" Type="2">
<StringValue>
<![CDATA[Jochen Feldkoetter
http://www.soundcloud.com/virgill
Adapted from https://www.shadertoy.com/view/llK3Dy]]>
</StringValue>
</Constant>
</Children>
</Group>
<Material Name="ScreenMaterial" Shading="1" Light="0" ZBuffer="0" Shader="ScreenShader"/>
<Shader Name="ScreenShader">
<VertexShaderSource>
<![CDATA[varying vec2 position;
void main(){
vec4 vertex = gl_Vertex;
vertex.xy *= 2.0;
gl_Position = vertex;
position=vec2(vertex.x,vertex.y);
}]]>
</VertexShaderSource>
<FragmentShaderSource>
<![CDATA[uniform float iGlobalTime;
uniform float resX;
uniform float resY;
uniform float viewportX;
uniform float viewportY;
uniform vec3 pColor;
uniform float pFocus;
uniform float pBackground;
uniform float pFlameinten;
uniform float pRefract;
uniform float pTwirl;
uniform float pNoise;
uniform sampler2D tex1;
#define iChannel0 tex1
vec2 iResolution = vec2(resX,resY);
// ***********************************************************
// Alcatraz / Rhodium 4k Intro liquid carbon
// by Jochen "Virgill" Feldkötter
//
// 4kb executable: http://www.pouet.net/prod.php?which=68239
// Youtube: https://www.youtube.com/watch?v=YK7fbtQw3ZU
// ***********************************************************
// Params (Looking good with values from 0.00 - 1.00)
// Colors
#define p_col_r pColor.r //1.00
#define p_col_g pColor.g //0.25
#define p_col_b pColor.b //0.00
// Rendering
#define p_focus pFocus //0.50
#define p_background pBackground //0.50
#define p_flameinten pFlameinten //0.50
#define p_refract pRefract //0.50
// Object
#define p_twirl pTwirl //0.70
#define p_noise pNoise //1.00
float time=iGlobalTime;
vec3 res=vec3(iResolution.xy,0);
float bounce=abs(fract(0.05*time)-.5)*20.; // triangle function
// signed box
float sdBox(vec3 p,vec3 b)
{
vec3 d=abs(p)-b;
return min(max(d.x,max(d.y,d.z)),0.)+length(max(d,0.));
}
// rotation
void pR(inout vec2 p,float a)
{
p=cos(a)*p+sin(a)*vec2(p.y,-p.x);
}
// 3D noise function (IQ)
float noise(vec3 p)
{
vec3 ip=floor(p);
p-=ip;
vec3 s=vec3(7,157,113);
vec4 h=vec4(0.,s.yz,s.y+s.z)+dot(ip,s);
p=p*p*(3.-2.*p);
h=mix(fract(sin(h)*43758.5),fract(sin(h+s.x)*43758.5),p.x);
h.xy=mix(h.xz,h.yw,p.y);
return mix(h.x,h.y,p.z);
}
float map(vec3 p)
{
p.z-=1.0;
p*=0.9;
pR(p.yz,bounce*1.+0.4*p.x*(p_twirl+0.3));
return sdBox(p+vec3(0,sin(1.6*time),0),vec3(20.0, 0.05, 1.2))-.4*noise(8.*p+3.*bounce)*p_noise;
}
// normal calculation
vec3 calcNormal(vec3 pos)
{
float eps=0.0001;
float d=map(pos);
return normalize(vec3(map(pos+vec3(eps,0,0))-d,map(pos+vec3(0,eps,0))-d,map(pos+vec3(0,0,eps))-d));
}
// standard sphere tracing inside and outside
float castRayx(vec3 ro,vec3 rd)
{
float function_sign=(map(ro)<0.)?-1.:1.;
float precis=.0001;
float h=precis*2.;
float t=0.;
for(int i=0;i<120;i++)
{
if(abs(h)<precis||t>12.)break;
h=function_sign*map(ro+rd*t);
t+=h;
}
return t;
}
// refraction
float refr(vec3 pos,vec3 lig,vec3 dir,vec3 nor,float angle,out float t2, out vec3 nor2)
{
float h=0.;
t2=2.;
vec3 dir2=refract(dir,nor,angle);
for(int i=0;i<50;i++)
{
if(abs(h)>3.) break;
h=map(pos+dir2*t2);
t2-=h;
}
nor2=calcNormal(pos+dir2*t2);
return(.5*clamp(dot(-lig,nor2),0.,1.)+pow(max(dot(reflect(dir2,nor2),lig),0.),8.));
}
// softshadow
float softshadow(vec3 ro,vec3 rd)
{
float sh=1.;
float t=.02;
float h=.0;
for(int i=0;i<22;i++)
{
if(t>20.)continue;
h=map(ro+rd*t);
sh=min(sh,4.*h/t);
t+=h;
}
return sh;
}
// main function
void main()
{
vec2 uv=(gl_FragCoord.xy-vec2(viewportX,viewportY))/res.xy;
vec2 p=uv*2.-1.;
// bouncy cam every 10 seconds
//float wobble=(fract(.1*(time-1.))>=0.9)?fract(-time)*0.1*sin(30.*time):0.;
float wobble =0.;
// camera
vec3 dir = normalize(vec3(2.*(gl_FragCoord.xy-vec2(viewportX,viewportY)) -res.xy, res.y));
vec3 org = vec3(0,2.*wobble,-3.);
// standard sphere tracing:
vec3 color = vec3(0.);
vec3 color2 =vec3(0.);
float t=castRayx(org,dir);
vec3 pos=org+dir*t;
vec3 nor=calcNormal(pos);
// lighting:
vec3 lig=normalize(vec3(.2,6.,.5));
// scene depth
float depth=clamp((1.-0.09*t),0.,1.);
vec3 pos2 = vec3(0.);
vec3 nor2 = vec3(0.);
if(t<12.0)
{
color2 = vec3(max(dot(lig,nor),0.) + pow(max(dot(reflect(dir,nor),lig),0.),16.));
color2 *=clamp(softshadow(pos,lig),0.,1.); // shadow
float t2;
color2.rgb +=refr(pos,lig,dir,nor,0.9, t2, nor2)*depth;
color2-=clamp(.1*t2,0.,1.); // inner intensity loss
}
float tmp = 0.;
float T = 1.;
// animation of glow intensity
float intensity = (0.1*-sin(.209*time+1.)+0.05)+0.1*(p_flameinten-0.5);
for(int i=0; i<128; i++)
{
float density = 0.; float nebula = noise(org);
density=intensity-map(org+nor2*p_refract)*nebula;
if(density>0.)
{
tmp = density / 128.;
T *= 1. -tmp * 100.;
if( T <= 0.) break;
}
org += dir*0.078;
}
vec3 basecol=vec3(p_col_r , p_col_g , p_col_b);
T=clamp(T,0.,1.5);
color += basecol* exp(4.*(0.5-T) - 0.8);
color2*=depth;
color2+= (1.-depth)*noise(6.*dir+0.3*time)*.2*p_background; // subtle mist
// scene depth included in alpha channel
gl_FragColor = vec4(vec3(1.*color+0.8*color2)*1.3,abs(0.67-depth)*4.*p_focus);
}]]>
</FragmentShaderSource>
<UniformVariables>
<ShaderVariable VariableName="iGlobalTime" ValuePropRef="App.Time"/>
<ShaderVariable VariableName="resX" Value="1163" ValuePropRef="App.ViewportWidth"/>
<ShaderVariable VariableName="resY" Value="432" ValuePropRef="App.ViewportHeight"/>
<ShaderVariable VariableName="viewportX" Value="262" ValuePropRef="App.ViewportX"/>
<ShaderVariable VariableName="viewportY" Value="262" ValuePropRef="App.ViewportY"/>
<ShaderVariable VariableName="pColor" VariableRef="ShaderColor"/>
<ShaderVariable VariableName="pFocus" ValuePropRef="Parameters[4];"/>
<ShaderVariable VariableName="pBackground" ValuePropRef="Parameters[5];"/>
<ShaderVariable VariableName="pFlameinten" ValuePropRef="Parameters[6];"/>
<ShaderVariable VariableName="pRefract" ValuePropRef="Parameters[7];"/>
<ShaderVariable VariableName="pTwirl" ValuePropRef="Parameters[8];"/>
<ShaderVariable VariableName="pNoise" ValuePropRef="Parameters[9];"/>
</UniformVariables>
</Shader>
<Variable Name="ShaderColor" Type="7"/>
<Shader Name="PostShader">
<VertexShaderSource>
<![CDATA[varying vec2 position;
void main(){
vec4 vertex = gl_Vertex;
vertex.xy *= 2.0;
gl_Position = vertex;
position=vec2(vertex.x,vertex.y);
}]]>
</VertexShaderSource>
<FragmentShaderSource>
<![CDATA[// ***********************************************************
// Alcatraz / Rhodium 4k Intro liquid carbon
// by Jochen "Virgill" Feldkötter
//
// 4kb executable: http://www.pouet.net/prod.php?which=68239
// Youtube: https://www.youtube.com/watch?v=YK7fbtQw3ZU
// ***********************************************************
uniform float resX;
uniform float resY;
uniform float viewportX;
uniform float viewportY;
uniform float size;
uniform vec2 pos;
uniform float Alpha;
uniform sampler2D tex1;
#define iChannel0 tex1
vec2 iResolution = vec2(resX,resY);
vec3 res = vec3(iResolution.xy,0);
float GA =2.399;
mat2 rot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA));
// simplyfied version of Dave Hoskins blur
vec3 dof(sampler2D tex,vec2 uv,float rad)
{
vec3 acc=vec3(0);
vec2 pixel=vec2(.002*res.y/res.x,.002),angle=vec2(0,rad);;
rad=1.;
for (int j=0;j<80;j++)
{
rad += 1./rad;
angle*=rot;
vec4 col=texture2D(tex,uv+pixel*(rad-1.)*angle);
acc+=col.xyz;
}
return acc/80.;
}
//-------------------------------------------------------------------------------------------
void main()
{
vec2 uv = (gl_FragCoord.xy-vec2(viewportX,viewportY)) / res.xy;
gl_FragColor=vec4(dof(iChannel0,uv,texture2D(iChannel0,uv).w),Alpha);
}]]>
</FragmentShaderSource>
<UniformVariables>
<ShaderVariable VariableName="resX" Value="1163" ValuePropRef="App.ViewportWidth"/>
<ShaderVariable VariableName="resY" Value="432" ValuePropRef="App.ViewportHeight"/>
<ShaderVariable VariableName="viewportX" Value="262" ValuePropRef="App.ViewportX"/>
<ShaderVariable VariableName="viewportY" Value="262" ValuePropRef="App.ViewportY"/>
<ShaderVariable VariableName="Alpha" ValuePropRef="1-Parameters[0];"/>
</UniformVariables>
</Shader>
<Material Name="PostMaterial" Shading="1" Light="0" Blend="1" ZBuffer="0" Shader="PostShader">
<Textures>
<MaterialTexture RenderTarget="FirstPassTarget" TexCoords="1"/>
</Textures>
</Material>
<RenderTarget Name="FirstPassTarget" Width="0" Height="0"/>
</Content>
</ZApplication>
Any ideas?