浏览代码

fix decal rendering in editor

/Add-support-for-light-specular-color-tint
Paul Melamed 7 年前
当前提交
ddee46ec
共有 4 个文件被更改,包括 13 次插入17 次删除
  1. 10
      ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalProjectorComponent.cs
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs
  3. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.cs

10
ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalProjectorComponent.cs


public void Start()
{
m_PropertyBlock = new MaterialPropertyBlock();
UpdatePropertyBlock();
m_PropertyBlock = new MaterialPropertyBlock();
DecalSystem.instance.AddDecal(this);
}

Selection.activeObject = go;
}
public void UpdatePropertyBlock()
public void UpdatePropertyBlock(Vector3 cameraPos)
// Vector4 worldSpaceCameraPos = Shader.GetGlobalVector(HDShaderIDs._WorldSpaceCameraPos);
CRWStoAWS = Matrix4x4.Translate(Camera.main.transform.position);
CRWStoAWS = Matrix4x4.Translate(cameraPos);
}
else
{

m_PropertyBlock = new MaterialPropertyBlock();
}
m_PropertyBlock.SetMatrix(m_DecalToWorldR, decalToWorldR);
m_PropertyBlock.SetMatrix(m_WorldToDecal, worldToDecal);
m_PropertyBlock.SetMatrix(m_WorldToDecal, worldToDecal * CRWStoAWS);
}
public MaterialPropertyBlock GetPropertyBlock()

8
ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs


m_Decals.Remove(d);
}
public void Render(ScriptableRenderContext renderContext, Camera camera, CommandBuffer cmd)
public void Render(ScriptableRenderContext renderContext, Vector3 cameraPos, CommandBuffer cmd)
if (decal.transform.hasChanged)
{
decal.UpdatePropertyBlock();
decal.transform.hasChanged = false;
}
decal.UpdatePropertyBlock(cameraPos);
cmd.DrawMesh(m_CubeMesh, decal.transform.localToWorldMatrix, decal.m_Material, 0, 0, decal.GetPropertyBlock());
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


bool enableBakeShadowMask = m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
ConfigureForShadowMask(enableBakeShadowMask, cmd);
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
RenderDBuffer(camera, renderContext, cmd);
RenderDBuffer(hdCamera.cameraPos, renderContext, cmd);
RenderGBuffer(m_CullResults, camera, renderContext, cmd);

}
}
void RenderDBuffer(Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
void RenderDBuffer(Vector3 cameraPos, ScriptableRenderContext renderContext, CommandBuffer cmd)
CoreUtils.SetRenderTarget(cmd, m_DbufferManager.GetDBuffers(), m_CameraDepthStencilBufferRT);
Color clearColor = new Color(0,0,0,0);
CoreUtils.SetRenderTarget(cmd, m_DbufferManager.GetDBuffers(), m_CameraDepthStencilBufferRT, ClearFlag.Color, clearColor);
DecalSystem.instance.Render(renderContext, camera, cmd);
DecalSystem.instance.Render(renderContext, cameraPos, cmd);
}
}

1
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.cs


// DBuffer management
//-----------------------------------------------------------------------------
// should this be rolled into common class shared with Lit.cs???
static public int GetMaterialDBufferCount() { return (int)DBufferMaterial.Count; }
static RenderTextureFormat[] m_RTFormat = { RenderTextureFormat.ARGB32, RenderTextureFormat.ARGB32};

正在加载...
取消
保存