material is gone ,is black
this is my shader coder
the shader is copy from "Dual Tone Car Shader With Fresnel And Sphere Mapping By Omaremad "
Code: Select all
//Vertex shader
uniform vec3 fvLightPosition;
uniform vec3 fvEyePosition;
varying vec2 Texcoord;
varying vec3 ViewDirection;
varying vec3 LightDirection;
varying vec3 Normal;
//get this from irr (important for sphere mapping)
uniform mat4 matWorldInverseTranspose;
varying vec2 reflcoord;
void main( void )
{
gl_Position = ftransform();
Texcoord = gl_MultiTexCoord0.xy;
vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;
ViewDirection = fvEyePosition - fvObjectPosition.xyz;
vec3 ViewDirectionn=normalize(ViewDirection);
LightDirection = fvLightPosition - fvObjectPosition.xyz;
Normal = gl_NormalMatrix * gl_Normal;
vec3 normal2=vec4(Normal,1)*matWorldInverseTranspose;
vec3 fin=ViewDirectionn-(2*(dot(normalize(normal2),ViewDirectionn))*normal2);
float p=sqrt(pow(fin.x,2)+pow(fin.y,2)+pow((fin.z+1),2));
reflcoord=vec2(((fin.x/(2*p))+1/2),((fin.y/(2*p))+1/2));
}
//Fragment shader
uniform vec4 fvLowTone;
uniform vec4 fvSpecular;
uniform vec4 fvHighTone;
uniform float fSpecularPower;
uniform sampler2D baseMap;
uniform sampler2D cube;
varying vec2 Texcoord;
varying vec3 ViewDirection;
varying vec3 LightDirection;
varying vec3 Normal;
varying vec2 reflcoord;
void main( void )
{
vec3 fvLightDirection = normalize( LightDirection );
vec3 fvNormal = normalize( Normal );
float fNDotL = dot( fvNormal, fvLightDirection );
vec3 fvReflection = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection );
vec3 fvViewDirection = normalize( ViewDirection );
float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
vec4 fvBaseColor = texture2D( baseMap, Texcoord );
vec4 fvTotalAmbient = fvLowTone * fvBaseColor;
vec4 fvTotalDiffuse = fvHighTone * (fNDotL) * fvBaseColor;
vec4 fvTotalSpecular = fvSpecular * ( pow( fRDotV, fSpecularPower ) );
float fresnel =(1/dot( Normal, fvViewDirection) )/5;
gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular )+(fresnel*texture2D(cube,reflcoord))+(fresnel /2);
}
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
core::matrix4 invWorld = driver->getTransform(video::ETS_WORLD);
invWorld.makeInverse();
services->setVertexShaderConstant("matWorldInverseTranspose", invWorld.pointer(), 16);
}