Results 1 to 2 of 2

Thread: Simple effect, slicing a texture into multiple rows, and rotating each individually

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2015
    Posts
    8

    Question Simple effect, slicing a texture into multiple rows, and rotating each individually

    Here is something that I thought would be easier for me to manage, but it's proving to be a challenge for me (mainly because of a lack of understanding of the math behind it). I am trying to separate a texture into multiple diagonal rows and have each row move forward or backwards at different rates. A similar effect is this:

    Code :
    varying vec4 vertTexCoord;
    uniform sampler2D texture;
    uniform float time;      
    uniform vec2 pixels;     
    uniform float rollRate;   
    uniform float rollAmount;  
     
     
    void main(void) {
      	vec2 p = vertTexCoord.st;
    	p.x -= mod(p.x, 1.0 / pixels.x);  
    	p.y -= mod(p.y, 1.0 / pixels.y);
     
     
    	p.y = mod(p.y + rollAmount * sin(rollRate * time * p.x + p.x), 1.0);   
      	gl_FragColor = vec4(texture2D(texture, p).rgb, 1.0);                
    }

    This is close, but it is first reducing the number of pixels of the texture and then just modulating each individually. I want to keep the original texture intact within the slices. Does anyone know of how I might want to get this started? Or if you have any advice of what I should look into to make this easier in the future? For example, I understand modulus, but I have a hard time making sense of it particularly within glsl...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2013
    Posts
    186
    What exactly are you rendering? One big quad? Triangle?
    Why exactly can you not "slice" the texture by rendering more triangles? You shouldnt even need any custom glsl code for that.

Similar Threads

  1. Delay in texture 2D slicing
    By Kal Mar in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 10-05-2010, 05:40 AM
  2. adding rows together
    By The Ordinary in forum OpenGL: General
    Replies: 2
    Last Post: 12-11-2008, 02:58 AM
  3. Strobe effect in multiple viewports
    By Erfdain in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-08-2005, 03:34 PM
  4. How to apply reflection effect to a simple cube?
    By powervr in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-19-2004, 08:34 PM
  5. rotating multiple circles
    By nystama in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-29-2002, 06:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean