[GSoC 2012] Off-Screen Particles project - continuation

Threads related to Google Summer of Code
Post Reply
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 was preparing answer mainly about setting just the depth without the colour.
I finally finished it.
There were few reports in commits to repository.

Depth is now passed simplest as it can be to texture that has 32 bits (only one channel for float in red channel).
All happens in vertex program.
Fragment program is used only for passing TEXCOORD (single float). To texture (also single float) PF_FLOAT32_R.

Texture is not rendered - it is passed to next componen right now.

I think it could not be simplified more.

Right now I am doing the post-effect.

This is how rendering to a texture looks right now (detailed description in revision comments - this one has a lot of things corrected):
compositor

Code: Select all

compositor OSP_SolidMaterialsBuffer
{
    technique
    {
        // GBuffer enconding: --------------------------------------------------
        // depthTexture: r --> normalized linear depth [0, 1]
        // ---------------------------------------------------------------------
        
        texture depthTexture target_width target_height PF_FLOAT32_R chain_scope
        texture occlusion target_width target_height PF_FLOAT32_RGBA chain_scope

        target depthTexture
        {
            input none
            shadows off
            
            pass clear 
			{
			    buffers colour depth stencil
				depth_value 1.0 
			}

            pass render_scene {}
        }
    }
}


compositor OSP_ShowDepth
{
    technique 
    {
        texture_ref occlusion OSP_SolidMaterialsBuffer occlusion

        target occlusion
        {
            input none
            
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material OSP_ShowDepth
            }
        }
    }
}

compositor OSP_PostFilter
{
    technique 
    {
        target_output
        {
            input none
            
            pass render_quad
            {
                material OSP_PostFilter
            }
        }
    }
}
material

Code: Select all

//DepthBuffer

material OSP_SolidMaterialsBuffer
{
    technique
    {
        pass
        {	 
            vertex_program_ref OSP_SolidMaterialsBuffer_vp
            {
                param_named_auto worldViewProjection worldviewproj_matrix
			    param_named_auto depthRange scene_depth_range
            }

            fragment_program_ref OSP_SolidMaterialsBuffer_fp
            {
            }
        }
    }
}

//------------------------------------------------

material OSP_ShowDepth
{
    technique
    {
        pass
        {
            depth_check off

			vertex_program_ref Ogre/Compositor/StdQuad_vp {}			
            fragment_program_ref OSP_ShowDepth_fp {}

            texture_unit 
            {
                content_type compositor OSP_SolidMaterialsBuffer depthTexture
                tex_address_mode clamp
                filtering none
            }

            /*texture_unit
            {
                texture gray256.png
                tex_address_mode wrap
                filtering none
            }*/
        }
    }
}

//---------------------------------------------------

material OSP_PostFilter
{
    technique
    {
        pass
        {
            cull_hardware none
			cull_software none
			depth_check off
			
			vertex_program_ref Ogre/Compositor/StdQuad_vp {}
            fragment_program_ref OSP_PostFilter_fp {}

            texture_unit
            {
                content_type compositor OSP_SolidMaterialsBuffer occlusion
                tex_address_mode clamp
                filtering none
            }
        }
    }
}
program

Code: Select all

vertex_program OSP_SolidMaterialsBuffer_vp_cg cg
{
    source OSP.cg
    entry_point OSP_SolidMaterialsBuffer_vp
    profiles vs_2_x arbvp1
}
vertex_program OSP_SolidMaterialsBuffer_vp unified
{
	delegate OSP_SolidMaterialsBuffer_vp_cg
}

fragment_program OSP_SolidMaterialsBuffer_fp_cg cg
{
    source OSP.cg
    entry_point OSP_SolidMaterialsBuffer_fp
    profiles ps_3_0 arbfp1
}
fragment_program OSP_SolidMaterialsBuffer_fp unified
{
	delegate OSP_SolidMaterialsBuffer_fp_cg
}

//------------------------------------------------

fragment_program OSP_ShowDepth_fp_cg cg
{
    source OSP.cg
    entry_point OSP_ShowDepth_fp
    profiles ps_2_x arbfp1
}
fragment_program OSP_ShowDepth_fp unified
{
	delegate OSP_ShowDepth_fp_cg
}

//------------------------------------------------

fragment_program OSP_PostFilter_fp_cg cg
{
    source OSP.cg
    entry_point OSP_PostFilter_fp
    profiles ps_3_0 ps_2_x arbfp1
}
fragment_program OSP_PostFilter_fp unified
{
	delegate OSP_PostFilter_fp_cg 
}
shader

Code: Select all

void OSP_SolidMaterialsBuffer_vp(
        float4 inputPosition : POSITION,

        out float4 outputPosition : POSITION,
        out float outputDepth : TEXCOORD0,

        uniform float4x4 worldViewProjection,
		uniform float4 depthRange
        )
{
        outputPosition = mul(worldViewProjection, inputPosition);
		outputDepth = (outputPosition.z - depthRange.x) * depthRange.w;
}

void OSP_SolidMaterialsBuffer_fp(
        float inputDepth : TEXCOORD0,
        out float oDepth : COLOR   //linear depth [0, 1]
		)
{
		oDepth = inputDepth;
}


void OSP_ShowDepth_fp
(
    in float2 iTexCoord: TEXCOORD0, 
    
    out float4 oColor0 : COLOR0,

    uniform sampler depthTexture: register(s0)
)
{
    float depth = tex2D(depthTexture, iTexCoord).r;
    oColor0 = float4(depth,depth,depth, 1);
}

void OSP_PostFilter_fp (
    in float2 uv : TEXCOORD0,
    out float4 oColor0 : COLOR0,

    uniform sampler sOcclusion : register(s0)
)
{
    oColor0 = float4(tex2D(sOcclusion, uv).xyz, 1);
} 
I've red this morning the link You have posted. I'm trying to apply that solution.
When i red this post it turned out that "mask" symtax was just proposition.
Solution in the end is the same solution as in Deffered Shading, so I suppose it is the only one correct (render queue + litenets + identifier bits). I found that helpfull.

About order of rendering:
I simplified depth acquisition to fit it.
It seems that presented proposition is two-pass solution for colour and for depth. (that means the most heavy one).

Rigt now colour (defined by default materials given to objects on level of *.cpp) is lost, because special material had to be granted to objects that acquire depth (it will change when I give a new pass to material, by material listeners + rendering queues).

One-pass would mean that you have to take everything into considetarion (setting normals, lights, everything that people could think of, to calculate colour in the same pass) in one vertex program. I haven't found yet solution that would do everything, without listener - so I think your proposition to continue multiple-pass soltion is good.


At the moment "show depth" material is temporary one .
Compositor "Show depth" uses textures acquired by buffer compositor to create and render output texture. For step 3 used in particle effects, I'll use simmilar structure to get multiple textures from previous passes to mage depth test there.

I am wondering if my current solution will have to be rebuilt completely when I add rendering_queque (I hope that rendered textures won't be lost between two queues).
Last edited by Karol Badowski 1989 on Sat Jul 07, 2012 11:43 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
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 »

Yes, but can you finish the sample I suggested?
It is only two render to texture - and writing the compositor - based on the shader code from the article.
You are welcome to integrate your one pass depth code (nice work on that by the way) - but lets try to focus on what we want - off screen particles...

What do you say? How do you want to proceed?
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 »

Yes, I can finish it (previous post above updated).
It is much simpler than one I was trying to do.

I also think that the structure used for now for sharing textures between compositors will be good enough when I add rendering_queues + identificators, as you suggested.
How do you want to proceed?
This is the order of tasks:

a) As soon as downsampling is finished, I'll Implement masking to exclude particles from created passes and to exclude rest of the scene from depth testing - analogous to examples (listeners + masks given by identificators + rendering queue).
I have all needed examples for succesfully implementing listeners.

I'd like to give a third mask to semi-transparent non-particle objects (Explained few days ago) - TO DO LATER (for now see next step)

b) When masking is ready, I'll acquire downsampled depth texture (the same way the "show depth" compositor acquired non-downsampled depth texture right now).
In that pass I'll modify vertex shader for particles (scale in x and y of woldViewProjection as kind of downsampling before pixel shader) - so the created small output texture would easily be referenced to appropriate fields of depth texture and so the view would scale to fit texture, instead of cutting view edges) unless it is already covered by POSITION parameter that is passed between verex and fragment program - I've recognised that it is modified (some dimensions are cut), so it is possible that it is also already scaled.
In pixel shader of this pass there is going to be depth testing - it will use depth texture taken from previous rendering queue, as one of sources.

d)STEPS FOR FUTURE (could be skipped for a second until step c) of compositor chain is implemented)
Ouput texture will go to next pass (when it works, It will be merged with previous pass). This pass will create new texture (original size) - for Sobel filter.
Then I'll have to spend a little bit time on stenciling. (entire process will be repeated without downsampling on pixels that fit stencil mask).

c)STEP FOR INSTANT IMPLEMENTATION - this will be executed last, but can be implemented just after depth testing texture is created.
Rendering to screen will take as an input: full-size colour texture of solid objects, small texture of particles (/after steps d), also full-size texture of particles and stencil mask).
Last edited by Karol Badowski 1989 on Sun Jul 08, 2012 1:03 am, edited 2 times 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 »

Karol Badowski 1989 wrote:In pixel shader of this pass there is going to be depth testing - it will use depth texture taken from previous rendering queue, as one of sources.
In this pixel shader, the depth is needed too, so I'll copy THE SAME depth acquisition method to antecedending vertex shader. It has to be exactly the same method.
On this step it will turn out whether depth created and scaled by scene_depth_range is better, or the one created with near_clip_distance and far_clip_distance.
Why? Because of alpha-blending and soft-patricles. There will be a difference in accuracy/cost of rendering.


FURTHER-FURTHER steps MODIFICATIONS (after previous steps a)-c) are done):
Both of alpha blending/soft particles will be added to this fragment program as alternative modification to be used in compositor chain, to be executed in one pass of depth-test renderiing of particles. Well, it seems that a lot will happen in one fragment program.

There is also blur considered as an alternatively good post-effect done on resizing particle texture to full-size - also to be implemented later.
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 implementing downsampling compositor with constant scale. When finished, I'll move to point a) from the list above.

In compositor OSP_SolidMaterialsBuffer new texture is added:

Code: Select all

texture depthTextureDownsampled2x2 target_width_scaled 0.5 target_height_scaled 0.5 PF_FLOAT32_R chain_scope
Compositor called in place where "OSP_ShowDepth" compositor is called right now.

Code: Select all

compositor OSP_DownsampleDepth
{
    technique 
    {
		texture_ref depthTexture OSP_SolidMaterialsBuffer depthTexture
		texture_ref depthTextureDownsampled2x2 OSP_SolidMaterialsBuffer depthTextureDownsampled2x2

        target depthTextureDownsampled2x2
        {
            input none
            pass render_quad
            {
                material OSP_DownsampleDepth
				input 0 depthTexture
            }
        }
    }
}
You can see it is similar to structure of bloom compositor, where texture rt0 is achieved from texture rt_output, but here ir is referenced from other compositor (OSP_SolidMaterialsBuffer).
The same compositor will be referenced in depth testing compositor to further use that texture.

Now I'm implementing shader, idea based on shader solutions used in these two materials: "Ogre/Compositor/BrightPass2" and "Ogre/Compositor/HDR/Downsample2x2Luminence".
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 »

Depth downsampling is ready - I think it is allright. I'll have to write a shader that will test the output texture.
I'll make revision to repository now.

I have almost finished also maximum of depth downsampling (to reference neighbour pixels of texture coordinate, I use

Code: Select all

				param_named_auto texelSize inverse_texture_size 0 //inversed sizes of depthTexture
).. well this will be in next revision.
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 »

Fixed scale downsamples use arrays of offsets.

I've implemented version for any possible size of single sample (scaleA x scaleB) // parameters actually are inversions of scale
They are set right now to a constant value, but they will be passed as uniform parameter in the future.

Is the solution with for(;;) loops correct (allowed) in cg fragment shaders?

Modification to compositor OSP_SolidMaterialsBuffer:

Code: Select all

compositor OSP_SolidMaterialsBuffer
{
    technique
    {
        // GBuffer enconding: --------------------------------------------------
        // depthTexture: r --> normalized linear depth [0, 1]
        // ---------------------------------------------------------------------
        
        texture depthTexture target_width target_height PF_FLOAT32_R chain_scope
        texture depthTextureDownsampled2x2 target_width_scaled 0.5 target_height_scaled 0.5 PF_FLOAT32_R chain_scope
        texture occlusion target_width target_height PF_FLOAT32_RGBA chain_scope

        target depthTexture
        {
            input none
            shadows off
            
            pass clear 
			{
			    buffers colour depth stencil
				depth_value 1.0 
			}

            pass render_scene {}
        }
    }
}
Media for Depth downsampling (used on objects with given material OSP_SolidMaterialsBuffer):

Compositor

Code: Select all

compositor OSP_DownsampleDepth
{
    technique 
    {
		texture_ref depthTexture OSP_SolidMaterialsBuffer depthTexture
		texture_ref depthTextureDownsampled2x2 OSP_SolidMaterialsBuffer depthTextureDownsampled2x2

        target depthTextureDownsampled2x2
        {
            input none
            pass render_quad
            {
                material OSP_DownsampleDepth
				input 0 depthTexture
            }
        }
    }
}
material

Code: Select all

material OSP_DownsampleDepth
{
    technique
    {
        pass
        {
			cull_hardware none
			cull_software none
            depth_check off

			vertex_program_ref Ogre/Compositor/StdQuad_vp {}			
            fragment_program_ref OSP_DownsampleDepth_fp
			{
				param_named_auto texelSize inverse_texture_size 0 //inversed sizes of depthTexture
			}

            texture_unit 
            {
                tex_coord_set 0
                //content_type compositor OSP_SolidMaterialsBuffer depthTexture
                tex_address_mode clamp
                filtering none
            }
        }
    }
}
program

Code: Select all

fragment_program OSP_DownsampleDepth_fp_cg cg
{
    source OSP.cg
    entry_point OSP_DownsampleDepth_fp
    profiles ps_2_x arbfp1
}
fragment_program OSP_DownsampleDepth_fp unified
{
	delegate OSP_DownsampleDepth_fp_cg
}
shader

Code: Select all

void OSP_DownsampleDepth_fp
(
    in float2 iTexCoord: TEXCOORD0, 
    out float outputDepth : COLOR0, //red channel only texture
    uniform sampler depthTexture: register(s0),
	uniform float2 texelSize
	)
{
  /*
   //simple version
    float depth = tex2D(depthTexture, iTexCoord).r;
    outputDepth = depth;
  */
	
   //maximum of depth version
	int scaleA = 2; //fixed xAxis number of pixels in sample - to be replaced with variable
	int scaleB = 2; //fixed yAxis number of pixels in sample - to be replaced with variable

		
	float2 offset;
	float depthAtOffset;
	float maxDepth = 0;
	float2 beginningOffset = float2(
		iTexCoord.x - scaleA*0.5 + texelSize.x*0.5,
		iTexCoord.y - scaleB*0.5 + texelSize.y*0.5
		);
	
   //loop searching for maximum depth value	
	for(int x=0; x<scaleA; x++){
		offset.x = beginningOffset.x + x*texelSize.x;
		for(int y=0; y<scaleB; y++){
			offset.y = beginningOffset.y + y*texelSize.y;
			depthAtOffset = tex2D(depthTexture, iTexCoord).r;
			if(depthAtOffset>maxDepth){
				maxDepth = depthAtOffset;
			}
		}
	}
    outputDepth = maxDepth;
}

To *cpp file we add two lines (to include depth downsampling), here:

Code: Select all

(...)
	Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "OSP_SolidMaterialsBuffer");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "OSP_SolidMaterialsBuffer", true);
	Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "OSP_DownsampleDepth");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "OSP_DownsampleDepth", true);
	Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "OSP_ShowDepth");//"SSAO/Volumetric");//"SSAO/ShowNormals");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "OSP_ShowDepth", true);//"SSAO/Volumetric", true);//"SSAO/ShowNormals", true);
	Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "OSP_PostFilter");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "OSP_PostFilter", true);
(...)


Now I have to change PostFilter compositor or ShowDepth compositor to display downsampled texture and test if it is correct, so I can debug this shader by observation of the screen.
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 »

Code update is commited to repository.

Now I'll do debugging on the level of checking log files. Then I'll modify source of depth dilsplayer to the downsampled texture (in order to see if the logical part works correctly).
However, if you notice any mistakes right now, feel free to notice.

When this task is done, I'm going to the part a) of ToDo list mentioned yesterday - that means render queues, identifiers and listeners used to split rendering resources to two groups before their output is concatenated.
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
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: [GSoC 2012] Off-Screen Particles project

Post by jacmoe »

Great work, I guess.
Could you post a screen shot or two, please? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
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 »

Sneekpeak of visual output today (it is not downsampled):
Image
Version with and version without additional Compositor Chain:
ImageImage (sorry for loss of colour in this one, It is screen output recorder by Cam-Studio Recorder and then printscreened again).


Yeas, I have these movies taken during entire project realisation till now.
They have been taken during every day of training, doing tutorials and on every breakthrough in coding related with depth testing, compositors, compositor chains post-effects, module that chooses rendering system, Debugging code using colour channels as output, etcetera.
They are 8 GB right now, so I think editing that much material would take more than 5 hours.

I am coding, so right now I'll upload from one to 3 screenshots from every movie temporarily as faster solution (I'm still fixing the downsampler - I have a bug somewhere withpassing data - I'm trying to localise it before midnight, so I could start implementing listeners and render queues - I can't wait to finally be able to do that :) ).

In few hours I'll add descriptions. to what exactly is going on each of tehem.
1 movie = 1 to 3 pictures:

[EDIT By Assaf - removed a 100 images that made this thread too long to view]

EDIT:
Well, it took above 2 hours hour to take pictures from movies anyway :D, since I started writing this post...
In next post, I'll upload just the newest movie - it is from the beginning of this weekend.
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
PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Off-Screen Particles project

Post by PhilipLB »

O_o


F6 makes nice screenshots directly from the rendering area and writes them as png in your execution directory.
And for movies: I recently searched a lot for a free Fraps alternative and MSI Afterburner works pretty well: http://event.msi.com/vga/afterburner/overview.htm (just ignore those overclocking features ;))
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.
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'll try to use that one in the future, thanks.

I've edited the most recent video (It was taken 5 hours ago) of current compositor chain output just before debugging of "maximum of depth" downsampler.
It should be visible soon (it is still "processed" on vimeo).
Waiting in line

Your video will begin converting in approximately 00:33:10. If you have other things to do besides stare at this screen, you can leave this page and we’ll email you when your video is ready to watch.
(...)
0%
00:32:17 remaining
[vimeo]45399464[/vimeo]
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
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: [GSoC 2012] Off-Screen Particles project

Post by Mind Calamity »

Wow... No screenshots... No screenshots... Then just BOOM! Tons of screenshots! :D

Nice job. Is the low framerate a result of the particles, or is it just your PC + screen capture ?
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: [GSoC 2012] Off-Screen Particles project

Post by jacmoe »

Is this excessive?! :D

Really interesting watching your progress - a picture is worth a lot - and I think you just posted an entire library worth of words. :lol:

Good luck on your project - you are going to need it - but I think you'll make it if you put your mind to it.
Sharing progress like this is a major step forward.
So, kudos! :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
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 »

Well, I was hoping all the time to find time for editing videos, I've been making after "halo effect" is visible.
Because that would let me make report that shows something more valuable.

I had thought I would have been finished with that at least a week ago. Little bit overestimated speed of fixing some issues that show up with compositor/material/shader concatenation.
However after getting more experience, it has accelerated, so there is no problem in next steps -they are easier ones.

Debugging shaders was tricky, cose you can't set breakpoints in shader files... You have to find ways around. I mean not compilation debug, but breakpoins kind of debug. Preview of calculations on GPU is of cours unaccessible from CPU (only access to global level of memory). Except you have heared of any miracle emulator of gpu.

I lost one screenshot of really fine debugging technique I used (outputs in r,g,b channels) - ut i think you ger idea that there always is a way to debug.

I've heared that there are some patches for debug of ogre shaders in Visual Studio, but the link was expired. If you have some information about such a tool for VS, it would be great for me, because I'll be doing shaders every week.

At the moment I've redeuced downsampler code to fit into compositor chain and display the same texture - so I am now sure that nothing goes wrong there.

I'll gradually paste back line after line of my previous code to this one and fix thet little tricky bug i had somewhere. It should be ready in few moments.
Last edited by Karol Badowski 1989 on Sun Jul 08, 2012 9:09 pm, edited 4 times 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 »

Thanks.
Mind Calamity wrote:Is the low framerate a result of the particles, or is it just your PC + screen capture ?
It is result of particles and of transformations (movement of penguin has many encapsulated rotations - I'll optimise it and lover the encapsulation level of transformations).
I spread also a lot of particles on the map on purpose, so after implementing Off-screen particles, we could recognise increase of framerate.

If you mean framerate of movie, not application, than it is the second one. But not "my PC + screen capture". It is "video capture of quality that is not perfect + screen capture".

I was doing "screen recording" archieves regularry. I achieved today screenshots from these archieve movies. I used "Cam-Studio Recorder" (it lowers quality - especially there is a loss of colours range). It is impossible to make the same screenshots with original quality again, because of amount of changes to project. That's why I used my movie archives.


I am still going to compile these movies into one bigger movie report after halo effects are visible. For now I estimate that this level of progress will be ready approximately 15'th of July.
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 »

Well, nice progress, but as I wrote before - can you focus on the goal of the project? Meaning "off screen particles" and finish the small demonstration of the idea?
Regarding your movies and screenshots, I would ask not to post so many random images on this thread, can you remove all non-relevant images? I don't see the need for you to work on creating movies for now.
Try to focus on the project if you can, it is still isn't clear that you are getting a passing grade, as you started late and you are not communicating with me, read my last posts and see your responses, it is vary hard to understand your answers as you don't respond directly to what I write.
You wrote:
Karol Badowski 1989 wrote:Yes, I can finish it (previous post above updated).
It is much simpler than one I was trying to do.
Ok, lets see it then (or I missed it and it is already done).
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 »

Right now I'm implementing the masking.
Here is visualisation of downsampled depth texture that I achieved (particles are not set to unvisible yet - I'm still doing the masking):
8x8 downsample Image
4x4 downsample Image
2x2 downsample Image.
It works under OpenGL.
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 »

As I wrote - can you leave the depth aside for the time - and try to finish the simple proof of concept?
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 »

Assaf Raman wrote:Well, nice progress, but as I wrote before - can you focus on the goal of the project? Meaning "off screen particles" and finish the small demonstration of the idea?
"
Yes Sir, I am focusing on creating the demonstration.
1. Just RTT the scene without the particle systems into a texture the size of the window.
2. Render the scene once more, to a smaller texture - but no color write - just depth write.
3. Render the particle system to the smaller sized texture (same one as in stage 2) - the depth test will work.
4. Use the resulting textures from 1 and 2+3 - with a compositor to reach the desired effect.
I quite do not understand what is wrong in downsampling the depth that I achieved - as it is one of the steps for the proof of concept (step 2). Or is it much simpler solution? somenthing much simpler like setting flague "depth write"?

For step 2 I've created depth acquisition and downsampling to a smaller texture (wrote the achieved depth to channel r of downsampled texture).
Assaf Raman wrote:It is vary hard to understand your answers as you don't respond directly to what I write.
I'm quite confused, because I thought I understood the question. I try my best to answer, these questions.
Yes, but can you finish the sample I suggested?
(...)
What do you say? How do you want to proceed?
I tried to answer how do I want to proceed this task:
Karol Badowski 1989 wrote: This is the order of tasks:

a) As soon as downsampling is finished, I'll Implement masking to exclude particles from created passes and to exclude rest of the scene from depth testing - analogous to examples (listeners + masks given by identificators + rendering queue).
(..)
b) When masking is ready, I'll acquire downsampled depth texture (the same way the "show depth" compositor acquired non-downsampled depth texture right now).
In pixel shader of this pass there is going to be depth testing - it will use depth texture taken from previous rendering queue, as one of sources.
(..)
c)Rendering to screen will take as an input: full-size colour texture of solid objects, small texture of particles.
Right now I'm trying to implement step 1 and 3 by advices from the topic you have presented (http://www.ogre3d.org/forums/viewtopic.php?f=4&t=24145) - that is usinf listeners and render_queue and indexes.


Please try to explain to me If i understood something the wrong way.
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 »

What you don't seem to understand that you started last minute and focused all the time you had on "getting and down sampling the depth texture". That is nice - but it is a vary small part of this project, I asked more then once to focus on the project, meaning "off screen particles", in order for you to demonstrate the article - I even suggested that you will create a more simple sample of it, and I have described what I expect.
You keep updating the down sampling of the depth texture part of the project for days, even when I asked you to leave that part for later - so you will be able to finish the proof of concept, but you ignored my request.
I really don't know what to do with this project at this stage.
I defined the minimal result I expected, and it doesn't seem that you are working on what I asked, but on other things you want to work on, I am not sure that is the best choice for you...
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 »

Assaf Raman wrote:I asked more then once to focus on the project, meaning "off screen particles", in order for you to demonstrate the article - I even suggested that you will create a more simple sample of it.
I misunderstood your advice. It was not ignoring it on purpose. I thought you were referencing part of depth acquisition with more than one technique, so I moved to next step. Getting and downsampling depth texture took me a bit more time than I expected. Now when I read your messages I finally got that thing that I was missing, that this element could have been skipped too.

Honestly, totally misundestood point 2 "2. Render the scene once more, to a smaller texture - but no color write - just depth write.". now I see that it was not about calculating depth, but just setting attributes. I missed the part about that back buffer already takes care of everything I've been doing (except maximum of depth verion of back buffer)... That could be my worst missreading in life.

I am still continuing to do the masking part that is needed to achieve the needed effect. I am sure I am able to finish it. I did not manage to achieve it yet, but I am still fighting to reach that based on granting identifier flagues to . It would be tragedy to stop now and leave all implementation and project. I thought I would have finished part of rendering only particles and only solid objects to separate rendering targets by now, but I still some time to achieve it (examples of use are very wide, like deffered shading example). I know that this needs rendering queues, identifiers and operating on compositor from level of application by listeners - I have problem with getting better example to pattern after (at the current moment I am right now more advanced in rendering on level of scripts than using listeners, but one example simpler than Deffered Shading could change that).

All the other parts are trivial:

Point one: Material technique executed for part 1 is just a basic rendering technique of the object and does not need new implementation.

Point three. Depth testing is for now done by back buffer, but material and compositor I'd write to use my "maximum of depth" example just takes one more input source than the compositors I've already written. It addresses appropriate depth by

Code: Select all

tex2D(depthTextureDownsampled, iTexCoord).r
operation and then compares .

Achieving right scale of particle texture does not need special downsampling method in any case - appropriate set of texture coordinates is achieved just by using scale_target_width and scale_target_heigth operation.

Point four
Compositor would look like this:
2 input textures referenced from part 1 (big texture) and 3 (small texture).
Target is screen.
References to full size texture are just simple tex2D operation, as it has the same size that screen has. Reference to color modification comming from particle texture is done the same way, because size parameters are already achieved from texture in tex2D operation (iTexCoord are float values, so the offset is achiewed with no problem).


I am so stupid that I did not understand your advice. That was misinterpretation (my interpretation back then all the time was the one from answer that I presented Yesterday, 2012 12:49 am how i understood that). It was my very big missunderstanding. And now I know why you said that my answer did not seem to be clear.

---------------------------------
I am able to finish example from your advice as soon as I finally figure out the masking method (in link you posted - the only solution are listeners - it is the same solution that was used in Deff. shading). I'm still fighting to understand how to use them.
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 »

8:30 I moved forward - i think i finally found good solution.

I finally found how to do that from the level of *cpp code.
I think it is still possible that I'll finish today a version with
-original scene.
-mini viewport with debug view of texture with only solid objects visible
-mini viewport with debug view of texture with only particles visible (downsampled, depth-tested by backbuffer texture)
-mini viewport with debug view of texture with their concatenation
-Applay shaders.

It appears that I skipped it earlier from one of early Intermediate tutorials and started from more complicated tutorials and forum articles, like DoF.

At the moment I'm creating debug miniviews to display textures created from camera view.
Next step is setting visibility.
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 »

Right now I have working save of solid objects without particles (and without miniViewport, to avoid infinity nesting), to a texture. It seems to be fine in debug viewport.

I am going to post office for 45 minutes and comming back in order to apply creation of small texture with back-buffer only.

I'll do the version, where colour is cleared in clear pass.
I know how to achieve that with my shader too, but I do not have depth-testing yet, so perhaps this will be faster.
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 »

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
Post Reply