[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.
scroll.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<c2effect>
   <!-- About -->
   <id>Scroll</id>         <!-- Never change the ID.  Change the name instead -->
   <name>Scroll</name>
   <category>Distortion</category>
   <description>Seamlessly scroll the texture within a given amount of time</description>
   <author>Somebody</author>
   
   <!-- 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. -->
   <extend-box-horizontal>0</extend-box-horizontal>
   <extend-box-vertical>0</extend-box-vertical>
   
   <!-- Set to true if the background is sampled (samplerBack is referenced at all in the shader) -->
   <blends-background>false</blends-background>
   
   <!-- 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) -->
   <cross-sampling>false</cross-sampling>
   
   <!-- Set to true if the effect changes over time, e.g. Noise or Warp effects. -->
   <animated>true</animated>
   
   <!-- Parameters -->
   <parameters>
      <param>
         <name>X shift</name>
         <description>Amount of time for a full horizontal shift</description>
         <type>float</type>
         <initial>0</initial>
         <uniform>xshift</uniform>
      </param>
      <param>
         <name>Y shift</name>
         <description>Amount of time for a full vertical shift</description>
         <type>float</type>
         <initial>0</initial>
         <uniform>yshift</uniform>
      </param>
   </parameters>
</c2effect>

scroll.fx
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
B
10
S
1
G
1
Posts: 63
Reputation: 840

Return to Effects

Who is online

Users browsing this forum: No registered users and 1 guest