xxxxxxxxxx
60
// This line is used for auto completion in VSCode
/// <reference path="../../node_modules/@types/p5/global.d.ts" />
//this variable will hold our shader object
let myShader;
let noise;
var easycam;
function preload() {
// a shader is composed of two parts, a vertex shader, and a fragment shader
// the vertex shader prepares the vertices and geometry to be drawn
// the fragment shader renders the actual pixel colors
// loadShader() is asynchronous so it needs to be in preload
// loadShader() first takes the filename of a vertex shader, and then a frag shader
// these file types are usually .vert and .frag, but you can actually use anything. .glsl is another common one
myShader = loadShader("shader.vert", "shader.frag");
noise = loadImage("equirectangular_hd.jpg");
}
function setup() {
// shaders require WEBGL mode to work
createCanvas(windowWidth, windowHeight, WEBGL);
noStroke();
pixelDensity(1);
easycam = createEasyCam();
}
function draw() {
background(0);
//translate(0,0,frameCount);
// shader() sets the active shader with our shader
stroke(255);
shader(myShader);
// Send the frameCount to the shader
myShader.setUniform("uFrameCount", frameCount);
myShader.setUniform("uNoiseTexture", noise);
// Rotate our geometry on the X and Y axes
//rotateX(frameCount * 0.01);
rotateY(frameCount * 0.005);
// Draw some geometry to the screen
// We're going to tessellate the sphere a bit so we have some more geometry to work with
sphere(200,200,200);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
function keyPressed(){
// easycam.zoom(-100);
}