浏览代码

sample game delta:

-FPS Mode (Render mesh with custom FOV)
-only PCF shadows with game specific limits
-Atmosphere y-offset property
/sample_game
runes 7 年前
当前提交
dd5838bd
共有 15 个文件被更改,包括 124 次插入12 次删除
  1. 4
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  3. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  4. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  5. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  6. 43
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  7. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  8. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  9. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  10. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  11. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs
  12. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl
  13. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  14. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs
  15. 34
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader

4
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


}
}
m_MaxShadows[(int)GPUShadowType.Point ,0] = m_MaxShadows[(int)GPUShadowType.Point ,1] = 4;
m_MaxShadows[(int)GPUShadowType.Spot ,0] = m_MaxShadows[(int)GPUShadowType.Spot ,1] = 8;
m_MaxShadows[(int)GPUShadowType.Point ,0] = m_MaxShadows[(int)GPUShadowType.Point ,1] = 2;
m_MaxShadows[(int)GPUShadowType.Spot ,0] = m_MaxShadows[(int)GPUShadowType.Spot ,1] = 4;
m_MaxShadows[(int)GPUShadowType.Directional,0] = m_MaxShadows[(int)GPUShadowType.Directional ,1] = 2;
#if UNITY_EDITOR

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


atlasInit.baseInit.maxPayloadCount = 0;
atlasInit.baseInit.shadowSupport = ShadowmapBase.ShadowSupport.Directional | ShadowmapBase.ShadowSupport.Point | ShadowmapBase.ShadowSupport.Spot;
atlasInit.shaderKeyword = null;
/*
var varianceInit = atlasInit;
varianceInit.baseInit.shadowmapFormat = ShadowVariance.GetFormat( false, false, true );

var varianceInit3 = varianceInit;
varianceInit3.baseInit.shadowmapFormat = ShadowVariance.GetFormat( true, false, true );
m_Shadowmaps = new ShadowmapBase[] { new ShadowVariance( ref varianceInit ), new ShadowVariance( ref varianceInit2 ), new ShadowVariance( ref varianceInit3 ), new ShadowAtlas( ref atlasInit ) };
*/
m_Shadowmaps = new ShadowmapBase[] { /*new ShadowVariance( ref varianceInit ), new ShadowVariance( ref varianceInit2 ), new ShadowVariance( ref varianceInit3 ), */new ShadowAtlas( ref atlasInit ) };
ShadowContext.SyncDel syncer = (ShadowContext sc) =>
{

cb.SetComputeBufferParam(computeShader, computeKernel, HDShaderIDs._ShadowDatasExp, s_ShadowDataBuffer);
cb.SetComputeBufferParam(computeShader, computeKernel, HDShaderIDs._ShadowPayloads, s_ShadowPayloadBuffer);
// bind textures
/*
cb.SetComputeTextureParam(computeShader, computeKernel, HDShaderIDs._ShadowmapExp_PCF, tex[3]);
*/
cb.SetComputeTextureParam(computeShader, computeKernel, HDShaderIDs._ShadowmapExp_PCF, tex[0]);
}
else
{

// bind textures
/*
cb.SetGlobalTexture(HDShaderIDs._ShadowmapExp_PCF, tex[3]);
*/
cb.SetGlobalTexture(HDShaderIDs._ShadowmapExp_PCF, tex[0]);
}
// TODO: Currently samplers are hard coded in ShadowContext.hlsl, so we can't really set them here

if (m_Shadowmaps != null)
{
(m_Shadowmaps[0] as ShadowAtlas).Dispose();
/*
*/
m_Shadowmaps = null;
}
m_ShadowMgr = null;

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


EditorGUILayout.Space();
VertexAnimationPropertiesGUI();
EditorGUILayout.Space();
FpsModePropertiesGUI();
EditorGUILayout.Space();
}
if (EditorGUI.EndChangeCheck())

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableFpsMode("Enable Fps Mode", Float) = 0.0
_FpsModeFov("_FpsModeFov", Float) = 60.0
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0

#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _FPS_MODE
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableFpsMode("Enable Fps Mode", Float) = 0.0
_FpsModeFov("_FpsModeFov", Float) = 60.0
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0

#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _FPS_MODE
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

43
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


public static GUIContent windShiverDragText = new GUIContent("Shiver Drag");
public static GUIContent windShiverDirectionalityText = new GUIContent("Shiver Directionality");
public static string vertexAnimation = "Vertex Animation";
public static string vertexAnimation = "Vertex Animation";
// FPS Mode
public static GUIContent fpsModeText = new GUIContent("Enable FPS Mode");
public static GUIContent fpsModeFovText = new GUIContent("Fov");
public static string fpsMode = "FPS Mode";
}
public enum DoubleSidedNormalMode

protected MaterialProperty windShiverDrag = null;
protected const string kWindShiverDrag = "_ShiverDrag";
protected MaterialProperty windShiverDirectionality = null;
protected const string kWindShiverDirectionality = "_ShiverDirectionality";
protected const string kWindShiverDirectionality = "_ShiverDirectionality";
// Fps mode
protected MaterialProperty fpsModeEnable = null;
protected const string kFpsModeEnabled = "_EnableFpsMode";
protected MaterialProperty fpsModeFov = null;
protected const string kFpsModeFov = "_FpsModeFov";
// Per pixel displacement params
protected MaterialProperty enablePerPixelDisplacement = null;

windStiffness = FindProperty(kWindStiffness, props);
windDrag = FindProperty(kWindDrag, props);
windShiverDrag = FindProperty(kWindShiverDrag, props);
windShiverDirectionality = FindProperty(kWindShiverDirectionality, props);
windShiverDirectionality = FindProperty(kWindShiverDirectionality, props);
fpsModeEnable = FindProperty(kFpsModeEnabled, props);
fpsModeFov = FindProperty(kFpsModeFov, props);
}
void TessellationModePopup()

}
EditorGUI.indentLevel--;
}
protected override void FpsModePropertiesGUI()
{
GUILayout.Label(StylesBaseLit.fpsMode, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(fpsModeEnable, StylesBaseLit.fpsModeText);
if (fpsModeEnable.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(fpsModeFov, StylesBaseLit.fpsModeFovText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change

}
bool windEnabled = material.GetFloat(kWindEnabled) > 0.0f;
SetKeyword(material, "_VERTEX_WIND", windEnabled);
SetKeyword(material, "_VERTEX_WIND", windEnabled);
bool fpsModeEnabled = material.GetFloat(kFpsModeEnabled) > 0.0f;
SetKeyword(material, "_FPS_MODE", fpsModeEnabled);
}
static public void SetupBaseLitMaterialPass(Material material)

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableFpsMode("Enable Fps Mode", Float) = 0.0
_FpsModeFov("_FpsModeFov", Float) = 60.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above

#pragma shader_feature _THICKNESSMAP
#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _FPS_MODE
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


float _ShiverDrag;
float _ShiverDirectionality;
float _FpsModeFov;
#ifndef LAYERED_LIT_SHADER
// Set of users variables

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableFpsMode("Enable Fps Mode", Float) = 0.0
_FpsModeFov("_FpsModeFov", Float) = 60.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above

#pragma shader_feature _THICKNESSMAP
#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _FPS_MODE
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


protected abstract void SetupMaterialKeywordsAndPassInternal(Material material);
protected abstract void MaterialPropertiesGUI(Material material);
protected abstract void VertexAnimationPropertiesGUI();
protected abstract void FpsModePropertiesGUI();
// This function will say if emissive is used or not regarding enlighten/PVR
protected abstract bool ShouldEmissionBeEnabled(Material material);

VertexAnimationPropertiesGUI();
EditorGUILayout.Space();
FpsModePropertiesGUI();
EditorGUILayout.Space();
MaterialPropertiesGUI(material);

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs


protected override void VertexAnimationPropertiesGUI()
{
}
protected override void FpsModePropertiesGUI()
{
}
protected override bool ShouldEmissionBeEnabled(Material mat)

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl


ApplyWind(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, vertexColor.a, _Time);
#endif
#if _FPS_MODE
float3 positionVS = mul(GetWorldToViewMatrix(), float4(positionWS - _WorldSpaceCameraPos, 1.0f));
positionVS.xy *= 1.0f / (-_ProjMatrix[1].y * tan(_FpsModeFov * 0.5f * PI / 180.0f)); // *= tan(old_fov * 0.5) / tan(new_fov * 0.5)
positionWS = mul(positionVS, (float3x3)GetWorldToViewMatrix()) + _WorldSpaceCameraPos;
#endif
positionWS = GetCameraRelativePositionWS(positionWS);
#ifdef TESSELLATION_ON

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs


m_ProceduralSkyMaterial.SetFloat("_WorldRayleighDensity", -param.worldRayleighDensity / 100000f);
m_ProceduralSkyMaterial.SetFloat("_WorldMieDensity", -param.worldMieDensity / 100000f);
m_ProceduralSkyMaterial.SetFloat("_SkyDepth", 1.0f / param.maxSkyDistance);
m_ProceduralSkyMaterial.SetFloat("_SkyYOffset", param.skyYOffset);
var rayleighColorM20 = param.worldRayleighColorRamp.Evaluate(0.00f);
var rayleighColorM10 = param.worldRayleighColorRamp.Evaluate(0.25f);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs


// public Shader occlusionShader = null;
public float worldScaleExponent = 1.0f;
public float maxSkyDistance = 4000.0f;
public float skyYOffset = 0.0f;
public ScatterDebugMode debugMode = ScatterDebugMode.None;
// Camera m_currentCamera;

worldScaleExponent = Mathf.Clamp(worldScaleExponent, 1f, 2f);
maxSkyDistance = Mathf.Clamp(maxSkyDistance, 1.0f, 1000000.0f);
skyYOffset = Mathf.Clamp(skyYOffset, -10000.0f, 10000.0f);
/*
occlusionBias = Mathf.Clamp01(occlusionBias);

34
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader


// x = width, y = height, z = 1.0/width, w = 1.0/height
float4 _ScreenSize;
float4 _ZBufferParams;
float4 _CameraPosWS;

float _SkyYOffset;
float _DisableSkyOcclusionTest;

// input.positionCS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);
#if 1
float linearDist = 1.0f / _SkyDepth;
float yOffset = -_SkyYOffset;
#ifdef PERFORM_SKY_OCCLUSION_TEST
// Determine whether the sky is occluded by the scene geometry.
// Do not perform blending with the environment map if the sky is occluded.
float skyTexWeight = 1.0;
if (_DisableSkyOcclusionTest == 0.0)
{
float depthRaw = LOAD_TEXTURE2D(_MainDepthTexture, posInput.unPositionSS).r;
if (depthRaw > 0.0f)
{
skyTexWeight = 0.0f;
linearDist = LinearEyeDepth(depthRaw, _ZBufferParams) * length(input.eyeVector);
yOffset = 0.0;
}
}
#else
float skyTexWeight = 0.0;
#endif
float3 positionWS = _CameraPosWS + linearDist * dir;
positionWS.y += yOffset;
#else
#ifdef PERFORM_SKY_OCCLUSION_TEST
// Determine whether the sky is occluded by the scene geometry.
// Do not perform blending with the environment map if the sky is occluded.

// Since we only need the world space position, so we don't pass the view-projection matrix.
UpdatePositionInput(depthRaw, _InvViewProjMatrix, k_identity4x4, posInput);
float3 positionWS = posInput.positionWS;
#endif
VolundTransferScatter(posInput.positionWS, c1, c2, c3);
VolundTransferScatter(positionWS, c1, c2, c3);
float4 coord1 = float4(c1.rgb + c3.rgb, max(0.f, 1.f - c1.a - c3.a));
float3 coord2 = c2.rgb;

正在加载...
取消
保存