浏览代码
separating out some utility functions which make sense for conventional fwd as well as tiled.
separating out some utility functions which make sense for conventional fwd as well as tiled.
separating out some utility functions which make sense for conventional fwd as well as tiled./main
mmikk
8 年前
当前提交
56b1c9d5
共有 2 个文件被更改,包括 89 次插入 和 79 次删除
-
80Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl
-
88Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl
|
|||
#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