浏览代码

add support file for texture cube arrays and stub in commented out cookie support for later

/main
Filip Iliescu 7 年前
当前提交
490fb1b8
共有 5 个文件被更改,包括 116 次插入12 次删除
  1. 3
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs
  2. 7
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/LightingTemplate.hlsl
  3. 22
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/UnityStandardForwardMobile.cginc
  4. 76
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ShaderBase.h
  5. 20
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ShaderBase.h.meta

3
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs


Matrix4x4 temp2 = Matrix4x4.Translate( new Vector3 (.5f, .5f, 0.0f));
m_LightMatrix[i] = temp2 * temp1 * worldToLight;
if (light.light.cookie != null)
m_LightData [i].z = m_CookieTexArray.FetchSlice (light.light.cookie);
}
}

7
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/LightingTemplate.hlsl


UNITY_DECLARE_DEPTH_TEXTURE(_CameraGBufferZ);
// UNITY_DECLARE_TEX2D(_LightTextureB0);
// sampler2D _LightTextureB0;
// UNITY_DECLARE_TEX2DARRAY(_spotCookieTextures);
// UNITY_DECLARE_ABSTRACT_CUBE_ARRAY(_pointCookieTextures);
// StructuredBuffer<DirectionalLight> g_dirLightData;
//debug
//float3 GetViewPosFromLinDepth(float2 v2ScrPos, float fLinDepth)
//{

22
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/UnityStandardForwardMobile.cginc


#include "UnityStandardConfig.cginc"
#include "UnityStandardCore.cginc"
#include "ShaderBase.h"
#define MAX_SHADOW_LIGHTS 10
#define MAX_SHADOWMAP_PER_LIGHT 6
#define MAX_DIRECTIONAL_SPLIT 4

for (int lightIndex = 0; lightIndex < gLightData.x; ++lightIndex)
{
float atten = 1;
float atten = 1;
int shadowIdx = asint(gPerLightData[lightIndex].y);
[branch]
if (shadowIdx >= 0)

}
float4 cookieColor = float4(1,1,1,1);
// float4 uvCookie = mul (gLightMatrix[lightIndex], float4(vPw,1));
// float2 cookCoord = uvCookie.xy / uvCookie.w;
// const bool bHasCookie = gPerLightData[lightIndex].z > 0;
// [branch]if(bHasCookie)
// {
// cookieColor *= UNITY_SAMPLE_TEX2DARRAY_LOD(_spotCookieTextures, float3(cookCoord, gPerLightData[lightIndex].z), 0.0);
// atten *= (-cookieColor.w>0.0);
// }
light.color.xyz = gLightColor[lightIndex].xyz * atten;
light.color.xyz = gLightColor[lightIndex].xyz*atten*cookieColor.xyz;
light.dir.xyz = -gLightDirection[lightIndex].xyz;
ints += EvalMaterial(light, ind);

float att = dot(toLight, toLight) * gLightPos[lightIndex].w;
float atten = tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
// spot attenuation -- programatic no cookie
// For debug: spot attenuation -- programatic no cookie
//const float fProjVec = -dot(vL, gLightDirection[lightIndex].xyz); // spotDir = lgtDat.lightAxisZ.xyz
//float2 cookCoord = (-lgtDat.cotan)*float2( dot(vLw, lgtDat.lightAxisX.xyz), dot(vL, lgtDat.lightAxisY.xyz) ) / fProjVec;

76
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ShaderBase.h


#ifndef __SHADERBASE_H__
#define __SHADERBASE_H__
half2 DirectionToSphericalTexCoordinate(half3 dir_in)
{
half3 dir = normalize(dir_in);
// coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis.
float recipPi = 1.0 / 3.1415926535897932384626433832795;
return half2(1.0 - 0.5 * recipPi * atan2(dir.x, -dir.z), asin(dir.y) * recipPi + 0.5);
}
#ifdef UNITY_NO_CUBEMAP_ARRAY
#define UNITY_DECLARE_ABSTRACT_CUBE_ARRAY UNITY_DECLARE_TEX2DARRAY
#define UNITY_PASS_ABSTRACT_CUBE_ARRAY UNITY_PASS_TEX2DARRAY
#define UNITY_ARGS_ABSTRACT_CUBE_ARRAY UNITY_ARGS_TEX2DARRAY
#define UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(tex, coord, lod) UNITY_SAMPLE_TEX2DARRAY_LOD(tex, float3(DirectionToSphericalTexCoordinate((coord).xyz), (coord).w), lod)
#else
#define UNITY_DECLARE_ABSTRACT_CUBE_ARRAY UNITY_DECLARE_TEXCUBEARRAY
#define UNITY_PASS_ABSTRACT_CUBE_ARRAY UNITY_PASS_TEXCUBEARRAY
#define UNITY_ARGS_ABSTRACT_CUBE_ARRAY UNITY_ARGS_TEXCUBEARRAY
#define UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(tex, coord, lod) UNITY_SAMPLE_TEXCUBEARRAY_LOD(tex,coord,lod)
#endif
// can't use UNITY_REVERSED_Z since it's not enabled in compute shaders
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
#define REVERSE_ZBUF
#endif
#ifdef SHADER_API_PSSL
#ifndef Texture2DMS
#define Texture2DMS MS_Texture2D
#endif
#ifndef SampleCmpLevelZero
#define SampleCmpLevelZero SampleCmpLOD0
#endif
#ifndef firstbithigh
#define firstbithigh FirstSetBit_Hi
#endif
#endif
#define __HLSL 1
#define public
#define unistruct cbuffer
#define hbool bool
#define _CB_REGSLOT(x) : register(x)
#define _QALIGN(x) : packoffset(c0);
float FetchDepth(Texture2D depthTexture, uint2 pixCoord)
{
float zdpth = depthTexture.Load(uint3(pixCoord.xy, 0)).x;
#ifdef REVERSE_ZBUF
zdpth = 1.0 - zdpth;
#endif
return zdpth;
}
float FetchDepthMSAA(Texture2DMS<float> depthTexture, uint2 pixCoord, uint sampleIdx)
{
float zdpth = depthTexture.Load(pixCoord.xy, sampleIdx).x;
#ifdef REVERSE_ZBUF
zdpth = 1.0 - zdpth;
#endif
return zdpth;
}
#endif

20
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ShaderBase.h.meta


fileFormatVersion: 2
guid: 29c17a8a0e3839341bef6e5f440c7dac
timeCreated: 1467917168
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存