浏览代码
Merge remote-tracking branch 'origin/master'
Merge remote-tracking branch 'origin/master'
# Conflicts: # Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs # Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader # Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightingForward.hlsl # Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit.hlsl # Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl/main
sebastienlagarde
8 年前
当前提交
feca166f
共有 70 个文件被更改,包括 6058 次插入 和 6037 次删除
-
29Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
-
47Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
-
239Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs
-
52Assets/ScriptableRenderLoop/AdditionalLightData.cs
-
388Assets/ScriptableRenderLoop/ForwardRenderLoop/ForwardRenderLoop.cs
-
878Assets/ScriptableRenderLoop/ForwardRenderLoop/Shaders/vr_lighting.cginc
-
1001Assets/ScriptableRenderLoop/ForwardRenderLoop/Shaders/vr_standard.shader
-
332Assets/ScriptableRenderLoop/ForwardRenderLoop/Shaders/vr_utils.cginc
-
995Assets/ScriptableRenderLoop/ForwardRenderLoop/ValveMenuTools.cs
-
987Assets/ScriptableRenderLoop/ForwardRenderLoop/ValveShaderGUI.cs
-
37Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
-
16Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader
-
16Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLit.shader
-
14Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitTemplate.hlsl
-
598Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitUI.cs
-
66Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Lighting.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightingDeferred.shader
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightingForward.hlsl
-
34Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lit.shader
-
10Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LitTemplate.hlsl
-
723Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LitUI.cs
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/BuiltinData.cs
-
16Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/BuiltinData.cs.hlsl
-
66Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit.cs.hlsl
-
138Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit.hlsl
-
72Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl
-
30Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/PostProcess/FinalPass.shader
-
1Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs
-
16Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl
-
16Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Unlit.shader
-
689Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
-
20Assets/ScriptableRenderLoop/ScriptableRenderLoop.cs
-
98Assets/ScriptableRenderLoop/ScriptableRenderLoopPicker.cs
-
8Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl
-
18Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
-
16Assets/ScriptableRenderLoop/ShaderLibrary/Color.hlsl
-
46Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
6Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
2Assets/ScriptableRenderLoop/ShaderLibrary/Debug.hlsl
-
2Assets/ScriptableRenderLoop/ShaderLibrary/Filtering.hlsl
-
600Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
-
8Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
-
4Assets/ScriptableRenderLoop/ShaderLibrary/QuaternionMath.hlsl
-
16Assets/ScriptableRenderLoop/common/ShaderBase.h
-
445Assets/ScriptableRenderLoop/common/SkyboxHelper.cs
-
513Assets/ScriptableRenderLoop/common/TextureCache.cs
-
28Assets/ScriptableRenderLoop/common/TextureSettings.cs
-
71Assets/ScriptableRenderLoop/fptl/ClusteredUtils.h
-
74Assets/ScriptableRenderLoop/fptl/FinalPass.shader
-
992Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
-
108Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
-
106Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
-
44Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
-
138Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl
-
347Assets/ScriptableRenderLoop/fptl/LightingTemplate.hlsl
-
170Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl
-
190Assets/ScriptableRenderLoop/fptl/StandardTest.shader
-
14Assets/ScriptableRenderLoop/fptl/TiledLightingTemplate.hlsl
-
136Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl
-
14Assets/ScriptableRenderLoop/fptl/TiledReflectionTemplate.hlsl
-
130Assets/ScriptableRenderLoop/fptl/UnityStandardForwardNew.cginc
-
2Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute
-
97Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute
-
17Assets/ShaderGenerator/CSharpToHLSL.cs
-
2Assets/ShaderGenerator/ShaderGeneratorMenu.cs
-
1Assets/ShaderGenerator/ShaderTypeGeneration.cs
-
88Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl
|
|||
using System; |
|||
using System; |
|||
//@TODO: We should continously move these values
|
|||
// into the engine when we can see them being generally useful
|
|||
[RequireComponent(typeof(Light))] |
|||
public class AdditionalLightData : MonoBehaviour |
|||
{ |
|||
public const int defaultShadowResolution = 512; |
|||
//@TODO: We should continously move these values
|
|||
// into the engine when we can see them being generally useful
|
|||
[RequireComponent(typeof(Light))] |
|||
public class AdditionalLightData : MonoBehaviour |
|||
{ |
|||
public const int defaultShadowResolution = 512; |
|||
public int shadowResolution = defaultShadowResolution; |
|||
public int shadowResolution = defaultShadowResolution; |
|||
[RangeAttribute(0.0F, 100.0F)] |
|||
public float innerSpotPercent = 0.0F; |
|||
[RangeAttribute(0.0F, 100.0F)] |
|||
public float innerSpotPercent = 0.0F; |
|||
public static float GetInnerSpotPercent01(AdditionalLightData lightData) |
|||
{ |
|||
if (lightData != null) |
|||
return Mathf.Clamp( lightData.innerSpotPercent, 0.0f, 100.0f ) / 100.0f; |
|||
else |
|||
return 0.0F; |
|||
} |
|||
public static float GetInnerSpotPercent01(AdditionalLightData lightData) |
|||
{ |
|||
if (lightData != null) |
|||
return Mathf.Clamp(lightData.innerSpotPercent, 0.0f, 100.0f) / 100.0f; |
|||
else |
|||
return 0.0F; |
|||
} |
|||
public static int GetShadowResolution(AdditionalLightData lightData) |
|||
{ |
|||
if (lightData != null) |
|||
return lightData.shadowResolution; |
|||
else |
|||
return defaultShadowResolution; |
|||
} |
|||
} |
|||
public static int GetShadowResolution(AdditionalLightData lightData) |
|||
{ |
|||
if (lightData != null) |
|||
return lightData.shadowResolution; |
|||
else |
|||
return defaultShadowResolution; |
|||
} |
|||
} |
|||
|
|||
|
1001
Assets/ScriptableRenderLoop/ForwardRenderLoop/Shaders/vr_standard.shader
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
995
Assets/ScriptableRenderLoop/ForwardRenderLoop/ValveMenuTools.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
public abstract class ScriptableRenderLoop : ScriptableObject |
|||
{ |
|||
public abstract void Render(Camera[] cameras, RenderLoop renderLoop); |
|||
public virtual void Rebuild() { } |
|||
public abstract class ScriptableRenderLoop : ScriptableObject |
|||
{ |
|||
public abstract void Render(Camera[] cameras, RenderLoop renderLoop); |
|||
public virtual void Rebuild() {} |
|||
#if UNITY_EDITOR
|
|||
public virtual UnityEditor.SupportedRenderingFeatures GetSupportedRenderingFeatures() { return new UnityEditor.SupportedRenderingFeatures(); } |
|||
#endif
|
|||
} |
|||
} |
|||
#if UNITY_EDITOR
|
|||
public virtual UnityEditor.SupportedRenderingFeatures GetSupportedRenderingFeatures() { return new UnityEditor.SupportedRenderingFeatures(); } |
|||
#endif
|
|||
} |
|||
} |
|
|||
// Final compositing pass, just does gamma conversion for now. |
|||
// Final compositing pass, just does gamma conversion for now. |
|||
Shader "Hidden/FinalPass" |
|||
Shader "Hidden/FinalPass" |
|||
Properties { _MainTex ("Texture", any) = "" {} } |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always Cull Off ZWrite Off |
|||
Properties { _MainTex ("Texture", any) = "" {} } |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always Cull Off ZWrite Off |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma target 2.0 |
|||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma target 2.0 |
|||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA |
|||
#include "UnityCG.cginc" |
|||
#include "UnityCG.cginc" |
|||
sampler2D _MainTex; |
|||
uniform float4 _MainTex_ST; |
|||
sampler2D _MainTex; |
|||
uniform float4 _MainTex_ST; |
|||
struct appdata_t { |
|||
float4 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
struct appdata_t { |
|||
float4 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
v2f vert (appdata_t v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex); |
|||
return o; |
|||
} |
|||
v2f vert (appdata_t v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex); |
|||
return o; |
|||
} |
|||
fixed4 frag (v2f i) : SV_Target |
|||
{ |
|||
return tex2D(_MainTex, i.texcoord); |
|||
} |
|||
ENDCG |
|||
fixed4 frag (v2f i) : SV_Target |
|||
{ |
|||
return tex2D(_MainTex, i.texcoord); |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
992
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
Shader "Experim/StdShader" |
|||
{ |
|||
Properties |
|||
{ |
|||
_Color("Color", Color) = (1,1,1,1) |
|||
_MainTex("Albedo", 2D) = "white" {} |
|||
|
|||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
Properties |
|||
{ |
|||
_Color("Color", Color) = (1,1,1,1) |
|||
_MainTex("Albedo", 2D) = "white" {} |
|||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0 |
|||
[Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0 |
|||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 |
|||
_MetallicGlossMap("Metallic", 2D) = "white" {} |
|||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0 |
|||
[Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0 |
|||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 |
|||
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0 |
|||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 |
|||
_MetallicGlossMap("Metallic", 2D) = "white" {} |
|||
_BumpScale("Scale", Float) = 1.0 |
|||
_BumpMap("Normal Map", 2D) = "bump" {} |
|||
|
|||
_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 |
|||
_ParallaxMap ("Height Map", 2D) = "black" {} |
|||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 |
|||
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0 |
|||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 |
|||
_OcclusionMap("Occlusion", 2D) = "white" {} |
|||
_BumpScale("Scale", Float) = 1.0 |
|||
_BumpMap("Normal Map", 2D) = "bump" {} |
|||
_EmissionColor("Color", Color) = (0,0,0) |
|||
_EmissionMap("Emission", 2D) = "white" {} |
|||
|
|||
_DetailMask("Detail Mask", 2D) = "white" {} |
|||
_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 |
|||
_ParallaxMap ("Height Map", 2D) = "black" {} |
|||
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} |
|||
_DetailNormalMapScale("Scale", Float) = 1.0 |
|||
_DetailNormalMap("Normal Map", 2D) = "bump" {} |
|||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 |
|||
_OcclusionMap("Occlusion", 2D) = "white" {} |
|||
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 |
|||
_EmissionColor("Color", Color) = (0,0,0) |
|||
_EmissionMap("Emission", 2D) = "white" {} |
|||
_DetailMask("Detail Mask", 2D) = "white" {} |
|||
// Blending state |
|||
[HideInInspector] _Mode ("__mode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
} |
|||
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} |
|||
_DetailNormalMapScale("Scale", Float) = 1.0 |
|||
_DetailNormalMap("Normal Map", 2D) = "bump" {} |
|||
CGINCLUDE |
|||
#define UNITY_SETUP_BRDF_INPUT MetallicSetup |
|||
ENDCG |
|||
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 |
|||
SubShader |
|||
{ |
|||
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" } |
|||
LOD 300 |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Forward pass |
|||
Pass |
|||
{ |
|||
Name "FORWARD" |
|||
Tags { "LightMode" = "ForwardSinglePass" } |
|||
// Blending state |
|||
[HideInInspector] _Mode ("__mode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
} |
|||
Blend [_SrcBlend] [_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
CGINCLUDE |
|||
#define UNITY_SETUP_BRDF_INPUT MetallicSetup |
|||
ENDCG |
|||
CGPROGRAM |
|||
#pragma target 5.0 |
|||
SubShader |
|||
{ |
|||
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" } |
|||
LOD 300 |
|||
// ------------------------------------- |
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICGLOSSMAP |
|||
#pragma shader_feature ___ _DETAIL_MULX2 |
|||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF |
|||
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF |
|||
#pragma shader_feature _PARALLAXMAP |
|||
// ------------------------------------------------------------------ |
|||
// Forward pass |
|||
Pass |
|||
{ |
|||
Name "FORWARD" |
|||
Tags { "LightMode" = "ForwardSinglePass" } |
|||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON |
|||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE |
|||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON |
|||
#pragma multi_compile_fog |
|||
Blend [_SrcBlend] [_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
#pragma vertex vertForward |
|||
#pragma fragment fragForward |
|||
CGPROGRAM |
|||
#pragma target 5.0 |
|||
#include "UnityStandardForwardNew.cginc" |
|||
// ------------------------------------- |
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICGLOSSMAP |
|||
#pragma shader_feature ___ _DETAIL_MULX2 |
|||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF |
|||
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF |
|||
#pragma shader_feature _PARALLAXMAP |
|||
ENDCG |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Shadow rendering pass |
|||
Pass { |
|||
Name "ShadowCaster" |
|||
Tags { "LightMode" = "ShadowCaster" } |
|||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON |
|||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE |
|||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON |
|||
#pragma multi_compile_fog |
|||
|
|||
#pragma vertex vertForward |
|||
#pragma fragment fragForward |
|||
|
|||
#include "UnityStandardForwardNew.cginc" |
|||
|
|||
|
|||
ENDCG |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Shadow rendering pass |
|||
Pass { |
|||
Name "ShadowCaster" |
|||
Tags { "LightMode" = "ShadowCaster" } |
|||
ZWrite On ZTest LEqual |
|||
ZWrite On ZTest LEqual |
|||
CGPROGRAM |
|||
#pragma target 5.0 |
|||
CGPROGRAM |
|||
#pragma target 5.0 |
|||
// ------------------------------------- |
|||
// ------------------------------------- |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON |
|||
#pragma shader_feature _METALLICGLOSSMAP |
|||
#pragma multi_compile_shadowcaster |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON |
|||
#pragma shader_feature _METALLICGLOSSMAP |
|||
#pragma multi_compile_shadowcaster |
|||
|
|||
#pragma vertex vertShadowCaster |
|||
#pragma fragment fragShadowCaster |
|||
#pragma vertex vertShadowCaster |
|||
#pragma fragment fragShadowCaster |
|||
#include "UnityStandardShadow.cginc" |
|||
#include "UnityStandardShadow.cginc" |
|||
ENDCG |
|||
} |
|||
// ------------------------------------------------------------------ |
|||
// Deferred pass |
|||
ENDCG |
|||
} |
|||
// ------------------------------------------------------------------ |
|||
// Deferred pass |
|||
|
|||
} |
|||
} |
|||
FallBack "VertexLit" |
|||
CustomEditor "StandardShaderGUI" |
|||
FallBack "VertexLit" |
|||
CustomEditor "StandardShaderGUI" |
|||
} |
|
|||
#ifndef __LIGHTINGUTILS_H__ |
|||
#define __LIGHTINGUTILS_H__ |
|||
|
|||
|
|||
#include "..\common\ShaderBase.h" |
|||
#include "LightDefinitions.cs.hlsl" |
|||
|
|||
|
|||
uniform float4x4 g_mViewToWorld; |
|||
uniform float4x4 g_mWorldToView; // used for reflection only |
|||
uniform float4x4 g_mScrProjection; |
|||
uniform float4x4 g_mInvScrProjection; |
|||
|
|||
|
|||
uniform uint g_widthRT; |
|||
uniform uint g_heightRT; |
|||
|
|||
|
|||
float3 GetViewPosFromLinDepth(float2 v2ScrPos, float fLinDepth) |
|||
{ |
|||
float fSx = g_mScrProjection[0].x; |
|||
//float fCx = g_mScrProjection[2].x; |
|||
float fCx = g_mScrProjection[0].z; |
|||
float fSy = g_mScrProjection[1].y; |
|||
//float fCy = g_mScrProjection[2].y; |
|||
float fCy = g_mScrProjection[1].z; |
|||
|
|||
#ifdef LEFT_HAND_COORDINATES |
|||
return fLinDepth*float3( ((v2ScrPos.x-fCx)/fSx), ((v2ScrPos.y-fCy)/fSy), 1.0 ); |
|||
#else |
|||
return fLinDepth*float3( -((v2ScrPos.x+fCx)/fSx), -((v2ScrPos.y+fCy)/fSy), 1.0 ); |
|||
#endif |
|||
} |
|||
|
|||
float GetLinearZFromSVPosW(float posW) |
|||
{ |
|||
#ifdef LEFT_HAND_COORDINATES |
|||
float linZ = posW; |
|||
#else |
|||
float linZ = -posW; |
|||
#endif |
|||
|
|||
return linZ; |
|||
} |
|||
|
|||
float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far |
|||
{ |
|||
float3 vP = float3(0.0f,0.0f,zDptBufSpace); |
|||
float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0)); |
|||
return v4Pres.z / v4Pres.w; |
|||
} |
|||
|
|||
|
|||
|
|||
float3 OverlayHeatMap(uint numLights, float3 c) |
|||
{ |
|||
///////////////////////////////////////////////////////////////////// |
|||
// |
|||
const float4 kRadarColors[12] = |
|||
{ |
|||
float4(0.0,0.0,0.0,0.0), // black |
|||
float4(0.0,0.0,0.6,0.5), // dark blue |
|||
float4(0.0,0.0,0.9,0.5), // blue |
|||
float4(0.0,0.6,0.9,0.5), // light blue |
|||
float4(0.0,0.9,0.9,0.5), // cyan |
|||
float4(0.0,0.9,0.6,0.5), // blueish green |
|||
float4(0.0,0.9,0.0,0.5), // green |
|||
float4(0.6,0.9,0.0,0.5), // yellowish green |
|||
float4(0.9,0.9,0.0,0.5), // yellow |
|||
float4(0.9,0.6,0.0,0.5), // orange |
|||
float4(0.9,0.0,0.0,0.5), // red |
|||
float4(1.0,0.0,0.0,0.9) // strong red |
|||
}; |
|||
|
|||
float maxNrLightsPerTile = 31; |
|||
|
|||
|
|||
|
|||
int nColorIndex = numLights==0 ? 0 : (1 + (int) floor(10 * (log2((float)numLights) / log2(maxNrLightsPerTile))) ); |
|||
nColorIndex = nColorIndex<0 ? 0 : nColorIndex; |
|||
float4 col = nColorIndex>11 ? float4(1.0,1.0,1.0,1.0) : kRadarColors[nColorIndex]; |
|||
|
|||
return lerp(c, pow(col.xyz, 2.2), 0.3*col.w); |
|||
} |
|||
|
|||
|
|||
|
|||
#endif |
撰写
预览
正在加载...
取消
保存
Reference in new issue