Better visual for texture stress test

This commit is contained in:
Brad Davis 2016-04-19 23:08:12 -07:00
parent 2689f2cc4a
commit b85b8db337
2 changed files with 11 additions and 28 deletions

View file

@ -3,35 +3,18 @@ float aspect(vec2 v) {
}
vec3 aspectCorrectedTexture() {
vec2 uv = _position.xy;
vec2 uv;
if (abs(_position.y) > 0.4999) {
uv = _position.xz;
} else if (abs(_position.z) > 0.4999) {
uv = _position.xy;
} else {
uv = _position.yz;
}
uv += 0.5;
uv.y = 1.0 - uv.y;
float targetAspect = iWorldScale.x / iWorldScale.y;
float sourceAspect = aspect(iChannelResolution[0].xy);
float aspectCorrection = sourceAspect / targetAspect;
if (aspectCorrection > 1.0) {
float offset = aspectCorrection - 1.0;
float halfOffset = offset / 2.0;
uv.y -= halfOffset;
uv.y *= aspectCorrection;
} else {
float offset = 1.0 - aspectCorrection;
float halfOffset = offset / 2.0;
uv.x -= halfOffset;
uv.x /= aspectCorrection;
}
if (any(lessThan(uv, vec2(0.0)))) {
return vec3(0.0);
}
if (any(greaterThan(uv, vec2(1.0)))) {
return vec3(0.0);
}
vec4 color = texture(iChannel0, uv);
return color.rgb * max(0.5, sourceAspect) * max(0.9, fract(iWorldPosition.x));
return texture(iChannel0, uv).rgb;
}
float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float shininess) {

View file

@ -42,7 +42,7 @@ function createItems(count) {
name: TEST_ENTITY_NAME,
position: AUSTIN.avatarRelativePosition(AUSTIN.randomPositionXZ({ x: 0, y: 0, z: -2 }, RADIUS)),
color: { r: 255, g: 255, b: 255 },
dimensions: AUSTIN.randomDimensions(),
dimensions: { x: 0.5, y: 0.5, z: 0.5 }, //AUSTIN.randomDimensions(),
lifetime: ENTITY_LIFETIME,
userData: JSON.stringify({
ProceduralEntity: {