浏览代码

GPU Instancing work on LWRP shadergraph shaders

-Fixed placement of main passes instancing setup
-Added missing stereo instancing macros
-Added missing fragment Instancing ID for future work in shadow/depth passes
/main
Andre McGrail 7 年前
当前提交
d0452097
共有 5 个文件被更改,包括 38 次插入14 次删除
  1. 2
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
  2. 14
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template
  3. 11
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template
  4. 14
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template
  5. 11
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template

2
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs


foreach (var channel in vertexRequirements.requiresMeshUVs.Distinct())
vertexDescriptionInputStruct.AppendLine("half4 {0};", channel.GetUVName());
vertexDescriptionInputStruct.AppendLine("UNITY_VERTEX_INPUT_INSTANCE_ID");
}
// -------------------------------------

14
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template


{
float2 uv : TEXCOORD0;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
// x: global clip space bias, y: normal world space bias

{
VertexOutput o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}

return o;
}
half4 ShadowPassFragment() : SV_TARGET
half4 ShadowPassFragment(VertexOutput IN) : SV_TARGET
UNITY_SETUP_INSTANCE_ID(IN);
return 0;
}

{
float2 uv : TEXCOORD0;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
VertexOutput vert(GraphVertexInput v)

UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}

return o;
}
half4 frag() : SV_TARGET
half4 frag(VertexOutput IN) : SV_TARGET
UNITY_SETUP_INSTANCE_ID(IN);
return 0;
}
ENDHLSL

11
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template


// Interpolators defined by graph
${VertexOutputStruct}
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0;

VertexDescription vd = PopulateVertexData(vdi);
v.vertex.xyz = vd.Position;
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
// Vertex shader outputs defined by graph
${VertexShaderOutputs}

14
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template


{
float2 uv : TEXCOORD0;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
// x: global clip space bias, y: normal world space bias

{
VertexOutput o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}

return o;
}
half4 ShadowPassFragment() : SV_TARGET
half4 ShadowPassFragment(VertexOutput IN) : SV_TARGET
UNITY_SETUP_INSTANCE_ID(IN);
return 0;
}

{
float2 uv : TEXCOORD0;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
VertexOutput vert(GraphVertexInput v)

UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}

return o;
}
half4 frag() : SV_TARGET
half4 frag(VertexOutput IN) : SV_TARGET
UNITY_SETUP_INSTANCE_ID(IN);
return 0;
}
ENDHLSL

11
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template


// Interpolators defined by graph
${VertexOutputStruct}
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Vertex transformations performed by graph
${VertexShader}
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0;

VertexDescription vd = PopulateVertexData(vdi);
v.vertex.xyz = vd.Position;
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
o.position = TransformObjectToHClip(v.vertex.xyz);
// Vertex shader outputs defined by graph

正在加载...
取消
保存