Historique des modifications - Message

Message #8396

Sujet: [ GLSL ]Rendu cel-shading -- La lumière suis la caméra --


Type Date Auteur Contenu
Création du message 30-07-2010 22:41:06 narugohan
Bonjour à tous,
j'ai crée un shader cel-shading en GLSL, le voilà :

vertex_shader.vert
varying vec3 Normal;
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform vec3 mLightPos;
uniform vec4 mLightColor;

void main(void)
{
    gl_FrontColor = gl_Color;
    Normal = gl_NormalMatrix * gl_Normal;
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = ftransform();
 
}

pixel_shader.frag
uniform vec3 mLightPos;
uniform vec4 mLightColor;
uniform sample    r2D Texture0;
 
varying vec3 Normal;

vec4 CelShading ( vec4 color )
{
    float Intensity = dot( mLightPos , normalize(Normal) );
    float factor = 0.8;
    if ( Intensity < 0.5 ) factor = 0.2;
        color *= vec4 ( factor, factor, factor, 1.0 );
 
    return color;
}

void main (void)
{
    vec4 color = texture2D( Texture0 , vec2( gl_TexCoord[0] ) );
 
    color = CelShading ( color );
 
    gl_FragColor = color;
}

CShaderPerso.h
namespace irr
{
namespace video
{


class CShaderPerso : public irr::video::IShaderConstantSetCallBack
{
      
private :
        IrrlichtDevice* m_device;

public:

    CShaderPerso( IrrlichtDevice* device )
    {
        m_device = device;
    }
    
    virtual void OnSetConstants(irr::video::IMaterialRendererServices* services, irr::s32 userData)
    {
        video::IVideoDriver* driver = services->getVideoDriver();

        core::matrix4 invWorld = driver->getTransform(video::ETS_WORLD);
        invWorld.makeInverse();
        services->setVertexShaderConstant("mInvWorld", invWorld.pointer(), 16);

        core::matrix4 worldViewProj;
        worldViewProj = driver->getTransform(video::ETS_PROJECTION);
        worldViewProj *= driver->getTransform(video::ETS_VIEW);
        worldViewProj *= driver->getTransform(video::ETS_WORLD);
        services->setVertexShaderConstant("mWorldViewProj", worldViewProj.pointer(), 16);

        core::vector3df pos = irr::core::vector3df(100,50,30);
        services->setVertexShaderConstant ( "mLightPos" , reinterpret_cast<f32*>( &pos ) , 3 );

        video::SColorf col(0.0f,1.0f,1.0f,0.0f);
        services->setVertexShaderConstant("mLightColor", reinterpret_cast<f32*>(&col), 4);

        core::matrix4 world = driver->getTransform(video::ETS_WORLD);
        world = world.getTransposed();
        services->setVertexShaderConstant("mTransWorld", world.pointer(), 16);

    }

};

}
}

Le problème est que la lumière suis la caméra, donc alors que je voudrais qu'elle reste à la position vector3df(100,50,30).
Quelqu'un pourrait m'aider svp, je ne comprend rien car pourtant je récupère bien les bonnes positions

Je vous remercie d'avance

Cordialement

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
239 invités en ligne
membre en ligne: -
RSS Feed