-
-
Save SableRaf/a201508a07befa19205732581342ebbe to your computer and use it in GitHub Desktop.
Sohail Mehra – Spark AR Scripting - Ep 1 - Basics (updated for Spark AR Studio v102)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Materials = require('Materials'); | |
const Textures = require('Textures'); | |
const Shaders = require('Shaders'); | |
const Time = require('Time'); | |
const Reactive = require('Reactive'); | |
// const Diagnostics = require("Diagnostics"); | |
// const {log} = require('Diagnostics'); | |
async function main() | |
{ | |
const myMaterial = await Materials.findFirst('material0'); | |
const myCameraTexture = await (await Textures.findFirst('cameraTexture0')).signal; | |
let uvs = await Shaders.vertexAttribute({variableName: Shaders.VertexAttribute.TEX_COORDS}); // {variableName: ‘TEX_COORDS’} would work too | |
let ct = Reactive.mul(Time.ms,0.001); | |
let curve = Reactive.abs(Reactive.sin(ct)); | |
let color = await Shaders.textureSampler(myCameraTexture, uvs); | |
let modulationColor = Reactive.pack4(curve,0,0,1); | |
let finalColor = Reactive.mul(color, modulationColor); | |
myMaterial.setTextureSlot('DIFFUSE', finalColor); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment