浏览代码
simplify shader to hell and ability to have one material per scene or per object
/batch_rendering
simplify shader to hell and ability to have one material per scene or per object
/batch_rendering
Arnaud Carre
8 年前
当前提交
a98e1734
共有 8 个文件被更改,包括 259 次插入 和 132 次删除
-
24Assets/BasicRenderBatching/BasicBatching.unity
-
134Assets/BasicRenderBatching/BasicRenderBatchingShader.shader
-
27Assets/BasicRenderBatching/Scripts/PopulateScene.cs
-
2ProjectSettings/ProjectSettings.asset
-
74Assets/BasicRenderBatching/BasicMat_ColorsFlat.mat
-
8Assets/BasicRenderBatching/BasicMat_ColorsFlat.mat.meta
-
110Assets/BasicRenderBatching/Scripts/MiniProfiler.cs
-
12Assets/BasicRenderBatching/Scripts/MiniProfiler.cs.meta
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: BasicMat_ColorsFlat |
|||
m_Shader: {fileID: 4800000, guid: 88dc421b065e08e4caeb32d940c57312, type: 3} |
|||
m_ShaderKeywords: _EMISSION |
|||
m_LightmapFlags: 1 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 2, y: 2} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 2, y: 2} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0.474 |
|||
- _GlossyReflections: 1 |
|||
- _Metallic: 0.194 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.97794116, g: 0, b: 0, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4c676c131a81b634988506c3023ea7a5 |
|||
timeCreated: 1481127206 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
using UnityEngine.Profiling; |
|||
|
|||
public class MiniProfiler : MonoBehaviour { |
|||
|
|||
public bool m_Enable = false; |
|||
|
|||
private int frameCount = 0; |
|||
private const int kAverageFrameCount = 64; |
|||
private float m_AccDeltaTime; |
|||
private float m_AvgDeltaTime; |
|||
|
|||
internal class RecorderEntry |
|||
{ |
|||
public string name; |
|||
public float time; |
|||
public int count; |
|||
public float avgTime; |
|||
public float avgCount; |
|||
public float accTime; |
|||
public int accCount; |
|||
public Recorder recorder; |
|||
}; |
|||
|
|||
RecorderEntry[] recordersList = |
|||
{ |
|||
new RecorderEntry() { name="Camera.Render" }, |
|||
new RecorderEntry() { name="GUI.Repaint" }, |
|||
new RecorderEntry() { name="PrepareValues" }, |
|||
new RecorderEntry() { name="ApplyGpuProgram" }, |
|||
new RecorderEntry() { name="WriteParameters" }, |
|||
new RecorderEntry() { name="FlushBuffers" }, |
|||
new RecorderEntry() { name="BindBuffers" }, |
|||
new RecorderEntry() { name="Gfx.ProcessCommand" }, |
|||
}; |
|||
|
|||
void Awake() |
|||
{ |
|||
for (int i=0;i<recordersList.Length;i++) |
|||
{ |
|||
var sampler = Sampler.Get(recordersList[i].name); |
|||
if ( sampler != null ) |
|||
{ |
|||
recordersList[i].recorder = sampler.GetRecorder(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void Update() |
|||
{ |
|||
|
|||
if (m_Enable) |
|||
{ |
|||
|
|||
// get timing & update average accumulators
|
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
recordersList[i].time = recordersList[i].recorder.elapsedNanoseconds / 1000000.0f; |
|||
recordersList[i].count = recordersList[i].recorder.sampleBlockCount; |
|||
recordersList[i].accTime += recordersList[i].time; |
|||
recordersList[i].accCount += recordersList[i].count; |
|||
} |
|||
|
|||
m_AccDeltaTime += Time.deltaTime; |
|||
|
|||
frameCount++; |
|||
// time to time, update average values & reset accumulators
|
|||
if (frameCount >= kAverageFrameCount) |
|||
{ |
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
recordersList[i].avgTime = recordersList[i].accTime * (1.0f / kAverageFrameCount); |
|||
recordersList[i].avgCount = recordersList[i].accCount * (1.0f / kAverageFrameCount); |
|||
recordersList[i].accTime = 0.0f; |
|||
recordersList[i].accCount = 0; |
|||
|
|||
} |
|||
|
|||
m_AvgDeltaTime = m_AccDeltaTime / kAverageFrameCount; |
|||
m_AccDeltaTime = 0.0f; |
|||
frameCount = 0; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
|
|||
if (m_Enable) |
|||
{ |
|||
GUI.color = new Color(1, 1, 1, .75f); |
|||
float w = 500, h = 204; |
|||
|
|||
GUILayout.BeginArea(new Rect(10, 150, w, h), "Mini Profiler", GUI.skin.window); |
|||
string sLabel = System.String.Format("<b>{0:F2} FPS ({1:F2}ms)</b>\n", 1.0f / m_AvgDeltaTime, Time.deltaTime * 1000.0f); |
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
sLabel += string.Format("{0:F2}ms (*{1:F2})\t({2:F2}ms *{3:F2})\t<b>{4}</b>\n", recordersList[i].avgTime, recordersList[i].avgCount, recordersList[i].time, recordersList[i].count, recordersList[i].name); |
|||
} |
|||
GUILayout.Label(sLabel); |
|||
GUILayout.EndArea(); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dd3f3fa5c40a66f44a9444b42845b28f |
|||
timeCreated: 1481192301 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue