[osg-users] why does the adding of lighting, colour and fusion to the "shader" model result in the opacity of its windowpane?

Mirro Xu mirro187 at gmail.com
Sun Feb 10 19:03:38 PST 2019


Hi,


Code:

const char* gl2_VertexFaceShader = {
	"vec4 directionalLight(in vec3 normal,in vec4 color)\n"
	"{\n"
	"	float NdotL = dot(normal, normalize(gl_LightSource[0].position.xyz)); \n"
	"	NdotL = max(0.0, NdotL); \n"

	"	float NdotHV = dot(normal, gl_LightSource[0].halfVector.xyz); \n"
	"	NdotHV = max(0.0, NdotHV); \n"
	"	color *= gl_FrontLightModelProduct.sceneColor + \n"
	"		gl_FrontLightProduct[0].ambient + \n"
	"		gl_FrontLightProduct[0].diffuse * NdotL; \n"
	"	if (NdotL * NdotHV > 0.0)\n"
	"		color += gl_FrontLightProduct[0].specular * pow(NdotHV, gl_FrontMaterial.shininess); \n"
	"	return color;\n"
	"}\n"
	"varying vec2 texCoord;\n"
	"varying vec4 vertexColor;\n"
	"void main(void)\n"
	"{\n"
	"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
	"    texCoord    = gl_MultiTexCoord0.xy;\n"
	"    vec3 normal = normalize(gl_NormalMatrix * gl_Normal);\n"
	"    vertexColor = directionalLight(normal,gl_Color); \n"
	"}\n"
};

const char* gl2_FragmentFaceShader = {
	"uniform   vec3      highlightColor;\n"
	"uniform   float     transparency  ;\n"
	"uniform   sampler2D baseTexture;\n"
	"varying   vec2 texCoord;\n"
	"varying   vec4 vertexColor;\n"
	"void main(void)\n"
	"{\n"
	"    gl_FragColor = vertexColor * texture2D(baseTexture, texCoord) * vec4(highlightColor.x,highlightColor.y,highlightColor.z,transparency);\n"
	"}\n"
};





Thank you!

Cheers,
Mirro

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75616#75616







More information about the osg-users mailing list