Home Technical Talk

UE 3 - Shader

polycounter lvl 18
Offline / Send Message
shadows polycounter lvl 18
Got bored, started to play with shaders in UE3 and this thing just kept on growing. Doesn't do anything that special..yet other than blending two set of textures together by using vertex color and a height map. And giving you a lot of options with just one shader.
It's a scalable shader, so as you turn the switches on and off . More options will show or disappear.
And since it's scalable, when you turn something off (StaticParameterSwitchesValues) it will not add up to the total shader instructions and it will drop the textures that it is not using. That way it does not add up to the total texture call.

I will clean it up a bit, add a few more things and reorder some of the switches later. If you find any bugs or want something extra let me know.

Some of the options...excuse the textures. Good enough for testing. ;D
This is with a lot of things turned on if you want to just use a diffuse, spec, normal. You can also do that and it will drop all the unnecessary instructions.
ue3_shader.jpg

http://dl.dropbox.com/u/849247/SC_shadersV1.upk

StaticParameterSwitchesValues.
Use Color Specular? Drops the red channels of the MSG textures and uses a color specular texture instead.

Use Simple Gloss? Uses a simple constant to define the strenght of the glossiness. Drops the blue channels of the MSG textures.

Use Reflection? By default uses the result of the vertex and height map mask.
Use Base Reflection Mask (G)? Uses the green channel of the BaseMSG map for the reflection mask.

VectorParameterValues.
Normal Strenght : Increases the strenght of the normal map. RGB values should be kept between 255,255,255 and 255,255,0

Specular Tint : Tints the specular of the red channel from the MSG textures.

Base MSG :
Green channel. Reflection mask
Red channel. Specular map
Blue channel. Gloss map

Overlay MSG :
Green channel. Height map (used for blending with vertex color)
Red channel. Specular map
Blue channel. Gloss map

Replies

  • Ben Apuna
    Awesome, thank you very much :)
  • Neox
    Offline / Send Message
    Neox veteran polycounter
    instead of using a premade fresnel you could create your own and give the user the possibility to change the falloff :)
  • shadows
    Offline / Send Message
    shadows polycounter lvl 18
    Neox wrote: »
    instead of using a premade fresnel you could create your own and give the user the possibility to change the falloff :)

    Done, now the size of fresnel falloff can also be changed, ill update it later today with other things aswell
  • PixelMasher
    Offline / Send Message
    PixelMasher veteran polycounter
    looks pretty awesome dude. one thing to keep in mind though, for every variation of the material instance it has to recompile and creates another call if Im remembering right. on most projects i've worked on they have had variations of shaders, one super complex like this, with others being simpler so there is less recompiled materials due to less variations of material instances.

    I really like how you are using channel textures too with the option to tint the spec, great way to save some texture memory.this looks like quite the ubershader dude, thanks for sharing.
  • shadows
    Offline / Send Message
    shadows polycounter lvl 18
    Yea just read up on Static switches on UDN, and yea it has to compile a new material for every combinations used. umm So I guess ill end up splitting it up a bit in the end.
  • Irreal
    Offline / Send Message
    Irreal polycounter lvl 10
    Thanks. I've been messing around with this shader at work for most of the day.
  • shadows
    Offline / Send Message
    shadows polycounter lvl 18
    Version 2
    New fresnel type, the falloff scale can now be changed and using the mask from the green channel (reflection mask) of the Base MSG texture the fresnel can be masked out. That mask can also be blended, so that fresnel will still show on the rest of the model even if the reflection mask is pure black and white.

    Use Diffuse color simple? Tints the whole diffuse texture.
    Use Diffuse color RGB? Uses an extra texture with all the channels used as masks to change the colors of the diffuse texture.

    Removed Ambient Color shading, since this cannot work with the current method of texture blending. Its kind of pointless to have two different ways of shading the meshes, when it can't be used on everything.

    Normal strenght doesn't work anymore if t fresnel is used. Still inside the material mainly for testing purposes.

    http://dl.dropbox.com/u/849247/SC_shadersV2.upk

    ue3_shaderv2.jpg
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    I think it's awesome you're experimenting and working with the material system. I did want to make a point though that from a practicality standpoint these materials can get pretty hairy. When it comes time to optimize it's hard to make quick dirty optimizations to a subset if every material is based on one master. I also want to point out these materials become a pain in the ass to update when a lot of materials instance off of it because it has to propogate changes when you compile. You should take a look at doing some materials via custom lighting. It could be very rewarding.
  • shadows
    Offline / Send Message
    shadows polycounter lvl 18
    Yea right now this "thing" is just a way to try out new things and give people that are interested a shader that they can use to show off their assets into the engine, not something one should use in a production environment.
    Is there anything about custom lighting on UDN?, didn't see anything about it there.
  • planaria
  • shadows
Sign In or Register to comment.