I am implementing a GLScene application to visualize rooms containing objects. In the application the eye point is exterior to the room and always pointing towards the center of the room, the user can rotate the eyepoint around the center with the mouse changing the view.
Room surfaces are introduced in the scene as a TGLFreeForm while the objects inside the room are inserted in a TGLDummyCube using the AddNewChild method, they are mainly spheres, cylinders and cones. In order to visualize the interior objects the materials of room's surfaces are made transparent (setting alpha to 0.5 and blending mode to bmTransparency).
The problem is that the objects inside disappear while the user changes the view, so for example in the attached file pic1 interior objects are visible but changing the view they disappear (see pic2). All the interior objects disappear all at once while rotating the eye point and they remain invisible for a wide solid angle (see attached video).
Carlos,
Maybe, but I don't see the code. We have a GLSViewer in Advdemos , thus I included landscape and room in the menu View. Please, add your objects there and we'll see what's going on. Leave a comment there. ..
procedure TFormGLSViewer.acRoomExecute(Sender: TObject);
begin
// Room
end;
First thing is that I kind of solved my problem with the interior objects disappearing behid the room walls in transparent mode. The problem was related with the objects in the scene been separated in different TGLDummyCubes each of them corresponding to a different category (say Furniture, Sources, Receivers,... ) which was handy for accessing the items in the code but turned out to be problematic for the rendering (as illustrated in my previous email). In fig1 you can see the design of my GLScene before (left) and after (right).
I realized that only the objects in the dummyCube that was lowest in the World list were properly rendered behind the transparent room walls (so in my example Furniture worked fine, but source and receivers had some angles for which they were hidden behind the room, inside ModelFreeForm). I did gather all objects inside the same DummyCube (see ListOfSceneObjects in the right of fig1) and it seems to work fine now as seen in video1.
Still I have some problems when the room walls are made transparent. It turns out that some of the interior parts of the room are not visible from certain angles, it is like if some of the surfaces were opaque and doesn't allow to view the surfaces of the model that are behind them. I manage to create and STL file of my room that is in the attachments, you will be able to load the STL on your GLSViewer advDemo just need to make a change on TGLSTLVectorFile.LoadFromStream at GLS.FileSTL so blank lines are allowed in ASCII STL files (the revised method in ForLoadingMySTL). Also attached fMain.pas from GLSViewer with a few changes regarding a change in the orientation of ffobject (see TMainForm.DoOpen and TMainForm.DoResetCamera) and making transparent ffobject triangles at TMainForm.SetupFreeFormShading. Also made the grid invisible in the design of the project to illustrate the problem in video2 more clearly.
Notice the vertical rectangles located inside the room just behind the side walls (pointed in the beginning of video2), It turns that both the floor of the room also the wall behind the stage are able to eclipse the vertical rectangles! I wonder if this problem could be due to the illumination, I am using a single omnidirectional light in the middle of the room. In my application the surfaces of the room are grouped in layers each on a different color, and I can say the color of a surface
is very affected by the one of the surfaces closer to the eye that we are looking trough. The color of surfaces behind is in some cases not recognisable at all. Do you have any idea how can I deal with this problem with the transparency?
Carlos,
It seems that the issue here is not about transparency, not about the alpha channel. Perhaps it is necessary to change the bypass of some polygons not clockwise, but counterclockwise. And reconfigure the camera settings.
Pavel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
when you ask to redefine the orientation of the polygons, I guess that would be equivalent to change the sign of the mesh.normals, no? should they be redefined for each triangle so they point towards the camera position? or does the position of the lights play a role on the problem?
could you please elaborate on the appropriate camera settings to achieve the desired transparency effect.
I will be trying several things on my own, will let you know if I reach any conclusion.
regards, Carlos
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am implementing a GLScene application to visualize rooms containing objects. In the application the eye point is exterior to the room and always pointing towards the center of the room, the user can rotate the eyepoint around the center with the mouse changing the view.
Room surfaces are introduced in the scene as a TGLFreeForm while the objects inside the room are inserted in a TGLDummyCube using the AddNewChild method, they are mainly spheres, cylinders and cones. In order to visualize the interior objects the materials of room's surfaces are made transparent (setting alpha to 0.5 and blending mode to bmTransparency).
The problem is that the objects inside disappear while the user changes the view, so for example in the attached file pic1 interior objects are visible but changing the view they disappear (see pic2). All the interior objects disappear all at once while rotating the eye point and they remain invisible for a wide solid angle (see attached video).
Do you have any idea of what is the problem?
Regards, Carlos
Carlos,
Maybe, but I don't see the code. We have a GLSViewer in Advdemos , thus I included landscape and room in the menu View. Please, add your objects there and we'll see what's going on. Leave a comment there. ..
procedure TFormGLSViewer.acRoomExecute(Sender: TObject);
begin
// Room
end;
Pavel
Dear Pavel, Thanks for your help!
First thing is that I kind of solved my problem with the interior objects disappearing behid the room walls in transparent mode. The problem was related with the objects in the scene been separated in different TGLDummyCubes each of them corresponding to a different category (say Furniture, Sources, Receivers,... ) which was handy for accessing the items in the code but turned out to be problematic for the rendering (as illustrated in my previous email). In fig1 you can see the design of my GLScene before (left) and after (right).
I realized that only the objects in the dummyCube that was lowest in the World list were properly rendered behind the transparent room walls (so in my example Furniture worked fine, but source and receivers had some angles for which they were hidden behind the room, inside ModelFreeForm). I did gather all objects inside the same DummyCube (see ListOfSceneObjects in the right of fig1) and it seems to work fine now as seen in video1.
Still I have some problems when the room walls are made transparent. It turns out that some of the interior parts of the room are not visible from certain angles, it is like if some of the surfaces were opaque and doesn't allow to view the surfaces of the model that are behind them. I manage to create and STL file of my room that is in the attachments, you will be able to load the STL on your GLSViewer advDemo just need to make a change on TGLSTLVectorFile.LoadFromStream at GLS.FileSTL so blank lines are allowed in ASCII STL files (the revised method in ForLoadingMySTL). Also attached fMain.pas from GLSViewer with a few changes regarding a change in the orientation of ffobject (see TMainForm.DoOpen and TMainForm.DoResetCamera) and making transparent ffobject triangles at TMainForm.SetupFreeFormShading. Also made the grid invisible in the design of the project to illustrate the problem in video2 more clearly.
Notice the vertical rectangles located inside the room just behind the side walls (pointed in the beginning of video2), It turns that both the floor of the room also the wall behind the stage are able to eclipse the vertical rectangles! I wonder if this problem could be due to the illumination, I am using a single omnidirectional light in the middle of the room. In my application the surfaces of the room are grouped in layers each on a different color, and I can say the color of a surface
is very affected by the one of the surfaces closer to the eye that we are looking trough. The color of surfaces behind is in some cases not recognisable at all. Do you have any idea how can I deal with this problem with the transparency?
regards, Carlos
Last edit: Carlos Monteserin 2024-06-26
Carlos,
It seems that the issue here is not about transparency, not about the alpha channel. Perhaps it is necessary to change the bypass of some polygons not clockwise, but counterclockwise. And reconfigure the camera settings.
Pavel
Dear Pavel,
Thanks for your replay.
when you ask to redefine the orientation of the polygons, I guess that would be equivalent to change the sign of the mesh.normals, no? should they be redefined for each triangle so they point towards the camera position? or does the position of the lights play a role on the problem?
could you please elaborate on the appropriate camera settings to achieve the desired transparency effect.
I will be trying several things on my own, will let you know if I reach any conclusion.
regards, Carlos