glsl shader question

ok so im teaching myself how to use glsl shaders in blender and so far i understand it but i have run into a problem

## test1---------------------------------

import GameLogic as gl
cont = gl.getCurrentController()
ow = cont.getOwner()
olist = gl.getCurrentScene().getObjectList()
gl.setLogicTicRate(60.0)
lamp = olist['OBLamp']

ShaderObjects = [olist['OB*****']]
MaterialIndexList = [0, 1]
GlobalAmbient = [0.4, 0.4, 0.4, 1]
AmbF = 0.5
#--------------------------------------------
Vertshader = '''
varying vec3 LightDir;
varying vec3 EyeDir;
varying vec3 Normal;

uniform vec3 LightPosition;
uniform float Scale;

void main(void) 
{
    vec4 pos = gl_ModelViewMatrix * gl_Vertex;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    vec3 eyeDir = vec3(pos);
    gl_TexCoord[0] = gl_MultiTexCoord0;

    vec3 n = normalize(gl_NormalMatrix * gl_Normal);
    vec3 t = normalize(cross(vec3(1.141, 2.78, 3.14), n));
    vec3 b = cross(n, t);

    vec3 v;
    v.x = dot(LightPosition, t);
    v.y = dot(LightPosition, b);
    v.z = dot(LightPosition, n);
    LightDir = normalize(v);

    v.x = dot(eyeDir, t);
    v.y = dot(eyeDir, b);
    v.z = dot(eyeDir, n);
    EyeDir = normalize(v);
}
'''

Fragshader = '''
varying vec3 LightDir;
varying vec3 EyeDir;
varying vec3 Normal;

const vec3 color = vec3(0.7, 0.6, 0.18);

//const float Density = 16.0;
//const float Size = 0.25;

uniform float Density;
uniform float Size;
//uniform float Scale;

const float SpecularFactor = 0.5;

void main (void)
{
    vec3 litColor;

    vec2 c = Density * (gl_TexCoord[0].xy);
    vec2 p = fract(c) - vec2(0.5);
    float d = (p.x * p.x) + (p.y * p.y);
    if (d >= Size)
        p = vec2(0.0);

    vec3 normDelta = vec3(-p.x, -p.y, 1.0);
      
    litColor = color * max(0.0, dot(normDelta, LightDir));
      
    float t = 2.0 * dot(LightDir, normDelta);
    vec3 reflectDir = t * normDelta;
    reflectDir = LightDir - reflectDir;
    
//    vec3 reflectDir = LightDir - 2.0 * dot(LightDir, normDelta) * normDelta;
    
    float spec = max(dot(EyeDir, reflectDir), 0.0);
    spec = spec * spec;
    spec = spec * spec;
    spec *= SpecularFactor;

    litColor = min(litColor + spec, vec3(1.0));
    gl_FragColor = vec4(litColor, 1.0);
//    gl_FragColor = vec4(Scale);
}
'''

def MainLoop():
    for obj in ShaderObjects:
        
        mesh_index = 0
        mesh = obj.getMesh(mesh_index)
        
        while mesh != None:
            for mat in mesh.materials:
                if not hasattr(mat, "getMaterialIndex"):
                    return
                mat_index = mat.getMaterialIndex()
                
                found = 0
                for i in range(len(MaterialIndexList)):
                    if mat_index == MaterialIndexList[i]:
                        found = 1
                        break
                    if not found: continue
                        
                shader = mat.getShader()
                if shader != None:
                    if not shader.isValid():
                        shader.setSource(Vertshader, Fragshader, 1)
                    shader.setUniform1f('Scale', 1)
                    shader.setUniformfv('LightPosition', lamp.getPosition())
            mesh_index += 1
            mesh = obj.getMesh(mesh_index)
            
        
        
MainLoop()

when i use this code it returns an error invalid uniform value: scale
so i was wondering if anyone could help me debug this and get it to work
and no i did not write this it is straight out of shader designer from typhoon labs

I think the problem is this… you’ve declared the uniform Scale… (with a value of 1 in the python part of the script)… but it’s not used in either the vertex or fragment shader… in fact it is commented out in the fragment shader… it’s not commented out of the vertex shader.

You’ve also got other uniforms in the fragment shader that are not declared in your python script… e.g…
uniform float Density;
uniform float Size;

I would suggest using shader designer (you can download it for free with tuts etc) or the ATI version thing… has monkey in the name I think? Use them to test that your shader actually works and compiles first. Only then put it into blender.

EDIT: I see you are using shader designer… good good

so what could the problem be because it works fine in shader designer

and it doesnt work when i declare those in the python script it still tells me invalid uniform float value Scale

well the you must make sure that your uniforms are all being used and that they are exactly the same as in the shader designer version. eg. Same uniforms, same variables etc. Like I pointed out… shader designer also won’t let you declare a uniform in a shader and then not use it in the fragment or vertex code.

In a nutshell the reason why it doesn’t work is that you’ve typed it in wrong in blender.