Drive skybox off of timer

This commit is contained in:
Zach Pomerantz 2016-03-09 18:35:15 -08:00
parent d89d89fd08
commit 3cd0f0d237
3 changed files with 55 additions and 23 deletions

View file

@ -1,5 +1,5 @@
// rapidUniformChangeTest.js
// examples
// rapidProceduralChangeTest.js
// examples/tests/rapidProceduralChange
//
// Created by Eric Levin on 3/9/2016.
// Copyright 2016 High Fidelity, Inc.
@ -25,32 +25,40 @@ centerUp.y += 0.5;
var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
centerDown.y -= 0.5;
var SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/rapidUniformChangeTest.fs";
var ENTITY_SHADER_URL = "file:///C:/Users/User/Code/hifi-master/examples/tests/rapidUniformChange/uniformTest.fs";
var SKYBOX_SHADER_URL = "file:///C:/Users/User/Code/hifi-master/examples/tests/rapidUniformChange/timerTest.fs";
var userData = {
var entityData = {
ProceduralEntity: {
shaderUrl: SHADER_URL,
shaderUrl: ENTITY_SHADER_URL,
uniforms: { red: 0.0 }
}
}
var edit = JSON.stringify(userData);
};
var skyboxData = {
ProceduralEntity: {
shaderUrl: SKYBOX_SHADER_URL,
uniforms: { red: 0.0 }
}
};
var testBox = Entities.addEntity({
type: "Box",
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
position: centerUp,
userData: edit
userData: JSON.stringify(entityData)
});
var testSphere = Entities.addEntity({
type: "Sphere",
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
position: centerDown,
userData: edit
userData: JSON.stringify(entityData)
});
var testZone = Entities.addEntity({
type: "Zone",
dimensions: { x: 3, y: 3, z: 3 },
dimensions: { x: 50, y: 50, z: 50 },
position: MyAvatar.position,
userData: edit
userData: JSON.stringify(skyboxData),
backgroundMode: "skybox",
skybox: { url: "http://kyoub.googlecode.com/svn/trunk/KYouB/textures/skybox_test.png" }
});
@ -58,11 +66,13 @@ var currentTime = 0;
function update(deltaTime) {
var red = (Math.sin(currentTime) + 1) / 2;
userData.ProceduralEntity.uniforms.red = red;
edit = { userData: JSON.stringify(userData) };
Entities.editEntity(testBox, edit);
Entities.editEntity(testSphere, edit);
Entities.editEntity(testZone, edit);
entityData.ProceduralEntity.uniforms.red = red;
skyboxData.ProceduralEntity.uniforms.red = red;
entityEdit = { userData: JSON.stringify(entityData) };
skyboxEdit = { userData: JSON.stringify(skyboxData) };
Entities.editEntity(testBox, entityEdit);
Entities.editEntity(testSphere, entityEdit);
Entities.editEntity(testZone, skyboxEdit);
currentTime += deltaTime;
}

View file

@ -0,0 +1,21 @@
//
// timerTest.fs
// examples/tests/rapidProceduralChange
//
// Created by Eric Levin on 3/9/16.
// Copyright 2016 High Fidelity, Inc.
//
// This fragment shader is designed to test the rapid changing of a uniform on the timer.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
uniform float red;
vec3 getSkyboxColor() {
float blue = red;
blue = (cos(iGlobalTime) + 1) / 2;
return vec3(1.0, 0.0, blue);
}

View file

@ -1,26 +1,27 @@
//
// rapidUniformChangeTest.fs
// examples/homeContent/plant
// uniformTest.fs
// examples/tests/rapidProceduralChange
//
// Created by Eric Levin on 3/9/16.
// Copyright 2016 High Fidelity, Inc.
//
// This fragment shader is designed to test the rapid changing of a uniform
// This fragment shader is designed to test the rapid changing of a uniform.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
uniform float red = 0.1;
uniform float red;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
fragColor = vec4(red, 0.0, 1.0, 1.0);
}
vec4 getProceduralColor() {
vec4 result;
vec2 position = _position.xz;
position += 0.5;
mainImage(result, position * iWorldScale.xz);
return result;
}
}