浏览代码

Fixed Lightmap issue and shadow issues on mobile.

/vr_sandbox
Felipe Lira 8 年前
当前提交
5450c598
共有 4 个文件被更改,包括 24 次插入24 次删除
  1. 22
      Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity
  2. 12
      Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader
  3. 4
      Assets/LowEndRenderLoop/LowEndRenderPipeline.cs
  4. 10
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs

22
Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity


m_ReflectionIntensity: 0.5
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.09192931, g: 0.11433018, b: 0.15055472, a: 0.5}
m_IndirectSpecularColor: {r: 0.323799, g: 0.3597683, b: 0.40908712, a: 0.5}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4
m_IsActive: 1
m_IsActive: 0
--- !u!23 &261580743
MeshRenderer:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1084503477
MonoBehaviour:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1111054116}
m_LocalRotation: {x: 0.48990765, y: 0.28636816, z: 0.41042274, w: 0.7138186}
m_LocalRotation: {x: 0.7882043, y: 0.51460123, z: 0.11175055, w: 0.31848294}
m_LocalEulerAnglesHint: {x: 27.668001, y: 66.301, z: 78.069}
m_LocalEulerAnglesHint: {x: 22.771002, y: 146.87001, z: 106.865005}
--- !u!108 &1111054118
Light:
m_ObjectHideFlags: 0

m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.8014706, b: 0.8014706, a: 1}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447851825}
m_LocalRotation: {x: 0.33125272, y: 0.0038699294, z: -0.0013586428, w: 0.9435332}
m_LocalPosition: {x: 0, y: 9.64, z: 0}
m_LocalRotation: {x: 0.18362224, y: -0.27254936, z: 0.05307446, w: 0.9429649}
m_LocalPosition: {x: 1.2794738, y: 3.0590448, z: 0.3753147}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1485985477}
m_LocalRotation: {x: -0.3750127, y: -0.41611558, z: 0.7215448, w: -0.40692312}
m_LocalRotation: {x: -0.45457986, y: -0.24911958, z: 0.7948072, w: -0.31555998}
m_LocalEulerAnglesHint: {x: 64.917, y: -28.537, z: 220.46599}
m_LocalEulerAnglesHint: {x: 43.071003, y: -50.710003, z: 202.125}
--- !u!1 &1499111012
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4
m_IsActive: 1
m_IsActive: 0
--- !u!23 &2031315346
MeshRenderer:
m_ObjectHideFlags: 0

12
Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader


// They are not used by the scriptable render loop; only here so that
// if we turn off our example loop, then regular forward rendering kicks in
// and objects look just like with a Standard shader.
//UsePass "Standard (Specular setup)/FORWARD"
//UsePass "Standard (Specular setup)/FORWARD_DELTA"
UsePass "Standard (Specular setup)/FORWARD"
UsePass "Standard (Specular setup)/FORWARD_DELTA"
Pass
{

#pragma shader_feature _SPECGLOSSMAP
#pragma shader_feature _NORMALMAP
#pragma shader_feature _EMISSION
#pragma shader_feature LIGHTMAP_ON
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog
#pragma only_renderers d3d9 d3d11 d3d11_9x glcore gles gles3

light.pos = globalLightPos[lightIndex]; \
light.color = globalLightColor[lightIndex]; \
light.atten = globalLightAtten[lightIndex]; \
light.spotDir = globalLightSpotDir[lightIndex];
light.spotDir = globalLightSpotDir[lightIndex]
#define FRESNEL_TERM(normal, viewDir) Pow4(1.0 - saturate(dot(normal, viewDir)))

// Compute direct contribution from main directional light.
// Only a single directional shadow caster is supported.
LightInput mainLight;
INITIALIZE_LIGHT(mainLight, 0)
INITIALIZE_LIGHT(mainLight, 0);
#if DEBUG_CASCADES
return half4(EvaluateMainLight(mainLight, diffuse, specular, normal, i.posWS, viewDir), 1.0);

4
Assets/LowEndRenderLoop/LowEndRenderPipeline.cs


Mathf.Infinity);
ShadowSliceData[] shadowSlices = shadowOutput.shadowSlices;
int shadowSliceCount = shadowSlices.Length;
if (shadowSlices == null)
return;
int shadowSliceCount = shadowSlices.Length;
const int maxShadowCascades = 4;
Matrix4x4[] shadowMatrices = new Matrix4x4[maxShadowCascades];
for (int i = 0; i < shadowSliceCount; ++i)

10
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


return 0;
}
int currentTileCount = atlasWidth / resolution + atlasHeight / resolution;
int currentTileCount = atlasWidth / resolution * atlasHeight / resolution;
currentTileCount = atlasWidth / resolution + atlasHeight / resolution;
currentTileCount = atlasWidth / resolution * atlasHeight / resolution;
}
return resolution;
}

var matScaleBias = Matrix4x4.identity;
matScaleBias.m00 = 0.5f;
matScaleBias.m11 = 0.5f;
matScaleBias.m22 = 0.5f;
matScaleBias.m22 = 0.5f;
// TODO: Projection Matrix is changed after SetViewProjectoinMatrix depending on zbuffer params and api.
// TODO: Provide API to check zBuffer direction
if (m_Settings.shadowType == ShadowSettings.ShadowType.LIGHTSPACE)
if (m_Settings.shadowType == ShadowSettings.ShadowType.LIGHTSPACE && SystemInfo.usesReversedZBuffer)
matScaleBias.m22 = -0.5f;
var matTile = Matrix4x4.identity;

正在加载...
取消
保存