浏览代码

simplify vertex shader a bit

/batch_rendering
Arnaud Carre 8 年前
当前提交
34440083
共有 2 个文件被更改,包括 99 次插入9 次删除
  1. 72
      Assets/BasicRenderBatching/BasicBatching.unity
  2. 36
      Assets/BasicRenderBatching/BasicRenderBatchingShader.shader

72
Assets/BasicRenderBatching/BasicBatching.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18323539, g: 0.22689644, b: 0.29487598, a: 1}
m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

tileSize: 256
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &16948590
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 16948591}
- component: {fileID: 16948592}
m_Layer: 0
m_Name: Point light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &16948591
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 16948590}
m_LocalRotation: {x: 0.30016837, y: 0.23065634, z: 0.29749814, w: 0.8764653}
m_LocalPosition: {x: -0.73540246, y: 4.2341523, z: 1.2737548}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!108 &16948592
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 16948590}
m_Enabled: 1
serializedVersion: 8
m_Type: 2
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 3.6
m_Range: 19
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &431751544
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!108 &431751545
Light:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 870320112}
m_LocalRotation: {x: 0.2672005, y: -0.21772358, z: 0.060980394, w: 0.93674}
m_LocalPosition: {x: 5.91, y: 8.58, z: -18.38}
m_LocalPosition: {x: 5.12, y: 7.47, z: -16.78}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 870320112}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dd3f3fa5c40a66f44a9444b42845b28f, type: 3}
m_Name:

36
Assets/BasicRenderBatching/BasicRenderBatchingShader.shader


// Upgrade NOTE: replaced 'glstate_matrix_invtrans_modelview0' with 'UNITY_MATRIX_IT_MV'
// Upgrade NOTE: replaced 'glstate_matrix_modelview0' with 'UNITY_MATRIX_MV'
// Upgrade NOTE: replaced 'glstate_matrix_mvp' with 'UNITY_MATRIX_MVP'
// Example shader for a scriptable render loop that calculates multiple lights
// in a single forward-rendered shading pass. Uses same PBR shading model as the
// Standard shader.

// Global ambient/SH probe, similar to unity_SH* built-in variables.
float4 globalSH[7];
CBUFFER_END
/*
CBUFFER_START(UnityPerDraw) // 352 bytes, uploaded per object (even if just position change position )
float4x4 UNITY_MATRIX_MVP;
float4x4 UNITY_MATRIX_MV;
float4x4 UNITY_MATRIX_IT_MV;
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
CBUFFER_END
*/
// Compute attenuation & illumination from one light
half3 EvaluateOneLight(int idx, float3 positionWS, half3 normalWS, float3 vAlbedo)

}
// Vertex shader
struct v2f
struct v2f // vertex to fragment
float2 uv : TEXCOORD0;
// float2 uv : TEXCOORD0;
v2f vert(appdata_base v)
struct s2v // stream to vertex
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 texcoord : TEXCOORD0;
};
v2f vert(s2v v)
o.hpos = UnityObjectToClipPos(v.vertex);
o.hpos = mul(UNITY_MATRIX_MVP, v.vertex);
o.normalWS = UnityObjectToWorldNormal(v.normal);
o.normalWS = normalize(mul((float3x3)unity_WorldToObject, v.normal));
return o;
}

正在加载...
取消
保存