issues with GLfilter zDepth when using several scenes

edit : this is working actually, unlike my brain, oops


I was working this morning on a GL filter that uses a depth function (extracted from a martinsh filter of course)

float readDepth(in vec2 coord) 
	if (gl_TexCoord[3].x<0.0||gl_TexCoord[3].y<0.0) return 1.0;
	return (2.0 * znear) / (zfar + znear - texture2D(bgl_DepthTexture, coord ).x * (zfar-znear));
	// return (2.0 * znear) / ( zfar + znear - x * (zfar-znear) );

the filter work well, provided there’s only one scene.

but in my own project there’s two scenes, and the objects are in the second one,
‘below’ the main scene - logic.addScene(scname,0) :

readDepth() only see the edges of the game window, everything is flat.

‘flat’ filters - that don’t use the bgl_DepthTexture, work fine on the ‘below’ scene - give the same results whereever the object with the filter brick is, the two scenes are here, in bgl_RenderedTexture.

logic.addScene(scname,1) does not solve the problem - actually the objects of the scene are ignored by the filter…
even if the filter brick is on the scname object.
float mood = ( normalize(interesting) + normalize(frustrating)*-9.0) * 0.1…
but maybe Im wrong the project is tricky, I did not test it in a small file. yet.

so before I rewrite my project to put everything in a single scene, have you any pointers or ideas about how I could retrieve the right depth from ‘below’ scene ?
ie a way to tell the BGE how to layer the scene keepZplease = True ?


The backdrop scene doesn’t really exist. Or not as far as the overlay scene’s camera is concerned. If the backdrop scene isn’t there it would just be filled with background color.
You need to run the depth sensitive filter in your back scene, and maybe another filter in the overlay scene. If the overlay is just a HUD then it doesn’t matter that much about the depth, you can just fake it.

You need to run the depth sensitive filter in your back scene

I did, I tried to run the filter in each scene - but not the two together, wait…

ok, you need to use the same 2Dfilter on the two scenes.
works on a small test file, but for some other reason not in my project … :frowning:

ok found the problem… rewriting…