make_clone.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. function make_clone_run(vert: node_shader_t, frag: node_shader_t) {
  2. node_shader_add_uniform(frag, "vec2 clone_delta", "_clone_delta");
  3. ///if (arm_direct3d11 || arm_direct3d12 || arm_metal || arm_vulkan)
  4. node_shader_write(frag, "vec2 tex_coord_inp = texelFetch(gbuffer2, ivec2((sp.xy + clone_delta) * gbuffer_size), 0).ba;");
  5. ///else
  6. node_shader_write(frag, "vec2 tex_coord_inp = texelFetch(gbuffer2, ivec2((sp.x + clone_delta.x) * gbuffer_size.x, (1.0 - (sp.y + clone_delta.y)) * gbuffer_size.y), 0).ba;");
  7. ///end
  8. node_shader_write(frag, "vec3 texpaint_pack_sample = textureLod(texpaint_pack_undo, tex_coord_inp, 0.0).rgb;");
  9. let base: string = "textureLod(texpaint_undo, tex_coord_inp, 0.0).rgb";
  10. let rough: string = "texpaint_pack_sample.g";
  11. let met: string = "texpaint_pack_sample.b";
  12. let occ: string = "texpaint_pack_sample.r";
  13. let nortan: string = "textureLod(texpaint_nor_undo, tex_coord_inp, 0.0).rgb";
  14. let height: string = "0.0";
  15. let opac: string = "1.0";
  16. node_shader_write(frag, "vec3 basecol = " + base + ";");
  17. node_shader_write(frag, "float roughness = " + rough + ";");
  18. node_shader_write(frag, "float metallic = " + met + ";");
  19. node_shader_write(frag, "float occlusion = " + occ + ";");
  20. node_shader_write(frag, "vec3 nortan = " + nortan + ";");
  21. node_shader_write(frag, "float height = " + height + ";");
  22. node_shader_write(frag, "float mat_opacity = " + opac + ";");
  23. node_shader_write(frag, "float opacity = mat_opacity * brush_opacity;");
  24. if (context_raw.material.paint_emis) {
  25. node_shader_write(frag, "float emis = 0.0;");
  26. }
  27. if (context_raw.material.paint_subs) {
  28. node_shader_write(frag, "float subs = 0.0;");
  29. }
  30. }