"advanced" clipping question

hi guys.

just got a silly question, but i cannot solve it atm. i am familiar with python scripting, and, in difference to most people who ask such silly questions as mine definitely is, i actually like to use python and, coming from javascript n php, i think PYTHON ROCKS and, surprise, our friend b.a. thinks the same, just look at his face: :ba:

i have a scene named “main” and a second scene named “overlay”
the secondary scene will be applied with the “add overlay Scene” actuator to the first one.
so far so good, everything is working fine and looking good.

but now i am running into problems:
how could i clip the contents of the overlay-scene depending on the form of the backgroundmesh (or backgroundpic or anything else) of the overlay scene?
so to say, if the background is a triangle, everything shown in the overlay scene will be clipped at the triangles edges?

i hope to make a clear point here. if not, i have appended a blend file here to show you the problem.
its just a simple blend file, containing two scenes as mentioned above.

the question i got is, is there a way to only show the parts of the rotating cube which are “inside” the grey triangle.

anyhow, i hope my gibberish is understandable, thnx a lot in advance for reading this thread, even greater thanks if you bother to answer “the noobs” question ^^

greetings from cloudy vienna
manarius

second edit:
one way to achieve this that came to my small and humble mind was, to get an correctly shaped plane with alpha 0 directly in front of the cam. this plane should practically transmit its alpha to all the objects behind it which are in the same scene. of course this solution grounds on my 2d programming expirience with flash and i dont know, if this would be practical in blender. testing it i struggled with applying the alpha of one object to another object. i just dont get, how i could link the two objects.

the second posibility would be the classical graphical portal like in the famous youtube video:


its a portal. but not the one that teleports (since i found several postings where somebody asked about graphical portals and everyone was answering as though they were brainwashed by the promised cake ^^)
this would be great, but afaik its not possible in the game engine?
once more thanks for reading

Attachments

cliptest.blend (144 KB)

Welcome to the forums!

If I understand correctly, what you want to do is
-make sure you’re using glsl mode
-in the overlay scene, invert the triangle (make a plane, with the triangle cut out- make sure the plane fills the camera, and sits in front of the cube
-give the plane a material with 0 alpha, and ztransp OFF. this means that instead of rendering whatever is behind it, it just displays the background color or, in this case, the scene behind it.
-make sure you have the same background in this scene as the other one (materials, world tab, there should only be one world material available)

in theory, it should work fine like that.

Unfortunately the graphical part of portals is the least possible part in blender. The rest is some clever physics manipulation and vector math, but actually making it so you can see through a portal in the game engine is nigh-on impossible. This may change when the videotexture plugin is finished, but that would probably be a lot of overkill for what you’re trying to accomplish.

actually we are developing an 2.5D adventure, so i am not really talking about portals.

in the end its really just that simple pointer you gave me there, that i needed, gonna sit down on my ass and test it and reply here again when finished,

thanks a lot!

four weeks and still lost in blenders ui, but also still loving it for the things it can do :yes:
manarius

just a dumb question, when i use glsl mode the alpha transparency of the texture is not used?
any tips on that problem?

thanks again ^^

edit:
i edited the blend to show my current problem. maybe you could just pull some switches and tell me what i did wrong? would be gratefull if you did.

thx a lot in advance!

my head currently is spinning :spin:

Attachments

cliptest1_1.blend (190 KB)

Ahh… for GLSL alpha… you need to put the alpha slider down to 0 and click Ztransp.

i just tried that, but now it once again simply doesnt display the alphaed texture, instead of clipping the content.
if you wanna see what i mean just play around with the cliptest1_1.blend file provided above.
i really am lost atm, so many buttons and so little brain ^^

edit:
i’m gonna play around a bit but since its 9pm here and i am working since about 12 hours my head feals like a mashed potato right now.

sorry to doublepost, but i am lost here :frowning:

yeah thats exactly what i want.

i’ve been trying to get this alpha-masking (or alpha-shadowing) working, i pulled levers and pressed buttons, but nothing seems to produce the effect you describe
i have no clue what exactly i am doing wrong, and it would really be great, if you could do me an example?
with that i will have some hints about the buttons to check and the buttons to UNCHECK

sorry for being so impudent to ask about such a thing, but i am really lost here

Hiya.

I’ve thought of doing something like this in my projects so I had a mess about.

Captain Oblivion was spot on at explaining this.

I’ve uploaded a little .blend here that i put together.

Start the ‘game’ whilst in the “main” scene.

There are 2 scenes, main and overlay.

“main” has a cube parented to a rotating empty. The cube has the logic for adding the overlay scene. Environment is coloured a sick green and the cube is red (didn’t spend much time on this ;)).

“overlay” has a plane with a hole in it. Environment is the default blue, the plane has a material with the alpha slider set all the way to 0 (in “Material” panel). By default, ZTransp in “Links and Pipeline” is turned off, this is left turned off.

I had to make sure that the camera in the overlay scene was looking straight down at the plane in order to have it orientated correctly. It seems that the scene actuator uses the camera in the overlay scene rather than keeping the same orientation as the main scene.

If this isn’t what you were intending to achieve then I hope it will clear up enough issues for you to figure it out.

Good luck. :slight_smile:

-in the overlay scene, invert the triangle (make a plane, with the triangle cut out- make sure the plane fills the camera, and sits in front of the cube
-give the plane a material with 0 alpha, and ztransp OFF. this means that instead of rendering whatever is behind it, it just displays the background color or, in this case, the scene behind it.

when i tried this the overlay scene worked fine by itself, but in the main scene all you could see was through the triangle.:frowning:

thanks again for all that help,

i downloaded the blend FunkyWyrm provided.
when i start it, i got the blue plane visible.
is this what you intended or is it my gfx-card not supporting glsl shaders=?

the normal alpha of objects works even in glsl mode but the overlay doesnt.

captain oblivion, come to my rescue pls ^^

greetings
manarius

Honestly, I’m baffled- I tried to make it again (I didn’t save the first version, assuming it wasn’t worth the hard drive space being so easy to reproduce) and now I can’t get it to work. In theory there are about five ways this should be possible, but blender seem so have an all-encompassing bug that prevents these methods from working.

Sorry for getting your hopes up and all, but at this point as far as I know it’s no longer possible (I went back to games I’d made in the past using this method, and sure enough it no longer displays correctly)

The blue plane is what you were supposed to see (it’s actually the background from the overlay scene), but since I didn’t mess about further, I didn’t realise your problem fully.

Do you need a kind of ‘window’ into another scene? I’m not even sure if this is possible in Blender game engine…

Or do you need to mask a part of the current scene? This can be done fairly simply by parenting a plane to the camera, as I’ve done in this .blend. The plane that you parent to the camera can be the type of alpha plane that has been discussed above, or it could be a textured plane to provide a background for additional details contained in an overlay scene.

You were asking about image alpha also… I’ve added a simple texture with alpha to the .blend posted above with the correct settings. Got to go to work so can’t explain that, just check all settings in “Map To”, “Material”, “Links and Pipeline” and “Map Input” panels as well as the texture panels. I’ve UV unwrapped the plane using “project from view” and I’m pretty sure I packed the texture into the .blend (if I didn’t then the image will be missing, just add your own image with an alpha channel).

Edit:

Just took a look at that youtube video, and it’s pretty impressive. Unfortunately, I think that technique only applies to animated sequences. To the best of my knowledge, Blender game engine doesn’t currently support windows to other scenes (I would love for someone to prove me wrong with this :D). Crystal Space(CS) has the ability do do such things and there is a sophisticated export script available for Blender, but I found CS difficult to set up. To develop a game using CS, it’s highly beneficial to be a proficient C++ programmer.

I wonder if you could just render your animation, then uv map it to the triangle.(in a video texture build)

FunkyWyrm- the way scenes are drawn is su[poed to be everything on the topmost scene, then in any place where the background is visible the next scene down is drawn, and so on. In previous builds of blender, any object with alpha 0 and ztransp off would just render the background, or whatever scene was behind it if htere was one- now the scene behind is not rendered due to a bug of some sort. It’s not supposed to work that way.

What manarius wanted was to be able to draw the next scene down in the masked off parts (black in your .blend)

Aha. Sorry for my misunderstanding. I was trying to get stuff to work with ‘overlay’ on the scene actuator. Having messed about with ‘background’ on the scene actuator, I see the problem. Where the background is visible on the main scene, the background scene replaces it, however, where the background of the main scene is visible through an object without ZTransp and with alpha 0, the background of the main scene is still rendered even if there is a background scene that should take it’s place.

Have you filed a bug report?

I’m not entirely sure where to file bug reports, and I was in a bit of a hurry, so not yet -_-;

You can file bug reports here: http://projects.blender.org/

But, unfortunately, you’ll have to register first.

@manarius: Welcome to BA. It’s nice to see another Python user :smiley: . In order to have textures affect a material’s alpha in GLSL mode, you need to:
*Have the texture assigned to the material
*In the materials pane go to Map To and Click Alpha. Now turn the Alpha slider in Material down to 0 and the alpha on the texture should affect the material the way you want.

thanks guys for all the help you provided and thanks for the friendly welcomes :slight_smile:

good to know that its a bug and supposed to work, already thought i might be going crazy ^^

now that i know i’m gonna discuss this problem with my mentor, who is very expirienced when it comes to engine side programming.

gonna check the bug report repository and post the bug there, if it isnt already.

greetings from cloudy vienna
manarius

yessa

i think i got it to work.
unfortunately i cannot imagine how.
only major thing i changed is going to the “user preferences” -> “System & OpenGL”
and set the Clip Alpha value to 0.10(in the column “OpenGL” on the right side of the screen)
could this be it?
before i changed the value it was 0.0 and since i changed it the result looks like the blend file attached.
could someone verify, because then i would have to remove the bugreport :slight_smile:

as you can see in the clipcube1.2.blend attached to this post, it works by including the background color of the overlay scenes 1 and 2.

this causes the world background of the overlay scenes to shine through, which i do not appreciate.
does anyone know, which buttons i would have to push to get the main scene background to always display itself and never accept alpha?
or, the other way round,
how to get the world of an scene to be transparent?

and the second one, the cubes have one frame of animation ( i think its the first frame of the rotation) in which they “flicker” through the planes which mask them. is this a known problem or can i do anything about that (probably by using animations instead of the actuator=? -> the rotate actuator maybe buggy?)

again thanks a lot for the help, would be greatly appreciated if someone takes my hand and guides me through this :o
greetings
manarius

edit:
just some clarification :slight_smile:

Attachments

cliptest1_2.blend (571 KB)