浏览代码

fptl: proper linear rendering

/main
vlad-andreev 8 年前
当前提交
326ac6a3
共有 3 个文件被更改,包括 55 次插入19 次删除
  1. 5
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 15
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  3. 54
      Assets/ScriptableRenderLoop/fptl/FinalPass.shader

5
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


m_skyboxHelper = new SkyboxHelper();
m_skyboxHelper.CreateMesh();
m_blitMaterial = new Material(Shader.Find("Hidden/BlitCopy"));
m_blitMaterial = new Material(Shader.Find("Hidden/FinalPass"));
}
void OnDisable()

DirectionalLight l = new DirectionalLight();
float range = light.range;
Vector3 lightPos = lightToWorld.GetColumn(3);
Vector3 lightDir = lightToWorld.GetColumn(2); // Z axis in world space
// represents a left hand coordinate system in world space

15
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
//#include "UnityCG.cginc"
//#include "UnityPBSLighting.cginc"
//#include "UnityDeferredLibrary.cginc"
#include "..\common\ShaderBase.h"
#include "LightDefinitions.cs"

const int offs = tileIDX.y*nrTilesX+tileIDX.x;
#if defined(UNITY_COLORSPACE_GAMMA)
#else
return float4(pow(c,1/2.2),1.0);
#endif
}
struct StandardData

light.dir.xyz = mul((float3x3) g_mViewToWorld, -lightData.vLaxisZ).xyz;
ints += UNITY_BRDF_PBS(data.diffuseColor, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, vWSpaceVDir, light, ind);
// ints += LambertTerm(data.normalWorld, lightDir) * light.vCol;
}
// we need this outer loop for when we cannot assume a wavefront is 64 wide

54
Assets/ScriptableRenderLoop/fptl/FinalPass.shader


// Final compositing pass, just does gamma conversion for now.
Shader "Hidden/FinalPass"
{
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
#include "UnityCG.cginc"
sampler2D _MainTex;
uniform float4 _MainTex_ST;
struct appdata_t {
float4 vertex : 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;
}
fixed4 frag (v2f i) : SV_Target
{
float4 c = tex2D(_MainTex, i.texcoord);
#if defined(UNITY_COLORSPACE_GAMMA)
return c;
#else
return float4(pow(c.xyz,1/2.2), c.w);
#endif
}
ENDCG
}
}
Fallback Off
}
正在加载...
取消
保存