TEXLIGHT

edited December 2015 in GLSL / Shaders

Hi people, I'm studying OpenGL lighting in processing right now using the following example shader files from processing shader examples:

Fragment File:

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif


uniform sampler2D texture;

varying vec4 vertColor;
varying vec4 vertTexCoord;

void main() {
  gl_FragColor = texture2D(texture, vertTexCoord.st) * vertColor;
}

Vertex File:

#define PROCESSING_TEXTURE_SHADER

uniform mat4 transform;
uniform mat4 texMatrix;

attribute vec4 vertex;
attribute vec4 color;
attribute vec2 texCoord;

varying vec4 vertColor;
varying vec4 vertTexCoord;

void main() {
  gl_Position = transform * vertex;

  vertColor = color;
  vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
}

I get an error message saying that the shader has to be of TEXLIGHT type to user the PointLight() (or any lighting) command. Does anyone know what this means?

Answers

  • first google hit for TEXLIGHT shader:

    https://www.processing.org/tutorials/pshader/

    and use ctrl-f to search page for TEXLIGHT

  • edited December 2015

    Yup, should've read the whole thing. I can still save this thread though. So now I have a textured model of a cliff with the per-vertex light shaders (lighting calculated using a dot product between vertex normal and direction vector to light source) from the example and I'm getting an unnatural lighting effect (picture below). I'm guessing this has to do with the normal for each vertex?

    i

Sign In or Register to comment.