Hi Thorsten,

> I still haven't given up on the idea of 'masking' the terrain pixel
> shading by the cockpit, since even a very simple mask easily makes
> the system 50% faster for me. Lauri has kindly given me some
> instructions on how to use the stencil buffer - so the idea was to
> start by filling the stencil buffer with a mask whenever there is an
> opaque pixel in the model.
> 
> In order to do so, I added this pass in front of the first pass
> declared in model-default.eff
> 
> <pass>
> <stencil>
> <function>always</function>
> <value>1</value>
> <pass>replace</pass>
> </stencil>
> <alpha-test>
> <comparison>gequal</comparison>
> <value type="float">0.99</value>
> </alpha-test>
> <depth>
> <write-mask>false</write-mask>
> </depth>
> </pass>
> 
> What happened is that I got the near camera rendered fine, but as
> good pretty much nothing from the far camera.
> 
> I can insert the same code before the first pass declared in
> terrain-default.eff where it doesn't have any harmful side effects,
> the scene renders just fine. So the code as such isn't defunct. It
> seems I can insert no pass whatsoever before the first pass declared
> in model-default.eff without disabling the far camera.
> 
> Which means there is something I don't understand at all.
> 
> Is there absolute meaning to the passes, i.e. are all first passes
> done first, then the information obtained there is in the buffers
> and available for all other effects when the second passes run, or
> are passes only a means to establish relative order in the effect
> files? Why can't I add passes to model rendering, but I can to
> terrain, clouds or trees?
> 
> I've tried to understand what is happening in CameraGroup.cxx, but I
> have no real clue - the whole context beats me, I don't even see
> where near or far camera are defined. Some explanations perhaps?

The relevant code for passes is here :
https://gitorious.org/fg/simgear/blobs/next/simgear/scene/material/Technique.cxx#line165

A pass is an OSG StateSet, a collection of OpenGL states that have a draw order
( the <render-bin> bin number ). This code renders geometry n times, one time 
for 
each pass. You have to understand that at this stage, geometry is only stored 
in 
collections and after all the scene is traversed, these collections (render 
bins)
are sorted before the draw stage. The end result is that all geometry having a 
pass that have an order num of 0 is rendered before any geometry having a pass 
of 
higher order num.

What can happen with the two cameras is that the stencil buffer is shared, but 
I 
don't think it is cleared between the rendering of the far camera and the 
rendering 
on the near camera, so you may end up accumulating both camera in a single 
buffer.

If you want to experiment, try to change line 668 of renderer.cxx, and change :

camera->setClearMask(GL_DEPTH_BUFFER_BIT);

to :

camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

Regards,
-Fred

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to