AmplifyCreations / AmplifyShaderEditor-Feedback

4 stars 0 forks source link

Update URP templates - LIGHTMAP_ON #272

Open Dawie3565 opened 6 months ago

Dawie3565 commented 6 months ago

review Unity URP for changes and update templates and or Nodes below needs to be checked and translated for ASE

////////////////////////////////////////////////////////////////////////////////////////

/ase_srp_cond_begin:<120100/ float3 shadergraph_LWBakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) {

ifdef LIGHTMAP_ON

if (applyScaling)
    uvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw;

return SampleLightmap(uvStaticLightmap, normalWS);

else

return SampleSH(normalWS);

endif

} /ase_srp_cond_end/

////////////////////////////////////////////////////////////////////////////////////////

/ase_srp_cond_begin:>=120100, <150006/ float3 shadergraph_LWBakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) {

ifdef LIGHTMAP_ON

if (applyScaling)
{
    uvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw;
    uvDynamicLightmap = uvDynamicLightmap * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
}

if defined(DYNAMICLIGHTMAP_ON)

return SampleLightmap(uvStaticLightmap, uvDynamicLightmap, normalWS);

else

return SampleLightmap(uvStaticLightmap, normalWS);

endif

else

return SampleSH(normalWS);

endif

} /ase_srp_cond_end/

////////////////////////////////////////////////////////////////////////////////////////

/ase_srp_cond_begin:>=150006/ float3 shadergraph_LWBakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) {

ifdef LIGHTMAP_ON

if (applyScaling)
{
    uvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw;
    uvDynamicLightmap = uvDynamicLightmap * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
}

if defined(DYNAMICLIGHTMAP_ON)

return SampleLightmap(uvStaticLightmap, uvDynamicLightmap, normalWS);

else

return SampleLightmap(uvStaticLightmap, normalWS);

endif

else

#if (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
if (_EnableProbeVolumes)
{
    float3 bakeDiffuseLighting;
    EvaluateAdaptiveProbeVolume(positionWS, normalWS, GetWorldSpaceNormalizeViewDir(positionWS), 0.0, bakeDiffuseLighting);
    return bakeDiffuseLighting;
}
else
    return SampleSH(normalWS);
#else
return SampleSH(normalWS);
#endif

endif

} /ase_srp_cond_end/

Dawie3565 commented 6 months ago

Note SG uses

define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_LWBakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling)

Dawie3565 commented 6 months ago

Additional review needed to check for some random defines from SG and verify equivalent defines to Unity core vs ASE

for more study ////////////////////////////////////////////////////////////////////////////////////////

define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky

define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator

define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround

/ase_srp_cond_begin:>=130108/

define SHADERGRAPH_MAIN_LIGHT_DIRECTION shadergraph_URPMainLightDirection

/ase_srp_cond_end/