This is PureBasic 5.11, Guys! 5000px image on my terrain

Everything related to 3D programming
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: This is PureBasic 5.11, Guys! 5000px image on my terrain

Post by luis »

Lexicon wrote: Oops... PB don't load pic more than 8192 :(
Not really, it was an old limit but the documentation has been updated.

http://www.forums.purebasic.com/english ... 13&start=0
help wrote: The limit for the image size that can be handled depends on the operating system and the available amount of memory. If enough memory is available, then images up to at least 8192x8192 are can be handled by all operating systems supported by PureBasic.
Unless I'm missing something I don't see all the excitement about this anyway. Why one should try at any cost to load a gigantic image... where ?
In a single texture maybe ? So when the limit of the texture size it's hit on a specific hardware, you just see a white rectangle instead of your pic ?
Especially in an engine you would split the texture and problem solved, this can also be done transparently by the engine.
There are always some other problems to solve when doing this (texture seams) but they too can be solved once for all in the engine following certain rules.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: This is PureBasic 5.11, Guys! 5000px image on my terrain

Post by Bananenfreak »

Yes, a new form of Photoshop with GPU-Support. :D
Image
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: This is PureBasic 5.11, Guys! 5000px image on my terrain

Post by applePi »

this is an experiment using this wide image British_Museum_Reading_Room_Panorama_Feb_2006.jpg only 5 MB
http://upload.wikimedia.org/wikipedia/c ... b_2006.jpg

from the general link
http://en.wikipedia.org/wiki/File:Briti ... b_2006.jpg
from the wider link:
http://en.wikipedia.org/wiki/User:Diliff

adding it to the terrain in the example TerrainShadow.pb you may find it interesting. i know very little about the terrains so any unnecessary editing reflect my ignorance. so any improvements, ideas, will be great.
save this to the folder purebasic\examples\3d and save the picture in the Texture folder or the same 3D folder
and wait a few seconds, depends on your computer
i suggest a tiny version of the terrain such as in the blitz3D which runs instantaneous
move the mouse to position the terrain in a perpendicular position, then use the keys
PB 5.21 LTS

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Terrain : Shadow
;
;    (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
;

IncludeFile "Screen3DRequester.pb"

#CameraSpeed = 20
#TerrainMiniX = 0
#TerrainMiniY = 0
#TerrainMaxiX = 0
#TerrainMaxiY = 0
Define.f KeyX, KeyY, MouseX, MouseY

Procedure Clamp(*var.float, min.f, max.f)
  If *var\f < min
    *var\f = min
  ElseIf *var\f > max
    *var\f = max
  EndIf
EndProcedure

; OpenGL needs to have CG enabled to work (Linux and OS X have OpenGL by default)
;
CompilerIf #PB_Compiler_OS <> #PB_OS_Windows Or Subsystem("OpenGL")
  Flags = #PB_Engine3D_EnableCG
CompilerEndIf

If InitEngine3D(Flags)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    Add3DArchive("Data/Textures/"       , #PB_3DArchive_FileSystem)
    Add3DArchive("Data/Textures/nvidia" , #PB_3DArchive_FileSystem)
    Add3DArchive("Data/Scripts"         , #PB_3DArchive_FileSystem)
    Add3DArchive("Data/GUI"           , #PB_3DArchive_FileSystem)
    Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
    Add3DArchive("."       , #PB_3DArchive_FileSystem)
    Parse3DScripts()
    
    WorldShadows(#PB_Shadow_Modulative, -1, RGB(105, 105, 105))
    
    ;- Light 
    ;
    light = CreateLight(#PB_Any ,RGB(255, 255, 255), 4000, 1200, 1000,#PB_Light_Directional)
    SetLightColor(light, #PB_Light_SpecularColor, RGB(255*0.4, 255*0.4,255*0.4)) 
    LightDirection(light ,0.55, -0.3, -0.75) 
    AmbientColor(RGB(255*0.2, 255*0.2,255*0.2))
        
    ;- Camera 
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,  800, 400, 80, #PB_Absolute)
    CameraBackColor(0, RGB(5, 5, 10))
    
    
    ;----------------------------------
    ; terrain definition
    SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
    ; initialize terrain 
    CreateTerrain(0, 513, 12000, 600, 4, "TerrainShadow", "dat")
    ; set all texture will be use when terrrain will be constructed 
    AddTerrainTexture(0,  0, 12000, "British_Museum_Reading_Room_Panorama_Feb_2006.jpg",  "British_Museum_Reading_Room_Panorama_Feb_2006.jpg")
    AddTerrainTexture(0,  1,  30, "grass_green-01_diffusespecular.jpg", "grass_green-01_normalheight.jpg")
    AddTerrainTexture(0,  2, 200, "DosCarte.png", "DosCarte.png")
    
    ; construct terrains
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        DefineTerrainTile(0, tx, ty, "basic_droplet.png", ty % 2, tx % 2)  
      Next
    Next  
    BuildTerrain(0)  
    
    ;InitBlendMaps
    minHeight1.f = 70
    fadeDist1.f = 40
    minHeight2.f = 70
    fadeDist2.f = 15    
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        Size = TerrainTileLayerMapSize(0, tx, ty)
        For y = 0 To Size-1
          For x = 0 To Size-1
            Height.f = TerrainTileHeightAtPosition(0, tx, ty, 1, x, y)
            
            val.f = (Height - minHeight1) / fadeDist1
            Clamp(@val, 0, 1)
            SetTerrainTileLayerBlend(0, tx, ty, 1, x, y, val)
            
            val.f = (Height - minHeight2) / fadeDist2
            Clamp(@val, 0, 1)
            SetTerrainTileLayerBlend(0, tx, ty, 2, x, y, val)
          Next
        Next
        UpdateTerrainTileLayerBlend(0, tx, ty, 1)
        UpdateTerrainTileLayerBlend(0, tx, ty, 2)
      Next
    Next  
    
    ; enable shadow terrain
    TerrainRenderMode(0, 0)
        
    ; create sphere for test
    CreateSphere(1, 20.0, 50, 50)
    Global ball =CreateEntity(#PB_Any, MeshID(1), #Null)
    MoveEntity(ball, 300,60,0, #PB_Absolute)
    EntityRenderMode(ball, #PB_Entity_CastShadow)
    
    ; SkyBox
    ;
    SkyBox("desert07.jpg")
    
    ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()       
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left))
        
        If MouseButton(#PB_MouseButton_Left)
          TerrainMousePick(0,  CameraID(0), MouseX(),  MouseY())
          MoveEntity(ball, PickX(), PickY()+20, PickZ(), #PB_Absolute)
        EndIf
        
      EndIf
      ;CameraLocate(0, CameraX(0), PBO_GetTerrainHeight(0, CameraX(0), CameraZ(0)) + 20, CameraZ(0))
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)  
      
      RenderWorld()
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape)   
    
    End 
    
  EndIf 
Else
  CompilerIf #PB_Compiler_OS <> #PB_OS_Windows Or Subsystem("OpenGL")
    ;
    ; Terrain on Linux/OSX and Windows with OpenGL needs CG toolkit from nvidia
    ; It can be freely downloaded and installed from this site: https://developer.nvidia.com/cg-toolkit-download
    ;
    MessageRequester("Error","Can't initialize engine3D (Please ensures than CG Toolkit from nvidia is correcly installed)")
  CompilerElse
    MessageRequester("Error","Can't initialize engine3D")
  CompilerEndIf
EndIf 
Edit: adding the picture to the last layer and extending it to the whole terrain curve seems much better. and if we can make a concave terrain then the picture will be more impressive
from line 73

Code: Select all

AddTerrainTexture(0,  2, 12000, "British_Museum_Reading_Room_Panorama_Feb_2006.jpg", "British_Museum_Reading_Room_Panorama_Feb_2006.jpg")
    
    ; construct terrains
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        DefineTerrainTile(0, tx, ty, "terrain513.png", ty % 2, tx % 2)  
      Next
    Next  
    BuildTerrain(0)
User avatar
minimy
Enthusiast
Enthusiast
Posts: 556
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: This is PureBasic 5.11, Guys! 5000px image on my terrain

Post by minimy »

Fantastic PB, power and more power!!!
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: This is PureBasic 5.11, Guys! 5000px image on my terrain

Post by Lexicon »

Thanks guys! Ok! :D
Now please use second 5000px image and put it on your terrain.

Look at my video. I have use TWO 5000px maps on my terrain. I can use 10, 20 or 50 HiRes images, if any user will wait when all images will be loaded. :wink:
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
Post Reply