Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Materials Blending a'la UDK


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 maxest   Members   -  Reputation: 294

Like
0Likes
Like

Posted 16 May 2012 - 01:23 AM

Hey,

I've just stumbled upon an interesting video showing off materials blending in UDK (http://www.3dmotive.com/training/udk/advanced-mesh-paint-with-udk/) and I was wondering how such an effect could be implemented.

There are two ways that this could be accomplished I can think of.
First is to render the mesh twice and use alpha blending. One mesh would be rendered on top of the other one with alpha blending turned on.
The second way would be to render mesh once, with both materials computed in a single shader and lerped at the end. That would however require some materials generation system.

Which solution do you think UDK uses? Does it render mesh twice, or does it use its internal material system to combine component materials?

Sponsor:

#2 InvalidPointer   Members   -  Reputation: 1444

Like
0Likes
Like

Posted 16 May 2012 - 08:04 AM

Neither, it's all the same material. You're really just dinking with opacity values and shader constants to create variety.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.

#3 maxest   Members   -  Reputation: 294

Like
0Likes
Like

Posted 16 May 2012 - 12:02 PM

Are you completely sure of that? An artist told me that he could blend separate materials in UDK and asked me if I could do the same in Unity. Of course, "material" is quite a high-level concept which differs in UDK and Unity, so I was wondering how this could actually be done technically in UDK.

#4 MJP   Moderators   -  Reputation: 11786

Like
1Likes
Like

Posted 16 May 2012 - 12:58 PM

I'm not sure how Unreal implements it, but in our engine we do all of the material layer blending in a single pass. To make it nicer for the artists the tool supports having a layer derive its properties from a separate material, and then we build a shader with all of the seperate material properties specified for each layer. This obviously requires some pretty complex tools and build pipeline support.

IMO this is really the only way to do it, because rendering in multiple passes is expensive. It also prevents you from blending together the material properties from multiple layers...for instance a lot of times you want to blend the normals from multiple layers and then apply lighting to the surface (imagine a layer of water running over some bricks). With deferred rendering you can blend G-Buffer properties, but of course only if your G-Buffer uses blending-friendly texture formats and packing. And of course you have to blend multiple render targets, which may not be very cheap.

Edited by MJP, 16 May 2012 - 01:02 PM.


#5 maxest   Members   -  Reputation: 294

Like
0Likes
Like

Posted 16 May 2012 - 01:32 PM

I'm not sure how Unreal implements it, but in our engine we do all of the material layer blending in a single pass. To make it nicer for the artists the tool supports having a layer derive its properties from a separate material, and then we build a shader with all of the seperate material properties specified for each layer. This obviously requires some pretty complex tools and build pipeline support.

IMO this is really the only way to do it, because rendering in multiple passes is expensive. It also prevents you from blending together the material properties from multiple layers...for instance a lot of times you want to blend the normals from multiple layers and then apply lighting to the surface (imagine a layer of water running over some bricks). With deferred rendering you can blend G-Buffer properties, but of course only if your G-Buffer uses blending-friendly texture formats and packing. And of course you have to blend multiple render targets, which may not be very cheap.

What about shader instructions or textures limits? For instance, in our engine we right now have quite a simple shader that blends 4 diffuse maps. If we added normal maps that is as much as 8 textures (not counting others, like shadow map[s?]). I don't remember exactly the limits for this in Shader Model 3.0 for instance, but that is quite a lot of texture data to sample in a single shader. A good thing about that is that we could afford many ALUs without sacrificing much or any performance :).

#6 Frenetic Pony   Members   -  Reputation: 1405

Like
1Likes
Like

Posted 16 May 2012 - 02:42 PM

To get around blending 8+ textures (or at least get around the increasing performance hit for such) more people are going for baked blending using Megatextures. All your blending baked into one texture, a good trade off between performance and disc space if you've got the latter to spare.

Of course I wouldn't consider this a silver bullet. Odds are digital distribution will become momentously more popular for the next generation of consoles, and the less disc space you use the easier it is for people to get.

Edited by Frenetic Pony, 16 May 2012 - 02:44 PM.


#7 MJP   Moderators   -  Reputation: 11786

Like
0Likes
Like

Posted 16 May 2012 - 02:57 PM

What about shader instructions or textures limits? For instance, in our engine we right now have quite a simple shader that blends 4 diffuse maps. If we added normal maps that is as much as 8 textures (not counting others, like shadow map[s?]). I don't remember exactly the limits for this in Shader Model 3.0 for instance, but that is quite a lot of texture data to sample in a single shader. A good thing about that is that we could afford many ALUs without sacrificing much or any performance Posted Image.


SM3.0 is limited to 16 textures. I don't remember the instruction count limit, but I think it's in the thousands and you could possibly get around it using loop instructions. Either way I don't work on SM3.0 platforms, so I'm not too worried about that. Posted Image

If you want to look at it from a performance point of view then blending in the shader is always going to win. With multiple passes you end up doing the same amount of work per-pixel, except you have to pay for alpha blending and processing/rasterizing your triangles for a second time.

#8 MJP   Moderators   -  Reputation: 11786

Like
0Likes
Like

Posted 16 May 2012 - 03:00 PM

To get around blending 8+ textures (or at least get around the increasing performance hit for such) more people are going for baked blending using Megatextures. All your blending baked into one texture, a good trade off between performance and disc space if you've got the latter to spare.

Of course I wouldn't consider this a silver bullet. Odds are digital distribution will become momentously more popular for the next generation of consoles, and the less disc space you use the easier it is for people to get.


Yeah that is one of the really nice things about unique virtual texturing...it must be nice to not have to use vertex painting or decals to get some surface variety. Personally though the combination of LOTS of disc space + crappy runtime texture compression + lower peak texel density aren't very appealing.

#9 InvalidPointer   Members   -  Reputation: 1444

Like
1Likes
Like

Posted 17 May 2012 - 08:54 AM

Are you completely sure of that? An artist told me that he could blend separate materials in UDK and asked me if I could do the same in Unity. Of course, "material" is quite a high-level concept which differs in UDK and Unity, so I was wondering how this could actually be done technically in UDK.

No, for realz. There may be other approaches, but the specific materials used in the video you linked to were all designed explicitly to support vertex color-based blending. Unreal lacks the concept of multipass rendering for materials outright.

EDIT: In fairness, I think lighting is done multipass, but this is not something you work with as an artist. The material compiler generates a lightmap-lit shader for 'ambient' and point light additive shaders.

Edited by InvalidPointer, 17 May 2012 - 08:56 AM.

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS