Hi Francesco, Sajjadul

Francesco Tamagni wrote:
Carsten Neumann ha scritto:

Have you made any changes to the vertex and or fragment program? (I've attached my version for reference - it has no changes compared to what is in cvs). Especially the second warning is very surprising as in my version of the tutorial the vertex shader does write to fvObjectPosition.

in fact it doesn't:

vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;

in that way fvObjectPosition is re-declared and the shader is not writing into varying... it should be something like

fvObjectPosition = vec3( gl_ModelViewMatrix * gl_Vertex );

oops, you are right, good catch.

ok, so basically the problem is that the vp/fp are not quite correct and my graphics driver is more lenient than Sajjadul's. Anyway, I've committed a fixed version of the tutorial and attached the patch.

        Hope it helps,
                Carsten
Index: 31PhongShaderWithGLMaterials.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Tutorials/31PhongShaderWithGLMaterials.cpp,v
retrieving revision 1.1
diff -u -r1.1 31PhongShaderWithGLMaterials.cpp
--- 31PhongShaderWithGLMaterials.cpp	20 Aug 2007 17:05:47 -0000	1.1
+++ 31PhongShaderWithGLMaterials.cpp	14 Mar 2008 15:49:49 -0000
@@ -37,7 +37,6 @@
 // vertex shader program.
 static std::string _vp_program =
 "\n"
-"varying vec2 Texcoord;\n"
 "varying vec3 ViewDirection;\n"
 "varying vec3 fvObjectPosition;\n"
 "varying vec3 Normal;\n"
@@ -45,21 +44,20 @@
 "void main( void )\n"
 "{\n"
 "   gl_Position = ftransform();\n"
-"   Texcoord    = gl_MultiTexCoord0.xy;\n"
 "    \n"
-"   vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;\n"
+"   fvObjectPosition = vec3(gl_ModelViewMatrix * gl_Vertex);\n"
 "   \n"
 "   ViewDirection  = - fvObjectPosition.xyz;\n"
 "   Normal         = gl_NormalMatrix * gl_Normal;\n"
-"    gl_FrontColor  = gl_FrontMaterial.diffuse;\n"
+"   gl_FrontColor  = gl_FrontMaterial.diffuse;\n"
 "   \n"
 "}\n";
 
 // fragment shader program for bump mapping in surface local coordinates
 static std::string _fp_program =
-"vec4 fvAmbient = vec4(0.36, 0.36, 0.36, 1.0);\n"
-"vec4 fvSpecular = vec4(0.7, 0.7, 0.7, 1.0);\n"
-"vec4 fvDiffuse = vec4(0.5, 0.5, 0.5, 1.0);\n"
+"vec4 fvAmbient  = vec4(0.36, 0.36, 0.36, 1.0);\n"
+"vec4 fvSpecular = vec4(0.7,  0.7,  0.7,  1.0);\n"
+"vec4 fvDiffuse  = vec4(0.5,  0.5,  0.5,  1.0);\n"
 "float fSpecularPower = 25.0;\n"
 "\n"
 "uniform sampler2D baseMap;\n"
@@ -80,7 +78,7 @@
 "   vec3  fvViewDirection  = normalize( ViewDirection );\n"
 "   float fRDotV           = max( 0.0, dot( fvReflection, fvViewDirection ) );\n"
 "   \n"
-"    vec4  fvBaseColor    = gl_Color;\n"
+"   vec4  fvBaseColor      = gl_Color;\n"
 "   \n"
 "   vec4  fvTotalAmbient   = fvAmbient * fvBaseColor; \n"
 "   vec4  fvTotalDiffuse   = fvDiffuse * fNDotL * fvBaseColor; \n"
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to