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 8781187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:14:05+00:00 2026-06-13T20:14:05+00:00

I am writing a GLSL program for texture mapping. I am having a weird

  • 0

I am writing a GLSL program for texture mapping. I am having a weird problem. From my vertex shader I am trying to pass the texture coordinate vec2 as a varying to frag shader. In a diff shader in the same prog I did the same and it worked. But for this texture its not working. If I comment that line, then everything works. I have no clue why this is happening.

This is the vertex shader:

attribute vec4 position; 
attribute vec4 color1; 
attribute vec4 normal; 
attribute vec2 texCoord;

uniform mat4 model; //passed to shader 
uniform mat4 projection; //passed to shader
uniform mat4 view; // passed to shader
uniform mat4 normalMatrix; //passed to shader
uniform mat4 worldNormalMatrix;
uniform vec3 eyePos;

varying vec4 pcolor; 
varying vec3 fNormal;
varying vec3 v;
varying mat4 modelMat;
varying mat4 viewMat;
varying mat4 projectionMat;
varying vec2 texCoordinate;
varying vec3 reflector;

void main()
{     
      //texCoordinate = texCoord;  // If I uncomment this, then I get wrong output. but the same thing works in a diff shader!! 
      mat4 projectionModelView;
      vec4 N;
      vec3 WorldCameraPosition = vec3(model*vec4(eyePos,1.0));
      vec3 worldPos = vec3(model*position);
      vec3 worldNorm = normalize(vec3(worldNormalMatrix*normal));
      vec3 worldView = normalize(vec3(WorldCameraPosition-worldPos));
      reflector = reflect(-worldView, worldNorm);      
      projectionMat = projection;
      modelMat=model;
      viewMat=view;
      N=normalMatrix*normal;      
      fNormal = vec3(N); //need to multiply this with normal matrix
      projectionModelView=projection*view*model;
      v=vec3(view*model*position); // v is the position at eye space for each vertex passed to frag shader
      gl_Position =  projectionModelView * position; // calculate clip space position     
}
  • 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-06-13T20:14:06+00:00Added an answer on June 13, 2026 at 8:14 pm
    varying vec4 pcolor; 
    varying vec3 fNormal;
    varying vec3 v;
    varying mat4 modelMat;
    varying mat4 viewMat;
    varying mat4 projectionMat;
    varying vec2 texCoordinate;
    varying vec3 reflector;
    

    This is 17 total varying vectors. That’s too many for most 2.1-class hardware (they generally only support 16). That’s probably why it is “not working” when you uncomment that line, because your vertex shader will ignore any varying that you don’t actually write to.

    You should not be passing those matrices at all. They’re uniforms; by definition, they don’t change from vertex to vertex. And fragment shaders are perfectly capable of accessing those same uniforms too. So just declare them in your fragment shader if you need to use them.

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

Sidebar

Related Questions

I am writing a GLSL geometry shader and I am trying to use the
I'm writing a GLSL vertex shader for an iMac with a AMD Radeon HD
I'm writing a shader in GLSL and I need to pass it a certain
I am writing a GLSL program as part of a plugin that runs inside
I am writing a GLSL shader that simulates chromatic aberration for simple objects. I
I am working on a project writing a GLSL fragment shader, and it just
Writing a program in which I need to split strings from a struct linked
Writing a simple example from Odersky's book resulted in the following problem: // AbstractElement.scala
I am writing a GLSL program as part of a plugin running inside of
I'm writing a fragment shader for WebGL(GLSL ES 1.0) using the latest version of

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.