1

enter image description here

Hi unity peoples I found this effect (disabled greyed out) while looking for something in the hierarchy panel I like it! - How would it be possible to add this kind of effect to game objects in game. are there any easy to implement solutions.

is it possible to use what unity is doing here in game? for example - on a locked item?

I'm not even sure what to search for. If this is a shader, or how this would be working.

void OnItemEnabled()
{
?
}

Some experiments so far Using a lit shader, it however loses details, and seems to need a way of pulling the colours out of the current shaders to maintain all the details A lit shader

How I would like the monkey to look if locked

enter image description here

I made a grey scale shader... but it's a bit dark Not sure how to lighten it to match the look of "unity"

enter image description here

My final solution is here: Shader code is here, with slider-bar to adjust brightness :

enter image description here

Shader "Custom/GreyScale"
{
Properties
{
[PerRendererData] _MainTex("Base (RGB)", 2D) = "white" {}
_EffectAmount("Effect Amount", Range(0, 10)) = 1.0
}

SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200

CGPROGRAM
#pragma surface surf Lambert

uniform float _EffectAmount;
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};

void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = (c.r + c.g + c.b) / 3 * _EffectAmount;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
//Fallback "Transparent/VertexLit"
}

My solution here - code is above.

My solution here

Swapping materials on unlock

Also I found this solution only solved half the problem, I had planned to swap shaders (but found this to be a no-no) so my solution for that is here Creating an unlockable game asset, writing a simple class

With thanks N

StackBuddy
  • 577
  • 5
  • 17
  • Pretty sure that if you just remove the texture, use a lit shader and set the color to white/gray - you should get similar results. You can simply change the materials of the `MeshRenderer` on the fly – Ron Feb 05 '20 at 10:33
  • Thanks Ron, I have tried your suggestion; it seems to lose too much detail if I go that way - Hopefully there is a way to work with the colour channels?... or some such to keep the colour graduations but force it to grey scale... which would be useful as most of these objects are multi material procedural colours - some have maps... so replacing these to the correct part of the mesh might be complicated... – StackBuddy Feb 05 '20 at 10:52
  • try using grayscale color – Ghost The Punisher Feb 05 '20 at 11:00
  • Thanks Ankit, I made a grey scale shader, but I would like to brighten it a little more - half way there :) – StackBuddy Feb 05 '20 at 11:04
  • 1
    ```o.Albedo = (c.r + c.g + c.b) / 3 * intensityMultiplier;``` try adding this and make ```intensityMultiplier;``` editable from editor and it can't be lower then **1**. – Ghost The Punisher Feb 05 '20 at 11:16
  • Thanks Ankit you put me on the right path, so I added a slider to the shader and quite happy with the result! Cheers!. – StackBuddy Feb 05 '20 at 12:11
  • Cheers man, good luck ahead. Can you recommend me any place to learn shader development, I already know a little bit about shaders but all is from Amplify Shader Editor asset from the unity asset store. but don't know much about coding my own shader. – Ghost The Punisher Feb 05 '20 at 12:43
  • Thanks Anit, hmm i'd try brackeys or some YouTube TBH what I know about shaders fits on my little finger ;P Happy journeys in unity :) and thanks! https://www.youtube.com/watch?v=vqDOirux0Es – StackBuddy Feb 05 '20 at 13:11
  • As it turns out I can't swap the shader runtime... so now I have a differnt question ;P https://stackoverflow.com/questions/60078281/how-to-fix-normals-on-shader – StackBuddy Feb 05 '20 at 14:45

0 Answers0