0
votes

I have several objects without texture coordinates UV passed into the fragment shader, and i only have two other objects with texture coordinates UV passed into the fragment shader. The objects without texture were still visible but with a dull color. But after plugging in the light equations it becomes black and non-visible. How do i draw the non-texturized objects without changing it's original color and also keeping the light equation (i've already created color arrays for them and passed them into the vertex shader). I've tried this but my fragment shader wouldn't compile.

#version 330 

  in vec3 fragmentColor;
  in vec3 fragmentNormal;
  in vec2 UV;
  in vec4 Position;
  uniform vec4 lighteye;
  uniform float intensityh;
  uniform float intensityd;
  uniform float objectd;
  uniform vec4 worldCoord;

// Data for the texture uniform sampler2D texture_Colors;

if(UV.x >= 0.0)
color = intensityh * texture2D( texture_Colors, UV ).rgb * diffuse + (intensityd * texture2D( texture_Colors, UV ).rgb * something) ;
else
color = vec4(fragmentColor,1.0);
1
Please edit your question and write your entire shaders in it.John

1 Answers

0
votes

As far as I understood, you could do something like this:

color r = intensityh * texture2D( texture_Colours, worldCoord.xy).rgb * diffuse+( intensityd* texture2D (texture_Colours, worldCoord.xy).rgb * something

This should texture your objects based on their position in the 3D space. Don't forget, however, to enable texture repeating by CPU code for each texture, like this:

glTexParameterf(GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_WRAP_T, GL_REPEAT);