SkyBox and transparent texture for Cube.
Posted: Sat Oct 19, 2024 3:30 pm
I have a Cube, where sides have some transparent. and have some SkyBox. so when you look on that Cube it should be transparent and show SkyBox and it work, when this Cube is along. but what if behind of that Cube lays another Cube, with non transparent. Is any way to set for first Cube work as some kind of display, where sides will show SkyBox image, not second Cube or any other objects behind first Cube?
just image Excel table, where is 2:2 cell have my transparent Cube. user stay at 1:2 - at left side of Cube and look into that Cube and should see SkyBox, but he will see second nontransparent Cube, that lays at 3:2 cell.
so sides of first Cube should work like some x-ray and see SkyBox with no any other details behind of that first Cube. can i get that effect with PB ?
o... and how to work with SkyBox, but not external file - but some memory image?

just image Excel table, where is 2:2 cell have my transparent Cube. user stay at 1:2 - at left side of Cube and look into that Cube and should see SkyBox, but he will see second nontransparent Cube, that lays at 3:2 cell.
so sides of first Cube should work like some x-ray and see SkyBox with no any other details behind of that first Cube. can i get that effect with PB ?
Code: Select all
InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 640, 480, "Cube example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
SkyBox("stevecube.jpg")
; Light
CreateLight(#PB_Any, RGB(25, 25, 180), -5, 10, 5, #PB_Light_Point)
; Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 1, 1, 3, #PB_Absolute | #PB_Local)
CameraLookAt(0, 0, 0, 0)
CreateTexture(100, 64, 64)
If StartDrawing(TextureOutput(100)) ;{
DrawingMode(#PB_2DDrawing_AllChannels | #PB_2DDrawing_AlphaBlend)
Box(0, 0, 127, 63, RGBA(0, 0, 0, 255))
Box(0, 0, 127, 63, RGBA(0, 0, 0, 0))
DrawingMode(#PB_2DDrawing_Transparent | #PB_2DDrawing_AlphaBlend)
DrawText(10, 20, "texture", RGBA(200, 100, 100, 255), RGBA(0, 0, 0, 0))
;}
StopDrawing()
EndIf
CreateMaterial(101, TextureID(100))
SetMaterialAttribute(101, #PB_Material_AlphaReject, 128)
; Create the cube and attach it to the scene
CreateCube(0, 1)
CreateEntity(0, MeshID(0), MaterialID(101))
CreateCube(1, 1)
CreateEntity(1, MeshID(1), #PB_Material_None)
MoveEntity(1, 0, 0, -1.1)
Repeat
RenderWorld()
FlipBuffers()
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
