Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Shaders/BoxClipTemplate.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,14 @@ static float3 boxObjectSpaceCameraPosStereo = mul(unity_WorldToObject, float4(le
static float3 boxObjectSpaceCameraPosStereo = boxObjectSpaceCameraPos;
#endif

bool boxConditionCheck(float3 origvertpos);
void boxPreprocessVertex(inout float4 vert, inout float3 norm, inout float4 tang) {
vert.xyz *= (BOXCLIP_SCALE > 0 ? BOXCLIP_SCALE : 1);
#if defined(SHADER_API_MOBILE) || defined(SHADER_API_GLES30)
if (!boxConditionCheck(vert.xyz)) {
vert.xyz = sqrt(-vert.w);
}
#endif
}
void boxPreprocessVertex(inout float4 vert, inout float3 norm) {
float4 tangent = 0;
Expand Down Expand Up @@ -530,19 +536,27 @@ bool boxConditionCheck(float3 origvertpos) {
}

void boxConditionalClipLocal(float3 localPos) {
#if !defined(SHADER_API_MOBILE) && !defined(SHADER_API_GLES30)
clip(boxConditionCheck(localPos) ? 0 : -1);
#endif
}

void boxConditionalClipLocal(float4 localPos) {
#if !defined(SHADER_API_MOBILE) && !defined(SHADER_API_GLES30)
clip(boxConditionCheck(localPos.xyz) ? 0 : -1);
#endif
}

void boxConditionalClipWorld(float3 worldPos) {
#if !defined(SHADER_API_MOBILE) && !defined(SHADER_API_GLES30)
clip(boxConditionCheck(mul(unity_WorldToObject, float4(worldPos, 1)).xyz) ? 0 : -1);
#endif
}

void boxConditionalClipWorld(float4 worldPos) {
#if !defined(SHADER_API_MOBILE) && !defined(SHADER_API_GLES30)
clip(boxConditionCheck(mul(unity_WorldToObject, worldPos).xyz) ? 0 : -1);
#endif
}

bool geometry_check(float3 v1, float3 v2, float3 v3) {
Expand Down