Search Unity

reflection material help

Discussion in 'Shaders' started by gfxguru, Aug 7, 2010.

  1. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    i have some trouble with reflective unity materials.
    How to control the amount of reflection in ref. materials. When i make a material reflective it reflects like mirror. What i want is a reflection on a white glazed pot. The inspector says Alpha controls the amount of reflection, but it has no effect. I have even tried alpha in the image but that gave some very dark results...

    Am i wrong somewhere? :(

    What i want is to reduce the reflection amount from 100 percent to some 5 percent...
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    that requires an own shader, there is no control over the reflection amount in the offered ones
     
  3. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    With Unity's built-in reflective shaders, you can reduce the amount of reflection by darkening the reflection color (Or, alternatively, increase it), using different reflection color values.



    If you mean the actual "Sharpness" of the reflections, much can be obtained by adjusting the glossiness to produce wider specular highlights, or by blurring the reflection texture (which can get restrictively expensive for realtime use)
     
  4. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    Darkening the reflection color does not help...it will darken the whole detail, since i am using baked texture for the diffuse.What is the purpose of the refstrenth?
     

    Attached Files:

  5. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    The contribution of the cube map is determined as follows:

    Code (csharp):
    1. half4 frag (v2f i) : COLOR
    2. {
    3.     half4 texcol = tex2D (_MainTex, i.uv);
    4.     half4 reflcol = texCUBE( _Cube, i.I );
    5.     reflcol *= texcol.a;
    6.     return reflcol * _ReflectColor;
    7. }
    Which means:

    Code (csharp):
    1. reflectionColor = ReflStrength * ReflColor * ReflCubemap
    To reduce the reflection contribution, either darken the reflection colour (this will affect the entire surface), or darken the alpha channel in the spots where you want weaker reflection.
     
  6. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    You using the beta? I doubt the shader works in it, because Blend AppSrcAdd AppDstAdd is deprecated. You can copy and paste the appropriate passes, instead of using the two UsePass statements, and use Blend One One in the second pass. This shader might not have been rewritten to use surface shaders yet. If that's true, until it is, it's possibly a workaround.
     
  7. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    Thanx for all the replies...

    @Daniel Brauer - i have tried your suggestion of making an diffuse texture with alpha information.The reflection is according to alpha...but the rgb data of that image is not taken..for reflective diffuse,specular and vertexlit. For all other material types its considering the rgb
     

    Attached Files:

  8. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    I think the problem you're encountering is that ambient light is not taken into account for reflective materials. Without any dynamic lights, your diffuse channel will be ignored.
     
  9. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    No lights are there...
    I dont use lightmaps always... i use diffuse baking in some case..
     
  10. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    (please note that I edited my post above for clarity while you were posting)

    The reflective shaders do not have a place for baked light. If you put it in diffuse, as you do above, you won't see anything without dynamic lights. You should be using light mapped shaders for any baked lighting.
     
  11. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    Thanx for the help....

    I thought of performance issues to do some baking as diffuse...

    is there any considerable difference between using diffuse and lightmap?
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    lightmap = 2 textures, one for diffuse, one for "shadow baked ontop of the diffuse"

    you can also use a diffuse with that but it means that:
    1. diffuse can not be tiling
    2. you will normally need much more texture space and textures due to it
    3. the lightmap can only be grayscale (alpha channel) and you lose alpha material possibilities
    4. you can not use the glow postfx as that bases on the alpha channel of the diffuse texture