[Discussion] Shader works unexpected on TiledBackgrounds.

0 favourites
  • 1 posts
  • Disclaimer: I have not written this shader.

    scroll.xml

    <?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>
    [/code:3p4wo9m0]
    scroll.fx
    [code:3p4wo9m0]/////////////////////////////////////////////////////////
    // 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);
    }[/code:3p4wo9m0]
    
    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
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)