Page 1 of 2

How to make a gradient on the background color

Posted: Fri Apr 18, 2008 11:29 pm
by arfgh
Is possible to produce a background gradient on the scene ?
I don`t know have any idea to do.

Posted: Sat Apr 19, 2008 12:37 am
by Kriolyth
Draw a full-screen quad with vertex colors you need and lighting disabled. Turn off Z-buffer as well.

Posted: Sat Apr 19, 2008 12:04 pm
by arfgh
can someone show some example ?

also, is not possible to create the gradient using only the background color ?

Posted: Sat Apr 19, 2008 12:40 pm
by hybrid
Questions is what a gradient with just the background color would be. You know, gradients need at least two colors...
But no, there's no toehr way, and the suggested one is pretty simple.

Posted: Sat Apr 19, 2008 1:22 pm
by arfgh
well hybird. Maybe is simple, but if we need to disable the z-buffer this will affect to the quality of the whole scene ?

Posted: Sat Apr 19, 2008 2:02 pm
by hybrid
No, because you only disable it for rendering the quad (which is in the background anyway).

Posted: Sat Apr 19, 2008 2:26 pm
by arfgh
ok hybrid, but can you show me n example of the use of this procedure ? i am very new at all this :(

Posted: Mon Apr 21, 2008 5:27 am
by kornwaretm
make that background on adobe or what ever tools u have. use the

Code: Select all

virtual void irr::video::IVideoDriver::draw2DImage  (  const video::ITexture *  texture,  
  const core::rect< s32 > &  destRect,  
  const core::rect< s32 > &  sourceRect,  
  const core::rect< s32 > *  clipRect = 0,  
  video::SColor *  colors = 0,  
  bool  useAlphaChannelOfTexture = false 
 )  [pure virtual] 
put this code before the smgr->drawAll();
ofcourse u cant use skydome or sky box for your scene, otherwise your background will covered.
can you please read the Irrlicht Engine 1.4 API documentation
it is located on \irrlicht-1.4\doc\irrlicht.chm , on your hardDrive.
there's also some (one may be...) example about drawing 2d image included with the engine.

Posted: Mon Apr 21, 2008 12:50 pm
by arfgh
we are not talking about to put a texture on screen.
We are talking about to make a plane to show a gradient using the vertex colors.

Posted: Mon Apr 21, 2008 1:40 pm
by JP
Look at the custom scene node example/tutorial and work from there. It shows you how to do gradient colours and it shows how to construct shapes, you should be able to figure out how to create just a plane instead of the pyramid type shape.

Posted: Mon Apr 21, 2008 1:59 pm
by arfgh
yes but the problem is the fact i need this plane be on the background and covering the full irrlicht window.

Posted: Mon Apr 21, 2008 2:16 pm
by JP
So you've got your plane with the gradient coded and working? If not then get that working first, then you can tackle the problem of making it fill the background.

You could draw it by parenting the node to the camera and making it large enough to fill the view (fairly small and close to the camera should do it). When it's actually rendered you'll want to make sure the z write is disabled, that can be done in the material setting of the custom scene node, check the API for the correct way of doing this.

Posted: Mon Apr 21, 2008 6:47 pm
by arfgh
anyways JP what tutorial you mean ?

Posted: Mon Apr 21, 2008 9:31 pm
by vitek
Holy hell. The custom scene node example is included in the Irrlicht distribution in examples/03.CustomSceneNode/main.cpp. You already have the file on your machine, you just need to look at it.

Travis

Posted: Tue Apr 22, 2008 7:50 am
by JP
Yeah... there's not much more you can say apart from the custom scene node tutorial.... That's as descriptive as it gets :P