Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const Diagnostics = require('Diagnostics');
const Scene = require('Scene');
const Shaders = require('Shaders');
const Materials = require("Materials");
const R = require("Reactive");
const CameraInfo = require('CameraInfo');
const Textures = require('Textures');
const mat = Materials.get("material0");
const cameraTexture = Textures.get("cameraTexture0");
const cameraColor = cameraTexture.signal;
// get the texture coordinates in fragment stage
const texcoords = Shaders.fragmentStage(Shaders.vertexAttribute({'variableName': Shaders.VertexAttribute.TEX_COORDS}));
var color = R.pack4(1,0,0,1);
const pixelSizeX = R.div(1,CameraInfo.previewSize.width);
const pixelSizeY = R.div(1,CameraInfo.previewSize.height);
const isHalfStep = R.step(texcoords.y, 0.5);
const isHalf = R.mix(0,1,isHalfStep);
const newUV = R.pack2(
R.mul(R.mul(isHalf,texcoords.x),2),
R.mul(texcoords.y,2)
);
var sampled = greaterThenSignal(texcoords.y,0.5, R.pack4(1,0,0,1), R.pack4(0,1,0,1));
//var sampled = Shaders.textureSampler(cameraColor, newUV);
// set texture to sampled
const textureSlot = Shaders.DefaultMaterialTextures.DIFFUSE
mat.setTexture(sampled, {textureSlotName: textureSlot});
function greaterThenSignal(shadersignal, value, leftSignal, rightSignal) {
var step = R.step(shadersignal, value);
return R.mix(leftSignal, rightSignal, step);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.