I would like to show you how you can obtain cool fx with customIPP like those on this web pages :
http://glsl.heroku.com/
http://www.iquilezles.org/apps/shadertoy/
these shader are written in GLSL, it's the opengl version of HLSL. These 2 language are very close so it's very easy to convert one code to ther one
for example if you go to http://glsl.heroku.com/ and create new effect you obtain this code :
- Code: Select all
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy ) + mouse / 4.0;
float color = 0.0;
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
color *= sin( time / 10.0 ) * 0.5;
gl_FragColor = vec4( vec3( color, color * 0.5, sin( color + time / 3.0 ) * 0.75 ), 1.0 );
}
here the HLSL version, that you can use with customIPP :
- Code: Select all
uniform float time : register(c9); // var0
uniform float4 var1 : register(c10); // var1
uniform float4 var2 : register(c11); // var2
uniform float4 var3 : register(c12); // var3
uniform float4 var4 : register(c13); // var4
void main
(
in float2 uv0 : TEXCOORD0,
out float4 color0 : COLOR0,
in float2 vpos : VPOS
)
{
//float2 position = ( vpos.xy / resolution.xy ) + 0 / 4.0;
float2 position = uv0 - 0.5;
float color = 0.0;
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
color *= sin( time / 10.0 ) * 0.5;
color0 = float4( float3( color, color * 0.5, sin( color + time / 3.0 ) * 0.75 ), 1.0 );
}
The diff (GLSL => HLSL) :
gl_FragColor => color0
gl_FragCoord => vpos
vec4 (vec3, vec2) => float4 (float3, float2) (just replace vec with float)
declared variables :
uniform float time => uniform float time : register(c9); // ps_var0, so you need to edit the animation script and pass to ps_var0 the time value
uniform vec2 mouse => not used (there is no mouse interaction in werkkzeug), so just remove references of this variable
uniform vec2 resolution => (screen resolution) for now not known by customIPP, but I've posted a fix to pass this info to the pixel shader of customIPP.
in wait of screen resolution you can replace screen coordinate with uv coord, like this :
// float2 position = ( vpos.xy / resolution.xy ) + 0 / 4.0; // screen coord
float2 position = uv0 - 0.5; // uv coord
the only diff is taht ratio is unknow without screen resolution, so shape could be crushed...
If you obtain this error : "error X3014: incorrect number of arguments to numeric-type constructor" (in debug shadercode)
this is manly due to this mistake :
float3 pos = float3(0); // BAD, each value (x,y,z) need to be define into constructor in HLSL
float3 pos = float3(0,0,0); // GOOD BOY !!!
for example you can obtain this error with this bad declaration :
uniform float4 time : register(c9); // BAD, in most of code example time is a float, not a float4
Most of intrinsic functions are the same on both languages, but there is some specific case :
(non exhaustive list)
(GLSL => HLSL)
mix => lerp
mod => fmod
texture2D => tex2D
fract => frac
atan(y,x) => atan2(y,x)
...
Don't forrget to consult doc for help :
GLSL => http://www.opengl.org/sdk/docs/manglsl/
HLSL => msdn.microsoft.com/en-us/library/windows/desktop/ff471376%28v=vs.85%29.aspx
And here the wz4 example used on this post