Front Facing Alpha Only?

Hey Guys!

While waiting for 4.5.0 to be officially released I had been spending some time in Unity.
And I had been learning CG script. (To a lesser degree)

One of things I found you could do is write 2 separate passes.
One that calculated with full alpha, and then the visible pass which has fresnel alpha, etc.

meant that the first front faces would cull all other front and back faces of the same object.
Much like how a ghost would appear.

I can’t for the life of me figure out how to do it.

I have an image that gives the idea of what I’m after.

&stc=1

If anyone could help it would be massively appreciated!

Thanks guys!

-

Have you tried disabling Two-sided material rendering for your translucent material? If you do, UE should render nothing for backfaces, so the only visible elements of the material would be the outside (i.e. translucency should not let you see through the outside of the left half of the mesh to the inside of the right half, since the inside of the right half isn’t rendered at all.

@Loken01 - Have a look at TheBeej’s answer to my similar here: https://forums.unrealengine.com/showthread.php?45945-Translucent-Water-Material-Displacement-Banding-Issue

My was an ocean, but using the same method you should be able to get your setup working as well. :slight_smile:

**Hey Guys!
**
**RhythmScript:
**Everything you saw in the top image is actually all front faces. Two-sided is off.
Thanks for the reply though!

**:
**That looks like a perfect answer as to what I’m trying to achieve, however in terms of optimisation, I’m a bit worried.
I was going to be using on a skeletal mesh, so would I have to duplicate the entire moving mesh component?
(Would like to avoid basically doubling the vert and bone count for a simple Ghoul/Ghost)

**Thanks so much!
**
-

Well You’ve come accross a fundamental problem in realtime rendering, especially in deferred renderers such as UE4.
If you have nested or partially overlapping meshes you can try and set the transparency drawing order manually to resolve the, but in a skeletal mesh where you can probably see all of its sides while it moves you’re gonna have to use a dynamic method such as the one alreday linked by .
True OIT (order independent transparency) is not implemented right now in UE4, and as every solution out there has drawbacks of some sorts, i think it will take some time until the epic guys figure out how to do it in an elegant way.
In the meantime you’re gonna have to use hacks.

Take a look at to have a clearer understanding of the:
http://en.wikipedia.org/wiki/Order-independent_transparency

Hey !

Thanks so much for the info!
It seems like I’m going to have to create my own implementation for then. :smiley:

Would there be any way to create my own shader for Unreal?

The method I’m used to is like so:

  1. Draw to the z/depth-Buffer (as if it was Opaque), but don’t draw the mesh,
  2. then draw the mesh with required alpha,
  3. thus avoiding ordering issues, and technically… (I think) only drawing once.

I’m not even sure if is possible, however I don’t yet know how Unreal handles shaders.

For instance:

  1. If I made one, would it be used in every material?
  2. If not, how would I tell that one material to use a specific shader?
  3. Can they have more than one pass?

Sorry for the bombardment of questions!
I’m just really eager to learn! (However delving into PBR sounds scary)
**
Thanks!

**

To get to work with using the link I added earlier, you will have to create a blueprint with 2 of the same skel meshes with both at the same location (they will do by default when added), for the first one in the list apply your material as you have been, and for the second one, you will be applying a material that has no inputs (just a new blank opaque material, will default to totally black).

Now in the blueprint, with the second mesh selected, go down into the properties and change the settings to look like :

&stc=1

  • Turn ON “Render Custom Depth”
  • Turn OFF “Render in Main Pass”

Now the mesh and material applied to it will not be rendered, but instead input data to the depth buffer.

For your original material, you must now add the nodes shown here, attach your original opacity calculations and plug it into the Opacity slot:

&d=1411951325

And that’s it, it should now work properly. Since it is a blueprint, you can simply drag and drop these into your scene. I would keep a copy of your original material and do some performance testing, for example place 10 of them in a scene, profile it, delete them, then place 10 of the blueprints into the scene and profile again. I am not sure how big of an impact there will be, but since the mesh is not actually rendered, it shouldn’t be too much (performance difference on mine was very minimal, maybe 1-2fps for a 2km square ocean plane with approx 40,000 tri’s).

Yes, every material that has would need to be modified in the same way unfortunately.

Hope that helps! :slight_smile:

A depth prepass for an object is still drawing twice, but usually the whole object is drawn with the minimal amount of texture/material features as possible to reduce the load in the first pass as much as possible. So, the object you’re using to write depth should have a really simple material (you wont see it anyway) and then you only have the cost of rendering the geometry, not the textures. In your case it looks to be pretty low-poly, so it shouldn’t have a noticeable impact on performance.