Re: [osg-users] OSGSpotLight example on a GLSL material

2009-06-15 Thread Robert Osfield
HI Albino,

I'm not quite sure where to start... your GLSL shader doesn't seem to
have any reference whatsoever to projective texture coord setup in the
vertex shader or application of the projective texture in the fragment
shader.  To me this suggests that you haven't yet learnt enough about
the way GLSL shaders work.  GLSL shaders replace the fixed function
pipeline entirely, which means techniques like ones used in the spot
light that used the fixed function pipeline will need to replicated in
your GLSL shader.

Robert.

On Mon, Jun 15, 2009 at 1:20 AM, Albino Rodriguesb...@vrspace.com.au wrote:
 Hi,

Try including the vertex and fragment shaders you are using then
others might have a chance of spotting what is up.

 My apologies for the lack of source code.

 The Normal Vertex Map Shader:

 varying vec3 lightVec;
 varying vec3 eyeVec;
 varying vec2 texCoord;
 attribute vec3 tangent;


 void main(void)
 {
        gl_Position = ftransform();
        texCoord = gl_MultiTexCoord0.xy;

        vec3 n = normalize(gl_NormalMatrix * gl_Normal);
        vec3 t = normalize(gl_NormalMatrix * tangent);
        vec3 b = cross(n, t);

        vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
        vec3 tmpVec = gl_LightSource[0].position.xyz - vVertex;

        lightVec.x = dot(tmpVec, t);
        lightVec.y = dot(tmpVec, b);
        lightVec.z = dot(tmpVec, n);

        tmpVec = -vVertex;
        eyeVec.x = dot(tmpVec, t);
        eyeVec.y = dot(tmpVec, b);
        eyeVec.z = dot(tmpVec, n);
 }


 The Normal Fragment Map Shader:


 varying vec3 lightVec;
 varying vec3 eyeVec;
 varying vec2 texCoord;
 uniform sampler2D diffuseMap;
 uniform sampler2D normalMap;
 uniform float lightFallOff;

 void main (void)
 {
        float distSqr = dot(lightVec, lightVec);
        float att = clamp(1.0 - lightFallOff * sqrt(distSqr), 0.0, 1.0);
        vec3 lVec = lightVec * inversesqrt(distSqr);

        vec3 vVec = normalize(eyeVec);

        vec4 base = texture2D(diffuseMap, texCoord.xy);

        vec3 bump = normalize( texture2D(normalMap, texCoord.xy).xyz * 2.0 -
 1.0);

        vec4 vAmbient = gl_LightSource[0].ambient *
 gl_FrontMaterial.ambient;

        float diffuse = max( dot(lVec, bump), 0.0 );

        vec4 vDiffuse = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse
 *
                                        diffuse;

        float specular = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0,
 1.0),
                         gl_FrontMaterial.shininess );

        vec4 vSpecular = gl_LightSource[0].specular *
 gl_FrontMaterial.specular *
                                         specular;

        vec3 color = vec3(( vAmbient*base +
                                         vDiffuse*base +
                                         vSpecular) * att);


        gl_FragColor = vec4(color,gl_FrontMaterial.ambient.a);
        gl_FragColor = mix(base, colour, gl_FrontMaterial.ambient.a);
        gl_FragColor = vec4(1,0,0,1);
 }

 -Original Message-
 From: osg-users-boun...@lists.openscenegraph.org
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
 Osfield
 Sent: Friday, 12 June 2009 6:10 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] OSGSpotLight example on a GLSL material

 Hi Bino,

 I can't see how many of us will be able divine what is up with your
 shaders as we have absolutely no knowledge of what you've put into
 your shader.   You question is equivalent to I have a piece of string
 you can't see, but can you tell me exactly how long it is.

 Try including the vertex and fragment shaders you are using then
 others might have a chance of spotting what is up.

 Robert.

 On Fri, Jun 12, 2009 at 6:28 AM, Albino Rodriguesb...@vrspace.com.au
 wrote:
 Hi,



 I have been using the OSGSpotLight example as a starting base to simulate
 a
 flashlight with success.



 The scene I was using has now been updated to be drawn with a GLSL
 NormalMap
 shader (included as part of the .ive). The spotlight can no longer be
 seen.
 It does however appear to affect the general lighting of the area it's in,
 but the spotlight and the texture image that goes with it can no longer be
 seen.



 Any ideas on how to get around this would be much appreciated.



 Cheers,

 Bino







 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users

Re: [osg-users] OSGSpotLight example on a GLSL material

2009-06-14 Thread Albino Rodrigues
Hi, 

Try including the vertex and fragment shaders you are using then
others might have a chance of spotting what is up.

My apologies for the lack of source code.

The Normal Vertex Map Shader:

varying vec3 lightVec; 
varying vec3 eyeVec;
varying vec2 texCoord;
attribute vec3 tangent; 
 

void main(void)
{
gl_Position = ftransform();
texCoord = gl_MultiTexCoord0.xy;

vec3 n = normalize(gl_NormalMatrix * gl_Normal);
vec3 t = normalize(gl_NormalMatrix * tangent);
vec3 b = cross(n, t);

vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 tmpVec = gl_LightSource[0].position.xyz - vVertex;

lightVec.x = dot(tmpVec, t);
lightVec.y = dot(tmpVec, b);
lightVec.z = dot(tmpVec, n);

tmpVec = -vVertex;
eyeVec.x = dot(tmpVec, t);
eyeVec.y = dot(tmpVec, b);
eyeVec.z = dot(tmpVec, n);
}


The Normal Fragment Map Shader:


varying vec3 lightVec;
varying vec3 eyeVec;
varying vec2 texCoord;
uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
uniform float lightFallOff;

void main (void)
{
float distSqr = dot(lightVec, lightVec);
float att = clamp(1.0 - lightFallOff * sqrt(distSqr), 0.0, 1.0);
vec3 lVec = lightVec * inversesqrt(distSqr);

vec3 vVec = normalize(eyeVec);

vec4 base = texture2D(diffuseMap, texCoord.xy);

vec3 bump = normalize( texture2D(normalMap, texCoord.xy).xyz * 2.0 -
1.0);

vec4 vAmbient = gl_LightSource[0].ambient *
gl_FrontMaterial.ambient;

float diffuse = max( dot(lVec, bump), 0.0 );

vec4 vDiffuse = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse
* 
diffuse;

float specular = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0,
1.0), 
 gl_FrontMaterial.shininess );

vec4 vSpecular = gl_LightSource[0].specular *
gl_FrontMaterial.specular * 
 specular;  

vec3 color = vec3(( vAmbient*base + 
 vDiffuse*base + 
 vSpecular) * att);
 

gl_FragColor = vec4(color,gl_FrontMaterial.ambient.a);
gl_FragColor = mix(base, colour, gl_FrontMaterial.ambient.a);
gl_FragColor = vec4(1,0,0,1);
}

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: Friday, 12 June 2009 6:10 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] OSGSpotLight example on a GLSL material

Hi Bino,

I can't see how many of us will be able divine what is up with your
shaders as we have absolutely no knowledge of what you've put into
your shader.   You question is equivalent to I have a piece of string
you can't see, but can you tell me exactly how long it is.

Try including the vertex and fragment shaders you are using then
others might have a chance of spotting what is up.

Robert.

On Fri, Jun 12, 2009 at 6:28 AM, Albino Rodriguesb...@vrspace.com.au
wrote:
 Hi,



 I have been using the OSGSpotLight example as a starting base to simulate
a
 flashlight with success.



 The scene I was using has now been updated to be drawn with a GLSL
NormalMap
 shader (included as part of the .ive). The spotlight can no longer be
seen.
 It does however appear to affect the general lighting of the area it's in,
 but the spotlight and the texture image that goes with it can no longer be
 seen.



 Any ideas on how to get around this would be much appreciated.



 Cheers,

 Bino







 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSGSpotLight example on a GLSL material

2009-06-12 Thread Robert Osfield
Hi Bino,

I can't see how many of us will be able divine what is up with your
shaders as we have absolutely no knowledge of what you've put into
your shader.   You question is equivalent to I have a piece of string
you can't see, but can you tell me exactly how long it is.

Try including the vertex and fragment shaders you are using then
others might have a chance of spotting what is up.

Robert.

On Fri, Jun 12, 2009 at 6:28 AM, Albino Rodriguesb...@vrspace.com.au wrote:
 Hi,



 I have been using the OSGSpotLight example as a starting base to simulate a
 flashlight with success.



 The scene I was using has now been updated to be drawn with a GLSL NormalMap
 shader (included as part of the .ive). The spotlight can no longer be seen.
 It does however appear to affect the general lighting of the area it’s in,
 but the spotlight and the texture image that goes with it can no longer be
 seen.



 Any ideas on how to get around this would be much appreciated.



 Cheers,

 Bino







 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] OSGSpotLight example on a GLSL material

2009-06-11 Thread Albino Rodrigues
Hi,

 

I have been using the OSGSpotLight example as a starting base to simulate a
flashlight with success.

 

The scene I was using has now been updated to be drawn with a GLSL NormalMap
shader (included as part of the .ive). The spotlight can no longer be seen.
It does however appear to affect the general lighting of the area it's in,
but the spotlight and the texture image that goes with it can no longer be
seen.

 

Any ideas on how to get around this would be much appreciated.

 

Cheers,

Bino

 

 

 

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org