Historique des modifications - Message

Message #11822

Sujet: Changer la coloration de la texture d'une skybox


Type Date Auteur Contenu
Création du message 04-06-2017 23:16:24 jonath313
Merci Magun ! çà fonctionne super bien !
Par contre voici mon code :

Code c++ :

void CColorShader::OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
		// Set inverted world matrix
		// if we are using highlevel shaders (the user can select this when
		// starting the program), we must set the constants by name.
		core::matrix4 invWorld = Driver->getTransform(video::ETS_WORLD);
		invWorld.makeInverse();
		services->setVertexShaderConstant("mInvWorld", invWorld.pointer(), 16);

		// Set clip matrix
		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);

		// Set camera position
		core::vector3df pos = Dev->getSceneManager()->getActiveCamera()->getAbsolutePosition();
		services->setVertexShaderConstant ( "mLightPos" , reinterpret_cast<f32*>( &pos ) , 3 );

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

		// Set transposed world matrix
		core::matrix4 world = Driver->getTransform(video::ETS_WORLD);
		world = world.getTransposed();
		services->setVertexShaderConstant("mTransWorld", world.pointer(), 16);

// ICI
services->setVertexShaderConstant("background", reinterpret_cast<float*>(&background), 4);
} 

pixel_color_shader.frag :

Code c++ :

uniform sampler2D Texture1;
uniform vec4 background;

void main ( void )
{
    vec4 color = texture2D ( Texture1 , gl_TexCoord[0] );
    gl_FragColor = color * background;
}

vertex_color_shader.vert :

Code c++ :

uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform vec3 mLightPos;
uniform vec4 mLightColor;

void main ( void )
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = mWorldViewProj * gl_Vertex;
}

Pour le fichier pixel je comprends ce que je fais, par contre pour le fichier vertex je ne saisis pas trop pourquoi j'utilise:
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform vec3 mLightPos;
uniform vec4 mLightColor;
(Je me suis inspiré d'un tuto pas très complet et j'ai laissé comme çà).
En fait ce que je ne comprends pas c'est le rapport avec un vertex, qui est un point d'un mesh 3d non ?

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
135 invités en ligne
membre en ligne: -
RSS Feed