This is my shader code:
Code: Select all
float4x4 mWVP;
struct v_out
{
float4 pos : POSITION;
};
v_out v_main( float4 pos : POSITION )
{
v_out Out = (v_out)0;
Out.pos = mul(pos, mWVP);
return Out;
}
float4 p_main() : COLOR
{
return float4(1.0, 0.5, 0.5, 1.0);
}
Code: Select all
class SkyShader : public video::IShaderConstantSetCallBack
{
private:
IrrlichtDevice *device;
public:
SkyShader( IrrlichtDevice *_device )
{
device = _device;
}
virtual void OnSetConstants(video::IMaterialRendererServices* services,
s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
core::matrix4 WVP;
WVP = driver->getTransform(video::ETS_WORLD);
WVP *= driver->getTransform(video::ETS_VIEW);
WVP *= driver->getTransform(video::ETS_PROJECTION);
services->setPixelShaderConstant("mWVP", WVP.pointer(), 16);
}
};
//**************************
SkyShader *skyShader = new SkyShader(irr->device);
s32 skyMat = irr->gpu->addHighLevelShaderMaterialFromFiles("data//shaders//sky.hlsl", "v_main", EVST_VS_3_0,
"data//shaders//sky.hlsl", "p_main", EPST_PS_3_0,
skyShader, EMT_SOLID);
IMesh *skyMesh = irr->scene->getMesh("data//models//skysphere.x");
scene::ISceneNode* skyNode = irr->scene->addMeshSceneNode(skyMesh);
skyNode->setPosition(vector3df(0, 0, 0));
skyNode->setScale(vector3df(1, 1, 1));
skyNode->setMaterialFlag(EMF_LIGHTING, false);
skyNode->setMaterialType((video::E_MATERIAL_TYPE)skyMat);