Hiya,

very stupid question:

I’ve been working on velvet surface effect, based on the ATI ‘Velvety’ shader.

It’s working very nicely, but I’d like to change it slightly, and I can’t work out quite how to do it.

Currently, I can rotate the object, but the lighting rotates with it (so effectively what I’m actually doing is orbiting the virtual camera around the whole mesh/lighting setup). What I’d like to do is to rotate/scale the mesh, without moving the light. I can’t work out why the code below isn’t allowing me to do that. I’m sure this is a REALLY basic error I’m making, and apologies in advance.

Here’s the VS code:

```
/////////////////////////////////////
//// VELVET SHADER VS ////
/////////////////////////////////////
/*
Translated from HLSL shader for VVVV
vNoiseVelvety.fx
by Desaxismundi 2008
Velvet shader originally by ATI
GLSL conversion toneburst 2008
*/
// Transformation matrices
mat4 MVIT = gl_ModelViewMatrixInverseTranspose;
mat4 MVI = gl_ModelViewMatrixInverse;
mat4 MV = gl_ModelViewMatrix;
// Varyings (sent to Fragment Shader)
varying vec3 LightVec;
varying vec3 WorldNormal;
varying vec3 WorldView;
// Uniforms
uniform vec3 lPos; // Light position
// Velvet vertex shader function
// Takes normal as input and modifies varyings
void velvetVS(in vec3 n, in vec4 v)
{
WorldNormal = (vec4(n,1.0) * MVIT).xyz;
vec4 Po = vec4(v.xyz,1.0);
vec3 Pw = (MV * Po).xyz;
LightVec = normalize(lPos - Pw);
WorldView = normalize(MVI[3].xyz - Pw);
}
/////////////////////////////////////
uniform vec4 TT_0;
uniform vec4 TT_1;
uniform vec4 TT_2;
uniform vec4 TT_3;
void main()
{
// Pre-transform matrix
mat4 tt = mat4(TT_0,TT_1,TT_2,TT_3);
// Pre-transform vertices
vec4 vertex = tt * gl_Vertex;
// Normal
vec3 N = normalize(gl_NormalMatrix * gl_Normal);
// Velvet vertex function
velvetVS(N, vertex);
// Transform vertex by modelview and projection matrices
gl_Position = gl_ModelViewProjectionMatrix * vertex;
// Forward texture coordinates after applying texture matrix
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
```

And the Fragment Shader:

```
/////////////////////////////////////
//// VELVET SHADER VS ////
/////////////////////////////////////
/*
Translated from HLSL shader for VVVV
vNoiseVelvety.fx
by Desaxismundi 2008
Velvet shader originally by ATI
GLSL conversion toneburst 2008
*/
// Transformation matrices
mat4 MVIT = gl_ModelViewMatrixInverseTranspose;
mat4 MVI = gl_ModelViewMatrixInverse;
mat4 MV = gl_ModelViewMatrix;
// Varyings (sent to Fragment Shader)
varying vec3 LightVec;
varying vec3 WorldNormal;
varying vec3 WorldView;
// Uniforms
uniform vec3 lPos; // Light position
// Velvet vertex shader function
// Takes normal as input and modifies varyings
void velvetVS(in vec3 n, in vec4 v)
{
WorldNormal = (vec4(n,1.0) * MVIT).xyz;
vec4 Po = vec4(v.xyz,1.0);
vec3 Pw = (MV * Po).xyz;
LightVec = normalize(lPos - Pw);
WorldView = normalize(MVI[3].xyz - Pw);
}
/////////////////////////////////////
uniform vec4 TT_0;
uniform vec4 TT_1;
uniform vec4 TT_2;
uniform vec4 TT_3;
void main()
{
// Pre-transform matrix
mat4 tt = mat4(TT_0,TT_1,TT_2,TT_3);
// Pre-transform vertices
vec4 vertex = tt * gl_Vertex;
// Normal
vec3 N = normalize(gl_NormalMatrix * gl_Normal);
// Velvet vertex function
velvetVS(N, vertex);
// Transform vertex by modelview and projection matrices
gl_Position = gl_ModelViewProjectionMatrix * vertex;
// Forward texture coordinates after applying texture matrix
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
```

Can anyone spot where I’m going wrong?

a|x