maxest
Member
|
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 |
|
Esenthel
Administrator
|
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
Single Pass renderer is targetted only for old video cards
|
|
01-30-2009 03:44 PM |
|
maxest
Member
|
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 |
|
Esenthel
Administrator
|
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 |
|
maxest
Member
|
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
|
|
01-30-2009 04:23 PM |
|
Esenthel
Administrator
|
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 |
|
maxest
Member
|
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?
|
|
01-30-2009 05:04 PM |
|
Esenthel
Administrator
|
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 |
|
maxest
Member
|
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 |
|
Esenthel
Administrator
|
Re: Bump mapping with forward shading
please set ViewportFull.range=1000; in InitPre()
|
|
01-30-2009 05:31 PM |
|
maxest
Member
|
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 |
|
maxest
Member
|
Re: Bump mapping with forward shading
Of course. I won't ask again then
|
|
01-30-2009 06:46 PM |
|
b1s
Member
|
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 |
|
Esenthel
Administrator
|
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 |
|