Reputation: 11
We are working on an anatomical application in Unity, where the user can dissect a model of a human hand. We are trying to find a good shader/selection tool we can use when the user selects (from the menu) an object that currently is NOT visible (either on the backside of the hand or inside the hand covered by other structures).
no idea whats currently selected
Right now we are using a transparant shader to visualize this, but this option will be used somewhere else in future (you will be able to fade the other structures so you have a better view on the selected structure):
selected structure green, rest transparant
So if anybody would have a good idea how to fix this issue (allready thought about outlining/using an x-ray shader, but still need to find good shaders first which we can use to test) please let me know!
Thanks in advance
Upvotes: 0
Views: 119
Reputation: 11
thanks alot Jerry for your input! I used your script to alter on of the Marmoset shaders I was allready using:
// Marmoset Skyshop
// Copyright 2013 Marmoset LLC
// http://marmoset.co
Shader "Marmoset/Bumped Specular Xray" {
Properties {
_Color ("Diffuse Color", Color) = (1,1,1,1)
_ColorVisible04("Color Visible", Color) = (1,0,0,0.3)
_SpecColor ("Specular Color", Color) = (1,1,1,1)
_SpecInt ("Specular Intensity", Float) = 1.0
_Shininess ("Specular Sharpness", Range(2.0,8.0)) = 4.0
_Fresnel ("Fresnel Strength", Range(0.0,1.0)) = 0.0
_MainTex ("Diffuse(RGB) Alpha(A)", 2D) = "white" {}
_SpecTex ("Specular(RGB) Gloss(A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
//slots for custom lighting cubemaps
//_DiffCubeIBL ("Custom Diffuse Cube", Cube) = "black" {}
}
SubShader {
Tags {
"Queue"="Geometry"
"RenderType"="Opaque"
}
LOD 400
//diffuse LOD 200
//diffuse-spec LOD 250
//bumped-diffuse, spec 350
//bumped-spec 400
Pass{
Name "BASE"
Cull Off Lighting Off ZWrite Off ZTest Greater
Blend SrcAlpha OneMinusSrcAlpha
SetTexture[_MainTex]{
constantColor[_ColorVisible04]
Combine constant
}
}
//mac stuff
CGPROGRAM
#ifdef SHADER_API_OPENGL
#pragma glsl
#endif
#pragma target 3.0
#pragma exclude_renderers gles gles3 metal d3d11_9x flash
#pragma surface MarmosetSurf MarmosetDirect vertex:MarmosetVert fullforwardshadows
#pragma multi_compile MARMO_BOX_PROJECTION_OFF MARMO_BOX_PROJECTION_ON
#if MARMO_BOX_PROJECTION_ON
#define MARMO_BOX_PROJECTION
#endif
#pragma multi_compile MARMO_SKY_BLEND_OFF MARMO_SKY_BLEND_ON
#if MARMO_SKY_BLEND_ON
#define MARMO_SKY_BLEND
#endif
#define MARMO_HQ
#define MARMO_SKY_ROTATION
#define MARMO_DIFFUSE_IBL
#define MARMO_SPECULAR_IBL
#define MARMO_DIFFUSE_DIRECT
#define MARMO_SPECULAR_DIRECT
#define MARMO_NORMALMAP
#define MARMO_MIP_GLOSS
//#define MARMO_GLOW
//#define MARMO_PREMULT_ALPHA
//#define MARMO_OCCLUSION
//#define MARMO_VERTEX_OCCLUSION
//#define MARMO_VERTEX_COLOR
//#define MARMO_SPECULAR_FILTER
#include "MarmosetInput.cginc"
#include "MarmosetCore.cginc"
#include "MarmosetDirect.cginc"
#include "MarmosetSurf.cginc"
ENDCG
}
FallBack "Marmoset/Specular IBL"
}
with this script I get this result:
its what we had in mind from the beginning, so thanks alot!
Ive even thought of some extra adaptions allready, adding a black outlining might even make this better.
The problem right now is applying the outlining to the " covered part" as well, but I guess it should be possible!
Upvotes: 0
Reputation: 2720
Use my shader, I did for similar problem.
Shader "NameItAsYouWish" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ColorVisible04 ("Color Visible", Color) = (1,0,0,0.3)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass {
Name "BASE"
Cull Off Lighting Off ZWrite Off ZTest Greater
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] {
constantColor [_ColorVisible04]
Combine constant
}
}
Pass {
Material{
Diffuse[_Color]
Ambient [_Color]
}
Name "DIFFUSE"
Cull Off Lighting On ZWrite On ZTest Less
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * primary DOUBLE
}
}
}
Fallback "VertexLit"
}
Basicly this shader, draws one of these passes in front of every shader. But take in mind that not all of them. You need to test if applied on the hidden part will show its shape, if not try the over shader on the object that is above.
Upvotes: 0