A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
C4D to Unity Tutorials
Posted: 25 January 2015 11:02 PM   [ Ignore ]  
Total Posts:  9
Joined  2012-07-21

Relatively new to C4D. Very new to Unity thanks to my company’s interest in augmented reality.

Rick’s tutorial series cleared up a whole lotta the fog, but there’s one question I can’t seem to find an easy answer to:

How do you get an alpha channel/transparency to carry from C4D into Unity with an object? I’ve read a lot in various forums about Unity’s shaders that kinda make a little sense…but nothing resembling a clean and simple workflow to make this happen.

Thanks in advance for any guidance you can give!

Profile
 
 
Posted: 26 January 2015 01:28 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Wahoorob,

I’m not savvy with Unity, so: Just a simple question, is the link describing your problem?

http://docs.unity3d.com/Manual/HOWTO-alphamaps.html

If so, please test the option of straight alpha in C4D with Unity. I hope that helps.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 26 January 2015 04:44 AM   [ Ignore ]   [ # 2 ]  
Total Posts:  9
Joined  2012-07-21
Dr. Sassi - 26 January 2015 01:28 AM

Hi Wahoorob,

I’m not savvy with Unity, so: Just a simple question, is the link describing your problem?

http://docs.unity3d.com/Manual/HOWTO-alphamaps.html

If so, please test the option of straight alpha in C4D with Unity. I hope that helps.

All the best

Thanks, Doc…I’m diving in to that right now. I’ll let you know how it turns out. If you’re interested in what I’m working on you can get a look by downloading a free app called DAQRI, loading it onto your smartphone or tablet, and pointing your camera at the image of the hospital on this webpage:

https://www.normanregional.com/en/newsroom.html?news_id=305

A blue progress bar will let you know the app has recognized the image and is loading the augmented reality experience.

Rob

Profile
 
 
Posted: 26 January 2015 05:41 AM   [ Ignore ]   [ # 3 ]  
Total Posts:  9
Joined  2012-07-21

Hi Doc,

Just finished working through the edge padding suggestion and apparently these are not the droids I’m looking for. Here’s a more detailed explanation of what I have, along with results of the edge padding work.

The first 3 attached images show my initial (& pretty standard) attempt at creating the material for the cube that I exported to Unity. The first is a render showing the alpha channel at work as intended. The other two just show the material settings. The alpha channel is set up in the Attributes tab as it normally is for C4D materials. But Unity doesn’t see any of that when I export the object as an FBX and gives me a gray cube.

Since I’m limited to 3 images per message I’ll attach the results of the Unity edge padding attempt. Spoiler alert: it did not go as hoped…

Profile
 
 
Posted: 26 January 2015 05:59 AM   [ Ignore ]   [ # 4 ]  
Total Posts:  9
Joined  2012-07-21

Attached are the images using the .psd file created using the edge padding technique with no C4D alpha channel applied.

When the cube is exported into Unity it simply shows the full .psd image.

Here’s a link to a discussion I came across on the Unity forums that talks about the issue:

http://answers.unity3d.com/questions/16120/materials-from-cinema-4d-to-unity.html

There are some clues here, but I just can’t get my head wrapped around what they’re suggesting. It’s my understanding that Unity looks at the incoming textures and uses its own shaders to reproduce what it sees, but I get lost on exactly what they’re talking about, even after following the baking technique given by the one poster. Perhaps I’m missing something in the process.

Profile
 
 
Posted: 26 January 2015 03:25 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

HI Wahoorob,

The link that I gave you, which is the Unity Manual, was not so much about the padding, as it was about the way Unity seems to work with Alpha channels vs Layer transparencies.

The Link that you gave in post #4 discusses the problems to use Shaders (procedural methods—not initially pixel-based). Yes, the thread is confusing as they use terms interchangeably. Textures are pixel-based, and shaders are based on a coded definition. But the main information, which I think is true is “You can’t transfer the shader properties of C4D into Unity.” Which Rick says as well in the tutorials, it needs to be baked.

What I can see in your images is that you use transparency layers, which is (as the link of the manual suggests) not the way Unity works. The Padding is is a way to simulate a kind of “Straight Alpha”.

Try to avoid for a test any transparency and alpha at all. Have the image (layer) completely filled with color. If that works, set up a new channel in that PSD file, a real alpha channel that contains the “mask” that you are after.
This is how I understand the manual and what I have read so far.

The Straight Alpha technique is normally the better way, for many reasons, even in high end compositing.

Unity needs a clean UV information and a straight alpha based image information, again separate transparency information and no transparency in the layer.

I need to dive into this app more in detail, please allow for a week or two on my side. Perhaps the support (Unity) might help here.
However, I see that there is a need for it, I know how it feels when you sit between chairs and you need to sit on both at the same time to get it working. As I care only about the connection between both, I hope to reach that state quickly.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 26 January 2015 04:21 PM   [ Ignore ]   [ # 6 ]  
Total Posts:  9
Joined  2012-07-21

Thank you, sir! I appreciate the input. I will revisit the Straight Alpha technique. I also appreciate the patience in helping me sort out what is, for me, a whole new field of play in C4D.

Profile
 
 
Posted: 26 January 2015 06:03 PM   [ Ignore ]   [ # 7 ]  
Total Posts:  9
Joined  2012-07-21

Nothing to see here.

Move along. Move along.

Profile
 
 
Posted: 26 January 2015 06:34 PM   [ Ignore ]   [ # 8 ]  
Total Posts:  9
Joined  2012-07-21

Kind of a weird sequence of events happened re: C4D - CVSmart Export - Unity that I’m just unable to explain…

So I guess I’ll just leave it alone unless it happens again.

Profile
 
 
Posted: 26 January 2015 07:28 PM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Wahoorob,

Please attach the files. Otherwise it is not possible to say anything. We are talking here about Rick’s Game tutorial, right? As the head line of the thread is “C4D to Unity Tutorials”. You mentioned that you like to have a different use, but first we need to go through things that are tested and provided here, to see that this is working. IF that is working, we might go further.

What I don’t get why you use the
“Use the Revert to Saved command in UV Mesh Window/File to apply edited texture to object in Cinema 4d”
step in C4D, what was your idea about?

If you think that the Cv Smart Export plug in drives the problem, export natively. As Rick points out, textures have a similar place in Unity, except (so far I followed) that they create a folder structure.

I have attached a zip file with a texture from C4D to Unity4. Please check if that works for you. FBX exported natively (no plug in).

My best wishes.

(The checker images on the right is taken from the UV editor in C4D, so you can compare it.)

File Attachments
CV2_r16_drs_15_UNex_01.zip  (File Size: 1025KB - Downloads: 273)
 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 26 January 2015 08:14 PM   [ Ignore ]   [ # 10 ]  
Total Posts:  9
Joined  2012-07-21

OK….I believe we have a successful export. I just want to make sure I understand the concept:

Unity will look for all of the material information in the .fbx object’s material file, in this case a PSD. One of those layers should be an alpha channel of the main layer. A second layer is a padding layer. The third layer is a solid color. Unity will ignore any of the channels I would typically use in the Attributes section of C4D.

The final piece of the puzzle takes place inside Unity once the .fbx object and it’s accompanying texture haver been imported. By selecting the imported object and then changing the Shader to one of the transparent options in the Inspector the alpha channel and transparency are then activated.

Hopefully that’s it. I’m going to try and repeat this…repeatedly…to make sure I have the process locked in.

Thanks again for your help. You’ve made my Christmas card list!

Profile
 
 
Posted: 26 January 2015 08:18 PM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

If you go in Unity into Materials, you find a pull down menu. This shows clearly what channels (RGB-A) are used. My initial impression is, that “Decal” allows for a transparent, but keeps a background texture.
The Unlit Transparent, allows for an Alpha Channel to be “cut out”.  the gray value of that channel is in sync with that slider. Note: alpha means here a real channel (PSD) where the RGB channels are—NOT a layer transparency.

As this is not part of the tutorials, and clearly not a C4D question, I think I went the extra mile here, and we have reached the point where an “Unity Forum/Support” has to take over.

All the best

P.S.: I saw your post above, which came in while testing and writing. So it seems we have the same idea about. Shader in Unity means more a container and how this container uses a texture. In C4D a shader is normally seen as an algorithm which produces a pixel-values, but yes, some use textures as well for that work, but I hope we got the confusion out of the pipeline. Thanks for the question!.

(image on the left: Unity, image on the right: Photoshop/channels)

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 26 January 2015 09:12 PM   [ Ignore ]   [ # 12 ]  
Total Posts:  9
Joined  2012-07-21
Dr. Sassi - 26 January 2015 07:28 PM

Hi Wahoorob,

Please attach the files. Otherwise it is not possible to say anything. We are talking here about Rick’s Game tutorial, right? As the head line of the thread is “C4D to Unity Tutorials”. You mentioned that you like to have a different use, but first we need to go through things that are tested and provided here, to see that this is working. IF that is working, we might go further.

What I don’t get why you use the
“Use the Revert to Saved command in UV Mesh Window/File to apply edited texture to object in Cinema 4d”
step in C4D, what was your idea about?

If you think that the Cv Smart Export plug in drives the problem, export natively. As Rick points out, textures have a similar place in Unity, except (so far I followed) that they create a folder structure.

I have attached a zip file with a texture from C4D to Unity4. Please check if that works for you. FBX exported natively (no plug in).

My best wishes.

(The checker images on the right is taken from the UV editor in C4D, so you can compare it.)

Thanks for the C4D texture. That will help tremendously. I’ll also play around with FBX exporting negatively.

I use the “Revert to Saved” command based on a UV texturing tutorial I followed that suggested it. Seems like it works well for most UV texturing processes that involve Photoshop. Would the alternative be to just use the “Open Texture” command?

Finally - I think I’ve figured out that the CV Smart Export plugin wasn’t the problem. I think it might be a C4D bug/issue/quirk that has popped up again, but disappears with a C4D restart.

Again…thanks so much for your patience and input. I’m grateful for your help and insight.

Profile
 
 
Posted: 26 January 2015 09:50 PM   [ Ignore ]   [ # 13 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Thanks for the reply, Wahoorob.

To go back to the last saved state of the file, means that whatever you did after the last save—is lost—except anything which was exported or saved separately. If there was any need to change the slightest thing in the UV information (why go otherwise to the UV Editor), you lose it and with it, the usefulness of the texture.

To just create a texture, you can go to the place where you load textures and use the pull down menu entry, “Create New Texture”, and you only have to change to the (upper right corner) Layout>Body Paint 3D menu, to get the main Menu>Save Texture.

(As I do not know the tutorial, nor the motivation why s/he went that route or even say such thing – I leave it alone. Please no link to that—just to avoid trouble, thanks. :o)

If you found something in C4D that you call a bug, please report it to the Support, otherwise it might stay a bug forever. Yes, to have a random problem is not easy to report… I know. :o)

You’re welcome and I hope you get your project running smoothly!

My best wishes

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 03 March 2015 06:11 AM   [ Ignore ]   [ # 14 ]  
Avatar
Total Posts:  1
Joined  2015-03-02
Dr. Sassi - 26 January 2015 01:28 AM

Hi Wahoorob,

I’m not savvy with Unity, so: Just a simple question, is the link describing your problem?

http://docs.unity3d.com/Manual/HOWTO-alphamaps.html

If so, please test the option of straight alpha in C4D with Unity. I hope that helps.

All the best

I think a worthwhile share for me. As a designer I want to make a creative attention in my career. I just need a video tutorial for this action.

Profile
 
 
Posted: 03 March 2015 04:50 PM   [ Ignore ]   [ # 15 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Ataur Sujon,

A typical example for an premultiplied image is a layer in photoshop (transparent) and a soft brush stroke is applied. The soft-ness of the stroke has not a direct accessible alpha information. I see it sometimes in tutorials, that a CMD click on the layer will produce a layer mask (or the selection thereof), but it doesn’t prevent the double transparency problems. It certainly doesn’t create a straight alpha image! So, lots of confusion here and based on that I understand your request for an tutorial. It can drive the quality down if done wrongly.

If I understand the question/quote correctly, you need a tutorial that allows for the creation of “straight-alpha” RGB files from premultiplied files (from Photoshop transparency layer, merged to something…).

In a nutshell, just to give a little bit of information: Sometimes the “transparency” information of an RGB file is already stored and the process is called “premultiplied”. Why multiplied? The idea of transparency is normally given with the idea of an value of zero/black (=transparent) and one/white (=opaque). If the resulting value is for example 0.5 then we have a semi transparent. (I use here the term resulting, as sometimes a gamma value might change the result.)

Each R,G and B value is then multiplied with such an alpha value for transparency.

If an application expect an un-multiplied RGB image and the transparency information in a separate channel, e.g. the alpha channel, then a problem can occur if the image was already pre-multiplied. Simply said, the alpha information is then twice applied. This leads to artifacts. Typically in a seam around the image. As this is certainly not the best practice, many compositing books take on this theme. It is not trivial, but somehow even today often ignored.

The link that you quoted shows clearly that Unity needs pure RGB values, not premultiplied. Hence—premultiplied files have more information, realtime application have no interest in large files, hence the realtime idea.

So, if someone needs transparency in an object, then this is extra work for the real time engine.

To get an RGB file without that premultiplication is discussed in the tutorial inside the link.

I have explained the straight alpha vs premultiplied in the Multi-pass tutorials.

The tutorial in the link suggest to use an Action script that they provide. The action script is simple, it just creates new layers and moves them, so the problem areas of the edges become opaque again.

Alternative, you can duplicate the layer, protect transparency and fill the layer with black. Then take the original one do two copies and merge them, copy again and merge the two. Do this as often as your image has a bit depth, eight times for 8 bit or 16 times for integer images. Make an Action script, and for floating point images run it several times.
The idea is, that if the transparency was as low as “one” (0-255 for 8bit) then 2, 4, 8, 16, 32, 64, 128, 256 would be the result of eight repetitions. This should help for textures to get transparency areas opaque. The stored black layer needs one more step to work as alpha, it needs a white layer below and merged as well. Now you have both RGB and Alpha. That is the only real “procedure I found is working. In the past I had others, but I do not like to share them anymore.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile