Advertisement
romanilyin

UniversalFragmentPBR

Mar 25th, 2024
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void PBR_float(float3 positionWS, half3 normalWS, half3 viewDirectionWS, half3 bakedGI, half3 albedo,
  2.     half metallic, half3 specular, half smoothness, half occlusion, half3 emission, half alpha, out float3 Color)
  3. {
  4.     #if defined(SHADERGRAPH_PREVIEW)
  5.     Color = float3(1, 1, 1);
  6.     #else
  7.     InputData inputData;
  8.     inputData.positionWS = positionWS;
  9.     inputData.normalWS = NormalizeNormalPerPixel(normalWS);
  10.     inputData.viewDirectionWS = SafeNormalize(-viewDirectionWS);
  11.     inputData.shadowCoord = half4(0, 0, 0, 0);
  12.     inputData.fogCoord = 0;
  13.     inputData.vertexLighting = half3(0, 0, 0);
  14.     inputData.normalizedScreenSpaceUV = half2(0, 0);
  15.     inputData.shadowMask = half4(0, 0, 0, 0);
  16.     inputData.bakedGI = bakedGI;
  17.     Color = UniversalFragmentPBR(inputData, albedo, metallic, specular, smoothness, occlusion, emission, alpha);
  18.     #endif
  19. }
  20.  
  21. void PBR_half(half3 positionWS, half3 normalWS, half3 viewDirectionWS, half3 bakedGI, half3 albedo,
  22.     half metallic, half3 specular, half smoothness, half occlusion, half3 emission, half alpha, out half3 Color)
  23. {
  24.     #if defined(SHADERGRAPH_PREVIEW)
  25.     Color = half3(1, 1, 1);
  26.     #else
  27.     InputData inputData;
  28.     inputData.positionWS = positionWS;
  29.     inputData.normalWS = NormalizeNormalPerPixel(normalWS);
  30.     inputData.viewDirectionWS = SafeNormalize(-viewDirectionWS);
  31.     inputData.shadowCoord = half4(0, 0, 0, 0);
  32.     inputData.fogCoord = 0;
  33.     inputData.vertexLighting = half3(0, 0, 0);
  34.     inputData.normalizedScreenSpaceUV = half2(0, 0);
  35.     inputData.shadowMask = half4(0, 0, 0, 0);
  36.     inputData.bakedGI = bakedGI;
  37.     Color = UniversalFragmentPBR(inputData, albedo, metallic, specular, smoothness, occlusion, emission, alpha);
  38.     #endif
  39. }
  40.  
  41. /*
  42. struct InputData
  43. {
  44.     float3  positionWS;
  45.     half3   normalWS;
  46.     half3   viewDirectionWS;
  47.     float4  shadowCoord;
  48.     half    fogCoord;
  49.     half3   vertexLighting;
  50.     half3   bakedGI;
  51.     float2  normalizedScreenSpaceUV;
  52.     half4   shadowMask;
  53. };
  54. */
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement