[Fixed]SVN Rev 824 and EMT_TRANSPARENT_VERTEX_ALPHA OGL
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, you did not say that you tried a recent SVN revision, you simply said that you have the same problem. But it was said to be solved.
So go on and post some code you used for the test. I cannot reproduce the error. Maybe it's just your shader which flips the coords. Do you use RTT or just plain shaders?
So go on and post some code you used for the test. I cannot reproduce the error. Maybe it's just your shader which flips the coords. Do you use RTT or just plain shaders?
-
- Competition winner
- Posts: 95
- Joined: Wed Nov 30, 2005 8:53 am
- Location: France : midi pyrénées
I have tested now with the tmg's shader that i have made small modification and i have converted it to HLSL for testing with directx9.
Here the shader code :
Now the code of the sample 10.Shaders in the irrlicht LATEST SVN 888 examples folder :
With DX9 except the text that work fine, with openGL there is a bug.
maybe this bug appear only when you use another shader in the program because with the sample QuakeMap the glow work perfect.
Thanks you Hybrid.
Here the shader code :
Code: Select all
#ifndef __POST_PROCESS_EFFECT_BLOOM__
#define __POST_PROCESS_EFFECT_BLOOM__
#include "irrlicht.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
struct Bloom_Setup
{
video::SColorf Contrast;
video::SColorf Brightness;
float blurSize;
};
class Bloom_callback: public video::IShaderConstantSetCallBack
{
public:
video::SColorf Contrast;
video::SColorf Brightness;
float blurSize;
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
services->setPixelShaderConstant("Brightness", reinterpret_cast<f32*>(&Brightness),4);
services->setPixelShaderConstant("Contrast", reinterpret_cast<f32*>(&Contrast),4);
services->setPixelShaderConstant("blurSize", reinterpret_cast<f32*>(&blurSize),1);
}
};
class IPostProcessBloom : public scene::ISceneNode
{
public:
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[5];
video::SMaterial Material;
video::ITexture* rt0;
int mat;
Bloom_callback* callback;
IPostProcessBloom(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id): scene::ISceneNode(parent, mgr, id)
{
video::SColor Color = video::SColor(0,0,0,0);
Vertices[0]=video::S3DVertex(-1,1,0,0,0,0,Color,0,0);
Vertices[1]=video::S3DVertex(1,1,0,0,0,0,Color,1,0);
Vertices[2]=video::S3DVertex(-1,-1,0,0,0,0,Color,0,1);
Vertices[3]=video::S3DVertex(1,-1,0,0,0,0,Color,1,1);
}
void initiate(unsigned int sizeW,unsigned int sizeH,Bloom_Setup data,scene::ISceneManager* smgr)
{
c8 vertShaderDX[]=
"struct VS_OUTPUT\n" \
"{\n" \
"float4 pos : POSITION0;\n" \
"float2 texCoord : TEXCOORD0;\n" \
"};\n" \
"VS_OUTPUT vs_main( float4 inPos: POSITION )\n" \
"{\n" \
"VS_OUTPUT o = (VS_OUTPUT) 0;\n" \
"inPos.xy = sign( inPos.xy);\n" \
"o.pos = float4( inPos.xy, 0.0, 1.0);\n" \
"// get into range [0,1]\n" \
"o.texCoord = (float2(o.pos.x, -o.pos.y) + 1.0)/2.0;\n" \
"return o;\n" \
"}\n";
c8 pixShaderDX[]=
"sampler2D tex;\n" \
"float4 Contrast;\n" \
"float4 Brightness;\n" \
"float blurSize;\n" \
"float4 saturate(float4 inp)\n" \
"{\n" \
"return clamp(inp, 0.0f, 1.0f);\n" \
"}\n" \
"float4 ps_main( float2 texCoord : TEXCOORD0 ) : COLOR\n" \
"{\n" \
"//Initialisation\n" \
"float4 outp = float4(0.0, 0.0, 0.0, 0.0);\n" \
"//Texture\n" \
"outp = tex2D(tex,texCoord );\n" \
"//Saturation\n" \
"float4 c = float4(2.0,2.0,2.0,1.0) * (float4(1.0,1.0,1.0,1.0) - Contrast);\n" \
"outp = saturate((outp - float4(0.5,0.5,0.5,0.5)) * c + float4(0.5,0.5,0.5,0.5));\n" \
"float4 b = (float4(1.0,1.0,1.0,1.0) - Contrast * float4(2.0,2.0,2.0,1.0));\n" \
"outp = saturate(outp + b);\n" \
" float2 samples[12];\n" \
" samples[0] = texCoord + blurSize * float2(-0.326212, -0.405805);\n" \
" samples[1] = texCoord + blurSize * float2(-0.840144, -0.073580);\n" \
" samples[2] = texCoord + blurSize * float2(-0.695914, 0.457137);\n" \
" samples[3] = texCoord + blurSize * float2(-0.203345, 0.620716);\n" \
" samples[4] = texCoord + blurSize * float2(0.962340, -0.194983);\n" \
" samples[5] = texCoord + blurSize * float2(0.473434, -0.480026);\n" \
" samples[6] = texCoord + blurSize * float2(0.519456, 0.767022);\n" \
" samples[7] = texCoord + blurSize * float2(0.185461, -0.893124);\n" \
" samples[8] = texCoord + blurSize * float2(0.507431, 0.064425);\n" \
" samples[9] = texCoord + blurSize * float2(0.896420, 0.412458);\n" \
" samples[10] = texCoord + blurSize * float2(-0.321940, -0.932615);\n" \
" samples[11] = texCoord + blurSize * float2(-0.791559, -0.597705);\n" \
" float4 sample = tex2D(tex, texCoord);\n" \
" float4 avg = sample;\n" \
" float4 col;\n" \
" for (int i = 0; i < 12; i++)\n" \
" {\n" \
" float2 tC=min(float2(0.999,0.999),max(float2(0.001,0.001),samples[i]));\n" \
" col=tex2D(tex,tC );"
" float intensity=col.r+col.g+col.b;\n" \
" avg += col;\n" \
" }\n" \
" avg /= 13.0;\n" \
" outp += avg;\n" \
"outp *= Brightness;\n" \
"outp.a = 0.4;\n" \
"return outp;\n" \
"}\n";
c8 vertShader[] =
"varying vec2 vTexCoord;\n" \
"void main(void)\n" \
"{\n" \
"vec2 Position;\n" \
"Position.xy = sign(gl_Vertex.xy);\n" \
"gl_Position = vec4(Position.xy, 0.0, 1.0);\n" \
"//vTexCoord =Position.xy * 0.5 + 0.5;\n" \
"vTexCoord = (vec2(Position.x, -Position.y) + 1.0)/2.0;\n" \
"}\n";
c8 fragShader[] =
"varying vec2 vTexCoord;\n" \
"uniform sampler2D tex;\n" \
"uniform vec4 Contrast;\n" \
"uniform vec4 Brightness;\n" \
"uniform float blurSize;\n" \
"vec4 saturate(vec4 inp)\n" \
"{\n" \
"return clamp(inp, 0.0, 1.0);\n" \
"}\n" \
"void main(void)\n" \
"{\n" \
"//Initialisation \n" \
"vec4 outp = vec4(0.0, 0.0, 0.0, 0.0);\n" \
"//Texture \n" \
"outp = texture2D(tex,vTexCoord );\n" \
"//Saturation \n" \
"vec4 c = vec4(2.0,2.0,2.0,1.0) * (vec4(1.0,1.0,1.0,1.0) - Contrast);\n" \
"outp = saturate((outp - vec4(0.5,0.5,0.5,0.5)) * c + vec4(0.5,0.5,0.5,0.5));\n" \
"vec4 b = (vec4(1.0,1.0,1.0,1.0) - Contrast * vec4(2.0,2.0,2.0,1.0));\n" \
"outp = saturate(outp + b);\n" \
" vec2 samples[12];\n" \
" samples[0] = vTexCoord + blurSize * vec2(-0.326212, -0.405805);\n" \
" samples[1] = vTexCoord + blurSize * vec2(-0.840144, -0.073580);\n" \
" samples[2] = vTexCoord + blurSize * vec2(-0.695914, 0.457137);\n" \
" samples[3] = vTexCoord + blurSize * vec2(-0.203345, 0.620716);\n" \
" samples[4] = vTexCoord + blurSize * vec2(0.962340, -0.194983);\n" \
" samples[5] = vTexCoord + blurSize * vec2(0.473434, -0.480026);\n" \
" samples[6] = vTexCoord + blurSize * vec2(0.519456, 0.767022);\n" \
" samples[7] = vTexCoord + blurSize * vec2(0.185461, -0.893124);\n" \
" samples[8] = vTexCoord + blurSize * vec2(0.507431, 0.064425);\n" \
" samples[9] = vTexCoord + blurSize * vec2(0.896420, 0.412458);\n" \
" samples[10] = vTexCoord + blurSize * vec2(-0.321940, -0.932615);\n" \
" samples[11] = vTexCoord + blurSize * vec2(-0.791559, -0.597705);\n" \
" vec4 sample = texture2D(tex, vTexCoord);\n" \
" vec4 avg = sample;\n" \
" vec4 col;\n" \
" for (int i = 0; i < 12; i++)\n" \
" {\n" \
" vec2 tC=min(vec2(0.999,0.999),max(vec2(0.001,0.001),samples[i]));\n" \
" col=texture2D(tex,tC );"
" float intensity=col.r+col.g+col.b;\n" \
" avg += col;\n" \
" }\n" \
" avg /= 13.0;\n" \
" outp += avg;\n" \
"outp *= Brightness;\n" \
"outp.a = 0.4;\n" \
"gl_FragColor = outp;\n" \
"}\n";
video::IVideoDriver* driver = smgr->getVideoDriver();
video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();
callback= new Bloom_callback();
callback->Contrast=data.Contrast;
callback->Brightness=data.Brightness;
callback->blurSize=data.blurSize;
if (driver->getDriverType() == video::EDT_OPENGL)
{
Material.MaterialType=(E_MATERIAL_TYPE) gpu->addHighLevelShaderMaterial(vertShader,"main",video::EVST_VS_1_1,fragShader,"main",video::EPST_PS_1_1,callback,(video::EMT_TRANSPARENT_VERTEX_ALPHA));
}
else
{
Material.MaterialType=(E_MATERIAL_TYPE) gpu->addHighLevelShaderMaterial(vertShaderDX,"vs_main",video::EVST_VS_2_0,pixShaderDX,"ps_main",video::EPST_PS_2_0,callback,(video::EMT_TRANSPARENT_VERTEX_ALPHA));
}
rt0 = driver->createRenderTargetTexture(core::dimension2d<s32>(sizeW,sizeH));
Material.Wireframe = false;
Material.Lighting = false;
Material.Textures[0]=rt0;
}
virtual void render()
{
u16 indices[] = { 0,1,2, 3,2,1 };
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 2);
}
virtual u32 getMaterialCount(){return 1;}
virtual video::SMaterial& getMaterial(u32 i){return (Material);}
virtual const core::aabbox3d<f32>& getBoundingBox() const{return Box;}
};
#endif
Code: Select all
/*
This tutorial shows how to use shaders for D3D8, D3D9 and OpenGL
with the engine and how to create new material types with them. It also
shows how to disable the generation of mipmaps at texture loading, and
how to use text scene nodes.
This tutorial does not explain how shaders work. I would recommend to read the D3D
or OpenGL documentation, to search a tutorial, or to read a book about this.
At first, we need to include all headers and do the stuff we always do, like
in nearly all other tutorials:
*/
#include <irrlicht.h>
#include <iostream>
#include <PostProcessBloom.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
/*
Because we want to use some interesting shaders in this tutorials, we
need to set some data for them to make them able to compute nice
colors. In this example, we'll use a simple vertex shader which will
calculate the color of the vertex based on the position of the camera.
For this, the shader needs the following data: The inverted world matrix
for transforming the normal, the clip matrix for transforming the position,
the camera position and the world position of the object for the calculation
of the angle of light, and the color of the light. To be able to tell the
shader all this data every frame, we have to derive a class from the
IShaderConstantSetCallBack interface and override its only method,
namely OnSetConstants(). This method will be called every time the material
is set.
The method setVertexShaderConstant() of the IMaterialRendererServices interface
is used to set the data the shader needs. If the user chose to use a High Level shader
language like HLSL instead of Assembler in this example, you have to set the
variable name as parameter instead of the register index.
*/
IrrlichtDevice* device = 0;
bool UseHighLevelShaders = false;
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
// 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();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mInvWorld", invWorld.pointer(), 16);
else
services->setVertexShaderConstant(invWorld.pointer(), 0, 4);
// set clip matrix
core::matrix4 worldViewProj;
worldViewProj = driver->getTransform(video::ETS_PROJECTION);
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
if (UseHighLevelShaders)
services->setVertexShaderConstant("mWorldViewProj", worldViewProj.pointer(), 16);
else
services->setVertexShaderConstant(worldViewProj.pointer(), 4, 4);
// set camera position
core::vector3df pos = device->getSceneManager()->
getActiveCamera()->getAbsolutePosition();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mLightPos", reinterpret_cast<f32*>(&pos), 3);
else
services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 8, 1);
// set light color
video::SColorf col(0.0f,1.0f,1.0f,0.0f);
if (UseHighLevelShaders)
services->setVertexShaderConstant("mLightColor", reinterpret_cast<f32*>(&col), 4);
else
services->setVertexShaderConstant(reinterpret_cast<f32*>(&col), 9, 1);
// set transposed world matrix
core::matrix4 world = driver->getTransform(video::ETS_WORLD);
world = world.getTransposed();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mTransWorld", world.pointer(), 16);
else
services->setVertexShaderConstant(world.pointer(), 10, 4);
}
};
/*
The next few lines start up the engine. Just like in most other tutorials
before. But in addition, we ask the user if he wants this example to use
high level shaders if he selected a driver which is capable of doing so.
*/
int main()
{
// let user select driver type
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
// ask the user if we should use high level shaders for this example
if (driverType == video::EDT_DIRECT3D9 ||
driverType == video::EDT_OPENGL)
{
printf("Please press 'y' if you want to use high level shaders.\n");
std::cin >> i;
if (i == 'y')
UseHighLevelShaders = true;
}
// create device
device = createDevice(driverType, core::dimension2d<s32>(800, 600));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
/*
Now for the more interesting parts.
If we are using Direct3D, we want to load vertex and pixel shader programs, if we have
OpenGL, we want to use ARB fragment and vertex programs. I wrote the
corresponding programs down into the files d3d8.ps, d3d8.vs, d3d9.ps, d3d9.vs,
opengl.ps and opengl.vs. We only need the right filenames now. This is done in the
following switch. Note, that it is not necessary to write the shaders into text
files, like in this example. You can even write the shaders directly as strings
into the cpp source file, and use later addShaderMaterial() instead of
addShaderMaterialFromFiles().
*/
c8* vsFileName = 0; // filename for the vertex shader
c8* psFileName = 0; // filename for the pixel shader
switch(driverType)
{
case video::EDT_DIRECT3D8:
psFileName = "../../media/d3d8.psh";
vsFileName = "../../media/d3d8.vsh";
break;
case video::EDT_DIRECT3D9:
if (UseHighLevelShaders)
{
psFileName = "../../media/d3d9.hlsl";
vsFileName = psFileName; // both shaders are in the same file
}
else
{
psFileName = "../../media/d3d9.psh";
vsFileName = "../../media/d3d9.vsh";
}
break;
case video::EDT_OPENGL:
if (UseHighLevelShaders)
{
psFileName = "../../media/opengl.frag";
vsFileName = "../../media/opengl.vert";
}
else
{
psFileName = "../../media/opengl.psh";
vsFileName = "../../media/opengl.vsh";
}
break;
}
/*
In addition, we check if the hardware and the selected renderer is capable
of executing the shaders we want. If not, we simply set the filename string
to 0. This is not necessary, but useful in this example: For example, if
the hardware is able to execute vertex shaders but not pixel shaders, we create
a new material which only uses the vertex shader, and no pixel shader.
Otherwise, if we would tell the engine to create this material and the engine
sees that the hardware wouldn't be able to fullfill the request completely,
it would not create any new material at all. So in this example you would see
at least the vertex shader in action, without the pixel shader.
*/
if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1))
{
device->getLogger()->log("WARNING: Pixel shaders disabled "\
"because of missing driver/hardware support.");
psFileName = 0;
}
if (!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
{
device->getLogger()->log("WARNING: Vertex shaders disabled "\
"because of missing driver/hardware support.");
vsFileName = 0;
}
/*
Now lets create the new materials.
As you maybe know from previous examples, a material type in the Irrlicht engine
is set by simply changing the MaterialType value in the SMaterial struct. And this
value is just a simple 32 bit value, like video::EMT_SOLID. So we only need the
engine to create a new value for us which we can set there.
To do this, we get a pointer to the IGPUProgrammingServices and call
addShaderMaterialFromFiles(), which returns such a new 32 bit value. That's all.
The parameters to this method are the following:
First, the names of the files containing the code of the vertex and the pixel shader.
If you would use addShaderMaterial() instead, you would not need file names, then you
could write the code of the shader directly as string.
The following parameter is a pointer to the IShaderConstantSetCallBack class we wrote
at the beginning of this tutorial. If you don't want to set constants, set this to 0.
The last paramter tells the engine which material it should use as base material.
To demonstrate this, we create two materials with a different base material, one
with EMT_SOLID and one with EMT_TRANSPARENT_ADD_COLOR.
*/
// create materials
video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();
s32 newMaterialType1 = 0;
s32 newMaterialType2 = 0;
if (gpu)
{
MyShaderCallBack* mc = new MyShaderCallBack();
// create the shaders depending on if the user wanted high level
// or low level shaders:
if (UseHighLevelShaders)
{
// create material from high level shaders (hlsl or glsl)
newMaterialType1 = gpu->addHighLevelShaderMaterialFromFiles(
vsFileName, "vertexMain", video::EVST_VS_1_1,
psFileName, "pixelMain", video::EPST_PS_1_1,
mc, video::EMT_SOLID);
newMaterialType2 = gpu->addHighLevelShaderMaterialFromFiles(
vsFileName, "vertexMain", video::EVST_VS_1_1,
psFileName, "pixelMain", video::EPST_PS_1_1,
mc, video::EMT_TRANSPARENT_ADD_COLOR);
}
else
{
// create material from low level shaders (asm or arb_asm)
newMaterialType1 = gpu->addShaderMaterialFromFiles(vsFileName,
psFileName, mc, video::EMT_SOLID);
newMaterialType2 = gpu->addShaderMaterialFromFiles(vsFileName,
psFileName, mc, video::EMT_TRANSPARENT_ADD_COLOR);
}
mc->drop();
}
/*
Now time for testing out the materials. We create a test cube
and set the material we created. In addition, we add a text scene node to
the cube and a rotation animator to make it look more interesting and
important.
*/
// create test scene node 1, with the new created material type 1
scene::ISceneNode* node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,0,0));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
smgr->addTextSceneNode(gui->getBuiltInFont(),
L"PS & VS & EMT_SOLID",
video::SColor(255,255,255,255), node);
scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator(
core::vector3df(0,0.3f,0));
node->addAnimator(anim);
anim->drop();
/*
Same for the second cube, but with the second material we created.
*/
// create test scene node 2, with the new created material type 2
node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,-10,50));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
smgr->addTextSceneNode(gui->getBuiltInFont(),
L"PS & VS & EMT_TRANSPARENT",
video::SColor(255,255,255,255), node);
anim = smgr->createRotationAnimator(core::vector3df(0,0.3f,0));
node->addAnimator(anim);
anim->drop();
/*
Then we add a third cube without a shader on it, to be able to compare the
cubes.
*/
// add a scene node with no shader
node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,50,25));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->addTextSceneNode(gui->getBuiltInFont(), L"NO SHADER",
video::SColor(255,255,255,255), node);
/*
And last, we add a skybox and a user controlled camera to the scene.
For the skybox textures, we disable mipmap generation, because we don't
need mipmaps on it.
*/
// add a nice skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// add a camera and disable the mouse cursor
scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
cam->setPosition(core::vector3df(-100,50,100));
cam->setTarget(core::vector3df(0,0,0));
device->getCursorControl()->setVisible(false);
/*
Now draw everything. That's all.
*/
IPostProcessBloom *Bloom = new IPostProcessBloom(smgr->getRootSceneNode(), smgr, 666);
Bloom_Setup setup;
setup.Contrast=video::SColorf(0.8f,0.8f,0.8f,0.8f);
setup.Brightness=video::SColorf(1.0f,1.0f,1.0f,0.4f);
setup.blurSize=0.007f;
Bloom->initiate(384,384,setup,smgr);
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,0,0,0));
driver->setRenderTarget(Bloom->rt0, true, true, video::SColor(0,0,0,0));
smgr->drawAll();
driver->setRenderTarget(0);
smgr->drawAll();
Bloom->render();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
maybe this bug appear only when you use another shader in the program because with the sample QuakeMap the glow work perfect.
Thanks you Hybrid.