Enable post processing for view entities

Posted By: Grafton

Enable post processing for view entities - 11/14/09 17:09

If view entities are used for such things as first person weapons or sun flares, you can not use post processing effects or the view entities will not be visible. So currently you must choose between having postprocessing effects or view entities.

It would be slightly better if view entities would be rendered on top of the post processing so at least they would be visible.

Ideally, it would be nice to set a flag for each view entity as to whether it will be rendered with the view (post processed) or after postprocessing (no pp effects, but visible).

Thanks for considering my suggestion.
Posted By: Germanunkol

Re: Enable post processing for view entities - 11/15/09 19:47

seconed. we've had the same problem and it took ages to find out why the entities weren't showing. very annoying.
Posted By: jcl

Re: Enable post processing for view entities - 11/16/09 10:32

If a view entity does not show, check the view parameters, like angle, arc, flags and so on. I don't think that this can be related to post processing - view entities are rendered together with panels and should not be affected by the view material at all.
Posted By: Germanunkol

Re: Enable post processing for view entities - 11/16/09 14:06

It had something to do with shaders... if I enabled them I had no view entities and then, without changing anything else except for disabling the shaders, i couldn't see the models any more. It wasn't angles or flags...

I have no clue about shaders, but I'll ask someone from my team to post.
Posted By: jcl

Re: Enable post processing for view entities - 11/16/09 16:36

How did you enable the shaders? Can you post the code?
Posted By: Grafton

Re: Enable post processing for view entities - 11/17/09 21:31

In much post processing the original view or subsequent views are blended with a view or views that are processed. Such as in a multipass bloom effect.

However it seems that currently if a bitmap is assigned to the camera view, for later processing, view entities will not appear.

The code below uses the workshop emboss example modified with a blob view entity and two lines that set up a bitmap for the camera view. As is, the view entity appears, but uncomment the lines to create the camera bitmap, and the view entity is not rendered.

Code:
ENTITY* blob =
{
  type = "blob.mdl";
  flags2 = SHOW;  
  x = 150; 
  y = 35; 
}
 
BMAP* camera_scene;
 
MATERIAL* mtlEmboss = {effect = "pp_emboss.fx"; }
VIEW* viewEmboss = {material = mtlEmboss; flags = PROCESS_TARGET;}
 
function main()
{
  //camera_scene = bmap_createblack(screen_size.x, screen_size.y,32);
  //camera.bmap = camera_scene; 
 
  camera.stage = viewEmboss;
  level_load("");
  ent_create("blob.mdl",vector(150,0,0),NULL);
}



This is also the reason why a user of shade-c's DOF, HDR or bloom effect find that their view entities are no longer visible with any of shade-c's effects enabled.


Posted By: BoH_Havoc

Re: Enable post processing for view entities - 11/17/09 23:24

I have the exact same problem.
As described by Grafton, when using shade-c, view entities will not be visible, as soon as i render the scene into a bmap.
Tried everything i could think of to solve this problem so i can release a fix for shade-c, but so far i didn't have any luck.

If rendering view entities into render targets isn't possible at all at the moment, please consider releasing a fix in the future. It's not urgent as you can use workarounds, but it would be nice to have that feature some day laugh
Posted By: jcl

Re: Enable post processing for view entities - 11/18/09 08:33

I'll look into this. Probably it's some side effect. We'll make sure that view entities at least stay visible when postprocessing is active.
Posted By: Grafton

Re: Enable post processing for view entities - 11/18/09 13:56

Thanks JCL, I hope you also consider creating the ability to add view entities to the post processing via a flag. A first person weapon or sun flares might look strange if they were the only parts of the scene without DOF, HDR, bloom etc.
Posted By: jcl

Re: Enable post processing for view entities - 11/24/09 11:38

I could not see anything wrong with your example, or any side effect that would make view entities invisible when postprocessing views are active. Of course you must not assign the entity to the postprocessing view, but to the real view.
Posted By: Grafton

Re: Enable post processing for view entities - 11/26/09 02:00

Hmm... did you uncomment the two lines in the example creating the "camera.bmap" as I indicated in my post?
Sorry, sometimes I am not so clear in my communication.

In this stand alone example below, the view entity is erroneously not visible because a rendertarget is assigned to the camera view, even though the rendertarget is not used, just assigned. Also it seems to make no difference to which view the entity is assigned. If you comment out the line "camera.bmap = camera_scene;", the view entity becomes visible.

Code:
BMAP* camera_scene;
VIEW* SecondView = {flags = PROCESS_TARGET;}

ENTITY* blob =
{
  type = "blob.mdl";
  flags2 = SHOW;  
  x = 150; 
  y = 35; 
}
 
function main()
{
  camera_scene = bmap_createblack(screen_size.x, screen_size.y,32);
  camera.bmap = camera_scene; // This prevents view entity visibility, comment out to test

  camera.stage = SecondView;
  level_load("");
  ent_create("blob.mdl",vector(150,0,0),NULL);
}



If I am not understanding, could you please post a simple two stage PP example (like above), that has a camera.bmap assigned and a visible view entity?

Thanks JCL.
Posted By: jcl

Re: Enable post processing for view entities - 11/26/09 08:45

Of course you don't see an entity on the screen when you render it into a bitmap instead.

http://manual.3dgamestudio.net/aview-bmap.htm

It makes only sense to give a view entity a render target when you want to view it in a panel or something like that. Otherwise, just render it straight on the screen.

Posted By: Grafton

Re: Enable post processing for view entities - 11/26/09 17:01

Thanks for your patience JCL.

When the view.bmap is used in a panel, the view entity is indeed visible. However if the view.bmap is used as a skin in a view material for an PP effect, it is not.

This sample illustrates the problem myself and the others are having. Here I render the view with the view entity to a bitmap and pass the bitmap to the second view material as skin1. All the effect does is return skin1 to the screen. I expect the original view with the view entity to be displayed (two blobs), however the view entity is not visible (only one blob).


Code:
BMAP* camera_scene = "#1024x768x32";

ENTITY* blob = { type = "blob.mdl";  flags2 = SHOW; x = 150; y = 35; }

MATERIAL* mtl_ShowRt = 
{	
  skin1 = camera_scene;

  effect = "
  Texture mtlSkin1; 
  sampler OrgSampler = sampler_state { texture = <mtlSkin1>;};

  float4 main_PS(float2 Tex: TEXCOORD0) : COLOR  { return tex2D(OrgSampler, Tex); }

  technique one { pass P1 { PixelShader = compile ps_2_0 main_PS(); } }";
}

VIEW* SecondView = { material = mtl_ShowRt; flags = PROCESS_TARGET;}

function main()
{
  video_set(1024,768,0,1); 
  camera.bmap = camera_scene; 
  camera.stage = SecondView;
  level_load("");
  ent_create("blob.mdl",vector(150,0,0),NULL);
}



In the above example, if I use a predefined bitmap for skin1 (such as "logo_800.jpg" from the GS folder), it is rendered to the screen as expected, however if I use the view.bmap, the view.bmap is not rendered to the screen.

This example is the same as above, except the view.bmp is rendered in a panel, correctly. Since the effect only renders the view.bmap to the screen, the screen should be a duplicate of the panels bitmap, but it is not!

Code:
BMAP* camera_scene = "#1024x768x32";

ENTITY* blob = { type = "blob.mdl";  flags2 = SHOW; x = 150; y = 35; }

PANEL * RT_Panel = {pos_x = 0; pos_y = 0; scale_x = 0.25; scale_y = 0.25; flags = SHOW;}

MATERIAL* mtl_ShowRt = 
{	
  skin1 = camera_scene;

  effect = "
  Texture mtlSkin1; 
  sampler OrgSampler = sampler_state { texture = <mtlSkin1>;};

  float4 main_PS(float2 Tex: TEXCOORD0) : COLOR  { return tex2D(OrgSampler, Tex); }

  technique one { pass P1 { PixelShader = compile ps_2_0 main_PS(); } }";
}

VIEW* SecondView = { material = mtl_ShowRt; flags = PROCESS_TARGET;}

function main()
{
  video_set(1024,768,0,1); 
  camera.bmap = camera_scene; 
  RT_Panel.bmap = camera_scene;
  camera.stage = SecondView;
  level_load("");
  ent_create("blob.mdl",vector(150,0,0),NULL);
}



Quote:

It makes only sense to give a view entity a render target when you want to view it in a panel or something like that. Otherwise, just render it straight on the screen.


Simple example; say I have weapon as a view entity, and I have a PP view chain (which passes the original view to the effect chain for blending). I want the PP effects to include the weapon or at least for the weapon to be visible. This does not seem possible.

If I (and the others) can not do this, then beginners will never "get it" either. If it is possible, then please provide an example.

Thanks.
Posted By: jcl

Re: Enable post processing for view entities - 11/27/09 08:53

Hmm, I don't think that it's so difficult to "get" it. At least, many people use PP and view entities and we've never heard that anyone had problems with them.

But I'll do my best to make this issue more clear in the manual. You only need to understand one simple thing: view entities are totally unaffected by PP effects. They are rendered after all the views. Thus they just look plain on the screen. You can not use them for a view material simply because they are not yet rendered at the time when the views are processed.

If you want PP effects for a weapon, the obvious solution is to use a normal level entity and move it with the camera. It's just the same when you want other level effects like dynamic lights, fog, etc for your weapon - all this is not available for view entities. I think this is just sort of logical.
Posted By: Grafton

Re: Enable post processing for view entities - 11/27/09 18:24

The weapon senerio is only one. For example, I can not have quality DOF or Bloom applied to "sun flares" (view ents) unless the flare sprites are level entities? I dont think that is workable. I will have to choose between the two.

It seems that view entities are rendered in the first (camera) view. So that view cannot have a RT or the view ents will not be visible at all. Also, view ents can not be rendered to an RT for use elsewhere and also be visible on the screen. This makes post processing them tough.

The purpose of my post was to request a solution for view entity PP, or a working example if its possible, and I have, I'm done.

Thanks.



Posted By: Petra

Re: Enable post processing for view entities - 11/27/09 18:55

Hmm, why do you render all the time your view entities into a bitmap instead of just on the screen? I think that's what all the people tried to tell you, you just must not render them with a render target view when you want them visible.

I am using Shade-C and have many view entities for a compass and other elements, never had a problem with them. I just render them with a normal view.
Posted By: Grafton

Re: Enable post processing for view entities - 11/27/09 21:59

Originally Posted By: Petra
Hmm, why do you render all the time your view entities into a bitmap instead of just on the screen?


I do not. The examples I provide do. This thread is about post processing view entities, thus the title; "Enable post processing for view entities".

Originally Posted By: Petra

I think that's what all the people tried to tell you,

Huh? All what people? Perhaps there is some miscommunication.

Originally Posted By: Petra

you just must not render them with a render target view when you want them visible.


Then you can not post process the view entities to match the view, which again, is the subject of this thread, and the basis of my request.

Originally Posted By: Petra

I am using Shade-C and have many view entities for a compass and other elements, never had a problem with them. I just render them with a normal view.


If you are using shade-c and have visible view entities, then you are not using shade-c's PP. Shade-c's PP effects are set up to render the camera.view to a rendertarget exactly like the examples above, so you must either rewrite shade-c to use an additional, later view to supply this target, or in some way assign the view ent to a different view that does not use a rendertarget (not currently possible?), just to get the view ent visible. Neither of these solve the problem of post processing the view ent as part of the scene.

My request is simply to be able to choose via a flag, to postprocess a view ent with the rest of the scene or not.

Apologies if my post seems somewhat short, but I am weary of this topic.

Thanks for your interest.












Posted By: Matt_Aufderheide

Re: Enable post processing for view entities - 11/27/09 22:48

The obvious solution is to grab the frame buffer after all rendering (besides panels) and then do post processing.

I dont know why the engine isn't set up like this.
Posted By: Spirit

Re: Enable post processing for view entities - 11/28/09 06:30

Matt, I think this would not be good, you often need different postprocessing in different views. That would not work with postprocessing the whole frame buffer. Its better to postprocess views separately.

Grafton, Petra is right, your invisible view ent was just a clear mistake in your code. Thats what people tried to tell you all the time, you still seem not to understand.

You must not render them into the camera target bmap. You must render them with a normal view on the screen. Thats just missing in your code. When you dont assign a normal view, the entity uses the camera view by default and then you cant see it because of your code. Its this simple, no new engine feature required here.

I have lens flares together with a HDR shader that I took from a shader lib, I believe it was shade-C. Its using many render targets and I also never had a problem with my view ents.
Posted By: Grafton

Re: Enable post processing for view entities - 11/28/09 13:30

Originally Posted By: Spirit

Grafton, Petra is right, your invisible view ent was just a clear mistake in your code. Thats what people tried to tell you all the time, you still seem not to understand.


Are you and Petra the same person? All what people? Who are you talking about? Other than Petra, the others in this thread support my request. There is no mistake. I know the posted code does not work, thats why I posted it, to illustrate it does not. I would like it to work, thus my request to enable PP for view ents. I want postprocessing to affect view ents if i choose. This can be done if the view ents can be both visible and renderable to a target map.

Originally Posted By: Spirit

You must not render them into the camera target bmap. You must render them with a normal view on the screen. Thats just missing in your code. When you dont assign a normal view, the entity uses the camera view by default and then you cant see it because of your code. Its this simple, no new engine feature required here.


My request is to simply to be able to choose via a flag, to postprocess a view ent with the rest of the scene or not.
You currently can not do this, ergo the feature request.

Originally Posted By: Spirit

I have lens flares together with a HDR shader that I took from a shader lib, I believe it was shade-C. Its using many render targets and I also never had a problem with my view ents.


As even stated by the developer, Shade-c does not render view ents visibly. I even explained why. It sounds as if you just have visible view entities and stripped some fx code from shade-c, please explain how you are post processing the view entities so the effect is shared on them as it would be a level entity that uses a RTT in its effect chain? That is the topic of this thread and the crux of my request.

Thanks for your interest.





Posted By: Slin

Re: Enable post processing for view entities - 11/28/09 14:32

I think it would be good if a view entity would just get rendered after the scene and after the postprocessed fullscreenquad.

That would mean that the view entity attached to the view rendering the scene would be completely postprocessed and the one attached to the last postprocessing stages view wouldn´t be post processed. That seems the most logical way to me as I think that a flag wouldn´t really work.

I have no idea how far it is possible to have view and postprocessing at one time.

Edit:
Missed this part of one of jcls posts:
Quote:

They [view entities] are rendered after all the views.

But why are view entites attached to views?
When are panels rendered?
Wouldn´t it then make more sense to sort views, view entities, panels, ... all together by layers and to allow rendering view entities into bmaps the way panels can be rendered into a bmap?
I could then just set the camera layer to 0, the one of my view entity to 1 andthe one of my camera.stage to 2, set the same render targets for camera and the view entity and could postprocess it in camera.stage.
Probably just some stupid, senseless thinking...
Posted By: Spirit

Re: Enable post processing for view entities - 11/28/09 14:48

As far as I understand it works this way:

First, all views are rendered, including all postprocessing.

Then, view entities and panels are rendered, so they both appear above the postprocessed views but show no postprocessing themselves. I see my flare sprites over your Shade-C HDR effect but the flares dont contribute to the HDR effect itself.

View entities can probably be attached to a view only for rendering them with a certain aspect and arc, and also for rendering them into the target bitmap of that view. That was that thing that Grafton had his problem with.

You can see the rendering order when you check the layers. View entities appear above panels when they have a higher layer, this would not be possible when they were rendered before postprocessing. But views appear always below panels and view entities.
Posted By: jcl

Re: Enable post processing for view entities - 11/30/09 07:14

To come to a conclusion of this lenghty thread: There were two problems, view entities not being visible, and view entities not being subject to postprocessing. I hope we can now agree that the first one was just a script problem, but the second one is real.

The reason is that view entities were originally not meant to be part of the scene, they were meant as 3D panel elements. Thus they are not rendered together with the scene, but together with panels.

I'll check if I can change that in some way for postprocessing view entities. But in the mean time, you can easily use level entities for that purpose. Most other engines have no "view entities" anyway and nevertheless support guns, flares, etc. They just use a vec_for_screen function for placing an entity at a screen position. You can easily do the same when you want guns or flares to be subject to postprocessing.

I'm even willing to do that for you - donate some cool sun flare sprites to the community and I'll donate a script that renders them as light or sun flares, including postprocessing. Do we have a deal? laugh
© 2024 lite-C Forums