Created
October 18, 2019 11:41
-
-
Save kamend/8db1ead7840d82c8f85265f9c60c3664 to your computer and use it in GitHub Desktop.
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 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