Created
November 23, 2020 13:03
-
-
Save SableRaf/1a1cae1fdf5a81884fb5ede7fe31a509 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'); | |
async function main() | |
{ | |
const myMaterial = await Materials.findFirst('material0'); | |
const myCameraTexture = await Textures.findFirst('cameraTexture0'); | |
const myTextureSignal = myCameraTexture.signal; | |
let uvs = 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 = Shaders.textureSampler(myTextureSignal, 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
I't works perfectly, thank you so much!