Problem with STEP files, colors and Ray Tracing WB

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
FreeRadical
Posts: 49
Joined: Sun Nov 09, 2014 9:48 pm

Problem with STEP files, colors and Ray Tracing WB

Post by FreeRadical »

Hi all,

Here's some undesirable behavior I've observed with colors in STEP files.

In a new document, I opened the Part WB and created a default cube. I then changed the color of the cube to red using the View tab, Select Color requestor. Then, I exported the cube as STEP with color. Close the document.

Open the STEP file just created; it shows a red cube. Note that the View tab for the cube show the color as the default grey.

Open the Raytracing WB. Insert a new POV Ray project into the document. Add the red cube. Set the camera to the current view.

Now Render - the rendering is in shades of gray as if POV Ray used the default grey instead of the red.

Second problem: Also note that the view in the ray trace is NOT the view FreeCAD shows - the ray trace view is zoomed in by at least a factor of 2.

Third problem (minor): The picture file produced by POV Ray has a file extension of .bmp.png. The save file dialog said it was .bmp with no other choices. The file appears to be a PNG file.

The gray ray trace also happens with STEP file object(s) which have faces of different colors.

I've attached the STEP file and the FreeCAD file with the POV Ray project. I suspect the problem is in how FreeCAD process the colors in the STEP file and then how the Raytracing WB outputs the colors.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
StepCube.FCStd
FreCAD project including POV Ray info.
(5.03 KiB) Downloaded 96 times
StepCube.step
Step file of red cube
(16.7 KiB) Downloaded 85 times
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Problem with STEP files, colors and Ray Tracing WB

Post by quick61 »

It seems that the STEP color while displayed correctly when importing the STEP file, the color attribute is not picked up in FreeCAD's properties and it assigns the default color underneath. That default color assigned be FreeCAD is then the color assigned when generating the POV-Ray script. Whether this is something that can not be picked up by FreeCAD or it's an oversight or bug, I don't know. I'll leave that up to the devs to respond. :P

As for the zoom position, FreeCAD seems to of always been that way. You need to zoom out on your part before adding it to the render. It would be nice to have a "framing tool" of sort that could be toggled on and off to show the size and position of the raytrace window. Don't know how hard that would be to add, but might make for a nice feature request to get added in the 0.16 development cycle.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Problem with STEP files, colors and Ray Tracing WB

Post by wmayer »

Open the STEP file just created; it shows a red cube. Note that the View tab for the cube show the color as the default grey.
Currently a shape has two properties that keeps colour information. One holds the colour for the whole object and one for the individual faces -- there are historical reasons for this. For now this can be fixed by setting the first face colour as object colour but in the long-term we have to clean up the code and remove the shape colour property.

And in case you didn't notice you can change the colour of the Povray shape under the Data tab.
Second problem: Also note that the view in the ray trace is NOT the view FreeCAD shows - the ray trace view is zoomed in by at least a factor of 2.
I cannot confirm this. The image shows the object in the exact same size as the GL viewer does.
Third problem (minor): The picture file produced by POV Ray has a file extension of .bmp.png. The save file dialog said it was .bmp with no other choices. The file appears to be a PNG file.
Here it creates an image with the .bmp suffix only. There is no .png added.

I am using POV-Ray 3.6, I tried 3.7 but this doesn't work for me.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Problem with STEP files, colors and Ray Tracing WB

Post by quick61 »

The Raytrace camera view is tighter than the 3D view here, though not by a factor of 2.

.BMP.PNG? Must be a difference between the windows and Linux versions as my output graphic format is PNG. Or have you specified something in your POV-Ray output parameters that would cause this? My current output parameters are - +P +A0.1 +AM2 +R4 +J0.5 +UL +UV.
cu.png
cu.png (31.13 KiB) Viewed 3681 times
Mark

POV-Ray 3.7

OS: Kubuntu 14.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
This post made with 0.0% Micro$oft products - GOT LINUX?
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Problem with STEP files, colors and Ray Tracing WB

Post by wmayer »

The behaviour of PovRay 3.7 is very weird. It already starts with the installation. When you try to install it wants to go to C:\Program Files\ but then doesn't query the admin password and stops with an error message. If you then start the installer with admin rights you can install it to its default location but when you try to use it tons of errors are reported because it doesn't find its .ini files.

To get it working you have to install it as normal user somewhere into your home directory (or another directory where you have write access). Only this way you get it working. The next problem then is when you want to use it from FreeCAD. It always stops with an IO error that it cannot write to the requested image file. However, when you start it manually and open a pov file creating the images works OK.
.BMP.PNG? Must be a difference between the windows and Linux versions as my output graphic format is PNG
On Windows for Povray 3.6 the output format is BMP while it PNG on Linux. See also: https://github.com/FreeCAD/FreeCAD_sf_m ... d.cpp#L634
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Problem with STEP files, colors and Ray Tracing WB

Post by wmayer »

I wrote:It always stops with an IO error that it cannot write to the requested image file.
Apparently the output image in v3.7 is indeed PNG and it must be inside the same directory as where the .pov is loaded from. But still, the size of the object is the same, it's not zoomed at all.
FreeRadical
Posts: 49
Joined: Sun Nov 09, 2014 9:48 pm

Re: Problem with STEP files, colors and Ray Tracing WB

Post by FreeRadical »

quick61 wrote:The Raytrace camera view is tighter than the 3D view here, though not by a factor of 2.

.BMP.PNG? Must be a difference between the windows and Linux versions as my output graphic format is PNG. Or have you specified something in your POV-Ray output parameters that would cause this? My current output parameters are - +P +A0.1 +AM2 +R4 +J0.5 +UL +UV.
The attachment cu.png is no longer available
Mark

POV-Ray 3.7
I'm also using POV-Ray 3.7. I have not changed the default parameters except for perhaps adjusting the image size:
+P +A
image size: 800x600

Here's the image produced:
POV-Ray output
POV-Ray output
StepCube.bmp.png (3.81 KiB) Viewed 3647 times
Thanks for looking MarK!
FreeRadical
Posts: 49
Joined: Sun Nov 09, 2014 9:48 pm

Re: Problem with STEP files, colors and Ray Tracing WB

Post by FreeRadical »

wmayer wrote:
I wrote:It always stops with an IO error that it cannot write to the requested image file.
Apparently the output image in v3.7 is indeed PNG and it must be inside the same directory as where the .pov is loaded from. But still, the size of the object is the same, it's not zoomed at all.
I didn't have any difficulty installing POV-Ray 3.7 on Windows.

Running has a problem with the default IO restrictions setting (Options->Script IO restrictions). Set it to no restrictions.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Problem with STEP files, colors and Ray Tracing WB

Post by wmayer »

Running has a problem with the default IO restrictions setting (Options->Script IO restrictions). Set it to no restrictions.
Thanks this did the trick.

Now that I get working 3.7 I can confirm the problems you reported. About the scaling I have found out the reason:
When loading your project file the currently set camera has these settings:
OrthographicCamera {
viewportMapping ADJUST_CAMERA
position 6.9053712 5.1616583 14.571684
orientation -0.80729276 -0.51367694 -0.29054156 0.38135356
nearDistance 1.5600353
farDistance 15.774677
aspectRatio 1
focalDistance 8.6602545
height 31.560024

}
If you change the camera to perspective and back to orthographic the settings change to:
OrthographicCamera {
viewportMapping ADJUST_CAMERA
position 1.7738109 14.321496 42.071617
orientation -0.80729276 -0.51367694 -0.29054156 0.38135356
nearDistance 30.966665
farDistance 45.240181
aspectRatio 1
focalDistance 38.096321
height 31.560026

}
After applying the new camera settings to the Ray project the rendering output will be much better.
FreeRadical
Posts: 49
Joined: Sun Nov 09, 2014 9:48 pm

Re: Problem with STEP files, colors and Ray Tracing WB

Post by FreeRadical »

wmayer wrote: If you change the camera to perspective and back to orthographic the settings change to:
OrthographicCamera {
viewportMapping ADJUST_CAMERA
position 1.7738109 14.321496 42.071617
orientation -0.80729276 -0.51367694 -0.29054156 0.38135356
nearDistance 30.966665
farDistance 45.240181
aspectRatio 1
focalDistance 38.096321
height 31.560026

}
After applying the new camera settings to the Ray project the rendering output will be much better.
Aha! That is a much better scaled view.

Here's what I get now.
StepCube.bmp.png
StepCube.bmp.png (7.44 KiB) Viewed 3596 times
That doesn't look quite right to me ... the top of the cube is strange. It looks like the edge between the front (vertical) face and the top face is in the middle of the top face. Maybe that is an optical illusion.

Update: It looks much better using radiosity. Maybe the black line across the top is actually a small gap and behind it is a reflection?

To get the cube to render in red, I had to change the color in the View tab before adding it to the render project.
Post Reply