public override DecalInstance AddDecal(Transform projector, DecalMaterial decal, int submesh, float maxNormal) { base.AddDecal(projector, decal, submesh, maxNormal); // Multiply projector matrix by local transform; This keeps the decal local to the space of the object var ret = new ScreenSpaceInstance(this, decal, transform.worldToLocalMatrix * projector.localToWorldMatrix); instances.Add(ret); return(ret); }
/// <summary> /// Checks whether assigning a renderer to be drawn (as opposed to a mesh) will work for all cameras /// </summary> /// <param name="material"></param> /// <returns><c>true</c> if it will work, <c>false</c> if not</returns> public virtual bool CanDrawRenderers(DecalMaterial material) { if (decalCameraArray == null) { return(true); } foreach (var c in decalCameraArray) { if (c != null && c.Camera != sceneCamera && !c.CanDrawRenderers(material)) { return(false); } } return(true); }
public override DecalInstance AddDecal(Transform projector, DecalMaterial decal, int submesh, float maxNormal) { if (projector == null) { throw new ArgumentNullException(nameof(projector)); } if (decal == null) { throw new ArgumentNullException(nameof(decal)); } if (ScreenSpace ? submesh >= 0 : (submesh < 0 || submesh >= Mesh.subMeshCount)) { throw new ArgumentOutOfRangeException(nameof(submesh)); } ClearData(); return(null); }
/// <summary> /// Sets <c>matrix</c> and <c>material</c> /// </summary> /// <inheritdoc /> public virtual void GetDrawCommand(DecalCamera dcam, ref Mesh mesh, ref Renderer renderer, ref int submesh, ref Material material, ref Matrix4x4 matrix) { matrix = DefaultMatrix(); material = DecalMaterial?.GetMaterial(ModeString); }
/// <summary> /// Adds a new decal to this instance /// </summary> /// <param name="projector">The projection transform</param> /// <param name="decal">The decal material</param> /// <param name="submesh">The submesh index</param> /// <param name="maxNormal"></param> /// <returns>The instance created or added to, or <c>null</c> if the box didn't intersect any geometry</returns> public abstract DecalInstance AddDecal(Transform projector, DecalMaterial decal, int submesh, float maxNormal);
/// <summary> /// Checks whether <c>Graphics.DrawMesh</c> can be used for the given configuration /// </summary> /// <param name="rp"></param> /// <param name="dmat"></param> /// <param name="mat"></param> /// <remarks> /// This is only false when using deferred shading and a depth texture; we need to put it somewhere specific with a command buffer /// </remarks> /// <returns></returns> protected virtual bool CanUseDrawMesh(RenderingPath rp, DecalMaterial dmat, Material mat) { return(!(rp == RenderingPath.DeferredShading && dmat.RequiresDepthTexture(mat))); }
/// <summary> /// Checks whether we can draw Renderers (not just Meshes) directly with the given material /// </summary> /// <param name="dmat"></param> /// <returns><c>true</c> if possible, <c>false</c> if not</returns> /// <remarks> /// Renderers can only be drawn with Command Buffers, so we must be able to enumerate the shader passes. /// </remarks> public virtual bool CanDrawRenderers(DecalMaterial dmat) { return(dmat.GetKnownPasses(Camera.actualRenderingPath) != null); }
public ScreenSpaceInstance(DecalScreenSpaceObject obj, DecalMaterial decalMaterial, Matrix4x4 matrix) { this.obj = obj; this.decalMaterial = decalMaterial; this.matrix = matrix; }