i have a very basic custom scenenode, that draws a rectangle in front of the camera with some basic calculations. I use it to make a fast and basic bloom-effect (I have found the idea in this forum, but it just worked with FPS-cameras).
My problem is, that directX don't draws this rectangle, if the camerarotation is between two particular angles. When i render with openGL the rectangle is drawn always.
Here are 2 pictures of it:
first the one with the bloom:
and then the one without:
I hope you see the difference.
and some code of the scenenode:
Code: Select all
CQuadSceneNode::CQuadSceneNode(scene::ISceneNode* parent,scene::ISceneManager* mgr,s32 id): scene::ISceneNode(parent, mgr, id)
{
Material.DiffuseColor = video::SColor(200,200,200,200);
Material.EmissiveColor = video::SColor(200,200,200,200);
Material.SpecularColor = video::SColor(200,200,200,200);
Material.ZBuffer = false;
Material.Wireframe = false;
Material.PointCloud = false;
Material.Lighting = false;
Material.BackfaceCulling = false;
Material.FogEnable = false;
Material.GouraudShading = false;
Material.NormalizeNormals = true;
Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
irr::video::E_DRIVER_TYPE dr = mgr->getVideoDriver()->getDriverType();
if (dr != video::EDT_OPENGL)
{
video::SColor Color = video::SColor(4,40,40,40);
VertexQuad[0]=video::S3DVertex(-1,1,1,0,0,0,Color,0,0);
VertexQuad[1]=video::S3DVertex(1,1,1,0,0,0,Color,1,0);
VertexQuad[2]=video::S3DVertex(-1,-1,1,0,0,0,Color,0,1);
VertexQuad[3]=video::S3DVertex(1,-1,1,0,0,0,Color,1,1);
}
else
{
video::SColor Color = video::SColor(4,34,34,34);
VertexQuad[0]=video::S3DVertex(-1,1,0,0,0,0,Color,0,0);
VertexQuad[1]=video::S3DVertex(1,1,0,0,0,0,Color,1,0);
VertexQuad[2]=video::S3DVertex(-1,-1,0,0,0,0,Color,0,-1);
VertexQuad[3]=video::S3DVertex(1,-1,0,0,0,0,Color,1,-1);
}
Box.reset(VertexQuad[0].Pos);
for (s32 i=1; i<4; ++i)
{
Box.addInternalPoint(VertexQuad[i].Pos);
}
}
void CQuadSceneNode::OnPreRender()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT);
ISceneNode::OnPreRender();
}
void CQuadSceneNode::render()
{
u16 indices[] = { 0,1,2, 3,2,1 };
video::IVideoDriver* driver = SceneManager->getVideoDriver();
vector3df vCamPos = SceneManager->getActiveCamera()->getPosition();
vector3df vPlayerPos = SceneManager->getActiveCamera()->getTarget();
vector3df vCamPlayer = (vPlayerPos-vCamPos);
vector3df vNormal1 = vector3df(0,1,0).crossProduct( vCamPlayer ).normalize();
vector3df vNormal2 = vNormal1.crossProduct( vCamPlayer ).normalize()*3/4;
vector3df vTempPoint = vCamPos + (vCamPlayer.normalize())*1.01;
VertexQuad[0].Pos = vTempPoint - vNormal1 - vNormal2;
VertexQuad[1].Pos = vTempPoint + vNormal1 - vNormal2;
VertexQuad[2].Pos = vTempPoint - vNormal1 + vNormal2;
VertexQuad[3].Pos = vTempPoint + vNormal1 + vNormal2;
driver->setMaterial(Material);
driver->drawIndexedTriangleList(&VertexQuad[0], 4, &indices[0], 2);
}