示例#1
0
 public static bool IsLightingOrMaterial(this PassDescriptor pass)
 {
     return(pass.IsForward() ||
            pass.lightMode == HDShaderPassNames.s_GBufferStr
            // DXR passes without visibility, prepass or path tracing
            || (pass.lightMode.Contains("DXR") && pass.lightMode != HDShaderPassNames.s_RayTracingVisibilityStr && pass.lightMode != HDShaderPassNames.s_PathTracingDXRStr));
 }
        public static bool IsTessellation(this PassDescriptor pass)
        {
            foreach (var pragma in pass.pragmas)
            {
                if (pragma.value == "#pragma hull Hull")
                {
                    return(true);
                }
            }

            return(false);
        }
        public static bool IsRaytracing(this PassDescriptor pass)
        {
            foreach (var pragma in pass.pragmas)
            {
                if (pragma.value == "#pragma raytracing surface_shader")
                {
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
            public static PassDescriptor Forward(UniversalTarget target)
            {
                var result = new PassDescriptor
                {
                    // Definition
                    displayName   = "Universal Forward",
                    referenceName = "SHADERPASS_UNLIT",
                    useInPreview  = true,

                    // Template
                    passTemplatePath          = UniversalTarget.kUberTemplatePath,
                    sharedTemplateDirectories = UniversalTarget.kSharedTemplateDirectories,

                    // Port Mask
                    validVertexBlocks = CoreBlockMasks.Vertex,
                    validPixelBlocks  = CoreBlockMasks.FragmentColorAlpha,

                    // Fields
                    structs           = CoreStructCollections.Default,
                    requiredFields    = UnlitRequiredFields.Unlit,
                    fieldDependencies = CoreFieldDependencies.Default,

                    // Conditional State
                    renderStates = CoreRenderStates.UberSwitchedRenderState(target),
                    pragmas      = CorePragmas.Forward,
                    defines      = new DefineCollection()
                    {
                        CoreDefines.UseFragmentFog
                    },
                    keywords = new KeywordCollection()
                    {
                        UnlitKeywords.UnlitBaseKeywords
                    },
                    includes = UnlitIncludes.Unlit,

                    // Custom Interpolator Support
                    customInterpolators = CoreCustomInterpDescriptors.Common
                };

                CorePasses.AddTargetSurfaceControlsToPass(ref result, target);

                return(result);
            }
示例#5
0
            public static PassDescriptor Unlit(BuiltInTarget target)
            {
                var result = new PassDescriptor
                {
                    // Definition
                    displayName   = "Pass",
                    referenceName = "SHADERPASS_UNLIT",
                    lightMode     = "ForwardBase",
                    useInPreview  = true,

                    // Template
                    passTemplatePath          = BuiltInTarget.kTemplatePath,
                    sharedTemplateDirectories = BuiltInTarget.kSharedTemplateDirectories,

                    // Port Mask
                    validVertexBlocks = CoreBlockMasks.Vertex,
                    validPixelBlocks  = CoreBlockMasks.FragmentColorAlpha,

                    // Fields
                    structs           = CoreStructCollections.Default,
                    fieldDependencies = CoreFieldDependencies.Default,

                    // Conditional State
                    renderStates = CoreRenderStates.Default(target),
                    pragmas      = CorePragmas.Forward,
                    defines      = new DefineCollection()
                    {
                        CoreDefines.BuiltInTargetAPI
                    },
                    keywords = new KeywordCollection(),
                    includes = UnlitIncludes.Unlit,

                    // Custom Interpolator Support
                    customInterpolators = CoreCustomInterpDescriptors.Common
                };

                CorePasses.AddTargetSurfaceControlsToPass(ref result, target);
                return(result);
            }
示例#6
0
            public static PassDescriptor DepthNormalOnly(UniversalTarget target)
            {
                var result = new PassDescriptor
                {
                    // Definition
                    displayName   = "DepthNormals",
                    referenceName = "SHADERPASS_DEPTHNORMALSONLY",
                    lightMode     = "DepthNormalsOnly",
                    useInPreview  = false,

                    // Template
                    passTemplatePath          = UniversalTarget.kUberTemplatePath,
                    sharedTemplateDirectories = UniversalTarget.kSharedTemplateDirectories,

                    // Port Mask
                    validVertexBlocks = CoreBlockMasks.Vertex,
                    validPixelBlocks  = UnlitBlockMasks.FragmentDepthNormals,

                    // Fields
                    structs           = CoreStructCollections.Default,
                    requiredFields    = UnlitRequiredFields.DepthNormalsOnly,
                    fieldDependencies = CoreFieldDependencies.Default,

                    // Conditional State
                    renderStates = CoreRenderStates.DepthNormalsOnly(target),
                    pragmas      = CorePragmas.Forward,
                    defines      = new DefineCollection(),
                    keywords     = new KeywordCollection(),
                    includes     = CoreIncludes.DepthNormalsOnly,

                    // Custom Interpolator Support
                    customInterpolators = CoreCustomInterpDescriptors.Common
                };

                CorePasses.AddTargetSurfaceControlsToPass(ref result, target);

                return(result);
            }
示例#7
0
            public static PassDescriptor BuildPass()
            {
                PassDescriptor pass = new PassDescriptor()
                {
                    // Definition
                    displayName   = "DepthOnly",
                    referenceName = "SHADERPASS_DEPTHONLY",
                    lightMode     = "DepthOnly",
                    useInPreview  = true,

                    // Template
                    passTemplatePath          = "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Templates/ShaderPass.template",
                    sharedTemplateDirectories = GenerationUtils.GetDefaultSharedTemplateDirectories(),

                    // Port Mask
                    validVertexBlocks = new BlockFieldDescriptor[] { BlockFields.VertexDescription.Position, BlockFields.VertexDescription.Normal, BlockFields.VertexDescription.Tangent },
                    validPixelBlocks  = new BlockFieldDescriptor[] { BlockFields.SurfaceDescription.Alpha, BlockFields.SurfaceDescription.AlphaClipThreshold },

                    // Fields
                    structs = new StructCollection {
                        { Structs.Attributes }, { Structs.SurfaceDescriptionInputs }, { Structs.VertexDescriptionInputs }
                    },
                    fieldDependencies = FieldDependencies.Default,

                    // Conditional State
                    renderStates = null,
                    pragmas      = new PragmaCollection {
                        { Pragma.Target(ShaderModel.Target30) }, { Pragma.MultiCompileInstancing }, { Pragma.Vertex("vert") }, { Pragma.Fragment("frag") }
                    },
                    defines             = null,
                    keywords            = null,
                    includes            = null,
                    customInterpolators = null,
                };

                return(pass);
            }
        private void CollectPassRenderState(ref PassDescriptor pass)
        {
            if (pass.lightMode == DecalShaderPassNames.DecalGBufferProjector ||
                pass.lightMode == DecalShaderPassNames.DecalGBufferMesh)
            {
                // Make copy to avoid overwriting static
                pass.renderStates = new RenderStateCollection()
                {
                    pass.renderStates
                };

                if (decalData.affectsAlbedo)
                {
                    pass.renderStates.Add(RenderState.ColorMask("ColorMask RGB"));
                }
                else
                {
                    pass.renderStates.Add(RenderState.ColorMask("ColorMask 0"));
                }

                pass.renderStates.Add(RenderState.ColorMask("ColorMask 0 1"));

                if (decalData.affectsNormal)
                {
                    pass.renderStates.Add(RenderState.ColorMask("ColorMask RGB 2"));
                }
                else
                {
                    pass.renderStates.Add(RenderState.ColorMask("ColorMask 0 2"));
                }

                // GI needs it unconditionaly
                pass.renderStates.Add(RenderState.ColorMask("ColorMask RGB 3"));
            }

            if (pass.lightMode == DecalShaderPassNames.DBufferProjector ||
                pass.lightMode == DecalShaderPassNames.DBufferMesh)
            {
                // Make copy to avoid overwriting static
                pass.renderStates = new RenderStateCollection()
                {
                    pass.renderStates
                };

                if (decalData.affectsAlbedo)
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskRGBA0);
                }
                else
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskNone0);
                }

                if (decalData.affectsNormal)
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskRGBA1);
                }
                else
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskNone1);
                }

                if (decalData.affectsMAOS)
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskRGBA2);
                }
                else
                {
                    pass.renderStates.Add(DecalColorMasks.ColorMaskNone2);
                }
            }
        }
示例#9
0
 public static bool NeedsDebugDisplay(this PassDescriptor pass)
 {
     return(IsLightingOrMaterial(pass) || pass.lightMode == HDShaderPassNames.s_ForwardEmissiveForDeferredStr);
 }
示例#10
0
 public static bool IsForward(this PassDescriptor pass)
 {
     return(pass.lightMode == HDShaderPassNames.s_ForwardOnlyStr ||
            pass.lightMode == HDShaderPassNames.s_ForwardStr ||
            pass.lightMode == HDShaderPassNames.s_TransparentBackfaceStr);
 }
示例#11
0
 public static bool IsDXR(this PassDescriptor pass)
 {
     return(pass.lightMode.Contains("DXR") ||
            pass.lightMode == HDShaderPassNames.s_RayTracingVisibilityStr ||
            pass.lightMode == HDShaderPassNames.s_RayTracingPrepassStr);
 }
示例#12
0
 public static bool IsDepthOrMV(this PassDescriptor pass)
 {
     return(pass.lightMode == HDShaderPassNames.s_DepthForwardOnlyStr ||
            pass.lightMode == HDShaderPassNames.s_DepthOnlyStr ||
            pass.lightMode == HDShaderPassNames.s_MotionVectorsStr);
 }
示例#13
0
 public static bool NeedsDebugDisplay(this PassDescriptor pass)
 {
     return(IsLightingOrMaterial(pass));
 }
 // Methods
 public bool Equals(PassDescriptor other)
 {
     return(referenceName == other.referenceName);
 }