Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:38:08+00:00 2026-05-30T17:38:08+00:00

I want to write a shader that creates a reflection of an image similiar

  • 0

I want to write a shader that creates a reflection of an image similiar to the ones used for coverflows.

// Vertex Shader
uniform highp mat4 u_modelViewMatrix;
uniform highp mat4 u_projectionMatrix;
attribute highp vec4 a_position;
attribute lowp vec4 a_color;
attribute highp vec2 a_texcoord;
varying lowp vec4 v_color;
varying highp vec2 v_texCoord;
mat4 rot = mat4( -1.0, 0.0, 0.0, 0.0,
                  0.0, -1.0, 0.0, 0.0,
                  0.0, 0.0, 1.0, 0.0,
                  0.0, 0.0, 0.0, 1.0 );
void main()
{
  gl_Position = (u_projectionMatrix * u_modelViewMatrix) * a_position * rot;
  v_color = a_color;
  v_texCoord = a_texcoord;
}

// Fragment Shader
varying highp vec2 v_texCoord;
uniform sampler2D u_texture0;
uniform int slices;
void main()
{
  lowp vec3 w = vec3(1.0,1.0,1.0);
  lowp vec3 b = vec3(0.0,0.0,0.0);
  lowp vec3 mix = mix(b, w, (v_texCoord.y-(float(slices)/10.0)));
  gl_FragColor = texture2D(u_texture0,v_texCoord) * vec4(mix, 1.0);
}

But this shader is creating the following:
current result
And I dont know how to “flip” the image horizontally and I tried so many different parameters in the rotation matrix (I even tried to use a so called “mirror matrix”) but I dont know how to reflect the image on the bottom of original image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:38:10+00:00Added an answer on May 30, 2026 at 5:38 pm

    If you’re talking about what images.google.com returns for “coverflow” result, then you don’t need rotation matrix at all.

    void main()
    {
      gl_Position = (u_projectionMatrix * u_modelViewMatrix) * a_position;
      v_color = a_color;
      v_texCoord = vec2(a_texcoord.x, 1.0 - a_texcoord.y);
    }
    

    Simply flip it vertically.

    If you insist on using matrix and want to make a “mirror” shader (the one that takes it object, and puts it under “floor” to make reflection) then you need mirror matrix (don’t forget to adjust frontface/backface culling):

    mat4(1.0, 0.0, 0.0, 0.0,
        0.0, -1.0, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0,
        0.0, 0.0, 0.0, 1.0 );
    

    AND you must know where the floor is.

    gl_Position = (u_projectionMatrix * u_modelViewMatrix) * (a_position * mirrorMatrix - floor);
    

    Alternatively you could put floor translation into same matrix. Basically, to mirror against arbitrary height, you need to combine three transforms (pseudocode).

    translate(0, -floorHeight, 0) * scale(1, -1, 1) * translate(0, floorHeight, 0).

    and put them into your matrix.

    Also it might make sense to split modelView matrix into “model”(object/world) and “view” matrices. This way it’ll be easier to perform transformations like these.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to accomplish a GLSL Shader, that can texture and color my vertex
I'd like to write a pixel shader that takes an input image, and converts
I want to write a program in Prolog that confirms if a b-tree of
I want write a program that when installed, runs in background and adds a
I want write jquery code that will show form inputs after a checkbox is
I have whole page HTML in my database and i want write that html
I have 2 tables(1.Employee 2.Family). I want write a sql statement that produce the
I want write a simple query which will fetch data from a table (which
I want write a little code analyzer which parses nested structures and translates into
Hello I want write my own desktop sharing application in Java. The application should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.