[Discussion] Shader works unexpected on TiledBackgrounds.

Share your Construct 2 effect files

Post » Wed Jun 14, 2017 8:35 pm

Disclaimer: I have not written this shader.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
   <!-- About -->
   <id>Scroll</id>         <!-- Never change the ID.  Change the name instead -->
   <description>Seamlessly scroll the texture within a given amount of time</description>
   <!-- Settings -->

   <!-- Extend the bounding box for effect processing by a number of pixels to show the edges
       of effects which go beyond the object edges, e.g. blur and warp. -->
   <!-- Set to true if the background is sampled (samplerBack is referenced at all in the shader) -->
   <!-- Set to true if the background is not sampled at 1:1 with the foreground (e.g. the
       background texture co-ordinates are modified in some way by the shader, as done
       by Glass and Lens) -->
   <!-- Set to true if the effect changes over time, e.g. Noise or Warp effects. -->
   <!-- Parameters -->
         <name>X shift</name>
         <description>Amount of time for a full horizontal shift</description>
         <name>Y shift</name>
         <description>Amount of time for a full vertical shift</description>

Code: Select all
// Scroll effect
varying mediump vec2 vTex;
uniform lowp sampler2D samplerFront;
uniform lowp float seconds;

uniform lowp float xshift;
uniform lowp float yshift;

void main(void)
   mediump vec2 tex = vTex;
   if (xshift != 0.0) tex.x = mod(tex.x-mod(seconds,xshift)/xshift,1.0);
   if (yshift != 0.0) tex.y = mod(tex.y-mod(seconds,yshift)/yshift,1.0);
   gl_FragColor = texture2D(samplerFront,tex);

For some reasons tiledbackgrounds seem to do it though either layout size or window size. Sprites work as expected.
The tiledbackgrounds is 16x16 and its width is a multiple of 16 and its height is 16.
Any support, will be greatly appreciated, in addition can you explain what you done so I can learn.
Thank you
Posts: 63
Reputation: 840

Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests