About Store Forum Documentation Contact



Post Reply 
Bump mapping with forward shading
Author Message
maxest Offline
Member

Post: #1
Bump mapping with forward shading
Is it possible to be done? I tried to modify bump mapping demo with putting LightDir into the Draw function and omitting Renderer function. What I get is flat mapping. Is the solution or Esenthel supports bump mapping only in DS mode?
01-30-2009 03:26 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Bump mapping with forward shading
Single Pass renderer supports only Flat and Normal Bump Mapping (it's specified in the docs\programming\rendering)

Additional bump mapping modes in this renderer will not be added, because estimated size of generated shaders would exceed 100 MB smile

Single Pass renderer is targetted only for old video cards
01-30-2009 03:44 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #3
Re: Bump mapping with forward shading
Well, I actually wanted to use NORMAL mapping, but this also doesn't want to work. What should I change i bumpmapping demo to get it work with forward renderer?
Here is the code
Code:
void SetEffect()
{
   mbox .setEffect();
   mball.setEffect();
}
/******************************************************************************/
void InitPre()
{
   App.name="Rendering Bumpmapping";
   App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
   PakAdd("data/engine.pak");

   D.set_effect=SetEffect          ; // set 'SetEffect' function to be used when needed
   D.full(false).bumpMode(BUMP_NORMAL); // start with flat bump mapping
}
/******************************************************************************/
Bool Init()
{
   Cam.dist=3;

   Material *material=Materials("data/mtrl/wood/0.mtrl");

   mbox .create(1).B(0).create( Box(4),VTX_TX0|VTX_NRM|VTX_TNG).reverse(); // create mesh box, reverse it because it's meant to be viewed from inside
   mball.create(1).B(0).create(Ball(1),VTX_TX0|VTX_NRM|VTX_TNG)          ; // create mesh ball

   // set mesh materials, rendering versions and bounding boxes
   mbox .setMaterial(material).setRender().setBox();
   mball.setMaterial(material).setRender().setBox();

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1,10,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT)); // move camera on right mouse button

   // change bump mapping when keys pressed
   if(Kb.bp(KB_1))D.bumpMode(BUMP_FLAT    );
   if(Kb.bp(KB_2))D.bumpMode(BUMP_NORMAL  );
   if(Kb.bp(KB_3))D.bumpMode(BUMP_PARALLAX);
   if(Kb.bp(KB_4))D.bumpMode(BUMP_RELIEF  );
   return true;
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {
      case RM_SOLID:
         mbox .draw(MatrixIdentity);
         mball.draw(MatrixIdentity);
      break;

      case RM_LIGHT:
          LightDir(Vec(0,-1,0)).add();
      break;
   }
}
void Draw()
{
//   Renderer(Render);
   D.clear(TURQ);
   LightDir(Vec(0,-1,0)).set();

   mbox .draw(MatrixIdentity);
   mball.draw(MatrixIdentity);

   D.text(0,0.9,S+"Fps "+Tm.fps);
   D.text(0,0.8,"Press 1,2,3,4 keys for different Bumpmapping modes");
}
/******************************************************************************/
01-30-2009 04:05 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
Re: Bump mapping with forward shading
the problem is in this code

Code:
void Draw()
{
//   Renderer(Render);
   D.clear(TURQ);
   LightDir(Vec(0,-1,0)).set();

   mbox .draw(MatrixIdentity);
   mball.draw(MatrixIdentity);

   D.text(0,0.9,S+"Fps "+Tm.fps);
   D.text(0,0.8,"Press 1,2,3,4 keys for different Bumpmapping modes");

this way you're using a simplified version of SIMPLE renderer

you should do this

Code:
void Draw()
{
   Renderer(Render);
   D.text(0,0.9,S+"Fps "+Tm.fps);
   D.text(0,0.8,"Press 1,2,3,4 keys for different Bumpmapping modes");
}

and in the material you're using the bump effect is only slightly visible, use "data/mtrl/brick/0.mtrl" for better effect
01-30-2009 04:18 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #5
Re: Bump mapping with forward shading
Now I feel totally lost. The code you showed was the starting code of this example, and it uses deferred shading. By now I really don't know which renderer (forward or deferred) is being used smile
01-30-2009 04:23 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
Re: Bump mapping with forward shading
Hi

you select renderers using Renderer.type(..) command

call this just once in InitPre or in Init
01-30-2009 04:42 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #7
Re: Bump mapping with forward shading
Thanks, not it finally works!
However, this comment just seem strange to me: "allow single pass rendering, this will load extra shaders and thus make the application to start much longer". Shouldn't deferred renderer take longer time to load shaders? wink
01-30-2009 05:04 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
Re: Bump mapping with forward shading
No,
Deferred shaders are always loaded, because they're the main and default renderer,
single pass (forward renderer) is optional and used only on demand of the programmer

so it is wheter you load
1)deferred only
or
2)deferred + forward shaders

As a side note : forward shaders in total are 10MB, and deferred are 6MB
01-30-2009 05:13 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #9
Re: Bump mapping with forward shading
One more question not connected with this topics (just to not start the new topic): how to make greater view-distance?
01-30-2009 05:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
Re: Bump mapping with forward shading
please set ViewportFull.range=1000; in InitPre()
01-30-2009 05:31 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #11
Re: Bump mapping with forward shading
Thanks a lot. And if you could tell me that... what do you use for directional lights that shadow maps look quite nicely? Just PSSM or some more sophisticated method? :>
01-30-2009 06:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
Re: Bump mapping with forward shading
smile the techniques that I'm using are my sweet secret wink
01-30-2009 06:35 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #13
Re: Bump mapping with forward shading
Of course. I won't ask again then smile
01-30-2009 06:46 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #14
Re: Bump mapping with forward shading
is there some example how to enable bumpmapping via world editor..
how does the setshader thing work that way?
06-19-2009 02:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
Re: Bump mapping with forward shading
Hi,

Bumpmapping in the World Editor will be available in the next version.

SetShader functions reset the shaders of a mesh.
06-19-2009 02:29 PM
Find all posts by this user Quote this message in a reply
Post Reply