Update WebGL conformance suite 1.0.3 from upstream

This commit is contained in:
Imanol Fernandez 2017-10-30 19:07:01 +01:00
parent c4bb30413c
commit 4989f00916
1568 changed files with 27218 additions and 27288 deletions

View file

@ -53,7 +53,7 @@ FILE_PATTERNS_TO_CHECK = ["*.rs", "*.rc", "*.cpp", "*.c",
"*.yml"]
# File patterns that are ignored for all tidy and lint checks.
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh"]
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh", "*.ogv", "*.webm"]
SPEC_BASE_PATH = "components/script/dom/"

View file

@ -85,8 +85,7 @@ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, null);
wtu.glErrorShouldBe(gl, [gl.NO_ERROR, gl.INVALID_VALUE]);
wtu.shouldThrowOrGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_VALUE], "gl.bufferSubData(gl.ARRAY_BUFFER, 10, null)");
var successfullyParsed = true;
</script>

View file

@ -58,13 +58,15 @@ context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
var indexValidationError = wtu.shouldGenerateGLError(context,
[context.INVALID_OPERATION, context.NO_ERROR],
"context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -60,9 +60,9 @@ var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
var indexValidationError = wtu.shouldGenerateGLError(context, [context.INVALID_OPERATION, context.NO_ERROR], "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -112,7 +112,7 @@ gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT),
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, [gl.INVALID_OPERATION, gl.NO_ERROR]);
debug("Test with enabled attribute that does not belong to current program");

View file

@ -418,7 +418,6 @@ RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
@ -475,6 +474,7 @@ canvas : "implementation-dependent"
// added in versions of the spec that are backward-compatible with
// this version
var ignoredProperties = [
'STENCIL_INDEX',
];
// Constants removed from the WebGL spec compared to ES 2.0

View file

@ -64,8 +64,7 @@ void main()
var wtu = WebGLTestUtils;
var gl;
var contextAttribs = null;
var pixel_1 = [0, 0, 0, 1];
var pixel_2 = [0, 0, 0, 1];
var redChannels = [0, 0, 0];
var correctColor = null;
var framebuffer;
var fbHasColor;
@ -304,10 +303,13 @@ function testStencilAndDepth(stencil, depth)
function testAntialias(antialias)
{
debug("Testing antialias = " + antialias);
// Both the width and height of canvas are N.
// Note that "N = 2" doesn't work for some post processing AA per the discussion at https://github.com/KhronosGroup/WebGL/pull/1977.
var N = 3;
if (antialias)
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
else
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
var vertices = new Float32Array([
@ -319,17 +321,13 @@ function testAntialias(antialias)
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
var buf_1 = new Uint8Array(1 * 1 * 4);
var buf_2 = new Uint8Array(1 * 1 * 4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_1);
gl.readPixels(0, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_2);
pixel_1[0] = buf_1[0];
pixel_2[0] = buf_2[0];
// For some anti-alias algorithms, effects may be not on diagonal line pixels, so that either:
// - The red channel of the pixel at (0, 0) is not 0 and not 255, or,
// - If it is 0, expect that the red channel of the pixel at (0, 1) is not 0 and not 255.
shouldBe("pixel_1[0] != 255 && pixel_1[0] != 0 || pixel_1[0] == 0 && pixel_2[0] != 255 && pixel_2[0] != 0",
"contextAttribs.antialias");
var buf = new Uint8Array(N * N * 4);
gl.readPixels(0, 0, N, N, gl.RGBA, gl.UNSIGNED_BYTE, buf);
redChannels[0] = buf[4 * (N + 1)]; // (1, 1)
redChannels[1] = buf[4 * N * (N - 1)]; // left top
redChannels[2] = buf[4 * (N - 1)]; // right bottom
shouldBeTrue("redChannels[1] == 255 && redChannels[2] == 0");
shouldBe("redChannels[0] != 255 && redChannels[0] != 0", "contextAttribs.antialias");
}
function runTest()

View file

@ -87,6 +87,9 @@ function init()
canvas.addEventListener("webglcontextlost", testLostContext, false);
// We need to initialize |uniformLocation| before losing context.
// Otherwise gl.getUniform() when context is lost will throw.
uniformLocation = gl.getUniformLocation(program, "tex");
loseContext();
}

View file

@ -290,8 +290,8 @@ function runIndexValidationTests(drawType) {
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
'gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
debug("Test with enabled attribute that does not belong to current program");
@ -331,13 +331,14 @@ function runCopiesIndicesTests(drawType) {
var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runResizedBufferTests(drawType) {
@ -423,8 +424,9 @@ function runVerifiesTooManyIndicesTests(drawType) {
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]), drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runCrashWithBufferSubDataTests(drawType) {

View file

@ -183,10 +183,10 @@ function arrayToString(arr, size) {
mySize = size;
var out = "[";
for (var ii = 0; ii < mySize; ++ii) {
if (ii > 0) {
out += ", ";
}
out += arr[ii];
if (ii > 0) {
out += ", ";
}
out += arr[ii];
}
return out + "]";
}
@ -252,25 +252,25 @@ function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, s
var implType = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "getParameter of IMPLEMENTATION_COLOR_READ_{FORMAT|TYPE} should succeed");
if ((implFormat == gl.RGBA || implFormat == gl.RGB) && implType == gl.FLOAT) {
debug("Checking readback of floating-point values");
var arraySize = (implFormat == gl.RGBA) ? 4 : 3
var buf = new Float32Array(arraySize);
gl.readPixels(0, 0, 1, 1, implFormat, implType , buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels from floating-point renderbuffer should succeed");
var ok = true;
var tolerance = 8.0; // TODO: factor this out from both this test and the subtractor shader above.
for (var ii = 0; ii < buf.length; ++ii) {
if (Math.abs(buf[ii] - subtractor[ii]) > tolerance) {
ok = false;
break;
}
}
if (ok) {
testPassed("readPixels of float-type data from floating-point renderbuffer succeeded");
} else {
testFailed("readPixels of float-type data from floating-point renderbuffer failed: expected "
+ arrayToString(subtractor, arraySize) + ", got " + arrayToString(buf));
}
debug("Checking readback of floating-point values");
var arraySize = (implFormat == gl.RGBA) ? 4 : 3
var buf = new Float32Array(arraySize);
gl.readPixels(0, 0, 1, 1, implFormat, implType , buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels from floating-point renderbuffer should succeed");
var ok = true;
var tolerance = 8.0; // TODO: factor this out from both this test and the subtractor shader above.
for (var ii = 0; ii < buf.length; ++ii) {
if (Math.abs(buf[ii] - subtractor[ii]) > tolerance) {
ok = false;
break;
}
}
if (ok) {
testPassed("readPixels of float-type data from floating-point renderbuffer succeeded");
} else {
testFailed("readPixels of float-type data from floating-point renderbuffer failed: expected "
+ arrayToString(subtractor, arraySize) + ", got " + arrayToString(buf));
}
}
}

View file

@ -127,8 +127,9 @@ function getSharedArrayBufferSize() {
sharedArrayBufferSize = bufferSizeNeeded;
}
bufferSizeNeeded = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// ArrayBuffers can be at most 4GB (minus 1 byte)
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= 4294967295) {
// ArrayBuffers can be at most 4GB (minus 1 byte), but any allocations larger than 1 GB are unreliable in practice. So limit allocations to 1 GB.
// Textures that are wide in just one dimension can still be used to test max TEXTURE_2D size limit even if we don't allocate space for huge square textures.
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= Math.pow(2, 30)) {
sharedArrayBufferSize = bufferSizeNeeded;
}
}
@ -195,7 +196,7 @@ function testFormatType(t, test) {
for (var j = 0; j < t.targets.length; ++j) {
var target = t.targets[j];
debug("");
debug(wtu.glEnumToString(gl, target));
debug(wtu.glEnumToString(gl, target) + " " + wtu.glEnumToString(ext, test.format));
// positive test
var size = positiveTestSize;
@ -219,11 +220,25 @@ function testFormatType(t, test) {
var dataSize = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// this check assumes that each element is 1 byte
if (dataSize > sharedArrayBuffer.byteLength) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
if (t.target == gl.TEXTURE_CUBE_MAP) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
} else {
var wideAndShortDataSize = test.func(t.maxSize + test.sizeStep, test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, wideAndShortDataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (test.sizeStep));
var narrowAndTallDataSize = test.func(test.sizeStep, t.maxSize + test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, narrowAndTallDataSize);
gl.compressedTexImage2D(target, 0, test.format, test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
} else {
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, dataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds: should generate INVALID_VALUE."
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width and height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
// level out of bounds

View file

@ -62,6 +62,13 @@ void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderRedWithExtension" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderMacroDisabled" type="x-shader/x-fragment">
#ifdef GL_EXT_draw_buffers
bad code here
@ -104,7 +111,7 @@ var canvas = document.getElementById("canvas");
var output = document.getElementById("console");
var gl = wtu.create3DContext(canvas);
var ext = null;
var vao = null;
var programWithMaxDrawBuffersEqualOne = null;
var extensionConstants = [
{ name: "MAX_COLOR_ATTACHMENTS_WEBGL", enum: 0x8CDF, expectedFn: function(v) { return v >= 4; }, passMsg: " should be >= 4"},
@ -179,8 +186,7 @@ if (!gl) {
function createExtDrawBuffersProgram(scriptId, sub) {
var fsource = wtu.getScript(scriptId);
fsource = wtu.replaceParams(fsource, sub);
wtu.addShaderSource(output, "fragment shader", fsource);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"]);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"], undefined, true);
}
function runSupportedTest(extensionEnabled) {
@ -246,9 +252,7 @@ function runEnumTestEnabled() {
function testShaders(tests, sub) {
tests.forEach(function(test) {
var shaders = [wtu.getScript(test.shaders[0]), wtu.replaceParams(wtu.getScript(test.shaders[1]), sub)];
wtu.addShaderSource(output, "vertex shader", shaders[0]);
wtu.addShaderSource(output, "fragment shader", shaders[1]);
var program = wtu.setupProgram(gl, shaders, ["a_position"]);
var program = wtu.setupProgram(gl, shaders, ["a_position"], undefined, true);
var programLinkedSuccessfully = (program != null);
var expectedProgramToLinkSuccessfully = (test.expectFailure == true);
expectTrue(programLinkedSuccessfully != expectedProgramToLinkSuccessfully, test.msg);
@ -260,6 +264,7 @@ function runShadersTestDisabled() {
debug("");
debug("test shaders disabled");
var sub = {numDrawingBuffers: 1};
testShaders([
{ shaders: ["vshader", "fshaderMacroDisabled"],
msg: "GL_EXT_draw_buffers should not be defined in GLSL",
@ -268,7 +273,12 @@ function runShadersTestDisabled() {
msg: "#extension GL_EXT_draw_buffers should not be allowed in GLSL",
expectFailure: true,
},
], {numDrawingBuffers: 1});
], sub);
programWithMaxDrawBuffersEqualOne = createExtDrawBuffersProgram("fshaderBuiltInConstEnabled", sub);
wtu.setupUnitQuad(gl);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
@ -410,6 +420,7 @@ function runDrawTests() {
var checkProgram = wtu.setupTexturedQuad(gl);
var redProgram = wtu.setupProgram(gl, ["vshader", "fshaderRed"], ["a_position"]);
var redProgramWithExtension = wtu.setupProgram(gl, ["vshader", "fshaderRedWithExtension"], ["a_position"]);
var drawProgram = createExtDrawBuffersProgram("fshader", {numDrawingBuffers: maxDrawingBuffers});
var width = 64;
var height = 64;
@ -548,28 +559,56 @@ function runDrawTests() {
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
debug("test that gl_FragColor broadcasts");
debug("test that gl_FragColor does not broadcast unless extension is enabled in fragment shader");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index == 0) ? [255, 0, 0, 255] : [0, 255, 0, 255];
});
debug("test that gl_FragColor broadcasts if extension is enabled in fragment shader");
gl.clear(gl.COLOR_BUFFER_BIT);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgramWithExtension);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
if (maxUsable > 1) {
// First half of color buffers disable.
var bufs1 = makeColorAttachmentArray(maxUsable);
// Second half of color buffers disable.
var bufs2 = makeColorAttachmentArray(maxUsable);
// Color buffers with even indices disabled.
var bufs3 = makeColorAttachmentArray(maxUsable);
// Color buffers with odd indices disabled.
var bufs4 = makeColorAttachmentArray(maxUsable);
for (var ii = 0; ii < maxUsable; ++ii) {
if (ii < half) {
bufs1[ii] = gl.NONE;
} else {
bufs2[ii] = gl.NONE;
}
if (ii % 2) {
bufs3[ii] = gl.NONE;
} else {
bufs4[ii] = gl.NONE;
}
}
debug("test setting first half to NONE and clearing");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
// We should clear all buffers rather than depending on the previous
// gl_FragColor broadcasts test to succeed and setting the colors.
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs1);
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -594,6 +633,7 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs2);
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -698,6 +738,7 @@ function runDrawTests() {
});
gl.deleteProgram(checkProgram);
gl.deleteProgram(redProgram);
gl.deleteProgram(redProgramWithExtension);
gl.deleteProgram(drawProgram);
}
@ -729,6 +770,7 @@ function runPreserveTests() {
finishTest();
});
}
</script>
</body>
</html>

View file

@ -47,7 +47,10 @@ description("Tests calling WebGL APIs with wrong argument types");
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
function mayThrow(expression) {
wtu.shouldThrowOrGenerateGLError(context, [context.NO_ERROR, context.INVALID_VALUE, context.INVALID_OPERATION, context.INVALID_ENUM], expression);
}
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
@ -57,29 +60,25 @@ assertMsg(loc != null, "getUniformLocation succeeded");
var testArguments = [
{ value: "foo",
throws: true },
throws: "yes" },
{ value: 0,
throws: true },
throws: "yes" },
{ value: null,
throws: false },
throws: "maybe" },
{ value: undefined,
throws: false }
throws: "maybe" }
];
var argument;
function shouldBeEmptyString(command) {
shouldBe(command, "''");
}
for (var i = 0; i < testArguments.length; ++i) {
var func, func2;
if (testArguments[i].throws) {
if (testArguments[i].throws == "yes") {
func = shouldThrow;
func2 = shouldThrow;
} else {
func = shouldBeUndefined;
func2 = shouldBeNull;
func = mayThrow;
func2 = shouldBeUndefined;
}
argument = testArguments[i].value;
func("context.compileShader(argument)");
@ -88,28 +87,27 @@ for (var i = 0; i < testArguments.length; ++i) {
func("context.attachShader(argument, shader)");
func("context.detachShader(program, argument)");
func("context.detachShader(argument, shader)");
func("context.useProgram(argument)");
func("context.shaderSource(argument, 'foo')");
func("context.bindAttribLocation(argument, 0, 'foo')");
func("context.bindBuffer(context.ARRAY_BUFFER, argument)");
func("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
func("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
func("context.bindTexture(context.TEXTURE_2D, argument)");
func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
func("context.uniform2iv(argument, new Int32Array([0, 0]))");
func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
func2("context.getProgramInfoLog(argument)");
func2("context.getProgramParameter(argument, 0)");
func2("context.getShaderInfoLog(argument)");
func2("context.getShaderParameter(argument, 0)");
func2("context.getShaderSource(argument)");
func2("context.getUniform(argument, loc)");
func2("context.getUniform(program, argument)");
func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func("context.getProgramInfoLog(argument)");
func("context.getProgramParameter(argument, 0)");
func("context.getShaderInfoLog(argument)");
func("context.getShaderParameter(argument, 0)");
func("context.getShaderSource(argument)");
func("context.getUniform(argument, loc)");
func("context.getUniform(program, argument)");
func("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func2("context.useProgram(argument)");
func2("context.bindBuffer(context.ARRAY_BUFFER, argument)");
func2("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
func2("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
func2("context.bindTexture(context.TEXTURE_2D, argument)");
func2("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
func2("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
func2("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
func2("context.uniform2iv(argument, new Int32Array([0, 0]))");
func2("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
}
var successfullyParsed = true;

View file

@ -53,9 +53,7 @@ var program = wtu.loadStandardProgram(context);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveAttrib");
// Synthetic OpenGL error
shouldBeNull("context.getActiveAttrib(null, 2)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveAttrib(null, 2)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error
@ -65,9 +63,7 @@ wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveUniform");
// Synthetic OpenGL error
shouldBeNull("context.getActiveUniform(null, 0)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveUniform(null, 0)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error

View file

@ -48,19 +48,20 @@ var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
var shouldThrowOrGenerateGLError = wtu.shouldThrowOrGenerateGLError;
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)");
shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
@ -75,13 +76,13 @@ shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
debug("");
debug("check with bindings");

View file

@ -100,7 +100,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isTexture(tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
var texCubeMap = gl.createTexture();
@ -110,7 +110,7 @@ shouldBe("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)", "texCubeMap");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(texCubeMap)");
shouldBeFalse("gl.isTexture(texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
var t = gl.createTexture();
@ -118,7 +118,7 @@ shouldBeNonNull("t");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
var t2 = gl.createTexture();
@ -152,7 +152,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isRenderbuffer(rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo2)");
shouldBe("gl.getParameter(gl.RENDERBUFFER_BINDING)", "rbo2");
@ -337,7 +337,7 @@ shouldBe("gl.getParameter(gl.ARRAY_BUFFER_BINDING)", "buffer");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer)");
shouldBeFalse("gl.isBuffer(buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var buffer2 = gl.createBuffer();
@ -348,7 +348,7 @@ shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, null)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer2)");
shouldBeFalse("gl.isBuffer(buffer2)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var bufferElement = gl.createBuffer();
@ -358,7 +358,7 @@ shouldBe("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)", "bufferElement");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(bufferElement)");
shouldBeFalse("gl.isBuffer(bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
var b = gl.createBuffer();
@ -366,7 +366,7 @@ shouldBeNonNull("b");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
var b1 = gl.createBuffer();
@ -399,7 +399,7 @@ shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteFramebuffer(fbo)");
shouldBeFalse("gl.isFramebuffer(fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo2)");
shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo2");

View file

@ -51,6 +51,7 @@ gl.useProgram(program);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed");
debug("");

View file

@ -27,7 +27,6 @@ functions/deleteBufferBadArgs.html
functions/drawArrays.html
functions/drawArraysOutOfBounds.html
functions/drawElements.html
functions/drawElementsBadArgs.html
functions/isTests.html
--min-version 1.0.2 functions/isTestsBadArgs.html
functions/readPixels.html

View file

@ -22,7 +22,7 @@ Want to contribute?
1. Fork this repo
2. Run <code>gen_tests.rb</code>
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
1. copy methodName.html to functions/methodName.html and write tests that test the results of valid inputs.
2. copy methodNameBadArgs.html to functions/methodNameBadArgs.html and write tests to assert that invalid inputs throw exceptions.
3. If your test causes a segfault, add the following to the top of the script tag: <code>Tests.autorun = false; Tests.message = "Caution: this may crash your browser";</code>

View file

@ -306,7 +306,6 @@ RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
RENDERBUFFER_WIDTH : 0x8D42,

View file

@ -1,211 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<link rel="stylesheet" type="text/css" href="../unit.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script type="application/x-javascript" src="../unit.js"></script>
<script type="application/x-javascript" src="../util.js"></script>
<script type="application/x-javascript">
// Tests.autorun = false;
// Tests.message = "Caution: May crash your browser";
var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
var indices = [60000000,1,2]
Tests.startUnit = function () {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(getGLContext(canvas));
var prog = new Shader(gl, 'vert', 'frag');
prog.use();
var sh = prog.shader.program;
var v = gl.getAttribLocation(sh, 'Vertex');
var n = gl.getAttribLocation(sh, 'Normal');
var t = gl.getAttribLocation(sh, 'Tex');
return [gl,prog,v,n,t];
}
Tests.setup = function(gl, prog, v,n,t) {
assert(0 == gl.getError());
return [gl, prog, v,n,t];
}
Tests.teardown = function(gl, prog, v,n,t) {
gl.disableVertexAttribArray(v);
gl.disableVertexAttribArray(n);
gl.disableVertexAttribArray(t);
}
Tests.endUnit = function(gl, prog, v,n,t) {
prog.destroy();
}
Tests.testDrawElementsVBO = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOByte = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMulti = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 2*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 3*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMultiByte = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, -1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, -1, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 3);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testSharedBuffers = function(gl, prog, v,n,t) {
var vbo = gl.createBuffer();
var vertsArr = new Uint16Array([0,1,3,3,4,5,6,7,8]);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
assertFail(function(){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo)});
gl.deleteBuffer(vbo);
}
</script>
<script id="vert" type="x-shader/x-vertex">
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec2 Tex;
varying vec4 texCoord0;
void main()
{
gl_Position = vec4(Vertex * Normal, 1.0);
texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
}
</script>
<script id="frag" type="x-shader/x-fragment">
precision mediump float;
varying vec4 texCoord0;
void main()
{
vec4 c = texCoord0;
gl_FragColor = c;
}
</script>
<style>canvas{ position:absolute; }</style>
</head><body>
<canvas id="gl" width="1" height="1"></canvas>
</body></html>

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/opengl_logo.jpg";
var localImgUrl = "../../resources/opengl_logo.jpg";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -93,8 +93,8 @@ Tests.testVertexAttribPointerVBO = function(gl, prog, v,n,t) {
assertFail("bad index (big positive)",
function(){gl.vertexAttribPointer(8693948, 3, gl.FLOAT, false, 0, 0);});
gl.bindBuffer(gl.ARRAY_BUFFER, null);
assertFail("binding to null buffer",
function(){gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);});
assertFail("binding to null buffer with offset!=0",
function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 16);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 0.0, 1.0);
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (color.r - 0.5);
if(c < 0.0) c *= -1.0;
float c = 2.0 * (color.r - 0.5);
if(c < 0.0) c *= -1.0;
gl_FragColor = vec4(c, 0.0, 0.0, 1.0);
gl_FragColor = vec4(c, 0.0, 0.0, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(abs(c), 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(abs(c), 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,9 +30,9 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (gtf_Color.r - 0.5);
if(c < 0.0) c *= -1.0;
float c = 2.0 * (gtf_Color.r - 0.5);
if(c < 0.0) c *= -1.0;
color = vec4(c, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 1.0);
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 1.0);
}

View file

@ -30,9 +30,9 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
vec2 c = 2.0 * (color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
gl_FragColor = vec4(c, 0.0, 1.0);
gl_FragColor = vec4(c, 0.0, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(abs(c), 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(abs(c), 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,10 +30,10 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
color = vec4(c, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(abs(c), 1.0);
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(abs(c), 1.0);
}

View file

@ -30,11 +30,11 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
vec3 c = 2.0 * (color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
gl_FragColor = vec4(c, 1.0);
gl_FragColor = vec4(c, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(abs(c), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(abs(c), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,11 +30,11 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
color = vec4(c, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
}

View file

@ -39,73 +39,73 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 0.0, 1.0);
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,29 +30,29 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
float acos_c = 0.0;
float scale = 1.0;
float sign = 1.0;
float acos_c = 0.0;
float scale = 1.0;
float sign = 1.0;
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
acos_c = M_PI / 2.0 - sign * acos_c;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
acos_c = M_PI / 2.0 - sign * acos_c;
color = vec4(acos_c / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 1.0);
}

View file

@ -39,109 +39,109 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 1.0);
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,44 +30,44 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 acos_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 acos_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
color = vec4(acos_c / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 1.0);
}

View file

@ -39,145 +39,145 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 1.0);
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(acos(c) / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(acos(c) / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,60 +30,60 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 acos_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 acos_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
acos_c.b = M_PI / 2.0 - sign.b * acos_c.b;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
acos_c.b = M_PI / 2.0 - sign.b * acos_c.b;
color = vec4(acos_c / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec2(c))), 1.0);
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec2(c))), 1.0);
}

View file

@ -30,16 +30,16 @@ varying vec4 color;
bool _all(in bvec2 a)
{
bool temp = true;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
return temp;
}
void main (void)
{
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec2(c))), 1.0);
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec2(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _all(in bvec2 a)
{
bool temp = true;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
return temp;
}
void main (void)
{
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec3(c))), 1.0);
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec3(c))), 1.0);
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _all(in bvec3 a)
{
bool temp = true;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
return temp;
return temp;
}
void main (void)
{
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec3(c))), 1.0);
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec3(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,18 +30,18 @@ varying vec4 color;
bool _all(in bvec3 a)
{
bool temp = true;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
return temp;
return temp;
}
void main (void)
{
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(1.5 * color.rg); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(any(bvec2(c))), 1.0);
vec2 c = floor(1.5 * color.rg); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(any(bvec2(c))), 1.0);
}

View file

@ -30,16 +30,16 @@ varying vec4 color;
bool _any(in bvec2 a)
{
bool temp = false;
bool temp = false;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[0]) temp = true;
if(a[1]) temp = true;
return temp;
return temp;
}
void main (void)
{
vec2 c = floor(1.5 * color.rg); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(_any(bvec2(c))), 1.0);
vec2 c = floor(1.5 * color.rg); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(_any(bvec2(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(1.5 * gtf_Color.rg); // 1/3 true, 2/3 false
color = vec4(vec3(any(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(1.5 * gtf_Color.rg); // 1/3 true, 2/3 false
color = vec4(vec3(any(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _any(in bvec2 a)
{
bool temp = false;
bool temp = false;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[0]) temp = true;
if(a[1]) temp = true;
return temp;
return temp;
}
void main (void)
{
vec2 c = floor(1.5 * gtf_Color.rg); // 1/3 true, 2/3 false
color = vec4(vec3(_any(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(1.5 * gtf_Color.rg); // 1/3 true, 2/3 false
color = vec4(vec3(_any(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(1.5 * color.rgb); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(any(bvec3(c))), 1.0);
vec3 c = floor(1.5 * color.rgb); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(any(bvec3(c))), 1.0);
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _any(in bvec3 a)
{
bool temp = false;
bool temp = false;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[2]) temp = true;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[2]) temp = true;
return temp;
return temp;
}
void main (void)
{
vec3 c = floor(1.5 * color.rgb); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(_any(bvec3(c))), 1.0);
vec3 c = floor(1.5 * color.rgb); // 1/3 true, 2/3 false
gl_FragColor = vec4(vec3(_any(bvec3(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(1.5 * gtf_Color.rgb); // 1/3 true, 2/3 false
color = vec4(vec3(any(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = floor(1.5 * gtf_Color.rgb); // 1/3 true, 2/3 false
color = vec4(vec3(any(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,18 +30,18 @@ varying vec4 color;
bool _any(in bvec3 a)
{
bool temp = false;
bool temp = false;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[2]) temp = true;
if(a[0]) temp = true;
if(a[1]) temp = true;
if(a[2]) temp = true;
return temp;
return temp;
}
void main (void)
{
vec3 c = floor(1.5 * gtf_Color.rgb); // 1/3 true, 2/3 false
color = vec4(vec3(_any(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = floor(1.5 * gtf_Color.rgb); // 1/3 true, 2/3 false
color = vec4(vec3(_any(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,16 +30,16 @@ varying vec4 color;
void main (void)
{
int i=0;
float new_mad[2];
float gray = 0.0;
int i=0;
float new_mad[2];
float gray = 0.0;
new_mad[0]=float(1);
new_mad[1]=float(2);
new_mad[0]=float(1);
new_mad[1]=float(2);
if( (new_mad[0] == 1.0) && (new_mad[1] == 2.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray,gray , gray, 1.0);
if( (new_mad[0] == 1.0) && (new_mad[1] == 2.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray,gray , gray, 1.0);
}

View file

@ -29,16 +29,16 @@ varying vec4 color;
void main (void)
{
int i=0;
float new_mad[2];
float gray = 0.0;
int i=0;
float new_mad[2];
float gray = 0.0;
new_mad[0]=float(1);
new_mad[1]=float(2);
new_mad[0]=float(1);
new_mad[1]=float(2);
if( (new_mad[0] == 1.0) && (new_mad[1] == 2.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
if( (new_mad[0] == 1.0) && (new_mad[1] == 2.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -31,15 +31,15 @@ uniform float new_mad2[2];
void main (void)
{
int i=0;
float new_mad[2];
float gray = 0.0;
int i=0;
float new_mad[2];
float gray = 0.0;
new_mad[0]=new_mad2[0];
new_mad[1]=new_mad2[1];
new_mad[0]=new_mad2[0];
new_mad[1]=new_mad2[1];
if( (new_mad[0] == 45.0) && (new_mad[1] == 14.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray, gray, gray, 1.0);
if( (new_mad[0] == 45.0) && (new_mad[1] == 14.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray, gray, gray, 1.0);
}

View file

@ -31,17 +31,17 @@ uniform float new_mad2[array_size];
void main (void)
{
int i=0;
float new_mad[array_size];
float gray = 0.0;
int i=0;
float new_mad[array_size];
float gray = 0.0;
new_mad[0] = new_mad2[0];
new_mad[1] = new_mad2[1];
new_mad[0] = new_mad2[0];
new_mad[1] = new_mad2[1];
if( (new_mad[0] == 45.0) && (new_mad[1] == 14.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
if( (new_mad[0] == 45.0) && (new_mad[1] == 14.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -32,19 +32,19 @@ varying vec4 color;
void initialise_array(out float array[2], float init_val);
void main (void)
{
int i=0;
float new_mad[2];
float gray = 0.0;
initialise_array(new_mad,25.0);
if( (new_mad[0] == 25.0) && (new_mad[1] == 25.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray, gray, gray, 1.0);
int i=0;
float new_mad[2];
float gray = 0.0;
initialise_array(new_mad,25.0);
if( (new_mad[0] == 25.0) && (new_mad[1] == 25.0) )
gray=1.0;
else gray=0.0;
gl_FragColor = vec4(gray, gray, gray, 1.0);
}
void initialise_array(out float array[2], float init_val)
{
int i=0;
array[0] = init_val;
array[1] = init_val;
int i=0;
array[0] = init_val;
array[1] = init_val;
}

View file

@ -31,19 +31,19 @@ void initialise_array(out float array[2], float init_val);
void main (void)
{
int i=0;
float new_mad[2];
float gray = 0.0;
initialise_array(new_mad,25.0);
if( (new_mad[0] == 25.0) && (new_mad[1] == 25.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
int i=0;
float new_mad[2];
float gray = 0.0;
initialise_array(new_mad,25.0);
if( (new_mad[0] == 25.0) && (new_mad[1] == 25.0) )
gray=1.0;
else gray=0.0;
color = vec4(gray, gray, gray, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}
void initialise_array(out float array[2], float init_val)
{
array[0] = init_val;
array[1] = init_val;
array[0] = init_val;
array[1] = init_val;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}

View file

@ -39,72 +39,72 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
gl_FragColor = vec4(asin_c / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_FragColor = vec4(asin_c / M_PI + 0.5, 0.0, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,28 +30,28 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
float asin_c = 0.0;
float scale = 1.0;
float sign = 1.0;
float asin_c = 0.0;
float scale = 1.0;
float sign = 1.0;
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
color = vec4(sign * asin_c / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(sign * asin_c / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 0.0, 1.0);
}

View file

@ -39,108 +39,108 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
gl_FragColor = vec4(asin_c / M_PI + 0.5, 0.0, 1.0);
gl_FragColor = vec4(asin_c / M_PI + 0.5, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,42 +30,42 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 asin_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 asin_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
color = vec4(sign * asin_c / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(sign * asin_c / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(asin(c) / M_PI + 0.5, 1.0);
}

View file

@ -39,144 +39,144 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
gl_FragColor = vec4(asin_c / M_PI + 0.5, 1.0);
gl_FragColor = vec4(asin_c / M_PI + 0.5, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(asin(c) / M_PI + 0.5, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,57 +30,57 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 asin_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 asin_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
// Taylors series expansion for asin
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
asin_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
color = vec4(sign * asin_c / M_PI + 0.5, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(sign * asin_c / M_PI + 0.5, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (color.r - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (color.r - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}

View file

@ -30,43 +30,43 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (color.r - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result;
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (color.r - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result;
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
if(c <= 1.0)
{
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
if(c <= 1.0)
{
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * atan_c / M_PI + 0.5, 0.0, 0.0, 1.0);
}
else
{
c = 1.0 / c;
result = vec4(sign * atan_c / M_PI + 0.5, 0.0, 0.0, 1.0);
}
else
{
c = 1.0 / c;
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}
gl_FragColor = result;
gl_FragColor = result;
}

View file

@ -34,15 +34,15 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (color.g - 0.5);
float y = 2.0 * (color.b - 0.5);
const float epsilon = 1.0e-4;
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (color.g - 0.5);
float y = 2.0 * (color.b - 0.5);
const float epsilon = 1.0e-4;
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
gl_FragColor = vec4(atan(y, x) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
gl_FragColor = vec4(atan(y, x) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
}

View file

@ -34,55 +34,55 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (color.g - 0.5);
float y = 2.0 * (color.b - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (color.g - 0.5);
float y = 2.0 * (color.b - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
if(x < 0.0 ^^ y < 0.0)
{
sign = -1.0;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
if(x < 0.0 ^^ y < 0.0)
{
sign = -1.0;
}
if(abs(y) <= abs(x))
{
float c = abs(y / x);
if(abs(y) <= abs(x))
{
float c = abs(y / x);
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * atan_c / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
else
{
float c = abs(x / y);
result = vec4(sign * atan_c / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
else
{
float c = abs(x / y);
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
if(x < 0.0)
if(y < 0.0) result.r -= 0.5;
else if(y > 0.0) result.r += 0.5;
}
if(x < 0.0)
if(y < 0.0) result.r -= 0.5;
else if(y > 0.0) result.r += 0.5;
}
gl_FragColor = result;
gl_FragColor = result;
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (gtf_Color.r - 0.5);
color = vec4(atan(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (gtf_Color.r - 0.5);
color = vec4(atan(c) / M_PI + 0.5, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,44 +30,44 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (gtf_Color.r - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result;
const float M_PI = 3.14159265358979323846;
float c = 4.0 * 2.0 * (gtf_Color.r - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result;
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
if(c <= 1.0)
{
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
if(c <= 1.0)
{
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * atan_c / M_PI + 0.5, 0.0, 0.0, 1.0);
}
else
{
c = 1.0 / c;
result = vec4(sign * atan_c / M_PI + 0.5, 0.0, 0.0, 1.0);
}
else
{
c = 1.0 / c;
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / M_PI + 0.5, 0.0, 0.0, 1.0);
}
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (gtf_Color.g - 0.5);
float y = 2.0 * (gtf_Color.b - 0.5);
const float epsilon = 1.0e-4;
color = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (gtf_Color.g - 0.5);
float y = 2.0 * (gtf_Color.b - 0.5);
const float epsilon = 1.0e-4;
color = vec4(0.0, 0.0, 0.0, 1.0);
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
color = vec4(atan(y, x) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
color = vec4(atan(y, x) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,56 +30,56 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (gtf_Color.g - 0.5);
float y = 2.0 * (gtf_Color.b - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
const float M_PI = 3.14159265358979323846;
float x = 2.0 * (gtf_Color.g - 0.5);
float y = 2.0 * (gtf_Color.b - 0.5);
float atan_c = 0.0;
float scale = 1.0;
float sign = 1.0;
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
if(x < 0.0 ^^ y < 0.0)
{
sign = -1.0;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x > epsilon || abs(y) > epsilon)
{
if(x < 0.0 ^^ y < 0.0)
{
sign = -1.0;
}
if(abs(y) <= abs(x))
{
float c = abs(y / x);
if(abs(y) <= abs(x))
{
float c = abs(y / x);
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * atan_c / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
else
{
float c = abs(x / y);
result = vec4(sign * atan_c / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
else
{
float c = abs(x / y);
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
// Taylors series expansion for atan
for(int i = 1; i < 12; i += 2)
{
atan_c += scale * pow(c, float(i)) / float(i);
scale *= -1.0;
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
result = vec4(sign * (M_PI / 2.0 - atan_c) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
}
if(x < 0.0)
if(y < 0.0) result.r -= 0.5;
else if(y > 0.0) result.r += 0.5;
}
if(x < 0.0)
if(y < 0.0) result.r -= 0.5;
else if(y > 0.0) result.r += 0.5;
}
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 0.0, 1.0);
}

View file

@ -30,103 +30,103 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (color.rg - 0.5);
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (color.rg - 0.5);
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
if(c[0] < 0.0)
{
sign[0] = -1.0;
c[0] *= -1.0;
}
if(c[0] < 0.0)
{
sign[0] = -1.0;
c[0] *= -1.0;
}
if(c[0] <= 1.0)
{
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
if(c[0] <= 1.0)
{
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * atan_c[0] / M_PI + 0.5;
}
else
{
c[0] = 1.0 / c[0];
result[0] = sign[0] * atan_c[0] / M_PI + 0.5;
}
else
{
c[0] = 1.0 / c[0];
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / M_PI + 0.5;
}
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / M_PI + 0.5;
}
if(c[1] < 0.0)
{
sign[1] = -1.0;
c[1] *= -1.0;
}
if(c[1] < 0.0)
{
sign[1] = -1.0;
c[1] *= -1.0;
}
if(c[1] <= 1.0)
{
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
if(c[1] <= 1.0)
{
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * atan_c[1] / M_PI + 0.5;
}
else
{
c[1] = 1.0 / c[1];
result[1] = sign[1] * atan_c[1] / M_PI + 0.5;
}
else
{
c[1] = 1.0 / c[1];
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / M_PI + 0.5;
}
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / M_PI + 0.5;
}
gl_FragColor = result;
gl_FragColor = result;
}

View file

@ -30,20 +30,20 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (color.gg - 0.5);
vec2 y = 2.0 * (color.bb - 0.5);
const float epsilon = 1.0e-4;
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (color.gg - 0.5);
vec2 y = 2.0 * (color.bb - 0.5);
const float epsilon = 1.0e-4;
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
gl_FragColor[0] = atan(y[0], x[0]) / (2.0 * M_PI) + 0.5;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
gl_FragColor[0] = atan(y[0], x[0]) / (2.0 * M_PI) + 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
gl_FragColor[1] = atan(y[1], x[1]) / (2.0 * M_PI) + 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
gl_FragColor[1] = atan(y[1], x[1]) / (2.0 * M_PI) + 0.5;
}
}

View file

@ -30,121 +30,121 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (color.gg - 0.5);
vec2 y = 2.0 * (color.bb - 0.5);
vec2 c;
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (color.gg - 0.5);
vec2 y = 2.0 * (color.bb - 0.5);
vec2 c;
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
if(x[0] < 0.0 ^^ y[0] < 0.0)
{
sign[0] = -1.0;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
if(x[0] < 0.0 ^^ y[0] < 0.0)
{
sign[0] = -1.0;
}
if(abs(y[0]) <= abs(x[0]))
{
c[0] = abs(y[0] / x[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
if(abs(y[0]) <= abs(x[0]))
{
c[0] = abs(y[0] / x[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * atan_c[0] / (2.0 * M_PI) + 0.5;
}
else
{
c[0] = abs(x[0] / y[0]);
result[0] = sign[0] * atan_c[0] / (2.0 * M_PI) + 0.5;
}
else
{
c[0] = abs(x[0] / y[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / (2.0 * M_PI) + 0.5;
}
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / (2.0 * M_PI) + 0.5;
}
if(x[0] < 0.0)
if(y[0] < 0.0) result[0] -= 0.5;
else if(y[0] > 0.0) result[0] += 0.5;
}
if(x[0] < 0.0)
if(y[0] < 0.0) result[0] -= 0.5;
else if(y[0] > 0.0) result[0] += 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
if(x[1] < 0.0 ^^ y[1] < 0.0)
{
sign[1] = -1.0;
}
if(x[1] < 0.0 ^^ y[1] < 0.0)
{
sign[1] = -1.0;
}
if(abs(y[1]) <= abs(x[1]))
{
c[1] = abs(y[1] / x[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
if(abs(y[1]) <= abs(x[1]))
{
c[1] = abs(y[1] / x[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * atan_c[1] / (2.0 * M_PI) + 0.5;
}
else
{
c[1] = abs(x[1] / y[1]);
result[1] = sign[1] * atan_c[1] / (2.0 * M_PI) + 0.5;
}
else
{
c[1] = abs(x[1] / y[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / (2.0 * M_PI) + 0.5;
}
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / (2.0 * M_PI) + 0.5;
}
if(x[1] < 0.0)
if(y[1] < 0.0) result[1] -= 0.5;
else if(y[1] > 0.0) result[1] += 0.5;
}
if(x[1] < 0.0)
if(y[1] < 0.0) result[1] -= 0.5;
else if(y[1] > 0.0) result[1] += 0.5;
}
gl_FragColor = result;
gl_FragColor = result;
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (gtf_Color.rg - 0.5);
color = vec4(atan(c) / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (gtf_Color.rg - 0.5);
color = vec4(atan(c) / M_PI + 0.5, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,104 +30,104 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (gtf_Color.rg - 0.5);
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 4.0 * 2.0 * (gtf_Color.rg - 0.5);
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
if(c[0] < 0.0)
{
sign[0] = -1.0;
c[0] *= -1.0;
}
if(c[0] < 0.0)
{
sign[0] = -1.0;
c[0] *= -1.0;
}
if(c[0] <= 1.0)
{
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
if(c[0] <= 1.0)
{
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * atan_c[0] / M_PI + 0.5;
}
else
{
c[0] = 1.0 / c[0];
result[0] = sign[0] * atan_c[0] / M_PI + 0.5;
}
else
{
c[0] = 1.0 / c[0];
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / M_PI + 0.5;
}
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / M_PI + 0.5;
}
if(c[1] < 0.0)
{
sign[1] = -1.0;
c[1] *= -1.0;
}
if(c[1] < 0.0)
{
sign[1] = -1.0;
c[1] *= -1.0;
}
if(c[1] <= 1.0)
{
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
if(c[1] <= 1.0)
{
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * atan_c[1] / M_PI + 0.5;
}
else
{
c[1] = 1.0 / c[1];
result[1] = sign[1] * atan_c[1] / M_PI + 0.5;
}
else
{
c[1] = 1.0 / c[1];
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / M_PI + 0.5;
}
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / M_PI + 0.5;
}
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,22 +30,22 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (gtf_Color.gg - 0.5);
vec2 y = 2.0 * (gtf_Color.bb - 0.5);
const float epsilon = 1.0e-4;
color = vec4(0.0, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (gtf_Color.gg - 0.5);
vec2 y = 2.0 * (gtf_Color.bb - 0.5);
const float epsilon = 1.0e-4;
color = vec4(0.0, 0.0, 0.0, 1.0);
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
color[0] = atan(y[0], x[0]) / (2.0 * M_PI) + 0.5;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
color[0] = atan(y[0], x[0]) / (2.0 * M_PI) + 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
color[1] = atan(y[1], x[1]) / (2.0 * M_PI) + 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
color[1] = atan(y[1], x[1]) / (2.0 * M_PI) + 0.5;
}
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,121 +30,121 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (gtf_Color.gg - 0.5);
vec2 y = 2.0 * (gtf_Color.bb - 0.5);
vec2 c;
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
const float M_PI = 3.14159265358979323846;
vec2 x = 2.0 * (gtf_Color.gg - 0.5);
vec2 y = 2.0 * (gtf_Color.bb - 0.5);
vec2 c;
vec2 atan_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
vec4 result = vec4(0.0, 0.0, 0.0, 1.0);
const float epsilon = 1.0e-4;
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
if(x[0] < 0.0 ^^ y[0] < 0.0)
{
sign[0] = -1.0;
}
// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
if(x[0] > epsilon || abs(y[0]) > epsilon)
{
if(x[0] < 0.0 ^^ y[0] < 0.0)
{
sign[0] = -1.0;
}
if(abs(y[0]) <= abs(x[0]))
{
c[0] = abs(y[0] / x[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
if(abs(y[0]) <= abs(x[0]))
{
c[0] = abs(y[0] / x[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * atan_c[0] / (2.0 * M_PI) + 0.5;
}
else
{
c[0] = abs(x[0] / y[0]);
result[0] = sign[0] * atan_c[0] / (2.0 * M_PI) + 0.5;
}
else
{
c[0] = abs(x[0] / y[0]);
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
// Taylors series expansion for atan
atan_c[0] += scale[0] * pow(c[0], float(1)) / float(1);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(3)) / float(3);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(5)) / float(5);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(7)) / float(7);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(9)) / float(9);
scale[0] *= -1.0;
atan_c[0] += scale[0] * pow(c[0], float(11)) / float(11);
scale[0] *= -1.0;
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / (2.0 * M_PI) + 0.5;
}
result[0] = sign[0] * (M_PI / 2.0 - atan_c[0]) / (2.0 * M_PI) + 0.5;
}
if(x[0] < 0.0)
if(y[0] < 0.0) result[0] -= 0.5;
else if(y[0] > 0.0) result[0] += 0.5;
}
if(x[0] < 0.0)
if(y[0] < 0.0) result[0] -= 0.5;
else if(y[0] > 0.0) result[0] += 0.5;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
if(x[1] < 0.0 ^^ y[1] < 0.0)
{
sign[1] = -1.0;
}
if(x[1] > epsilon || abs(y[1]) > epsilon)
{
if(x[1] < 0.0 ^^ y[1] < 0.0)
{
sign[1] = -1.0;
}
if(abs(y[1]) <= abs(x[1]))
{
c[1] = abs(y[1] / x[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
if(abs(y[1]) <= abs(x[1]))
{
c[1] = abs(y[1] / x[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * atan_c[1] / (2.0 * M_PI) + 0.5;
}
else
{
c[1] = abs(x[1] / y[1]);
result[1] = sign[1] * atan_c[1] / (2.0 * M_PI) + 0.5;
}
else
{
c[1] = abs(x[1] / y[1]);
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
// Taylors series expansion for atan
atan_c[1] += scale[1] * pow(c[1], float(1)) / float(1);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(3)) / float(3);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(5)) / float(5);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(7)) / float(7);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(9)) / float(9);
scale[1] *= -1.0;
atan_c[1] += scale[1] * pow(c[1], float(11)) / float(11);
scale[1] *= -1.0;
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / (2.0 * M_PI) + 0.5;
}
result[1] = sign[1] * (M_PI / 2.0 - atan_c[1]) / (2.0 * M_PI) + 0.5;
}
if(x[1] < 0.0)
if(y[1] < 0.0) result[1] -= 0.5;
else if(y[1] > 0.0) result[1] += 0.5;
}
if(x[1] < 0.0)
if(y[1] < 0.0) result[1] -= 0.5;
else if(y[1] > 0.0) result[1] += 0.5;
}
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = result;
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 4.0 * 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 4.0 * 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(atan(c) / M_PI + 0.5, 1.0);
}

Some files were not shown because too many files have changed in this diff Show more