Exclude a mesh from a light

Blitz3D Forums/Blitz3D Programming/Exclude a mesh from a light

FlagDKT(Posted 2008) [#1]
I have two near lights and a mesh.
How to to exclude this mesh from one of the two lights?
Maybe tom dll?


GfK(Posted 2008) [#2]
Multipass rendering. Something like:

Start of loop
Show everything
CameraClsMode cam,True,True
Hide light1
RenderWorld
CameraClsMode cam,False,False
Hide light2
Show light1
RenderWorld
End of Loop


FlagDKT(Posted 2008) [#3]
Yes but it would be too slow... :(


OJay(Posted 2008) [#4]
not if done right. take a look at this: http://blitzbasic.com/codearcs/codearcs.php?code=1246


Ross C(Posted 2008) [#5]
Set the mesh to full bright. Then use entity color to reduce the brightness of the entity is one way.


FlagDKT(Posted 2008) [#6]

As you can see, every character has to be enlightned by the light of the room he's in.
CharD has to stay dark.
How many multipass rendering I'd need?
Wouldn't the rooms be rendered 3 times?
Perhaps I just didn't understand CameraClsMode function?


GfK(Posted 2008) [#7]
I would render the rooms once, with all the lights on (With cameraClsMode cam,True,True set).

Then render each character individually, with only the light that's in the same room as he is (using CameraClsMode cam,False,False). That way you're still only rendering everything once.


FlagDKT(Posted 2008) [#8]
To render every character individually I need to hide the rooms.. right?
Isn't Hideentity too slow?


GfK(Posted 2008) [#9]
Yeah, hide the rooms. You're disabling clearing of the z-buffer with CameraClsMode after the first render, so the geometry of what's already been rendered will still be taken into account when you render the characters - i.e. if a character is behind a wall, you still won't be able to see him. Try it and see.

HideEntity is extremely fast.


FlagDKT(Posted 2008) [#10]
Ok!I'm going to try!
Thank you :)


Ross C(Posted 2008) [#11]
Wait... So not clearing the z-buffer actually allows you to render meshes behind other previously rendered? Man... i feel sooo stupid now...


FlagDKT(Posted 2008) [#12]
Uhm I have a problem now:the particle sprites are always behind the chars and if I don't hide them, they are rendered 3 times.
please don't tell me that sprites don't write on the Zbuffer :(
here's my loop:

Show level
Hide chars
Show particles
CameraClsMode camera,True,True
*RenderWorld*

Hide Cur_Level
Hide particles
CameraClsMode camera,False,False
Show chars(for light1)
*RenderWorld*

Show chars(for light2)
*RenderWorld*



jhocking(Posted 2008) [#13]
If they are using a blend mode where you can see through them (they default to add blending) then no they are not written into the z-buffer. This is why polygons with alpha transparency are sometimes rendered in the wrong order when they overlap.

I think the solution is to only render your sprites once after everything else. They will be affected by the z-buffer, they just don't affect the z-buffer themselves.


FlagDKT(Posted 2008) [#14]
Ok I rendered particles after everything else. thx It works.
Btw I think there's a problem with this multipass method.
Characters are rendered even if they are out of the screen?!
Trisrendered() after each *render* outputs as if it drew every character.
No more object culling with CameraClsMode camera,False,False ?
Forced to use EntityInView?


FlagDKT(Posted 2008) [#15]
Oh no!The chars cover level alphablended faces...


Ross C(Posted 2008) [#16]
They will only be rendered if ANY of the character is shown. In fact, i'm sure it's the bounding box of the character. So even if you can't see any of the character. It's bounding box may be on screen.