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

  • SEARCH
  • Home
  • 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 6157795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:50:51+00:00 2026-05-23T20:50:51+00:00

I have a vertex shader in which I do a texture lookup to determine

  • 0

I have a vertex shader in which I do a texture lookup to determine gl_Position. I am using this as part of a GPU particle simulation system, where particle positions are stored in a texture.

It seems that: vec4 textureValue = texture2D(dataTexture, vec2(1.0, 1.0)); behaves differently on the simulator than the iPad device. On the simulator, the texture lookup succeeds (the value at that location is 0.5, 0.5) and my particle appears there. However, on the iPad itself the texture lookup is constantly returning 0.0, 0.0.

I have tried both textures of the format GL_FLOAT and GL_UNSIGNED_BYTE.

Has anyone else experienced this? The GLSL ES spec says that texture lookups can be done in both the vertex and fragment shaders, so I don’t see what the problem is.

I am using the latest GM Beta of iOS SDK 4.2

  • 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-23T20:50:52+00:00Added an answer on May 23, 2026 at 8:50 pm

    I just tested this as well. Using iOS 4.3, you can do a texture lookup on the vertex shader on both the device and the simulator. There is a bit of strangeness though (which is maybe why it’s not “official” as szu mentioned). On the actual device (I tested on the iPad 2) you have to do a lookup on the fragment shader as well as on the vertex shader. That is, if you are not actually using it on the fragment shader, you’ll still have to reference it in some way. Here’s a trivial example where I’m passing in a texture and using the red pixel to reposition the y value of the vertex by a little bit:

    /////fragment shader
    uniform sampler2D tex; //necessary even though not actually used
    
    void main() {
      vec4 notUsed = texture2D(tex, vec2(0.0,0.0)); //necessary even though not actually used
      gl_FragColor = vec4(1.0,1.0,1.0,1.0);
    }
    
    /////vertex shader
    attribute vec4 position;
    attribute vec2 texCoord;   
    uniform sampler2D tex; 
    
    void main() {
      float offset = texture2D(tex, texCoord).x;
      offset = (offset - 0.5) * 2.0; //map 0->1 to -1 to +1
      float posx = position.x;
      float posy = position.y + offset/8.0;
    
      gl_Position = vec4(posx, posy, 0.0, 1.0);  
    }
    

    I have a slightly fuller write-up of this at http://www.mat.ucsb.edu/a.forbes/blog/?p=453

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

Sidebar

Related Questions

I have a radial blur shader in GLSL, which takes a texture, applies a
I currently have two shaders, a processing shader (both vertex and pixel) - which
I have the following vertex shader: attribute vec4 Position; attribute vec4 SourceColor; varying vec4
If you have a given vertex how could you determine whether that vertex is
I have a vertex shader (2.0) doing some instancing - each vertex specifies an
If I have a few Program3D objects (each with it's own Vertex-Shader and Fragment-Shader
I have the following vertex shader: uniform mat4 uMVP; attribute vec4 aPosition; attribute vec4
I have vertex and triangle data which contains a color for each triangle (face),
I have 2 HLSL ps2.0 shaders. Simplified, they are: Shader 1 Reads texture Outputs
I have a program in which I need to apply a 2-dimensional texture (simple

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.