Pixel shader for all screen

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Fernado Alonso

Pixel shader for all screen

Post by Fernado Alonso »

Hi, i know how put a new material for a one SceneNode with shaders and a funtion SetMeaterial. But i have a other question

I want apply a filter for all screen ( paint all green , or motion blur, etc)
My question is How can i apply one pixel shader (filter) to all screen when it is painted yet , without change the material of the scene node?

Example :

1) I render a scene , each SceneNode with your own Material (shader)
2) To the result (the screen, image result) i want apply other pixel shader (filter)
3) I put the total result in the screen

How can i do this in irrlicht??
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

i used that to make a night vision shader

here is how
-code the shader
-apply it to a billborad
-make the billboard a child of the camera
-apply the shader to the bill node wich has a render to texture texture(with render target of the same camera)

howver there is a bug where the billboard vibrate when the camera moves
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

i used that to make a night vision shader

here is how
-code the shader
-apply it to a billborad
-make the billboard a child of the camera
-apply the shader to the bill node wich has a render to texture texture(with render target of the same camera)

howver there is a bug where the billboard vibrate when the camera moves
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

Post by genesys »

hum . . . i thought about that as well . . . but there must be a better solution than that! this really sounds like "do it your self" effects . . .

by the way - if i understand you right you're using the same camera for the render to texture as you use to render the billboard . . .

you could just take two cameras - one for the render to texture and a secound (which won't ever move) for rendering the billboard for the final output . . .
Fernando Alonso

Post by Fernando Alonso »

Very thanks for your replies, i was sure Omaremad read this thread :-)

It sound very difficult, plz can you put a example (mini-tutorial) about your two tecnhiques??

have Anyone written a shader "hemispherical lighting" or any light for outdoor scenes?

shaders, shaders.... too powerfull , but we need examples with irrlicht :-)
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

Post by genesys »

what do you mean with hemispherical lighting? If you mean ambient occlusion, this is atm not possible without raytracing . . .


I recommend that you use rendermonkey to write your HLSL shaders because it's verry easy to use and straightforward - and as soon as you get the desired result, you port it to irrlicht . . .
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

i am not going to explain my above method since it is so bad that when the camera moves the billboard for some reason lags and artifacts happen

howver i found this tecqnique which is called "screen space effect" wich ill try and implement and then ill tell you
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

btw i founf the screen space stuff the same as my method
so here is the explanation

i found the artifacts are less when the billboard is far away

Code: Select all

//render 2 texture setup
video::ITexture* rt = 0;
	rt = driver->createRenderTargetTexture(core::dimension2d<s32>(1000,1000));

	scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
	cam->setPosition(core::vector3df(-100,50,100));
	cam->setTarget(core::vector3df(0,0,0));


ISceneNode*node;
node = smgr->addBillboardSceneNode(cam, core::dimension2d<f32>(50, 50));
	node->setMaterialFlag(video::EMF_LIGHTING, false);

			node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
node->setMaterialTexture(0, rt); // set material of cube to render target

	node->setPosition(core::vector3df(0,-20,50));



//render loop

	while(device->run())
		if (device->isWindowActive())
	{
		driver->beginScene(true, true, video::SColor(255,0,0,0));
		// draw scene into render target
			/*we do all this invisble and visble stuff so the camera doesnt see the billboard its rendering 2
			// set render target texture
			driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));     

			// make billboard invisible and set fixed camera as active camera
			node->setVisible(false);
			
			smgr->setActiveCamera(cam);

			// draw whole scene into render buffer
			smgr->drawAll();                 

			// set back old render target
			driver->setRenderTarget(0);      

			// make the cube visible and set the user controlled camera as active one
			node->setVisible(true);
			
			smgr->setActiveCamera(cam);

		smgr->drawAll();
		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;
		}
	}
[/code]
Fernando Alonso

Post by Fernando Alonso »

very very thanks , i am going to trying it. i will tell you what about with it :-)
Thulsa Doom
Posts: 63
Joined: Thu Aug 05, 2004 9:40 am
Location: Germany

Post by Thulsa Doom »

Hello people,
excuse me for the maybe offtopic question in this thread.
omaremad wrote: -make the billboard a child of the camera
...
howver there is a bug where the billboard vibrate when the camera moves
Is this a known bug?
If not, I will post a bug report.
I expire vibration on a *.3ds scenenode attached to the camera.
THX 4 input.
Fernando Alonso

Post by Fernando Alonso »

what do you mean with hemispherical lighting? If you mean ambient occlusion, this is atm not possible without raytracing . . .
No you are wrong. Hemisp. Lighitng is a tecnique for shader in real time for outdoor scenes

Example :
developer.nvidia.com/object/FX_Composer_Shaders.html

There is a book very good for shaders for videogames "Shaders for Game Programmers and Artists", but it use DirectX or OpenGL . I want learn to use shaders with irrlicht. In irrlicht is very easy use a shader for a one sceneNode (setMaterial) , but there are very shaders (type filters or Lighting outdoor) where it is necesary apply for all scene nodes or apply to the result of the render of one scene. I thinl there is a bit of examples of tecniques of shaders with irrlicht We need more tutorial of the guru people
Post Reply