Fade to black
Blitz3D Forums/Blitz3D Beginners Area/Fade to black
| ||
Is it possible fade screen to black except some meshes? |
| ||
Yep Create a small cube (5x5x5 or something) and position it at the camera coordinates. Colour it black, flip its normals, set it to fullbright. Adjust its alpha up/down to fade in/out. For the meshes that you still want to be visible, set them to be drawn last using EntityOrder. |
| ||
Thanks GfK. I tested and it works exactly the way I wanted. But now I have another problem: Setting Entity Order to a negative value for some meshes I have problems with z-order of their faces... |
| ||
Don't use meshes that have multiple "planes" of alpha surfaces. As blitz does not alpha sort stuff before rendering you potentially can run into such problems at any time (and using entity order makes the problem only worse normally) |
| ||
Don't use meshes that have multiple "planes" of alpha surfaces How I can check-avoid that?. I have these z-order issues with a fighter that comes with the Blitz3D package in Media folder... This is what I want to do: I need to leave a planet with my spaceship. Leaving the planet at a certain height I want to fade everything and smoothly transform to space environment... |
| ||
Another way, if the z ordering is still bothering you, is to use fog. For the entities you want NOT to fade, set there entityfx flag to 8. Then, you set up fog, the near value at 0, the far value a little bigger than the cameras position. Then, simply decrease the camerafog FAR range to meet the camera. Make sure your fog colour is 0,0,0 black though :o) |
| ||
just do 2 renderworlds with the second renderworld with the cls mode of 0... then just hide all the entities you wanted to fade for the second render. I.E HideEntities you don't want to fade ShowEntities you do want to fade + black cube Renderworld HideEntities you want to fade + black cube as described ShowEntities you don't want to fade Renderworld again |
| ||
Graphics3D 640,480,32,2 camera = CreateCamera() FadeEntities = CreatePivot() NonFadeEntities = CreatePivot() fadecube = CreateCube() EntityColor fadecube,0,0,0 FlipMesh fadecube EntityAlpha fadecube,0 Light=CreateLight() For n=1 To 20 cube = CreateCube(NonFadeEntities) PositionEntity cube,Rnd(-5,5),Rnd(-5,5),Rnd(0,20) ScaleEntity cube,Rnd(.2,1),Rnd(.2,1),Rnd(.2,1) RotateEntity cube,Rnd(360),Rnd(360),Rnd(360) EntityColor cube,Rand(255),Rand(255),Rand(255) Next For n=1 To 20 cube = CreateCube(FadeEntities) PositionEntity cube,Rnd(-5,5),Rnd(-5,5),Rnd(0,20) ScaleEntity cube,Rnd(.2,1),Rnd(.2,1),Rnd(.2,1) RotateEntity cube,Rnd(360),Rnd(360),Rnd(360) EntityColor cube,Rand(255),Rand(255),Rand(255) Next a# = 0 Repeat EntityAlpha fadecube,Abs(Sin(a)) a = a + .5 CameraClsMode camera,True,True HideEntity NonFadeEntities ShowEntity FadeEntities ShowEntity fadecube RenderWorld CameraClsMode camera,False,True ShowEntity NonFadeEntities HideEntity FadeEntities HideEntity fadecube RenderWorld Flip Until KeyHit(1) |
| ||
Thank you all. Ross C: I already use fog in planet's environment and I disabled the fog FX for the skydome. I think it will be very difficult to transform from one fog (I mean this one on planet's surface) to another (nearly the top of skydome). Rob: Thanks for the code but unfortunately I can't use a second camera with Cls Mode set to False because in this case AShadow lib cannot cast any shadows. In any case I'll think this solution again because I don't need any shadows during transition from planet's atmosphere to space... My last thought is to use a black colored sprite front of the camera playing with its alpha and then make a call of RenderEntity function (Fast Extension) only for those meshes I don't want to fade. |
| ||
I'm not using a second camera, just 2 render passes. |
| ||
Yep, you are right but the CameraClsMode function doesn't work with AShadow lib although this is the best solution for my case. :) |