Distance.hx 721 B

12345678910111213141516171819202122232425262728
  1. package h3d.pass;
  2. class Distance extends Base {
  3. var texture : h3d.mat.Texture;
  4. public function new() {
  5. super();
  6. priority = 10;
  7. lightSystem = null;
  8. }
  9. override function getOutputs() {
  10. return ["output.position", "output.distance"];
  11. }
  12. override function draw(ctx : h3d.scene.RenderContext, passes) {
  13. if( texture == null || texture.width != ctx.engine.width || texture.height != ctx.engine.height ) {
  14. if( texture != null ) texture.dispose();
  15. texture = new h3d.mat.Texture(ctx.engine.width, ctx.engine.height, [Target, TargetDepth, TargetNoFlipY]);
  16. }
  17. ctx.engine.setTarget(texture);
  18. passes = super.draw(ctx, passes);
  19. ctx.engine.setTarget(null);
  20. return passes;
  21. }
  22. }