[GSoC 2012] Off-Screen Particles project - continuation

Threads related to Google Summer of Code
Post Reply
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

I need to really see you are working and not just saying you are working, how can we improve that?
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

I've just uploaded version of application code and scripts from few days ago to repository (from 18.07 and 23.07 and some older versions of only scripts also in .zip archives). Since last update it has proof of concept and some levels of transformation into compositor (still working on chain of compositors). Some commented code of "application level" program have been deleted and code have been little more divided to separate functions.

About update that i am preparing right now:
On some step I've been doing tests and modyfying scripts code only on the set of solid objects (they had a given material without original colour), where particles were displayed only as a control (their red channel was displayed).

Currently during transferring all shaders from compositor chain to one compositor I've discovered that somewhere in between it stopped working in DirectX - only in OpenGL. (Exactly it was when I was trying to modify script to display colours of particles when it was a separate rendering group). I'm locating on which step hard to identify between composotors, there was some error not exactly specified in *.log file that makes the difference between working in Dx9 and OpenGL.


Recently I swapped from compressing everything to compositor named "OSP_SolidMaterialsBuffer" to compositor "OSP_AllInOne" and I'm checking on every step that it works in both DirectX and OpenGL -that is what I am doing right now, at this very moment.

It starts from separating solid objects and particles rendering by their RenderGroup ID and successful joining them back again - I am preparing this version for next commit.

Commented code and sripts:
At the moment compositors that I've used yesterday are not used in this test -they are commented in application code in function "SetCompositors()" so you can uncomment them if you want to check what is going on inside.
Also their scripts are still in script files. If you would like to uncomment compositor chain in SetCompositors() - you do not need to uncomment "OSP_DownsampleDepth" - it is already joined with OSP_SolidMaterialsBuffer compositor, they are one.

EDIT: I've uploaded zip archive file of yesterdays sript (27.07), but it is not ready - it is used just for backup.

In this hour I'm just putting "OSP_JoinSolidAndTransparent" compositor into an "OSP_AllInOne" compositor in the way that source textures are not ones set from application level, but they are textures defined in just the same compositor... It will be ready for commit to repository soon (together with commented yesterdays version).

Just after commit I'm putting downsample in between of splitting and merging (on every step checking if it still works in both: DirectX and OpenGL) - that is how I'll find on which step there was a malfunction.
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

ok.
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

Ok, joining separated textures (separated by difference in renderQueue ID) is close to be ready. After some reseatch and tests on my own joining shader (alpha blending) and ones supported by OGRE in script language of material i've noticed that particles texture rendered to a separate target is very exotic (i mean output alpha):

Particle effects rendered to a separate texture seem to be displayed better in additive way of joining textures.
In case of red-blue smoke, the colour is too transparent in both: alpha blending and additive way.

As the particle texture is generated, smoke particles really can hide fire behind them, etcetera - however it seems that final output alpha is strangely too small.

I'll have to do depth testing and particles rendering on my own now, so I could know exactly what is happening.

In case of flames, output texture seems to be completely solid so they are rendered in additive way for sure.
To sum up, I need to find better way of saving particles texture - universal for both: particle effects with depth testing and light particles that are additive.

Compositor for dividing and putting particles texture layer over solid objects layer:

Code: Select all

compositor OSP_AllInOne
 {
     technique
     {
         texture solid target_width target_height PF_R8G8B8A8
         texture particles target_width target_height PF_R8G8B8A8
 
         target solid
         {
             input none
             shadows off
             pass clear{}
 
             pass render_scene
             {
                 first_render_queue 10
                 last_render_queue  10            
             }
         }
 
         target particles
         {
			 input none
             //shadows off
             pass clear{}
			
             pass render_scene
             {
                 first_render_queue 20
                 last_render_queue  20
             }
         }
 
         target_output
         {
             input none
             pass clear{}
             pass render_quad
             {
                 material OSP_JoinSolidAndTransparent2 //DeferredShading/Post/SimpleQuad
                 input 0 solid 
				 input 1 particles
             }
         }
     }
 }
material for joining (I've commented use of own shader, because on this level of test id does just alpha blending)
faster ways to test properties of particles texture was using colour_op_ex operation.

Code: Select all

material OSP_JoinSolidAndTransparent2
{
    technique
    {
        pass
        {
			depth_check off
			
			/*
            fragment_program_ref OSP_JoinSolidAndTransparent2_fp {}
			vertex_program_ref Ogre/Compositor/StdQuad_vp{}
			*/

            texture_unit
            {
			    /*
				tex_address_mode clamp
				filtering linear linear linear// none
                tex_coord_set 0
				*/
			}
			texture_unit
            {
			
				//colour_op_ex blend_texture_alpha src_texture src_current
				//colour_op_ex blend_current_alpha src_texture src_current
			    colour_op_ex add src_current src_texture
			    //colour_op alpha_blend //IF YOU USE THAT LINE OR UNCOMMENT SHADERS, EFFECT IS THE SAME
				
				
				/*
				tex_address_mode clamp
				filtering linear linear linear// none
                tex_coord_set 0
				*/
			}
        }
    }
}
In this case additive version is chosen (we can see that it works wrong for dark particles).
Alpha blending seems to show that alpha of smoke AND of fumes is still too small and alpha of flames too big.
Fumes are renderes with modified version of smoke - they are displayed a little beter in additive mode, because they are nearly white.

To sum up, I believe in hypothesis that with in current particle layer texture: alpha under a pixel is alpha of last rendered particle (that is why smoke is too transparent in both: additive and alpha blend). I am not 100% sure, but it seems like it. Without splitting It just makes nodofference for particles, because they are rendered based on what currently is rendered under them.

PS:
Although everything will change when I render particles on my own (with soft particles /depth test), it would be nice to know If there is already an existing configuration of saving them into layer where output alpha is just appropriate (universally additive output texture or with universal alpha-blending).
I guess that if such rendering method exists, it would be some configuration used in this part of compositor:

Code: Select all

          target particles
         {
			 input none
             //shadows off
             pass clear{}
			
             pass render_scene
             {
                 first_render_queue 20
                 last_render_queue  20
             }
         }
Perhaps adding a material with use of two different "alpha_op_ex" attributes depending on kind of particle?[/color]
If that solution does not exist, than I'll do my own version to calculate output alpha when emissive and simple particles are forked between eachother (each time I will have to recognise the kind of particle on level of shader - that might be a little obstacle).
With simple particles, I would use method that I've described on Jul 12, 2012 1:58 and for emissive I'd have to modify previous colour of layer in emissive way, calculate aplha from normalised brightness of colour and update alpha of layer simmilar way like in simple particles...
Last edited by Karol Badowski 1989 on Sat Jul 28, 2012 11:19 pm, edited 1 time in total.
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

Comitted to repository (sripts and application from 28.07).
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

At the moment I am putting previous shaders to current compositor - when it is ready, I'll attempt to apply modifications to the way how particles are rendered. That means of cours depth test, ectc, but also finding a way to modify way of rendering their alpha channel - it needs to be unified and as I mentioned before, colour (except alpha) needs to remain displayed in SIMILAR way that it was displayed before (so remain additive / alpha blending or other, depending on original material... however, with modification of weight of backround colour, because we are operating on a semi-tranparent layer - not on constant colour background).
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

At the moment I am still trying to find best way of modifying materials of particles and solid objects, so they are just modified (and not completely replaced).
If I do not find better solution, I'll try to use MaterialGenerator ( like in solution used by Ahmedismaiel in softparticles project )
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

I've still been trying to find the best way to modify materials for this case (instead of replacing them completely).
Tomorrow I'll continue that, but today I'll clear my mind by starting doing the next missing steps (so the work could move forword faster) which is writing next compositor passes that will be put in this compositor anyway after render of downsampled particles texture (creating stencil sompositor pass that uses a constant mask texture, and if it works today: creating the mask in runtime - with Sobel filter).
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

Try to move faster if you can. We don't have a lot of time.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

What about the daily update? what about progress?
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

Alive?
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

Is everything ok?
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

This is looking grim.
Watch out for my OGRE related tweets here.
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: [GSoC 2012] Off-Screen Particles project

Post by drwbns »

I agree. I've been watching this thread from the start and it's been a rollercoaster...I think this and the DX11 project may not finish in time
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

This is the only project I have such big communication issues with...
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

Sorry for delay in communication.
Since saturday I've been still trying to solve my problem with modification of original materials, but I've also created Sobel filter (first just horizontal, then changed it to one that adds and clamps vertical version and mirrors of them both, so it detects edges from all sides).
Samples for matrix are taken from coordinates depending on texture element size in both axis (so it would work also for rectangular downsample).
I've tested it on rgb colour channels - it works properly (in final version it works only on alpha channel).

Since some time I've been also trying to apply output texture to stencil buffer to use stenciling in OGRE the proper way with provided hardware acceleration (using stencil section in next pass of compositor script instead of comparing 2 textures in one shader).

At the moment I am doing your tutorial on stencil buffer from level of application (using RenderSystem class). My objective is to achieve update of stencil buffer from texture, like in here:
Assaf Raman wrote:(...)
Image Image
(...)
(due to documentation, I think (but am not 100% sure) that I'll have to use Ogre::StencilOperation set to SOP_REPLACE and set referenced value (I am looking for some working example where it is done)).
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

No no, don't use the stencil.
You should do everything with compositors.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

Stick to the original article...
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

In article there is mentioned that full resolution rendering has to be done with stenciling, using buffer created with sobel filter to create a mask. I understood it this way: that for each pixel - stencil buffer value is checked, if it is not a value high enough, "discard" operation is used in shader.

(in Compositor there is also stencil {} section, so I assumed it is the "right way" for OGRE version, however i haven't found yet an example how to update this stencil buffer reference value attribute).

Right now I have a texture achieved with sobel filter (I would like to apply value of this texture to a stencil buffer - set value 1 if output of sobel filter is high enough or value 0 if it is low).

So in the next pass, the full resolution texture of particles would be rendered straight to earlier prepared solid objects texture (only in pixels where stencil buffer has value 1). Next, the downsampled particles texture would be rendered (without depth check, using alpha-blending).


For now I'll try to apply "discard" operation just exactly like in tutorial and come back to figuring out how to apply my depth test shader without loosing original material colour (figuring this out will mean end of problems, because it will let me solve similar issue with other compositor pass material the analogical way, so any advice is always helpful).
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

I see, if this is the case - I need to read the article better.
If you do need stencil - it is not that hard to use, view the code for my minimal stencil use demo: http://www.ogre3d.org/forums/viewtopic.php?t=27477
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

I've already been reading this demo code (there is use of stencil buffer from level of application instead of compositor, but it is analogic, because it has a script equivalence in "stencil{}" section parameters so should be possible to achieve the same in Compositor). It seems that stencil buffer is modified, but with a constant value for entire rendered quads (well, not entire, because not in transparent part of these quads - perhaps this is a solution?).

I'm interested in an example "dynamic wiping" that you have presented on page number two of mentioned forum thread (setting stencil buffer values based on a mask texture). (Did you manage to achieve success in your attempt to write OGRE equivalence of that application?)

I guess that in case of using [stencil section script code/or equivalent application code] instead of "discard" operation in CG shader, I would need to set desired value from my calculated sobel texture, to a "ref_value" attribute in "stencil{}" section;

Many forums about that issue end with questions without an answer, but I will continue to look for technique to set that value in mentioned thread.
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

The dynamic wiping can be done with compositors - so I never finished doing it with with the stencil.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

I understand what you want to do, I am not sure you will be able to get it to work with compositors, but you can just render the upscaled texture to a full screen quad that check the stencil - after you finish rendering the object and marking the stencil.
Watch out for my OGRE related tweets here.
Karol Badowski 1989
Google Summer of Code Student
Google Summer of Code Student
Posts: 185
Joined: Fri Apr 06, 2012 3:04 pm
x 18

Re: [GSoC 2012] Off-Screen Particles project

Post by Karol Badowski 1989 »

For my previous dilemma with modification of material (to extract information about depth without loosing colours and to unify alpha and additive blending techniques), I'll just use same solution as in Deferred shading (that means that original material is analysed similarly to what is happening in GBufferSchemeHandler::inspectPass and then new material is created by material generator simmilar to GBufferMaterialGenerator.

That transformation, like in Deffered shading, will be executed only during first rendering of object.

Only unfortunate solution there (that I do not like, but I know how to do, cose I used it before) is that in Deferred shading, compositor is split and there is a communication between compositors (passing textures) that makes everything a bit slower. I believe that splitting compositor will not be mandatory.

It seems to be the best way and there is only little above 1 week till 20'th of august, so there will be no better idea of achieving that missing goal.

At the moment I am reading GBufferSchemeHandler::inspectPass.
Google Summer of Code 2012 Student
Topic: "Implementation of Off-Screen Particles"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2012] Off-Screen Particles project

Post by Assaf Raman »

There are only a few days for the 'pencils down' date, I want to tell you in advance that without a working demo of the article, with clear commented code - you are going to fail, you have until the end of week to finish the project to that stage. Else - I am going to fail you.
I just want things to be clear.
If I where you - I wouldn't wait for the last day - because I may have comments to the work, and if they are not completed - I am also going to fail you.
Watch out for my OGRE related tweets here.
Post Reply