Hi,
I am Scene.Render() method to create an PNG image of my 3D models.
I do following steps
- Load .stl models
- Apply transparent PhongMaterial
- Add models to the Scene
- Add lights
- Save the Scene as FileFormat.Universal3D
- Create the Camera
- Set ImageRenderOptions { EnableShadows = true, BackgroundColor = Color.White }
- Render the image using
outputScene.Render(camera, outputFilePath, new Size(1024, 1024), ImageFormat.Png, opt);
My 3D scene in .u3d file gets the transparence, but PNG image doesn’t reflect transparency at all.
Could You please advise mi if it is possible to have model transparency rendered with Aspose 3D (Example code would be highly appreciated)?
@marcin.giemza,
Kindly send us the complete details of the scenario, including source models and code. We will investigate and share our findings with you.
Hi,
I attach complete solution You can use to reproduce the issue.
Please download it form here Dropbox - Link Expired - Simplify your life
@marcin.giemza,
We have logged an investigation under the ticket ID THREEDNET-351 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
Hi,
what are the findings in this topic. We were stopped with application development by this issue and it slowly become more and more urgent.
Is that a library issue or models issue? Is it possible to use Aspose 3D to render transparent model in image at all?
@marcin.giemza,
It is difficult to say anything without the completion of analysis phase. Our product team will investigate as per their development schedules. We will let you know once a significant progress has been made in this regard.
Thanks a lot,
would it be possible to give some raw estimation when such an analysis is planned to take place. It is important for us to know is it matter or days, weeks or months.
Regards.
@marcin.giemza,
We have added support of transparent background in the version 18.2 of Aspose.3D for .NET API. In order to render a transparent PNG, you need to set the BackgroundColor to Color.Transparency in ImageRenderOptions. Our product team has resolved the ticket ID THREEDNET-351 and it will be included in the next version 18.2. It is expected to be released in couple of days. We will notify you once the next version 18.2 is published.
@marcin.giemza,
The linked ticket ID THREEDNET-351 has been fixed. Please download and try the latest version 18.2 of Aspose.3D for .NET API.
Hello,
I updated Aspose.3D to version 18.2.0.0 via NuGet. My observations:
- It is not possible to set BackgroundColor to Color.Transparency. However we can set BackgroundColor = Color.Transparent in ImageRenderOptions.
- Model is still not transparent. Image has Transparent Background instead (what we could expect because of the setting)
- My impression is we didn’t understand each other:
- Lack of transparency in the PNG file is one thing
- Lack of transparency in the rendered model in another
When we render model with transparent parts we expect we will be able to see some parts of the model behind transparent parts. If whole the model is transparent, then we expect to see the background behind the model. I whole the model is transparent and the background is transparent, we expect to see what is behind the image.
Currently rendered PNG file has transparent background, but the model with transparent texture is rendered with solid texture. We could live with not transparent background (however it is nice to have a possibility to set background transparency), but when model with transparent texture is rendered with solid texture, it is real issue, because the final image is significantly different form the needed one.
This is example of what we get Dropbox - Solid model example.png - Simplify your life
This is example of what we expect
@marcin.giemza,
Thank you for the details. We are in communication with our product team and will get back to you soon.
@marcin.giemza,
We have fixed transparency issues. You can enable transparency texture mapping in rendering. This will provide per-pixel’s alpha blending ability.
C#
var mat = new LambertMaterial();
var diffuse = new Texture();
//this is the key point property, default value is AlphaSource.None
//which means no alpha information is defined in the texture
diffuse.AlphaSource = AlphaSource.PixelAlpha;
//After the AlphaSource is set to PixelAlpha, the alpha channel in the pixel will be used in blending.
diffuse.FileName = "your-texture-with-alpha-channel.png";
mat.SetTexture(Material.MapDiffuse, diffuse);
This is another way to define material that provide transparency information:
C#
var mat = new LambertMaterial();
// 0 means totally invisible and 1 is totally opaque
mat.Transparency = 0.3;
For the FBX compatibility, the transparency can be achieved by texture with specifying the AlphaSource to a fixed value:
C#
var mat = new LambertMaterial();
var diffuse = new Texture();
diffuse.AlphaSource = AlphaSource.FixedValue;
diffuse.Alpha = 0.3;
mat.SetTexture(Material.MapDiffuse, diffuse);
3rd and 2nd code examples do the same thing, but the AlphaSource.FixedValue makes it compatible with FBX SDK’s design. Aspose.3D for .NET API will automatically set the Texture.AlphaSource to AlphaSource.PixelAlpha on importing U3D file that contains the texture and enabled alpha channel.
Please download and try the latest Hotfix: Aspose.3D for .NET 18.2.1
Hi,
today, after updating to version 18.2.1, model is not rendered to PNG at all. I tested LambertMaterial and PhongMaterial - even setting Transparency (or Alpha) to 1 didn’t help - all the model parts were not visible on th image background.
Maybe You could try to modify solution I attached and send working example?
@marcin.giemza,
Sure, we will investigate your example project with the latest Hotfix version 18.2.1 of Aspose.3D for .NET API, and then will share our feedback with you.
@marcin.giemza,
We managed to find a bug to all objects with non-PBR materials (black result) and it has been fixed. Please download and try the latest Hotfix version 18.2.2 of Aspose.3D for .NET API.
Hi, I tested version 18.2.2. It looks we can have no some model transparency rendered, however rendering result is very different for model and image (having the same transparency values).
Please see on the example: Transparency comparison
@marcin.giemza,
We have logged an enhancement under ticket ID THREEDNET-358 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
Hi,
Were You able to investigate the issue? Maybe we could help somehow? Are provided examples clear?
@marcin.giemza,
The linked ticket ID THREEDNET-358 has been resolved and will be included in the next version 18.3 of Aspose.3D for .NET API. It is expected to be released in the recent week or earlier next week. We will notify you once the next version is published.
The issues you have found earlier (filed as THREEDNET-358) have been fixed in Aspose.3D for .NET 18.3. This message was posted using BugNotificationTool from Downloads module by imran.rafique