SkyBox and transparent texture for Cube.

Everything related to 3D programming
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

SkyBox and transparent texture for Cube.

Post by SeregaZ »

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 ?

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
o... and how to work with SkyBox, but not external file - but some memory image?


Image
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: SkyBox and transparent texture for Cube.

Post by SeregaZ »

Ogre specialists say:

Code: Select all

use "colour_write off"
and make sure that this part is rendered first. This way you can punch through using the depth buffer.
https://ogrecave.github.io/ogre/api/lat ... otoc_md147

we no have it in PB ?
benubi
Enthusiast
Enthusiast
Posts: 215
Joined: Tue Mar 29, 2005 4:01 pm

Re: SkyBox and transparent texture for Cube.

Post by benubi »

I don't know for sure. The way I understand it you can define this in the material scripts. You may need to give a specific name to your texture for those material scripts to work right

GetScriptMaterial(#Material, Name$)

Probably it won't work if you use LoadTexture() because it doesn't connect to the material scripts, and the texture themselves are used by the materials but do not have those depth features themselves.

I never tried but perhaps it could be as simple as GetScriptMaterial(#Material, "SkyBox") to make it work. If not, it should be possible to create such a material script IMO.

For materials created "on the fly" you can enable/disable depth write, and there are a few other options. See #PB_Material_DepthCheck & #PB_Material_DepthWrite if helps doing what you want with SetMaterialAttribute().

You can also manually set the render queue drawing order with SetRenderQueue()
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: SkyBox and transparent texture for Cube.

Post by SeregaZ »

so it can be apply to only transparent color ? and left nontransparent item visible ? it is animation, that run left to right part of side cube. probably that scripts is what i need... not clear, but i hope it is.

but i think need to start from small steps.
1. is any lences effect for making textures for skybox ? i still no have skybox textures from original game... my source is going somewhere and still didnt give it me. so i think it will be "flat" squares. and i see inside of examples for skyboxes - they have lences effect. some kind of that. is any method to make same effect with "flat" square image ?
Post Reply