Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
42297b0
clean history after 2021 upgrade
Jan 17, 2023
346be79
Comment out unused features
Jan 17, 2023
3ca1ec3
Errant property
Jan 17, 2023
5288dc7
New shadow pass
Jan 18, 2023
7953b7c
Forgot a file on last commit
Jan 18, 2023
8f3d4ef
fix warning
Jan 18, 2023
8135602
Extracted round corners
Jan 19, 2023
9936528
Broken and done for the day
Jan 20, 2023
f8df1fd
safe before clean
Jan 20, 2023
9fe2f32
rounded corners working. independent corners no.
Jan 20, 2023
6286ca4
remove commented code
Jan 20, 2023
aff52b8
fix some bugs
Jan 20, 2023
016930e
more cleanup
Jan 20, 2023
9a9307e
revert
Jan 20, 2023
be72f52
restore space
Jan 20, 2023
0e4d16d
Round corners and cutout alpha work together
Jan 24, 2023
f116818
nit
Jan 24, 2023
72907e0
shadows maybe sorta working
Jan 25, 2023
36038bb
absolute shadows maybe working?
Jan 26, 2023
13df814
broken, scaling object scales corner radius - needs fix
Jan 26, 2023
da1d71f
corners stay same size when uniform scaling. non-uniform buggy
Jan 26, 2023
0073adc
xy and z now all are same size in absolute
Jan 26, 2023
6ff6736
xy and z now all are same size in absolute
Jan 26, 2023
0b16af0
clean up, still lacking scale normalizer for absolute mode
Jan 26, 2023
2fab0d4
split up roundcorners()
Jan 30, 2023
f613ef7
stretching on axis seems to be fixed for color pass - todo shadow
Jan 30, 2023
9ec0449
shadows match
Jan 30, 2023
bbc079f
clean up, still lacking scale normalizer for absolute mode
Jan 30, 2023
9db903f
loose the include
Jan 30, 2023
6618e1f
revert
Feb 1, 2023
5167304
clean up, toward adding canvas support
Feb 1, 2023
6b4b9ed
backplate working again
Feb 2, 2023
0e2ac69
Revert "backplate working again"
Feb 2, 2023
17a3564
switch to standard program
Feb 2, 2023
d79faa9
checkpoint
Feb 2, 2023
b50e06c
checkpoint charlie
Feb 2, 2023
60058f4
less entropy
Feb 2, 2023
63ee542
loose shadow pass
Feb 2, 2023
5521979
ifdef for performance
Feb 2, 2023
d79675f
indenting
Feb 2, 2023
2dac68e
more indenting
Feb 2, 2023
f4f1aef
revert
Feb 2, 2023
85374af
space
Feb 2, 2023
130d59d
comment out renderdoc pragma
Feb 2, 2023
8bcf9cf
restore deleted line
Feb 2, 2023
8a370b9
restore deleted line
Feb 2, 2023
542caeb
Update com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/Graphic…
pinkwerks Feb 3, 2023
0f8fd27
do the right thing with transparency
Feb 3, 2023
761528e
remove debugging comment
Feb 3, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct GTMainLight
GTMainLight GTGetMainLight()
{
GTMainLight light;
#if defined(_DIRECTIONAL_LIGHT) || defined(_DISTANT_LIGHT)
#if defined(_DIRECTIONAL_LIGHT) || defined(_DISTANT_LIGHT) || defined(_SHADOW_PASS)
#if defined(_DISTANT_LIGHT)
light.direction = _DistantLightData[0].xyz;
light.color = _DistantLightData[1].xyz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,30 @@ Shader "Graphics Tools/Standard"
ENDHLSL
}

Pass
{
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}

ZWrite On
ZTest LEqual
ColorMask 0
Cull[_CullMode]

HLSLPROGRAM

#define _URP
#define _SHADOW_PASS

#pragma multi_compile_instancing

#pragma shader_feature_local_fragment _CLIPPING_BORDER

#include_with_pragmas "GraphicsToolsStandardProgram.hlsl"

ENDHLSL
}

// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,49 @@
#pragma fragment PixelStage

// Comment in to help with RenderDoc debugging.
//#pragma enable_d3d11_debug_symbols
#pragma enable_d3d11_debug_symbols

/// <summary>
/// Features.
/// </summary>

#pragma multi_compile_local _ _CLIPPING_PLANE _CLIPPING_SPHERE _CLIPPING_BOX

#pragma shader_feature_local _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHABLEND_TRANS_ON _ADDITIVE_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _DISABLE_ALBEDO_MAP
#pragma shader_feature_local_fragment _ _METALLIC_TEXTURE_ALBEDO_CHANNEL_A _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature_local _CHANNEL_MAP
#pragma shader_feature_local _ _DIRECTIONAL_LIGHT _DISTANT_LIGHT
#pragma shader_feature_local _VERTEX_COLORS
#pragma shader_feature_local _VERTEX_EXTRUSION
#pragma shader_feature_local_vertex _VERTEX_EXTRUSION_SMOOTH_NORMALS
#pragma shader_feature_local_vertex _VERTEX_EXTRUSION_CONSTANT_WIDTH
#pragma shader_feature_local _NEAR_PLANE_FADE
#pragma shader_feature_local_vertex _NEAR_LIGHT_FADE
#pragma shader_feature_local _ROUND_CORNERS
#pragma shader_feature_local_fragment _INDEPENDENT_CORNERS
#pragma shader_feature_local_fragment _ROUND_CORNERS_HIDE_INTERIOR
#pragma shader_feature_local_fragment _ _EDGE_SMOOTHING_AUTOMATIC
#pragma shader_feature_local _USE_WORLD_SCALE

#if !defined(_SHADOW_PASS)
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHABLEND_TRANS_ON _ADDITIVE_ON
#pragma shader_feature_local _NORMAL_MAP
#pragma shader_feature_local _EMISSION
#pragma shader_feature_local _TRIPLANAR_MAPPING
#pragma shader_feature_local _LOCAL_SPACE_TRIPLANAR_MAPPING
#pragma shader_feature_local_fragment _USE_SSAA
#pragma shader_feature_local _ _DIRECTIONAL_LIGHT _DISTANT_LIGHT
#pragma shader_feature_local _NON_PHOTOREALISTIC
#pragma shader_feature_local_fragment _SPECULAR_HIGHLIGHTS
#pragma shader_feature_local _SPHERICAL_HARMONICS
#pragma shader_feature_local _REFLECTIONS
#pragma shader_feature_local _RIM_LIGHT
#pragma shader_feature_local _VERTEX_COLORS
#pragma shader_feature_local _VERTEX_EXTRUSION
#pragma shader_feature_local_vertex _VERTEX_EXTRUSION_SMOOTH_NORMALS
#pragma shader_feature_local_vertex _VERTEX_EXTRUSION_CONSTANT_WIDTH
#pragma shader_feature_local _NEAR_PLANE_FADE
#pragma shader_feature_local_vertex _NEAR_LIGHT_FADE
#pragma shader_feature_local _HOVER_LIGHT
#pragma shader_feature_local_fragment _HOVER_COLOR_OVERRIDE
#pragma shader_feature_local _PROXIMITY_LIGHT
#pragma shader_feature_local_fragment _PROXIMITY_LIGHT_COLOR_OVERRIDE
#pragma shader_feature_local_fragment _PROXIMITY_LIGHT_SUBTRACTIVE
#pragma shader_feature_local _PROXIMITY_LIGHT_TWO_SIDED
#pragma shader_feature_local _ROUND_CORNERS
#pragma shader_feature_local_fragment _INDEPENDENT_CORNERS
#pragma shader_feature_local_fragment _ROUND_CORNERS_HIDE_INTERIOR
#pragma shader_feature_local_fragment _ _EDGE_SMOOTHING_AUTOMATIC
#pragma shader_feature_local _BORDER_LIGHT
#pragma shader_feature_local_fragment _ _BORDER_LIGHT_USES_HOVER_COLOR _BORDER_LIGHT_USES_COLOR _BORDER_LIGHT_USES_GRADIENT
#pragma shader_feature_local_fragment _BORDER_LIGHT_REPLACES_ALBEDO
Expand All @@ -55,7 +59,7 @@
#pragma shader_feature_local _ _IRIDESCENCE _GRADIENT_FOUR_POINT _GRADIENT_LINEAR
#pragma shader_feature_local _ENVIRONMENT_COLORING
#pragma shader_feature_local _ _BLUR_TEXTURE _BLUR_TEXTURE_2 _BLUR_TEXTURE_PREBAKED_BACKGROUND
#pragma shader_feature_local _USE_WORLD_SCALE
#endif

/// <summary>
/// Defines and includes.
Expand Down Expand Up @@ -169,7 +173,7 @@ Varyings VertexStage(Attributes input)
#endif
#endif
#endif

half3 localNormal = input.normal;

#if defined(_NORMAL) || defined(_VERTEX_EXTRUSION)
Expand Down Expand Up @@ -244,28 +248,21 @@ Varyings VertexStage(Attributes input)

#if defined(_BORDER_LIGHT) || defined(_ROUND_CORNERS)
output.uv = input.uv;

#if defined(_USE_WORLD_SCALE)
output.scale.z = canvasScale;
#else
float minScale = min(min(output.scale.x, output.scale.y), output.scale.z);
#endif


if (abs(localNormal.x) == 1.0) // Y,Z plane.
{
output.scale.x = output.scale.z;
output.scale.y = output.scale.y;
}
else if (abs(localNormal.y) == 1.0) // X,Z plane.
{
output.scale.x = output.scale.x;
output.scale.y = output.scale.z;
}
// Else X,Y plane.

#if !defined(_USE_WORLD_SCALE)
output.scale.z = minScale;
#endif
} // Else X,Y plane.

#if defined(_USE_WORLD_SCALE)
output.scale.z = canvasScale;
#else
output.scale.z = min(min(output.scale.x, output.scale.y), output.scale.z);
#endif

#elif defined(_UV)
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
Expand Down Expand Up @@ -516,7 +513,7 @@ half4 PixelStage(Varyings input, bool facing : SV_IsFrontFace) : SV_Target
_RoundCornersRadius = clamp(_RoundCornersRadius, 0.0h, 0.5h);
#endif
currentCornerRadius = GTFindCornerRadius(input.uv.xy, _RoundCornersRadius);
#else
#else
currentCornerRadius = _RoundCornerRadius;
#endif
#else
Expand Down Expand Up @@ -763,6 +760,11 @@ half4 PixelStage(Varyings input, bool facing : SV_IsFrontFace) : SV_Target
albedo.a = 1.0;
#endif

#if defined(_SHADOW_PASS)
// Return early to avoid unnecessary calculations for shadow pass.
return 0;
#endif

// Final lighting mix.
half4 output = albedo;

Expand Down