Search Unity

Alloy Physical Shader Framework Version 3 For Unity 5

Discussion in 'Assets and Asset Store' started by xenius, Mar 2, 2015.

  1. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    Happy New Year People!

    Is there any way to create parallax offset bump to create fake interior into windows with the current alloy shaders?

    Unreal done it..


    i found this shader code, how to implement with alloy?

    here's the map i used:
    Code (CSharp):
    1. Shader "Custom/InteriorMapping - 2D Atlas"
    2. {
    3.     Properties
    4.     {
    5.         _RoomTex ("Room Atlas RGB (A - back wall fraction)", 2D) = "white" {}
    6.         _Rooms ("Room Atlas Rows&Cols (XY)", Vector) = (1,1,0,0)
    7.     }
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" }
    11.         LOD 100
    12.         Pass
    13.         {
    14.             CGPROGRAM
    15.             #pragma vertex vert
    16.             #pragma fragment frag
    17.        
    18.             #include "UnityCG.cginc"
    19.             struct appdata
    20.             {
    21.                 float4 vertex : POSITION;
    22.                 float2 uv : TEXCOORD0;
    23.                 float3 normal : NORMAL;
    24.                 float4 tangent : TANGENT;
    25.             };
    26.             struct v2f
    27.             {
    28.                 float4 pos : SV_POSITION;
    29.                 float2 uv : TEXCOORD0;
    30.                 float3 tangentViewDir : TEXCOORD1;
    31.             };
    32.             sampler2D _RoomTex;
    33.             float4 _RoomTex_ST;
    34.             float2 _Rooms;
    35.        
    36.             v2f vert (appdata v)
    37.             {
    38.                 v2f o;
    39.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    40.                 o.uv = TRANSFORM_TEX(v.uv, _RoomTex);
    41.                 // get tangent space camera vector
    42.                 float4 objCam = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1.0));
    43.                 float3 viewDir = v.vertex.xyz - objCam.xyz;
    44.                 float tangentSign = v.tangent.w * unity_WorldTransformParams.w;
    45.                 float3 bitangent = cross(v.normal.xyz, v.tangent.xyz) * tangentSign;
    46.                 o.tangentViewDir = float3(
    47.                     dot(viewDir, v.tangent.xyz),
    48.                     dot(viewDir, bitangent),
    49.                     dot(viewDir, v.normal)
    50.                     );
    51.                 o.tangentViewDir *= _RoomTex_ST.xyx;
    52.                 return o;
    53.             }
    54.             // psuedo random
    55.             float2 rand2(float co){
    56.                 return frac(sin(co * float2(12.9898,78.233)) * 43758.5453);
    57.             }
    58.        
    59.             fixed4 frag (v2f i) : SV_Target
    60.             {
    61.                 // room uvs
    62.                 float2 roomUV = frac(i.uv);
    63.                 float2 roomIndexUV = floor(i.uv);
    64.                 // randomize the room
    65.                 float2 n = floor(rand2(roomIndexUV.x + roomIndexUV.y * (roomIndexUV.x + 1)) * _Rooms.xy);
    66.                 roomIndexUV += n;
    67.                 // get room depth from room atlas alpha
    68.                 fixed farFrac = tex2D(_RoomTex, (roomIndexUV + 0.5) / _Rooms).a;
    69.                 float depthScale = 1.0 / (1.0 - farFrac) - 1.0;
    70.                 // raytrace box from view dir
    71.                 float3 pos = float3(roomUV * 2 - 1, -1);
    72.                 // pos.xy *= 1.05;
    73.                 i.tangentViewDir.z *= -depthScale;
    74.                 float3 id = 1.0 / i.tangentViewDir;
    75.                 float3 k = abs(id) - pos * id;
    76.                 float kMin = min(min(k.x, k.y), k.z);
    77.                 pos += kMin * i.tangentViewDir;
    78.                 // 0.0 - 1.0 room depth
    79.                 float interp = pos.z * 0.5 + 0.5;
    80.                 // account for perspective in "room" textures
    81.                 // assumes camera with an fov of 53.13 degrees (atan(0.5))
    82.                 float realZ = saturate(interp) / depthScale + 1;
    83.                 interp = 1.0 - (1.0 / realZ);
    84.                 interp *= depthScale + 1.0;
    85.            
    86.                 // iterpolate from wall back to near wall
    87.                 float2 interiorUV = pos.xy * lerp(1.0, farFrac, interp);
    88.                 interiorUV = interiorUV * 0.5 + 0.5;
    89.                 // sample room atlas texture
    90.                 fixed4 room = tex2D(_RoomTex, (roomIndexUV + interiorUV.xy) / _Rooms);
    91.                 return fixed4(room.rgb, 1.0);
    92.             }
    93.             ENDCG
    94.         }
    95.     }
    96. }
    97.  
     
    Last edited: Jan 4, 2017
  2. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @KRGraphics I can't comment without actually seeing the probes that are contributing to how it looks. Remember that LPPV probe groups are a pretty coarse way to light things. They will look different.
     
  3. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    hey guys, how to export package for alloy maps, _alloypm.asset files & all the other textures that assioated with together with my prefabs?

    when i did a normal prefab export, my gloss/spec/AO maps are not being exported out, i have to manually export & re-import into my colleague's project folder...

    Do advise how to export
     
  4. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    @Alloy, Is there a way to access the rendering mode with the Alloy Skin Shader? I wanted to use transparency for my characters eyelashes. Or would you suggesting using a separate material for that? I'm just thinking ahead about performance and whether I should use 2 materials instead of one.

    Thanks.
     
  5. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I may have to drop the use of them... I am using LPV for a scene in my game for mainly the characters. It feels like a waste of resources.
     
  6. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @OP3NGL

    Basically, the dissolve feature functions using a greyscale texture that's almost like a height map. Think of it like alpha-cutout, but instead of feeding a pure black-white map, you feed in a noisy/gradient-ee map, and then in code, animate the dissolve threshold from 0 to 1.

    In terms of actually making a good looking texture to use the effect, my suggestion would be to generate world-space noise, either by baking a 3d texture in maya, or using Substance Designer/Painter and Tri-planar projection to make a seamless noise that doesn't feel like it 'warps' at all on the model. An fx dissolve (like melting away from a plasma gun or something), should look and feel homogeneous, which is why we need data that feels very 'world space'.

    If you wanted to get _really_ fancy, you could also blend into that texture a bit of a radial bias from common 'hit' points, like arm, torsos, legs, and swap in the 'correct' dissolve texture to the material at the moment of the fx event, so it looked like the model started dissolving from that point.

    Does that help ya get started?
     
  7. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @adamz: you should use two different materials. The draw call overhead is muuuuuuuuuch smaller than rendering a whole large part of a model with the 'wrong' material-type.
     
  8. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @OP3NGL: Uncheck 'export dependencies' and make sure you have directories selected that contain all the files you need. Unity does not grab dependencies correctly, so the only solution is to do your own folder organization such that you know exactly what you are and aren't exporting. There's no way around this.
     
  9. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @KRGraphics I'm not surprised. I still don't like the way enlighten encodes spherical harmonics.
     
  10. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Same... and my models are looking insanely detailed with the new HDR skies I am using
     
  11. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @xenius

    thanks for the help needed...
    any luck in create an alloy shader to replicate the "Fake interior?"
     
  12. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    hi
    quick question
    does the fact that alloy uses packed maps reduces the number of setpass calls
    as opposed to having each of those textures in individual texture slot?
     
  13. Deleted User

    Deleted User

    Guest

    @OP3NGL
    Sorry about the delayed response. The easiest option would be to use Unity's Surface shader API and then apply Alloy's Injection Headers to said shader.

    @AlteredPlanet
    The packed maps solve a number of problems.
    1. They pack better in VRAM.
    2. Consumes less storage on disk and in VRAM.
    3. Faster to do one packed read versus four unpacked reads in the shader.
    4. Only consumes 1 sampler versus 4 samplers of the shader 16 sampler limit.
     
  14. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    Faster to do one packed read versus four unpacked reads in the shader.......... is this in relation to setpass calls?
     
  15. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
  16. Deleted User

    Deleted User

    Guest

    @OP3NGL
    Can you be more specific on what isn't compiling? The regular shaders, or the injection header system? Also, can you screenshot the specific error from the console so I can diagnose the problem?

    Thanks.
     
  17. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @n00body
    No errors, when i put the fake interior shader into a new folder with the alloy injection cginc files
     
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,754
    No.
     
  19. zmaxz

    zmaxz

    Joined:
    Sep 26, 2012
    Posts:
    143
    Hi~
    How to fix this white edge ?
    This is speedtree with Alloy/Nature/speedtree shader,white edge is not so good.
    NGTree.jpg

    This is speedtree with unity defult Nature/speedtree shader,Looking great
    GTree.jpg

    I'm using linear + deferred.
    Version: Unity3d 5.50f3 ,Alloy 3.5.1
     
  20. Deleted User

    Deleted User

    Guest

    @OP3NGL
    Oh, so you are using that one example shader without modifications? That explains it. You need to convert it to be a Unity surface shader for it to work with Alloy's lighting model.

    @zmaxz
    Our SpeedTree shaders support light transmission on Leaves and Fronds. To fix the effect, please put the SpeedTree specular maps in the Transmission section's "Transmission(A)" property.

    EDIT:
    Also please make sure you follow all the steps for "Advanced Setup" in the Getting Started documentation.
     
  21. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Good morning, guys. I have run into a strange issue with the Alloy hair when I either move the model or camera around the scene. Once the hair touches something like the sky, there is a horrible sorting issue that will take place and it is important that this gets ironed out. It only happens in the game view, so it might be something else completely. And i also using Forward Rendering.


    This is before the camera and hair converge.
    Hair Looks good.png


    And this is when the character's hair touches the sky... and we can't have is happening during game play. I put a lot of work into this and I would hate to have to switch up everything because of this. Has anyone else had this issue?
    Hair Looks BAD.png
     
  22. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @n00body
    could you help me convert that shader to alloy? Im not a shader artist
     
  23. Deleted User

    Deleted User

    Guest

    Sorry about the delays. I've been having computer troubles again as well as a lot of frustration at my day job.
     
  24. istavang

    istavang

    Joined:
    Jan 17, 2015
    Posts:
    19
    Hi why do i get white human skin ? looking forward to your reply Thanks Dan

     
  25. Deleted User

    Deleted User

    Guest

    @KRGraphics
    That's again a result of the trick we had to use to trick the hair into layering correctly in the translucent pass. I will look into a better solution when I have time.

    @OP3NGL
    Unfortunately no. I'm super busy right now.

    @istavang
    Please follow the "Advanced Setup" instructions in our Getting Started documentation.
     
  26. istavang

    istavang

    Joined:
    Jan 17, 2015
    Posts:
    19
    wow ..thanks , that was a quick fix , adding the render plus script to the camera

    thanks again Dan
     
  27. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    It's cool... I was going to use a huge cube, but it wasn't gonna solve anything... Hopefully we can get a fix on this. And we all need shaders for vegetation.
     
  28. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    has anyone here used granite for unity with alloy
     
    KRGraphics likes this.
  29. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    What's that?
     
  30. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @nxrightthere. Import the main ShadersAndEditor subpackage _again_ (over the current installation of it). For reasons we don't fully understand, sometimes a file doesn't get imported from the package that contains critical definitions
     
  31. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @AlteredPlanet To my understanding all Virtual Texturing solutions require custom shaders. I've heard of Granite. We do not currently support it.
     
  32. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Hi
    Is Alloy skin shader compatible with "The Blacksmith: Wrinkle Maps" shader?
     
  33. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    I kinda have a question. Does this shader's POM feature modifies the depth buffer?
     
  34. Neo-Gamefactory

    Neo-Gamefactory

    Joined:
    Oct 18, 2012
    Posts:
    145
    Hey there, i'm a shader noob but i want to increase my Graphics quality in Unity.
    Now i'm hunting some assets :)
    I use UberShader but my results doesn't look better than Unity, maybe a little better.
    I have ShaderForge and maybe i can create some good materials with that... maybe...

    But, the most time and for my models i use Substance Painter 2 and Substance Designer 5.
    Few days ago i read in the unity forum and a user says, if you use substances i HIGHLY recommend Alloy

    is it so? why? can i get a graphics boost with alloy?
     
  35. Deleted User

    Deleted User

    Guest

    @Crossway
    Currently no. I would need to investigate that shader and see how applicable it is to Alloy.

    @Kolyasisan
    Currently no, since that disables some GPU-specific optimizations. I would need to look into adding that as a toggleable shader feature.

    @Neo-Gamefactory
    Alloy has several advantages over Unity's built-in pipeline. For the sake of Substance integration, Alloy ships with custom preview shaders for both Substance Designer and Substance Painter to better match how it will look in Unity. We also use the same material channels as Substance.
     
    Crossway likes this.
  36. Neo-Gamefactory

    Neo-Gamefactory

    Joined:
    Oct 18, 2012
    Posts:
    145
  37. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    That would be cool, skin shaders without dynamic normal maps can't be good enough cause all games using Wrinkle maps these days.

    Also there is an asset "SDS Wrinkle Maps" is developing by shaggydogstudios.
    If Alloy can get compatible with this asset that would be very nice.
     
    Last edited: Feb 10, 2017
  38. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    In general, if you are doing dynamic wrinkling, this should be handled _outside_ the shader, on render textures, which just link into a 'normal' skin shader. Doing it in-shader means one runs out of samplers after a single properly authored wrinkle set.
     
    KRGraphics likes this.
  39. Deleted User

    Deleted User

    Guest

    Hey all.

    Firstly, I got my computer replaced so I can finally get back to active development of Alloy. Secondly, I forgot to announce that we pushed an Alloy update to the asset store.

    Changelog:
    Version 3.5.2
    =====================
    Shaders:
    - Changed deferred Skin and Transmission to work with single-pass stereo VR rendering.
    - Fixed issues with deferred Transmission code that would fail to compile on some platforms.

    Integration:
    - Added support for "Vapor" transparency integration.
     
    Neo-Gamefactory, Crossway and punk like this.
  40. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    My terrain when standard shader placed on the graphic section.

    FF.jpg

    And when I place Alloy deferred skin shader there!!!!!!!!!!

    33.jpg


    It's awful man, I can't figure out why you don't fix this mass. or maybe RTP should fix it with Alloy?
    Please don't say put area light on your sun. It can't fix this mass.
     
  41. Deleted User

    Deleted User

    Guest

    @ksam2
    First, you're supposed to have an AreaLight component on all your dynamic lights. It's required for Alloy to even work.

    Second, in the file "ReplacementPBSLighting.cginc" line 200, paste the following:
    s.Occlusion *= dot(specColor, half3(0.33h, 0.33h, 0.33h));

    Right click the RTP folder, select "Reimport", and wait for it to recompile. Let me know how that goes.
     
    nxrighthere and ksam2 like this.
  42. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    Looks like you solved this old issue between Alloy and RTP :eek: That was really cool. thanks man, I should ask Tom to add this line to RTP. :)
     
  43. Deleted User

    Deleted User

    Guest

    @ksam2
    It will require further testing before I will call it "solved", but that hack has shown the most promise.
     
    ksam2 likes this.
  44. Deleted User

    Deleted User

    Guest

    @ksam2
    Try it with this one instead:
    half scale = dot(specColor, half3(0.33h, 0.33h, 0.33h));
    s.Occlusion *= scale < 0.02h ? scale : 1.0h;
     
  45. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @n00body

    Hi, is there a way to force checked auto regenerate for all alloy settings?
    also i recently found out that after pulling from my team's GIT, all the alloy materials appeared white/gray, even rebuilding via material migrater does not work.. have to repacked manually. using the latest 3.5.2 with unity 5.5.1f1
     
  46. Deleted User

    Deleted User

    Guest

    @OP3NGL
    1. Did you check to make sure all the packed map "*.asset" files were checked in?
    2. You can fix it by doing a search for all "_Alloy" files, ctrl+a, right click, reimport.
    3. Also, in the future you can repack them individually by left-clicking on their "*asset" file.
     
  47. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @n00body
    1. Yep, however when pulled from git, they were all unchecked
    2. thanks, i was going nuts repacking individually
    3. ok!
     
    Last edited: Feb 21, 2017
  48. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    Just to remind everyone, there is also Auto Regenerate option there. It's really awesome; you can modify your metal, occlusion, etc maps in photoshop and packed map is generated automagically, even at runtime!
     
  49. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386

    Does... This mean an announcement is imminent?
     
  50. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Good morning, Alloy Team... I hope all is well. I have been working on my characters and I was wondering if there is a way to modify the skin shader so I can actually have more scatter depth, like this? I am trying to create a character with very translucent skin, and most games I have been looking at has skin like this... would be nice to have in an update.