Advertisement
Reisyukaku

shader_alb_nrm_packGB

May 13th, 2023 (edited)
2,632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OpenGL Shading 3.07 KB | Source Code | 0 0
  1. #version 450
  2.  
  3. layout(set = 0, binding = 0, std140) uniform _9_12
  4. {
  5.     uint _m0;
  6.     uint _m1[8];
  7.     vec4 _m2;
  8.     int _m3;
  9.     float _m4[73];
  10. } _12;
  11.  
  12. layout(set = 0, binding = 20, std140) uniform fp_c1
  13. {
  14.     vec4 _m0[4096];
  15. } fp_c1_1;
  16.  
  17. layout(set = 0, binding = 23, std140) uniform fp_c4
  18. {
  19.     vec4 _m0[4096];
  20. } fp_c4_1;
  21.  
  22. layout(set = 2, binding = 128) uniform sampler2D albedo;
  23. layout(set = 2, binding = 129) uniform sampler2D normals;
  24. layout(set = 2, binding = 130) uniform sampler2D packed_tex;
  25.  
  26. layout(location = 0) in vec3 _36;
  27. layout(location = 1) in vec3 _38;
  28. layout(location = 2) in vec3 _44;
  29. layout(location = 3) in vec2 texcoord;
  30. layout(location = 4) in vec3 scale;
  31. layout(location = 5) in vec4 _42;
  32. layout(location = 6) in vec4 _40;
  33.  
  34. layout(location = 0) out vec4 outDiffuse;
  35. layout(location = 1) out vec4 outSpecSmooth;
  36. layout(location = 2) out vec4 outNormals;
  37. layout(location = 3) out vec4 outMotion;
  38. layout(location = 4) out vec4 outDepth;
  39.  
  40. void main()
  41. {
  42.     //load textures
  43.     vec2 packed_GB = texture(packed_tex, vec2(texcoord.x, texcoord.y)).yz;
  44.     vec3 alb = texture(albedo, vec2(texcoord.x, texcoord.y)).xyz;
  45.     vec3 norm = texture(normals, vec2(texcoord.x, texcoord.y)).xyz;
  46.    
  47.     float _216 = _40.x * (1.0 / _40.w);
  48.     float _218 = _40.y * (1.0 / _40.w);
  49.    
  50.     float _268 = fma(1.0 / _42.w, _42.y, -_218);
  51.     float _276 = fma(1.0 / _42.w, _42.x, -_216);
  52.    
  53.     float _268 = fma(1.0 / _42.w, _42.y, -_218);
  54.     float _276 = fma(1.0 / _42.w, _42.x, -_216);
  55.    
  56.     //Normalize light
  57.     vec3 nrm_1 = normalize(_36);
  58.     vec3 nrm_2 = normalize(_38);
  59.     vec3 nrm_3 = normalize(_44);
  60.    
  61.     //Convert from [0,1] to [-1,1] ?
  62.     float norm_R = fma(norm.x, 2.0, -1.0);
  63.     float norm_G = fma(norm.y, 2.0, -1.0);
  64.     float norm_B = fma(norm.z, 2.0, -1.0);
  65.    
  66.     vec3 nrm_4 = normalize((norm_R * nrm_2) + (norm_G * nrm_3) + (norm_B * nrm_1));
  67.    
  68.     float _340 = max(max(abs(_276 * 0.5), abs(_268 * 0.5)), 1.0);
  69.     float _362 = (_268 * 0.5) * (1.0 / _340);
  70.     float _364 = (_276 * 0.5) * (1.0 / _340);
  71.     float _376 = float(_362 >= 0.0);
  72.     float _388 = float(_364 >= 0.0);
  73.     float _384 = floor(_42.z * 8.0);
  74.    
  75.     //G-Buffer
  76.     outDiffuse = vec4(alb * scale, 0.0);
  77.    
  78.     outSpecSmooth.x = fp_c4_1._m0[0].x;
  79.     outSpecSmooth.y = packed_GB.x; //G
  80.     outSpecSmooth.z = 0.0;
  81.     outSpecSmooth.w = 0.0043137255124747753143310546875;
  82.    
  83.     outNormals.x = fma(nrm_4.x, 0.5, 0.5);
  84.     outNormals.y = fma(nrm_4.y, 0.5, 0.5);
  85.     outNormals.z = packed_GB.y * max(scaleB, max(scaleR, scaleG)); //find the max scale of all channels and use that to scale B
  86.     outNormals.w = fma(nrm_4.z, 1000.0, 0.5);
  87.    
  88.     outMotion.x = 1.0 / inversesqrt(abs(_364));
  89.     outMotion.y = 1.0 / inversesqrt(abs(_362));
  90.     outMotion.z = 0.0;
  91.     outMotion.w = fma(_388, fp_c1_1._m0[0].x, _376 * 0.666666686534881591796875) + 0.00999999977648258209228515625;
  92.    
  93.     outDepth.x = (_42.z * 8.0) - _384;
  94.     outDepth.y = (_384 / 255) - floor(_384 / 255);
  95.     outDepth.z = floor(_384 / 255) / 255;
  96.     outDepth.w = 0.0;
  97. }
  98.  
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement