- Home /
Ideas on Transparent shader that can receive shadows and is not ignored by Post processing stack?
Hey Everyone,
So I am currently working on an AR app for android using ARcore. For the trackable floor I am using a transparency shader that allows for shadows to rendered on top of it. I wanted to add in some very subtle ambient occlusion for a more natural look at the base of objects in an AR environment.
My problem is that I can't get the SSAO from the post processing stack to render onto the transparent shader. Does anyone have any experience with this in AR? Or any suggestions on how this might be achieved?
Thanks in advance
Could you share more about the transparency shader with shadow, preferably the code?
You could also check this answer that might be related (the rest of the results a search gives are VERY old).
Hey thanks for the reply,
Yes of course, the current shader I'm using is pasted below. In all fairness, I could settle for a transparent shader without shadows as long as it is included in the post process pipeline to receive the SSAO onto the transparent surface.
I did also check out that post previously, although it didn't result in much luck
Shader "Custom/ShadowCollector" { Properties { _ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6 }
SubShader
{
Tags {"Queue"="AlphaTest" }
Pass
{
Tags {"Light$$anonymous$$ode" = "ForwardBase" }
Cull Back
Blend SrcAlpha One$$anonymous$$inusSrcAlpha
CGPROGRA$$anonymous$$
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "AutoLight.cginc"
uniform float _ShadowIntensity;
struct v2f
{
float4 pos : SV_POSITION;
LIGHTING_COORDS(0,1)
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
TRANSFER_VERTEX_TO_FRAG$$anonymous$$ENT(o);
return o;
}
fixed4 frag(v2f i) : COLOR
{
float attenuation = LIGHT_ATTENUATION(i);
return fixed4(0,0,0,(1-attenuation)*_ShadowIntensity);
}
ENDCG
}
}
Fallback "VertexLit"
}
I'm not very good with shaders, but if the problem is that transparency doesn't write into the zbuffer, then maybe adding ZWrite On
and/or ZTest LEqual
could help.
Alternatively, check out how the standard vertex color shader adds shadows:
// ------------------------------------------------------------------
// Shadow rendering pass
Pass {
Name "ShadowCaster"
Tags { "Light$$anonymous$$ode" = "ShadowCaster" }
ZWrite On ZTest LEqual
CGPROGRA$$anonymous$$
#pragma target 2.0
#pragma shader_feature _VERTEXCOLOR
#pragma shader_feature _VERTEXCOLOR_LERP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPRE$$anonymous$$ULTIPLY_ON
#pragma shader_feature _$$anonymous$$ETALLICGLOSS$$anonymous$$AP
#pragma skip_variants SHADOWS_SOFT
#pragma multi_compile_shadowcaster
#pragma vertex vertShadowCaster_VC
#pragma fragment fragShadowCaster_VC
#include "UnityStandardShadow.cginc"
#include "UnityVCShadow.cginc"
ENDCG
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612161506im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom postprocess white in build 0 Answers
apply Transformation on augmented model ,apply transformation on individual target image 0 Answers
Heating Problem with Unity-Android App even in low FPS??!! 1 Answer
Extracting Dataset (AR) from OBB (Expansion Files) 1 Answer
[Post Processing] Depth of Field issue on Android & WebGL 1 Answer