Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#else outside of #if/#ifdef/#ifndef block ??? #15

Open
MarioMey opened this issue May 25, 2021 · 1 comment
Open

#else outside of #if/#ifdef/#ifndef block ??? #15

MarioMey opened this issue May 25, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@MarioMey
Copy link

MarioMey commented May 25, 2021

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.

@Limeth
Copy link
Owner

Limeth commented May 27, 2021

Hello, thank you for the bug report. It might be related to the way #pragma shaderfilter macros are processed, so I will investigate that.

@Limeth Limeth added the bug Something isn't working label May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants