浏览代码
HDRenderLoop: Lot of stuffs - try to prepare for various lighting architecture
HDRenderLoop: Lot of stuffs - try to prepare for various lighting architecture
- Move and rename file - Design for various lighting architecture/main
Sebastien Lagarde
8 年前
当前提交
00afee16
共有 31 个文件被更改,包括 328 次插入 和 98 次删除
-
2Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader
-
42Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs
-
72Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl
-
7Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl
-
5Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitEnvTemplate.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitShare.hlsl
-
5Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitData.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitShare.hlsl
-
5Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader.meta
-
16Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Forward.hlsl
-
28Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs
-
51Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.hlsl.meta
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass.meta
-
17Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs.meta
-
15Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl.meta
-
62Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePassLoop.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePassLoop.hlsl.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightingDeferred.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightingForward.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 00dd221e34a6ab349a1196b0f2fab693 |
|||
timeCreated: 1477266585 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
// There is two kind of lighting architectures. |
|||
// Those that are control from inside the "Material".shader with "Pass" concept like forward lighting. Call later forward lighting architecture. |
|||
// Those that are control outside the "Material".shader in a "Lighting".shader like deferred lighting. Call later deferred lighting architecture. |
|||
|
|||
// When dealing with deferred lighting architecture, the renderloop is in charge to call the correct .shader. |
|||
// RenderLoop can do multiple call of various deferred lighting architecture. |
|||
// (Note: enabled variant for deferred lighting architecture are in deferred.shader) |
|||
// When dealing with forward lighting architecture, the renderloop must specify a shader pass (like "forward") but it also need |
|||
// to specify which variant of the forward lighting architecture he want (with cmd.EnableShaderKeyword()). |
|||
// Renderloop can suppose dynamically switching from regular forward to tile forward for example within the same "Forward" pass. |
|||
|
|||
// The purpose of the following pragma is to define the variant available for "Forward" Pass in "Material".shader. |
|||
// If only one keyword is present it mean that only one type of forward lighting architecture is supported. |
|||
|
|||
// Must match name in GetKeyword() method of forward lighting architecture .cs file |
|||
// #pragma multi_compile SINGLE_PASS -> can't use a pragma from include... (for now) |
|
|||
using UnityEngine; |
|||
|
|||
//-----------------------------------------------------------------------------
|
|||
// structure definition
|
|||
//-----------------------------------------------------------------------------
|
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
{ |
|||
[GenerateHLSL] |
|||
public enum ShadowType |
|||
{ |
|||
Spot, |
|||
Point |
|||
} |
|||
|
|||
[GenerateHLSL] |
|||
public struct PunctualShadowData |
|||
{ |
|||
// World to ShadowMap matrix
|
|||
// Include scale and bias for shadow atlas if any
|
|||
public Vector4 shadowMatrix1; |
|||
public Vector4 shadowMatrix2; |
|||
public Vector4 shadowMatrix3; |
|||
public Vector4 shadowMatrix4; |
|||
|
|||
public ShadowType shadowType; |
|||
public Vector3 unused; |
|||
}; |
|||
} // namespace UnityEngine.Experimental.ScriptableRenderLoop
|
|
|||
// |
|||
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs. Please don't edit by hand. |
|||
// |
|||
|
|||
// |
|||
// UnityEngine.Experimental.ScriptableRenderLoop.ShadowType: static fields |
|||
// |
|||
#define SHADOWTYPE_SPOT (0) |
|||
#define SHADOWTYPE_POINT (1) |
|||
|
|||
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData |
|||
// PackingRules = Exact |
|||
struct PunctualShadowData |
|||
{ |
|||
float4 shadowMatrix1; |
|||
float4 shadowMatrix2; |
|||
float4 shadowMatrix3; |
|||
float4 shadowMatrix4; |
|||
int shadowType; |
|||
float3 unused; |
|||
}; |
|||
|
|||
// |
|||
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData |
|||
// |
|||
float4 GetShadowMatrix1(PunctualShadowData value) |
|||
{ |
|||
return value.shadowMatrix1; |
|||
} |
|||
float4 GetShadowMatrix2(PunctualShadowData value) |
|||
{ |
|||
return value.shadowMatrix2; |
|||
} |
|||
float4 GetShadowMatrix3(PunctualShadowData value) |
|||
{ |
|||
return value.shadowMatrix3; |
|||
} |
|||
float4 GetShadowMatrix4(PunctualShadowData value) |
|||
{ |
|||
return value.shadowMatrix4; |
|||
} |
|||
int GetShadowType(PunctualShadowData value) |
|||
{ |
|||
return value.shadowType; |
|||
} |
|||
float3 GetUnused(PunctualShadowData value) |
|||
{ |
|||
return value.unused; |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: f22956c3631d5f64388bdb93e12ec747 |
|||
timeCreated: 1477268655 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 548c943bc73a18d4998420073b25d44b |
|||
timeCreated: 1477263464 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 16efe1cc514ae594993f6705dacbf97d |
|||
folderAsset: yes |
|||
timeCreated: 1477266406 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using System; |
|||
|
|||
//-----------------------------------------------------------------------------
|
|||
// structure definition
|
|||
//-----------------------------------------------------------------------------
|
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
{ |
|||
public class SinglePass |
|||
{ |
|||
string GetKeyword() |
|||
{ |
|||
return "SINGLE_PASS"; |
|||
} |
|||
}; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cb651810696af0d4789441b1f469aa2f |
|||
timeCreated: 1477266406 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
//----------------------------------------------------------------------------- |
|||
// Single pass forward loop architecture |
|||
// It use maxed list of lights of the scene - use just as proof of concept - do not used in regular game |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
|
|||
/* |
|||
float SampleShadow(int shadowIndex) |
|||
{ |
|||
PunctualShadowData shadowData = _PunctualShadowList[shadowIndex]; |
|||
getShadowTextureSpaceCoordinate(shadowData.marix); |
|||
shadowData |
|||
return UNITY_SAMPLE_SHADOW(_ShadowMapAtlas, ...); |
|||
} |
|||
*/ |
|
|||
fileFormatVersion: 2 |
|||
guid: 16878a2c634119a4ab27e2c83a09b20e |
|||
timeCreated: 1477266410 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
// Users can use SHADERPASS_FORWARD here to dinstinguish behavior between deferred and forward. |
|||
|
|||
StructuredBuffer<PunctualLightData> _PunctualLightList; |
|||
int _PunctualLightCount; |
|||
|
|||
StructuredBuffer<EnvLightData> _EnvLightList; |
|||
int _EnvLightCount; |
|||
|
|||
// Use texture array for reflection |
|||
UNITY_DECLARE_TEXCUBEARRAY(_EnvTextures); |
|||
|
|||
/* |
|||
// Use texture atlas for shadow map |
|||
StructuredBuffer<PunctualShadowData> _PunctualShadowList; |
|||
UNITY_DECLARE_SHADOWMAP(_ShadowMapAtlas); |
|||
*/ |
|||
|
|||
// bakeDiffuseLighting is part of the prototype so a user is able to implement a "base pass" with GI and multipass direct light (aka old unity rendering path) |
|||
void LightingLoop( float3 V, float3 positionWS, PreLightData prelightData, BSDFData bsdfData, float3 bakeDiffuseLighting, |
|||
out float4 diffuseLighting, |
|||
out float4 specularLighting) |
|||
{ |
|||
diffuseLighting = float4(0.0, 0.0, 0.0, 0.0); |
|||
specularLighting = float4(0.0, 0.0, 0.0, 0.0); |
|||
|
|||
for (int i = 0; i < _PunctualLightCount; ++i) |
|||
{ |
|||
float4 localDiffuseLighting; |
|||
float4 localSpecularLighting; |
|||
EvaluateBSDF_Punctual(V, positionWS, prelightData, _PunctualLightList[i], bsdfData, localDiffuseLighting, localSpecularLighting); |
|||
diffuseLighting += localDiffuseLighting; |
|||
specularLighting += localSpecularLighting; |
|||
} |
|||
|
|||
/* |
|||
for (int i = 0; i < 4; ++i) |
|||
{ |
|||
float4 localDiffuseLighting; |
|||
float4 localSpecularLighting; |
|||
EvaluateBSDF_Area(V, positionWS, areaLightData[i], bsdfData, localDiffuseLighting, localSpecularLighting); |
|||
diffuseLighting += localDiffuseLighting; |
|||
specularLighting += localSpecularLighting; |
|||
} |
|||
*/ |
|||
|
|||
float4 iblDiffuseLighting = float4(0.0, 0.0, 0.0, 0.0); |
|||
float4 iblSpecularLighting = float4(0.0, 0.0, 0.0, 0.0); |
|||
|
|||
for (int j = 0; j < _EnvLightCount; ++j) |
|||
{ |
|||
float4 localDiffuseLighting; |
|||
float4 localSpecularLighting; |
|||
EvaluateBSDF_Env(V, positionWS, prelightData, _EnvLightList[j], bsdfData, UNITY_PASS_TEXCUBEARRAY(_EnvTextures), localDiffuseLighting, localSpecularLighting); |
|||
iblDiffuseLighting.rgb = lerp(iblDiffuseLighting.rgb, localDiffuseLighting.rgb, localDiffuseLighting.a); // Should be remove by the compiler if it is smart as all is constant 0 |
|||
iblSpecularLighting.rgb = lerp(iblSpecularLighting.rgb, localSpecularLighting.rgb, localSpecularLighting.a); |
|||
} |
|||
|
|||
diffuseLighting += iblDiffuseLighting; |
|||
diffuseLighting.rgb += bakeDiffuseLighting; |
|||
|
|||
specularLighting += iblSpecularLighting; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: beb12ac3f2147dd499eee23eab1aea89 |
|||
timeCreated: 1477266410 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: df85c88f855185249aad13cf37a4952a |
|||
folderAsset: yes |
|||
timeCreated: 1476653183 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8f27521401d2efc4fb35f246e296940e |
|||
folderAsset: yes |
|||
timeCreated: 1476653182 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue