0

I am trying to modify the resolution of the camera texture in Spark AR, either through a script or patches. This medium post has been helpful in understanding some of the components of the camera texture, but I could use some help.

require('Textures') and require('CameraInfo') seem to be essential, but I am unsure of how to modify them.

CameraInfo.previewSize.width and CameraInfo.previewSize.height would likely play a major role to reduce the size, but I am also unsure of how to then pass those variables to the texture.

This is a non-functional example. Any suggestions would be greatly appreciated:

const Scene = require('Scene');
const R = require('Reactive');
const Textures = require('Textures'); 
const CameraInfo = require('CameraInfo'); 

const blur_mat = Materials.get('blur_mat');
const cameraTex = Textures.get('cameraTex');

const cameraLoRes = cameraTex.signal;

// attempt reduce resolution of camera texture
const loResX = R.div(4, CameraInfo.previewSize.width);
const loResY = R.div(4, CameraInfo.previewSize.height);
const loResTex = R.mul(loResX, loResY);
const loResTex = R.add(texcoords, R.pack2(loResX,loResY));

blur_mat.setTexture(cameraLoRes, {textureSlotName: "diffuseTexture"});
WhooNo
  • 911
  • 2
  • 12
  • 28

2 Answers2

0

Very simple answer - the Shader render pass patch allows you to reduce the resolution of the camera texture for a specific object.

Add the Shader render pass from the patch menu. Adjust the size variables as necessary and choose the sizing mode you require. Plug your texture into the shader port, and attach the texture output to your material patch.

See this wonderful and detailed tutorial: https://www.youtube.com/watch?v=0L2Gr-SQpCU&feature=youtu.be

WhooNo
  • 911
  • 2
  • 12
  • 28
0

so currently render pass are not available for scripting. its only for patch currently .

rbkavin
  • 69
  • 7