Search Unity

Standard shader with vertex colors

Discussion in 'Shaders' started by defaxer, Apr 5, 2015.

  1. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    this is slightly off topic, but would you know how to modify your shader to make the occlusion use the UV 1 set? I only ask here, becuase the solutions i found i wasnt able to copy paste into your shader. the different passes confuses me, and you dont have "void surf (Input IN, inout SurfaceOutputStandard o)" which so many of the examples use. grateful for any suggestion!
     
  2. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    by UV1 you mean secondary uv set? if so locate all lines (there should be 2 of them)
    half occlusion = Occlusion(i.tex.xy);
    and change them to:
    half occlusion = Occlusion(i.tex.zw);
    and dont forget to switch UV set for Secondary maps.
    It was simpler to write a simple surface shader for vertex colors but to keep functionality of Standard shader I had to modify original which is not simple surface shader (I wish it was :))
     
  3. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    superthanks, will try it out tomorrow!
     
  4. LucaHofmann

    LucaHofmann

    Joined:
    Feb 24, 2015
    Posts:
    12
    First: Thank you for this Shader.
    I did get an older version to work but I had some strange issues so I decided to get the newest version UnityVC_092.unitypackage
    After importing the package I get the following errors:

    Image:
    error.png

    I was able to fix the first 8 errors by passing a string instead of a UnityEngine.GUIContent in the StandardShaderVCGUI.cs class.

    For the last 3 errors I had to comment out the lines:
    material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
    because RenderQueue seems not to be part of UnityEngine.Rendering.

    After this hacks I do not get any errors but the material keeps its magenta only color. The material inspector seems to be a custom one where I can not select the rendering mode (opaque, fade, cutoff and transparent):

    Image:
    inspector.png

    I don't know if this has to do with the issue.. but in the older version I had the standard material inspector. I can be almost sure that my meshes are correct because it worked with the older version.
    I am using Unity 5.3.5p5
    Any ideas?
     
    Last edited: Aug 24, 2016
  5. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    Version 0.92 was made for Unity 5.4
    Version 0.91 works with Unity 5.3

    I have no idea what Unity did in 5.4 but it broke with 0.91

    I haven't upgraded to 5.4 yet so I still use 0.91, and it works fine.
     
  6. LucaHofmann

    LucaHofmann

    Joined:
    Feb 24, 2015
    Posts:
    12
    Ok thank you Tzan. Thats something I should have notice on my own. It works with Unity 4.5. Thank you!
     
  7. Jose_Gallardo

    Jose_Gallardo

    Joined:
    Jul 29, 2010
    Posts:
    42
    Hi defaxer,

    I am using your vertex color shader, works great... I am usign Unity 5.4... However, when I switched to use Android the shader compiler throws an error, it said:

    invidalid subscript 'posWorld' on UnityVC.cginc:299

    is there any way to fix this?

    Thanks for your great work.
    Jose
     
  8. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    Hi!
    There is :)
    Yeah I'm aware of this bug, but not exactly working on it at the moment (busy, busy, busy).
    Will be fixing this as soon as I can.
     
  9. Jose_Gallardo

    Jose_Gallardo

    Joined:
    Jul 29, 2010
    Posts:
    42
    Opps :) I'll try to have a look and let's see if I can fix and contribute a little to your great work. I'll try my best, shaders are not my strong but maybe is a silly thing or not too much complicated. Maybe I ask you for further assistance trying to fix it?
     
  10. Jose_Gallardo

    Jose_Gallardo

    Joined:
    Jul 29, 2010
    Posts:
    42
    Ok, now is working, however it is just an odd job, but at least for my needs it's enough for now... maybe this can give you a clue about what's going on.

    on UnityVC.cginc i just removed this || UNITY_LIGHT_PROBE_PROXY_VOLUME from line 298

    I also commented all the block / function from lines 363 to 411, for some reason don't work too. My experience with shaders is very small, so I can't help more, but I hope this became useful for you.
     
    tkamruzzaman and Alverik like this.
  11. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    I guess now it does not work with deferred rendering path on android? Though not everyone is using it with deffered on mobile
     
    Alverik likes this.
  12. Jose_Gallardo

    Jose_Gallardo

    Joined:
    Jul 29, 2010
    Posts:
    42
    Maybe, I am using forward rendering.
     
  13. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    the occlusion worked out really well, but i have another thing i want the shader to do. i would like to have a mask for the vertex colors, a black and white texture map, that show where the vertex colors affect the albedo. it would add a lot of precision, for example making only the paint on a dumpster be affected and not the scratch marks that shows the underlying metal. is this hard to do? do you have a suggestion? super grateful for any help, totally understand if you are to busy
     
  14. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    For that kind of effect you should consider a specific surface shader, it's easier to write. This one is full of textures that take up slots and is hard to expand. I wouldn't recommend
     
  15. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    really? i thought it would be really easy, just add another map slot and multiply it with the vertex colours before adding them to the albedo.
     
  16. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    Yeap, in theory, thats exactly how one can make it with surface shader. But to add a map support I need to modify other code in other cginc files from Unity like "UnityStandardUtils.cginc" or "UnityStandardInput.cginc". In fact to add vertex color support I needed changed code from 3 different source files and change how shader deals with texture coordinates(!) from an object. So it's not that easy with this shader, while dealing with traditional surface shader is a lot more easier.
    At some point I thought about recreating standard shader from scratch with surface shader
     
  17. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    im suprised no one has done it already. wouldnt that be super useful for all the people wanting to modify the standard shader?
    for me, vertex colors arent really useful with pbr and the materials of the standard shader right now. for example if i have a surface that has part metal, part fabric and i want to color it red with vertex colors, not only will i have very limited control, but also the specular reflection will draw its colors from the albedo, so the metal parts will suddenly have a very tinted look. a yellow trash can will seem to be made of gold where the paint has worn off due to the tinted reflective light.

    is this solution possible; modify the shader so the specular reflection dont take vertex colors into account, only the abledo texture?

    Edit; nevermind, that solution wouldnt give me the result i want anyway
     
    Last edited: Sep 9, 2016
  18. stickadtroja

    stickadtroja

    Joined:
    Oct 25, 2015
    Posts:
    33
    sorry for spamming your thread, let me know if you want me to pm my questions instead of taking up space here.

    i started doing a surface shader of my own, and it was super easy! adding vertex colors and all the stuff from the standard shader worked like a charm! so my question is; why are you doing it another way? is there drawbacks doing it with a surface shader? any other reasons?

    also, it didnt really work perfectly. the vertex colors show stronger in your shader than in mine. do you have any idea why? the only thing i do is multiplying it with the albedo.
    Code (CSharp):
    1.         struct Input {
    2.             float2 uv_AlbedoTex;
    3.             float4 color: Color;
    4.         };
    5.  
    6.         sampler2D _AlbedoTex;
    7.  
    8.         void surf (Input IN, inout SurfaceOutputStandard o) {
    9.            
    10.             o.Albedo = tex2D(_AlbedoTex, IN.uv_AlbedoTex).rgb * IN.color.rgb;
    obviously feel free to not answer, i feel that im taking advantage of your helpfulness a bit to much
     
  19. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    The only reason is functionality of Standard Shader. You'll have to rewrite support for all maps and features. You can't switch from opaque to transparent version, you'll have to write your own transparent surface shader for that.

    Not sure what is a difference, maybe you should use scale vertex color value or something? like
    Code (CSharp):
    1. o.Albedo = tex2D(_AlbedoTex, IN.uv_AlbedoTex).rgb * IN.color.rgb * _VertexColorScale;
     
  20. Argonwolf

    Argonwolf

    Joined:
    Sep 29, 2014
    Posts:
    4
    Hey defaxer, first of all thanks for sharing this shader with us, it's nice to have a standard shader that finally handles vertex colors (which I consider an important aspect of a shader, being someone who likes to have procedural meshes colored arbitrarily without creating thousands of materials).

    I have a quick question/bug report. I'm using code to generate meshes (simple cubes). If only one object containing the mesh script is on-camera (not being culled), it renders fine with vertex colors working like a charm. However, if multiple identical duplicate objects are created and more than one are being rendered, the textures go pitch black. No shading or anything.


    Picture of one box rendering correctly shown in "workingTexture.PNG", multiple boxes without proper rendering shown in "notWorkingTexture.PNG".

    If you know what I'm doing wrong or how I might remedy the situation, please let me know! I'm using Unity 5.3, and I downloaded the corresponding 5.3 version of the shader.
     

    Attached Files:

  21. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    That is a bug from page 2 of this thread :) I thought it was fixed long time ago. What rendering path do you use? Tried disabling static/dynamic batching? There is some problem using this shader with procedurally generated meshes and I can't tell why. Can you attach a project (minimal: scene with that bug)?
     
  22. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    This is cut and pasted from page 3:

    Solved the black texture problem
    Ok, after working on a different part of my project I came back to this with a new idea.
    Because I didnt need UVs I didnt have any on the mesh, we use vert color.
    The dynamic batcher made them black when viewed from some angles.
    So I tried adding UVs just set to 0f,0f and it worked!

    Unfortunately the useless UVs count against the batching limits.
     
  23. Argonwolf

    Argonwolf

    Joined:
    Sep 29, 2014
    Posts:
    4
    Deactivating dynamic batching solved the issue, thank you! Also, from what I can tell there isn't any performance decrease involved. Are there major disadvantages to deactivating dynamic batching? I say this because I had some other solutions in mind if performance was an issue (passing a rainbow-colored texture and setting each cube's uvs to exactly one pixel on that sprite). It doesn't increase the Draw (SetPass) calls from what I've seen.
     
  24. Argonwolf

    Argonwolf

    Joined:
    Sep 29, 2014
    Posts:
    4
    I may also try this solution if straight-up disabling dynamic batching isn't a good enough solution. Also, I just noticed from following your signature link that we're doing very similar things! I too am attempting to use the building-block aesthetic in my game!
     
  25. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    My terrain is in 32x32 space baseplates.
    I make a space, save it, then combine them into a 32x32 plate using:
    https://docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html

    You will need to become a master of mesh merging.

    The studs are a separate 32x32 area mesh, because they dont cast shadows and dont have a collider.
    The trees and bushes are a separate 32x32 area mesh, they use a different material.

    Dynamic batching is good if you toss in a few low vertex GameObjects, they will combine, you can forget about them.
    If you are covering a large area like I am you need to combine the meshes yourself.

    I started doing that rainbow swatches texture thing, then I found a shader that did vertex colors, so I switched over to that. Using the old system I was able to edit that easily. I tried fixing an issue with multiple lights in Defaxers code and after many hours I failed.

    Defaxer wont be around forever to fix things and Unity will just keep breaking them.
    Keep that in mind.
     
    Last edited: Sep 14, 2016
  26. Argonwolf

    Argonwolf

    Joined:
    Sep 29, 2014
    Posts:
    4
    Oh I know he won't be around to fix things forever, but the knowledge he's passed on will always be useful. If his shader breaks, I'll try writing one myself using his info combined with other resources.

    Also from the very beginning every one of my meshes has been procedurally generated from code, and combined until they max out the vertex limit. For every GameObject I'm able to render 1,820 individual rectangular-prism shaped blocks (less for more-complex pieces), using list-to-array methods to assemble all 1,820 vertex, face and color lists into a single mesh that only needs to be recalculated when the player edits a component of it, and even then I may be offloading the recalculation to a coroutine or async thread. Combined with a simplified occlusion calculation that prevents fully-obscured blocks from being calculated at all, I'm able to render quite a lot even on my low-end development machine. In the future I intend to implement as-needed random generation so that underground and far away bits of world don't exist until a player needs to see them, reducing the amount of memory needed to store the data. Of course I'll also be using a custom serialization system to squeeze every bit of block data I possibly can into the smallest space possible (none of that inefficient XML stuff).

    I might not know much about shaders, but I'm intimately familiar with many of the optimizations I will require to make this game work. My goal is to make it work perfectly even on my crappy development computer, because I hate games that don't run on low-end machines.
     
    defaxer likes this.
  27. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    I was going by your post count, thinking you were just starting.
    But it looks like you have everything under control! :)
     
  28. tkamruzzaman

    tkamruzzaman

    Joined:
    Jun 28, 2015
    Posts:
    8
    @RetromadeGames you are a life saver!! cheers :)
     
  29. cyberluigi2k

    cyberluigi2k

    Joined:
    Oct 10, 2016
    Posts:
    3
    Hi,
    First of all thanks for your work, I've been testing it on Unity 5.3 and it works great, but for some reason I'm having problems when using it on Unity 5.4. It works on the viewport and on play mode but I get an error when I try to export an asset bundle of an asset with the Standard (Vertex Color) Shader.

    This is the error I get:

    Shader error in 'Standard (Vertex Color)': Program 'fragForwardBase_VC', error X4506: ps_4_0_level_9_1 input limit (8) exceeded, shader uses 9 inputs. (on d3d11_9x)

    Compiling Fragment program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF _VERTEXCOLOR
    Platform defines: UNITY_NO_LINEAR_COLORSPACE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_MOBILE


    Thanks!
     
  30. defaxer

    defaxer

    Joined:
    Nov 15, 2010
    Posts:
    140
    Looks like we can't push more data into fragment shader, have to cut features.
    I wonder why Unity does not give any warnings when compiling. Just today was in a same situation when could not publish finished project because of errors in shader, but when I was writing it there were none.
    Anyway on your prob, not sure how to handle this, looks like getting rid of parallax mapping or any other feature is the only way out. As for when it can be done, can't say as I'm soo "overprojected" right now, and I still have to do mobile version...
     
  31. sipon

    sipon

    Joined:
    Feb 8, 2009
    Posts:
    143
    Thks for sharing ! very useful !
     
  32. VanDeiMin

    VanDeiMin

    Joined:
    Feb 6, 2016
    Posts:
    4
    Unfortunately it doesnt't work in my 5.4.2 version, player settings IOS . Everything is pink.
     
  33. VanDeiMin

    VanDeiMin

    Joined:
    Feb 6, 2016
    Posts:
    4
    I have no knowledge about shaders and programing , but I used brute force and disabled "deffered pass" in subshader with LOD300 inside and changed rendering path to forward. Shader works. I have only one issue: In dark colors (especialy black) specular highlights dissapears.

    Edit. My "my pink problem" is generated by line " //#pragma vertex vertDeferred_VC " , but as I said I have no skills in programing and I don't know how to fix it.

    I have a question: It is normal that Standard (vertex color) shader shares albedo property with Standard Shader?
     
    Last edited: Nov 15, 2016
  34. Auburn199

    Auburn199

    Joined:
    Nov 15, 2016
    Posts:
    1
    Hi Defaxer, I really appreciate your work on this shader, it is a real time saver!

    One problem I had with it is that the vertex colors break (all colors turn to black) if meshes get dynamically batched. It took forever to figure this out, so I hope I can help other people that experience this. I'm pretty sure it's a bug in Unity since other vertex color shaders also break, but there's an easy solution. Just disable batching within the shader (add the tag "DisableBatching"="True" in the sub shaders).

    EDIT: I am now just discovering other people in this thread that had the same problem. Might have saved me some time... Also, by the way, this problem also occurs with meshes that are not generated dynamically. I think Unity might be throwing away vertex colors when it does dynamic batching or something.
     
    Last edited: Nov 15, 2016
  35. VanDeiMin

    VanDeiMin

    Joined:
    Feb 6, 2016
    Posts:
    4
    Hi Defaxer. I forgot to Thank You for the Shader. I messed up with it ,tried to add blend modes beacuse I realised default blend mode in Your shader is multiply. Here is result my lame programing. I added some lines to Your UnityVC.cginc file. I hope You will find it helpful for future improvements. Surprisingly the best color solution i found is Linear Burn with Your VertexColor = 0.75. More blend modes I found here: " http://elringus.me/blend-modes-in-unity/ " Best Regards

    half4 fragForwardBase_VC (VertexOutputForwardBase_VC i ) : SV_Target
    {
    FRAGMENT_SETUP(s)
    #if UNITY_OPTIMIZE_TEXCUBELOD
    s.reflUVW = i.reflUVW;
    #endif

    UnityLight mainLight = MainLight (s.normalWorld);
    half atten = SHADOW_ATTENUATION(i);

    half occlusion = Occlusion(i.tex.xy);
    UnityGI gi = FragmentGI(s, occlusion, i.ambientOrLightmapUV, atten, mainLight);

    half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect);

    #if _VERTEXCOLOR

    //c = (i.color > .5 ? 1.0 - (1.0 - c) * (1.0 - 2.0 * (i.color - .5)) : c * (2.0 * i.color))* _IntensityVC; //HardLihgt
    //c = ((1.0 - c) * c * i.color + c * (1.0 - (1.0 - c) * (1.0 - i.color)))* _IntensityVC; //SoftLight
    //c = max(c, i.color)*_IntensityVC; //Lighten
    //c = (1.0 - (1.0 - c) / i.color)*_IntensityVC; //ColorBurn
    //c = min(c, i.color)*_IntensityVC; //Darken
    //c = (c > .5 ? 1.0 - 2.0 * (1.0 - c) * (1.0 - i.color) : 2.0 * c * i.color)* _IntensityVC; //Overlay
    c = (((c + i.color - 1) )* _IntensityVC) ; //LinearBurn
    //c = (c + i.color)* _IntensityVC; //LinearDogde
    //c = (1 - (1 - c)*(1 - i.color))* _IntensityVC; //Screen
    //c = c * i.color * _IntensityVC; //multiply

    #endif
    #if _VERTEXCOLOR_LERP

    c = (c + lerp(half4(1, 1, 1, 1), i.color, _IntensityVC) - 1); //LinearBurn
    //c *= lerp(half4(1,1,1,1), i.color, _IntensityVC);
    #endif
    c.rgb += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, occlusion, gi);
    c.rgb += Emission(i.tex.xy); //i.color.a * s.diffColor;

    UNITY_APPLY_FOG(i.fogCoord, c.rgb);
    #if _VERTEXCOLOR
    s.alpha *= i.color.a;
    #endif
    #if _VERTEXCOLOR_LERP
    s.alpha *= lerp(1, i.color.a, _IntensityVC);
    #endif

    return OutputForward (c, s.alpha);
    }
     
    Alverik likes this.
  36. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    This used to work on mobile Android with opengl es2.0, in unity 5.2, now its not working, i get this error.

    Shader error in 'Standard Specular (Vertex Color)': invalid subscript 'posWorld' at Assets/UnityVC/UnityVC.cginc(299) (on d3d11)

    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF _EMISSION _VERTEXCOLOR _NORMALMAP _SPECGLOSSMAP
    Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF2 UNITY_HARDWARE_TIER3
     
  37. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    And this error too,

    Shader error in 'Standard (Vertex Color)': invalid subscript 'posWorld' at Assets/UnityVC/UnityVC.cginc(299) (on d3d11)

    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF _EMISSION _VERTEXCOLOR _METALLICGLOSSMAP _NORMALMAP
    Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF2 UNITY_HARDWARE_TIER3
     
  38. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    ok it turns out they were all related to deferred rendering, fragDeferred_VC() in unityvc.cginc, so i commented out all of the lines related to deferred and it works now on es2.0.
     
  39. VanDeiMin

    VanDeiMin

    Joined:
    Feb 6, 2016
    Posts:
    4
    In Unity 5.5 shader doesn't work :-(
     
  40. spsmith224

    spsmith224

    Joined:
    Oct 25, 2016
    Posts:
    5
    I only had to fix the StandardVC shader for my project in Unity 5.5 but it was simple enough. You just need to change two things:
    1. change all 'oneMinusRoughness' properties to 'smoothness'
    2. remove 's.normalWorld' parameters from the lighting functions that give errors
    Not sure if you'd have to do more for other shaders but this was all I needed. Looking through the Shader section in the 5.5 release notes and comparing the 5.5 and 5.4 shader source should tell you all you need to know.
     
    VanDeiMin likes this.
  41. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    I tried fixing the shader last time they broke it and got a never ending stream of error messages.
    So I doubt the shader source will tell me anything.

    I was able to modify shaders using the previous system, before standard.
     
  42. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    Coredumping has been using the Standard Shader straight, by changing a few lines.
    He posted this in the new 5.5 release thread:

     
  43. Mastaroth

    Mastaroth

    Joined:
    Dec 20, 2014
    Posts:
    13
    Is it possible to use/modify this shader to blend between textures? For example. R channel will show up as texture_1 (albedo_1 + normalmap_1 + occlusion_1 +etc...), B channel as texture_2 an so on?
     
  44. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Could some one attach the shader updated to 5.5 that is working? I tried what spsmith5 said and it didn't work for me.

    Any help would be appreciated. Really not sure why Unity doesn't have a VC shader built in....
     
  45. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    They claim its because they want to spend their time working on things that most people use.
    Which of course is why they make VR crap which 1% uses.

    I think they hate people who use vertex colors and wish we would die.
    Next they will probably stop "supporting" vertex color in a mesh, because nobody uses it.
     
  46. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Probably not OPENLY now that many of the other engines (like UE) have VERY similar "Indie-Friendly" plans they can easily move to, but I get what you mean.
     
  47. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    736
    I was just over exaggerating :)

    They never read here anyway.
     
    Last edited: Dec 20, 2016
  48. flybbit

    flybbit

    Joined:
    Jan 22, 2014
    Posts:
    1
    Have done quick fix of 0.91 for 5.5 after comparison of builtin shaders from 5.5 and 5.4. Works fine for me as temporary solution while defaxer celebrating (winter holidays continue till middle of january in Ukraine :) )
     

    Attached Files:

    Alverik and _Alexey_ like this.
  49. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    I did this edit to make it work with the diffuse, it did what I wanted and uses the alpha channel of the main colour to modulate the amount of vertex colour blended in.

    In UnityVC.cginc
    Edit the fragForwardBase_VC function to this:

    Code (CSharp):
    1. half4 fragForwardBase_VC (VertexOutputForwardBase_VC i) : SV_Target
    2. {
    3.     FRAGMENT_SETUP(s)
    4.     UnityLight mainLight = MainLight (s.normalWorld);
    5.     half atten = SHADOW_ATTENUATION(i);
    6.  
    7.     half occlusion = Occlusion(i.tex.xy);
    8.     UnityGI gi = FragmentGI (
    9.         s.posWorld, occlusion, i.ambientOrLightmapUV, atten, s.oneMinusRoughness, s.normalWorld, s.eyeVec, mainLight);
    10.  
    11.     half3 albedo = s.diffColor * (1 - _Color.a) + s.diffColor * i.color * _Color.a;
    12.     half4 c = UNITY_BRDF_PBS (albedo, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect);
    13.  
    14.     c.rgb += UNITY_BRDF_GI (albedo, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, -s.eyeVec, occlusion, gi);
    15.     c.rgb += Emission(i.tex.xy);
    16.  
    17.     UNITY_APPLY_FOG(i.fogCoord, c.rgb);
    18.     return OutputForward (c, s.alpha * i.color.a);
    19. }
     
  50. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    Anybody got any luck updating this shader for 5.5? I managed to make it work but my vertex colours (that are assigned through code) are now much more muted and a lot less vibrant as compared to 5.4. Anybody else experiencing this?