浏览代码

Addresssed UI issues.

/Add-support-for-light-specular-color-tint
Felipe Lira 7 年前
当前提交
a7ea582f
共有 12 个文件被更改,包括 31 次插入109 次删除
  1. 28
      ScriptableRenderPipeline/LightweightPipeline/Editor/LegacyShadersToLightweightPipelineUpgrader.cs
  2. 4
      ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightPipelineUpgraders.cs
  3. 8
      ScriptableRenderPipeline/LightweightPipeline/Editor/StandardToLightweightMaterialUpgrader.cs
  4. 7
      ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs
  5. 12
      ScriptableRenderPipeline/LightweightPipeline/LightweightPipelineAsset.cs
  6. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightBlit.shader
  7. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightCopyDepth.shader
  8. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader
  9. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardSimpleLighting.shader
  10. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightUnlit.shader
  11. 58
      ScriptableRenderPipeline/LightweightPipeline/Editor/GenerateTextures.cs
  12. 13
      ScriptableRenderPipeline/LightweightPipeline/Editor/GenerateTextures.cs.meta

28
ScriptableRenderPipeline/LightweightPipeline/Editor/LegacyShadersToLightweightPipelineUpgrader.cs


{
public class LegacyShadersToLightweightPipelineUpgrader
{
[MenuItem("RenderPipeline/LightweightPipeline/Material Upgraders/Upgrade Legacy Materials to LightweightPipeline - Project", false, 3)]
public static void UpgradeMaterialsToLDProject()
{
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
GetUpgraders(ref materialUpgraders);
//[MenuItem("RenderPipeline/Lightweight Pipeline/Material Upgraders/Upgrade Legacy Materials to LightweightPipeline - Project", false, 3)]
//public static void UpgradeMaterialsToLDProject()
//{
// List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
// GetUpgraders(ref materialUpgraders);
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
}
// MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
//}
[MenuItem("RenderPipeline/LightweightPipeline/Material Upgraders/Upgrade Legacy Materials to LightweightPipeline - Selection", false, 4)]
public static void UpgradeMaterialsToLDSelection()
{
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
GetUpgraders(ref materialUpgraders);
//[MenuItem("RenderPipeline/Lightweight Pipeline/Material Upgraders/Upgrade Legacy Materials to LightweightPipeline - Selection", false, 4)]
//public static void UpgradeMaterialsToLDSelection()
//{
// List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
// GetUpgraders(ref materialUpgraders);
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to Lightweight Materials");
}
// MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to Lightweight Materials");
//}
private static void GetUpgraders(ref List<MaterialUpgrader> materialUpgraders)
{

4
ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightPipelineUpgraders.cs


{
public StandardUpgrader(string oldShaderName)
{
RenameShader(oldShaderName, LightweightPipelineAsset.m_PBSShaderPath);
RenameShader(oldShaderName, LightweightPipelineAsset.m_StandardShaderPath);
}
}

{
RenameShader(oldShaderName, LightweightPipelineAsset.m_PBSShaderPath);
RenameShader(oldShaderName, LightweightPipelineAsset.m_StandardShaderPath);
SetFloat("_Shininess", 1.0f);
}
}

8
ScriptableRenderPipeline/LightweightPipeline/Editor/StandardToLightweightMaterialUpgrader.cs


{
public class StandardToLightweightMaterialUpgrader
{
[MenuItem("RenderPipeline/LightweightPipeline/Material Upgraders/Upgrade Standard Materials to Lightweight Mobile - Project Folder", false, 1)]
[MenuItem("RenderPipeline/Lightweight Pipeline/Material Upgraders/Upgrade Project Materials", false, 1)]
MaterialUpgrader.UpgradeProjectFolder(upgraders, "Upgrade to LD Materials");
MaterialUpgrader.UpgradeProjectFolder(upgraders, "Upgrade to Lightweight Pipeline Materials");
[MenuItem("RenderPipeline/LightweightPipeline/Material Upgraders/Upgrade Standard Materials to Lightweight Mobile - Selection", false, 2)]
[MenuItem("RenderPipeline/Lightweight Pipeline/Material Upgraders/Upgrade Selected Materials", false, 2)]
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to LD Materials");
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to Lightweight Pipeline Materials");
}
private static void GetUpgraders(ref List<MaterialUpgrader> upgraders)

7
ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


Vector4 dir = light.localToWorld.GetColumn(2);
lightSpotDir = new Vector4(-dir.x, -dir.y, -dir.z, 0.0f);
// Spot light attenuation with a smooth angle border is computed as follows:
// ( dot(spotDir, lightDir) - cosOuterAngle ) / smoothAngleRange
// we can rewrite that as
// invSmoothAngleRange = 1.0 / smoothAngleRange
// dot(spotDir, lightDir) * invSmoothAngleRange + (-cosOuterAngle * invSmoothAngleRange)
// and this will fit into a single MAD instruction
// Spot Attenuation with a linear falloff can be defined as
// (SdotL - cosOuterAngle) / (cosInnerAngle - cosOuterAngle)
// This can be rewritten as

12
ScriptableRenderPipeline/LightweightPipeline/LightweightPipelineAsset.cs


public class LightweightPipelineAsset : RenderPipelineAsset
{
public static readonly string m_SimpleLightShaderPath = "ScriptableRenderPipeline/LightweightPipeline/Standard (Simple Lighting)";
public static readonly string m_PBSShaderPath = "ScriptableRenderPipeline/LightweightPipeline/Standard (Simple Lighting)";
public static readonly string m_BlitShaderPath = "Hidden/ScriptableRenderPipeline/LightweightPipeline/Blit";
public static readonly string m_CopyDephPath = "Hidden/ScriptableRenderPipeline/LightweightPipeline/CopyDepth";
private static readonly string m_PipelineFolder = "Assets/ScriptableRenderPipeline/LightweightPipeline";
public static readonly string m_SimpleLightShaderPath = "LightweightPipeline/Standard (Simple Lighting)";
public static readonly string m_StandardShaderPath = "LightweightPipeline/Standard (Physically Based)";
public static readonly string m_BlitShaderPath = "Hidden/LightweightPipeline/Blit";
public static readonly string m_CopyDephPath = "Hidden/LightweightPipeline/CopyDepth";
private static readonly string m_PipelineFolder = "Assets/LightweightPipeline";
private static readonly string m_AssetName = "LightweightPipelineAsset.asset";
[SerializeField] private int m_MaxAdditionalPixelLights = 1;

[SerializeField] private Shader m_DefaultShader;
#if UNITY_EDITOR
[UnityEditor.MenuItem("RenderPipeline/LightweightPipeline/Create Pipeline Asset", false, 15)]
[UnityEditor.MenuItem("RenderPipeline/Lightweight Pipeline/Create Pipeline Asset", false, 15)]
static void CreateLightweightPipeline()
{
var instance = ScriptableObject.CreateInstance<LightweightPipelineAsset>();

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightBlit.shader


Shader "Hidden/ScriptableRenderPipeline/LightweightPipeline/Blit"
Shader "Hidden/LightweightPipeline/Blit"
{
SubShader
{

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightCopyDepth.shader


Shader "Hidden/ScriptableRenderPipeline/LightweightPipeline/CopyDepth"
Shader "Hidden/LightweightPipeline/CopyDepth"
{
SubShader
{

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader


Shader "ScriptableRenderPipeline/LightweightPipeline/Standard (PBS)"
Shader "LightweightPipeline/Standard (Physically Based)"
{
Properties
{

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardSimpleLighting.shader


// Shader targeted for low end devices. Single Pass Forward Rendering. Shader Model 2
Shader "ScriptableRenderPipeline/LightweightPipeline/Standard (Simple Lighting)"
Shader "LightweightPipeline/Standard (Simple Lighting)"
{
// Keep properties of StandardSpecular shader for upgrade reasons.
Properties

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightUnlit.shader


Shader "ScriptableRenderPipeline/LightweightPipeline/Unlit"
Shader "LightweightPipeline/Unlit"
{
Properties
{

58
ScriptableRenderPipeline/LightweightPipeline/Editor/GenerateTextures.cs


using System.IO;
using UnityEngine;
using UnityEditor;
public class GenerateTextures : MonoBehaviour
{
private static readonly int kTextureSize = 1024;
private static readonly float kQuadraticFac = 25.0f;
private static readonly float kToZeroFadeStart = 0.8f * 0.8f;
private static readonly string kSavePath = "Assets/ScriptableRenderPipeline/LightweightPipeline/Textures/LightweightLightAttenuation.png";
[MenuItem("RenderPipeline/LightweightPipeline/GenerateLightFalloffTexture")]
public static void GenerateLightFalloffTexture()
{
Texture2D tex = new Texture2D(kTextureSize, 4, TextureFormat.Alpha8, false, true);
tex.wrapMode = TextureWrapMode.Clamp;
byte[] bytes = new byte[kTextureSize * 4];
for (int x = 0; x < kTextureSize; ++x)
{
float sqrRange = (float) x/(float) kTextureSize;
byte atten = LightAttenuationNormalized(sqrRange);
bytes[x] = atten;
bytes[x + kTextureSize] = atten;
bytes[x + kTextureSize * 2] = atten;
bytes[x + kTextureSize * 3] = atten;
}
tex.LoadRawTextureData(bytes);
tex.Apply(false);
SaveTexture(tex);
}
public static void SaveTexture(Texture2D tex)
{
byte[] bytes = tex.EncodeToPNG();
File.WriteAllBytes(kSavePath, bytes);
}
public static byte LightAttenuationNormalized(float distSqr)
{
// 1 / 1.0 + quadAtten * distSqr attenuation function
float atten = 1.0f / (1.0f + CalculateLightQuadFac(1.0f) * distSqr);
// however the above does not falloff to zero at light range.
// Start fading from ktoZeroFadeStart to light range
float fadeMultiplier = Mathf.Clamp01((distSqr - 1.0f) / (kToZeroFadeStart - 1.0f));
atten *= fadeMultiplier;
//return atten;
return (byte)Mathf.RoundToInt(atten * (float)byte.MaxValue);
}
public static float CalculateLightQuadFac(float range)
{
return kQuadraticFac / (range * range);
}
}

13
ScriptableRenderPipeline/LightweightPipeline/Editor/GenerateTextures.cs.meta


fileFormatVersion: 2
guid: dd9e613bcee552646a17f8b54e3519de
timeCreated: 1503914974
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存