Home Technical Talk

Specular in UDK Shaders

polycounter lvl 13
Offline / Send Message
GarageBay9 polycounter lvl 13
Having some trouble getting the two specular slots to behave the way I want them to in UDK.

By my understanding, Specular should be specular color, and with a texture map plugged into it, should control the per-pixel color of any specular highlight. Specular power should be just that, a grayscale map that controls the intensity of the specular highlight on a per-pixel basis.

What I'm actually getting is that when I plug anything into just the Specular channel (either the diffuse, multiplied to brighten it up), or my plain grayscale spec power texture, I get a soft highlight with strange falloff that has no color and doesn't seem to actually be affected by the Specular texture.

When I put anything into the Specular Power channel, I get an insanely blown-out specular highlight that has no color and has strange gaps in it as if it has a 1-bit alpha mask over it.

I'm just trying to get basic control of the specular intensity and color on a per-pixel basis.

Absolute bliss would be mixing in a fresnel term so that the falloff would behave properly according to illumination angle. I tried that with the Fresnel expression and one of the Light / Camera / ReflectionVector expressions, but none of them seemed to produce the correct result (and some of them didn't even work at all).

Some moderate googling keeps turning up the same "basic materials in UDK" tutorials. : \

Replies

  • cholden
    Options
    Offline / Send Message
    cholden polycounter lvl 18
    In UDK, plugging a specular texture into the specular slot uses the spec texture as spec level and spec color. In Spec Power, it's common to plug in a constant (or para for instances) to control this. It behaves as Gloss, or making that spec highlight smaller the higher the number goes.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Pictures would really help here... It's a bit hard to tell what you're doing wrong with the specular.

    spec power is from 0-100 so you'll need to add a multiply node with a large value (eg 50) to get a normal highlight.

    Oh and I'd suggest having a look at the existing materials that are in the example levels that come with the UDK. They'll give you a better idea of what sort of thing is possible.
  • GarageBay9
    Options
    Offline / Send Message
    GarageBay9 polycounter lvl 13
    cholden wrote: »
    In UDK, plugging a specular texture into the specular slot uses the spec texture as spec level and spec color. In Spec Power, it's common to plug in a constant (or para for instances) to control this. It behaves as Gloss, or making that spec highlight smaller the higher the number goes.

    So how the hell do I separate out those specular terms? Say I want to fake some sub-surface scattering cheaply with a wide, soft spec using a slightly brighter color as the spec color, or a surface that flouresces when light falls on it (large spec highlight, relatively low spec power, bright neon spec color)? You can't do that without separate control of spec color and spec power...

    In Flight Sim we had separate control of spec color and spec power using the RGB of the _spec texture as spec color and 8-bit alpha as spec power (there was a numerical setting for intensity scale). We could also dictate a 4x128 pixel fresnel ramp to control falloff of the specular highlight according to view angle.

    That's the kind of control I'm aiming for at the moment.
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    GarageBay9 wrote: »
    So how the hell do I separate out those specular terms? Say I want to fake some sub-surface scattering cheaply with a wide, soft spec using a slightly brighter color as the spec color, or a surface that flouresces when light falls on it (large spec highlight, relatively low spec power, bright neon spec color)? You can't do that without separate control of spec color and spec power...

    In Flight Sim we had separate control of spec color and spec power using the RGB of the _spec texture as spec color and 8-bit alpha as spec power (there was a numerical setting for intensity scale). We could also dictate a 4x128 pixel fresnel ramp to control falloff of the specular highlight according to view angle.

    That's the kind of control I'm aiming for at the moment.


    What you have described is sounding quite possible with the unreal shader editor or did I miss something important?
  • Stromberg90
    Options
    Offline / Send Message
    Stromberg90 polycounter lvl 11
    From what i know you use a lerp for the spec power.
    The gloss map goes into the Alpha of the lerp then you make 2 constant nodes plugin the highest spec value in A and the lowest in B.

    I belive thats how it works.
  • GarageBay9
    Options
    Offline / Send Message
    GarageBay9 polycounter lvl 13
    cw wrote: »
    What you have described is sounding quite possible with the unreal shader editor or did I miss something important?

    I'm sure it is, I just can't make it work. Assume user error for now... :poly142: With a little more experimenting, I have gotten some noticeable color in the specular highlights, but I'm still not getting much of a distinct per-pixel response from the highlight itself. It almost looks like it's calculating the highlight per-vertex. I'll try and get some screenshots.
    From what i know you use a lerp for the spec power.
    The gloss map goes into the Alpha of the lerp then you make 2 constant nodes plugin the highest spec value in A and the lowest in B.

    I belive thats how it works.

    Thanks! I'll give that a shot...
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    I'm gonna fire up UDK and check I haven't used it for a while so I'm rusty in my brain as to what can or cannot be done.
  • Neox
    Options
    Offline / Send Message
    Neox godlike master sticky
    if you really want 2 seperate maps controlling the specular use a b&w map that multiplies over your full color map as input, but its rather stupid as using a 0,0,255 blue and weakening it by 50% with a multiply is the same as just using 0,0,128 - if its easier for you to set it up this way you could do both maps, multiply them in shader and later multiply them in PS and exchange the multiply in shader with your premultiplied map
Sign In or Register to comment.