Menu

Define a not uniform color background

Help
2018-02-19
2018-02-20
  • shine world

    shine world - 2018-02-19

    Hi,

    Is possible to set a scene background to be transparent or set it to a fixed BMP/PNG/etc (not must change when camera position/zoom change) to obtain something like in attached image ?

    Thank you very much in advance for suggestions :)

     

    Last edit: shine world 2018-02-19
  • Jerome.D (BeanzMaster)

    Hi Silverio, yes it's possible to set a fixed bitmap, i'll show you. for transparent Do you need that GLSceneViewer is transparent ?

    For set a fixed bitmap as background just put a TGLHudSprite and set material texture. (you can take a look in (examples\shaders\shaderlab for a sample.

    For setting GLSceneViewer background color pass thrue buffer : MyViewer.Buffer.BackgroundColor

     
  • shine world

    shine world - 2018-02-19

    Truly,
    I don't understand how to place a PNG (for esample) like background of scene and so all scene is drawn on top of that without the camera/light sources touch background.

    With MyViewer.Buffer.BackgroundColor actually I can change a fixed-uniform color.
    I've tried with clNone but don't work and Scene isn't transparent to see below form.

     
  • Jerome.D (BeanzMaster)

    Just set the Material.texture propertie or pass thrue material library

    procedure TMainForm.LoadBackgroundImgClick(Sender: TObject);
    begin
       if OpenPictureDialog.Execute then
        begin
         MaterialLibrary.LibMaterialByName('BackgroundTex').Material.Texture.Image.LoadFromFile(OpenPictureDialog.FileName);
        end;   
      end;
    
    // background texture visible or not 
    procedure TMainForm.chkBackgroundImgClick(Sender: TObject);
    begin
      Button11.Enabled := chkBackgroundImg.Checked;
      ScreenBackGround.Visible := chkBackgroundImg.Checked;
      if ScreenBackGround.Visible then
        Viewer.Buffer.BackgroundColor := clBlack;
    
    end; 
    

    For GLSceneViewer it is actually impossible to be transparent. The solution will be render the scene in a bitmap with Transparent color as background and Blend it to a custom panelthat support transparency. If you want the scene display on transparent form. You need play with Regions.

     
  • Jerome.D (BeanzMaster)

    Oups forgot a little screenshot :

     
  • shine world

    shine world - 2018-02-20

    Thank you very much Jerome.D.
    Now I was able to get a picture how background ;)

     

    Last edit: shine world 2018-02-20

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.