#else outside of #if/#ifdef/#ifndef block ???
I'm trying to make this shader (from https://www.shadertoy.com/view/Xsl3zn) work. :
#define PROCEDURAL 0
float4 render( float2 uv )
{
float4 image_color = image.Sample(builtin_texture_sampler, uv);
#if PROCEDURAL==0
vec2 warp = texture( image, uv*0.1 + builtin_elapsed_time*vec2(0.04,0.03) ).xz;
#else
float freq = 3.0*sin(0.5*builtin_elapsed_time);
vec2 warp = 0.5000*cos( uv.xy*1.0*freq + vec2(0.0,1.0) + builtin_elapsed_time ) +
0.2500*cos( uv.yx*2.3*freq + vec2(1.0,2.0) + builtin_elapsed_time ) +
0.1250*cos( uv.xy*4.1*freq + vec2(5.0,3.0) + builtin_elapsed_time ) +
0.0625*cos( uv.yx*7.9*freq + vec2(3.0,4.0) + builtin_elapsed_time );
#endif
float2 st = uv + warp*0.5;
float4 new_image = image.Sample(builtin_texture_sampler, st);
//~ new_image = vec4( texture( image_color, st ).xyz, 1.0 );
return new_image;
}
The first problem that #if, #else and #endif lines are not working well:
Could not create the effect due to the following error: /home/mario/meytv/shaders/Warping - texture.glsl (30, 5): Unexpected token after preprocessor, expected newline
/home/mario/meytv/shaders/Warping - texture.glsl (32, 2): #else outside of #if/#ifdef/#ifndef block
/home/mario/meytv/shaders/Warping - texture.glsl (38, 2): #endif outside of #if/#ifdef/#ifndef block
[EDIT] ~~Also, if I comment those lines and lines for PROCEDURAL==1 and I try to make the vec2 warp = texture(... line work, I get no error... but image is unmodified.~~
☝ This is erroneous: it does work, but the texture that it is used to warp the image does the job (with image moved up-right), and, finally, it dissapears... and then, image is not warped any more. It's a nice warpping effect... I would like it to work, but it isn't indispensable. So, it is not part of the bug.
Hello, thank you for the bug report. It might be related to the way #pragma shaderfilter macros are processed, so I will investigate that.