Skip to content

Commit

Permalink
renderer: Rename option 'perspectiveCorrectTexturing'...
Browse files Browse the repository at this point in the history
...to 'perspectiveCorrectInterpolation'. Since it now controls all
interpolation, not just that of textures.
  • Loading branch information
leikareipa committed Jun 13, 2020
1 parent 70b1101 commit 74fadc3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ Renders one or more n-gon meshes onto an existing canvas element.
| *boolean* | hibernateWhenNotOnScreen | If true, rendering will be skipped if the target canvas is not at least partially within the current viewport. Defaults to *true*. |
| *number* | nearPlane | Distance from the camera to the near plane. Vertices closer to the camera will be clipped. Defaults to *1*.|
| *number* | farPlane | Distance from the camera to the far plane. Vertices further from the camera will be clipped. Defaults to *1000*.|
| *number* | perspectiveCorrectTexturing | When set to true, textures whose texture-mapping mode is "affine" will be rendered with perspective correction. This results in less view-dependent texture distortion but will likely reduce performance. Defaults to *false*.|
| *number* | perspectiveCorrectInterpolation | When set to true, any properties that are linearly interpolated between vertices (e.g. texture coordinates) will be perspective-corrected. This results in less view-dependent distortion, but will reduce performance to some extent. Defaults to *false*.|
| *boolean* | clipToViewport | If set to true, the renderer will clip all n-gons against the viewport prior to rendering. If none of your n-gons extend beyond the screen's boundaries, setting this to false may save you some performance. Defaults to *true*. |
| *translation_vector* | cameraPosition | The camera's position. Defaults to *vector3(0, 0, 0)*. |
| *rotation_vector* | cameraDirection | The camera's direction. Defaults to *vector3(0, 0, 0)*. |
Expand Down
10 changes: 5 additions & 5 deletions distributable/rngon.cat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// WHAT: Concatenated JavaScript source files
// PROGRAM: Retro n-gon renderer
// VERSION: beta live (13 June 2020 17:29:46 UTC)
// VERSION: beta live (13 June 2020 17:57:09 UTC)
// AUTHOR: Tarpeeksi Hyvae Soft and others
// LINK: https://www.github.com/leikareipa/retro-ngon/
// FILES:
Expand Down Expand Up @@ -115,7 +115,7 @@ Rngon.internalState =
// use any shaders.
useShaders: false,

usePerspectiveCorrectTexturing: false,
usePerspectiveCorrectInterpolation: false,

// If set to true, all n-gons will be rendered with a wireframe.
showGlobalWireframe: false,
Expand Down Expand Up @@ -1076,7 +1076,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])

function add_edge(vert1, vert2, isLeftEdge)
{
const interpolatePerspective = Rngon.internalState.usePerspectiveCorrectTexturing;
const interpolatePerspective = Rngon.internalState.usePerspectiveCorrectInterpolation;
const startY = Math.min(renderHeight, Math.max(0, Math.round(vert1.y)));
const endY = Math.min(renderHeight, Math.max(0, Math.round(vert2.y)));
const edgeHeight = (endY - startY);
Expand Down Expand Up @@ -1556,7 +1556,7 @@ Rngon.render = function(canvasElementId,
Rngon.internalState.useDepthBuffer = (options.useDepthBuffer == true);
Rngon.internalState.showGlobalWireframe = (options.globalWireframe == true);
Rngon.internalState.applyViewportClipping = (options.clipToViewport == true);
Rngon.internalState.usePerspectiveCorrectTexturing = (options.perspectiveCorrectTexturing == true);
Rngon.internalState.usePerspectiveCorrectInterpolation = (options.perspectiveCorrectInterpolation == true);
Rngon.internalState.lights = options.lights;
Rngon.internalState.farPlaneDistance = options.farPlane;

Expand Down Expand Up @@ -1738,7 +1738,7 @@ Rngon.render.defaultOptions =
clipToViewport: true,
globalWireframe: false,
hibernateWhenNotOnScreen: true,
perspectiveCorrectTexturing: false,
perspectiveCorrectInterpolation: false,
auxiliaryBuffers: [],
lights: [],
};
Expand Down
6 changes: 3 additions & 3 deletions js/retro-ngon/ngon-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])

function add_edge(vert1, vert2, isLeftEdge)
{
const interpolatePerspective = Rngon.internalState.usePerspectiveCorrectTexturing;
const interpolatePerspective = Rngon.internalState.usePerspectiveCorrectInterpolation;
const startY = Math.min(renderHeight, Math.max(0, Math.round(vert1.y)));
const endY = Math.min(renderHeight, Math.max(0, Math.round(vert2.y)));
const edgeHeight = (endY - startY);
Expand Down Expand Up @@ -140,7 +140,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
const [startV, deltaV] = interpolants(v1, v2, interpolatePerspective);

// (1 / W), for perspective-correct mapping.
const [startInvW, deltaInvW] = interpolatePerspective? interpolants(1, 1, true) : [1, 0];
const [startInvW, deltaInvW] = (interpolatePerspective? interpolants(1, 1, true) : [1, 0]);

(isLeftEdge? leftEdges : rightEdges).push({
startY, endY,
Expand Down Expand Up @@ -171,7 +171,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
{
return [
(start / vert1.w),
(((end / vert2.w) - (start / vert1.w)) / edgeHeight)
(((end / vert2.w) - (start / vert1.w)) / edgeHeight)
];
}
else
Expand Down
4 changes: 2 additions & 2 deletions js/retro-ngon/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Rngon.render = function(canvasElementId,
Rngon.internalState.useDepthBuffer = (options.useDepthBuffer == true);
Rngon.internalState.showGlobalWireframe = (options.globalWireframe == true);
Rngon.internalState.applyViewportClipping = (options.clipToViewport == true);
Rngon.internalState.usePerspectiveCorrectTexturing = (options.perspectiveCorrectTexturing == true);
Rngon.internalState.usePerspectiveCorrectInterpolation = (options.perspectiveCorrectInterpolation == true);
Rngon.internalState.lights = options.lights;
Rngon.internalState.farPlaneDistance = options.farPlane;

Expand Down Expand Up @@ -221,7 +221,7 @@ Rngon.render.defaultOptions =
clipToViewport: true,
globalWireframe: false,
hibernateWhenNotOnScreen: true,
perspectiveCorrectTexturing: false,
perspectiveCorrectInterpolation: false,
auxiliaryBuffers: [],
lights: [],
};
2 changes: 1 addition & 1 deletion js/retro-ngon/retro-ngon.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Rngon.internalState =
// use any shaders.
useShaders: false,

usePerspectiveCorrectTexturing: false,
usePerspectiveCorrectInterpolation: false,

// If set to true, all n-gons will be rendered with a wireframe.
showGlobalWireframe: false,
Expand Down
4 changes: 2 additions & 2 deletions samples/sample-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
clipToViewport: true,
depthSort: "painter-reverse",
useDepthBuffer: true,
perspectiveCorrectTexturing: true,
perspectiveCorrectInterpolation: true,
cameraDirection: renderSettings.cameraDirection,
cameraPosition: renderSettings.cameraPosition,
scale: renderSettings.scale,
Expand All @@ -102,4 +102,4 @@
})();
</script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions tests/integration/render-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@

const quadMesh = Rngon.mesh([quad], {...meshSettings, rotation: Rngon.rotation_vector(0, 30, 45)});

Rngon.render(canvasId, [quadMesh], {...renderSettings, perspectiveCorrectTexturing: false});
Rngon.render(canvasId, [quadMesh], {...renderSettings, perspectiveCorrectInterpolation: false});
}),
await compare("Quad with perspective-correct affine mapping (9a920763abbe)",
"./render-output/reference-9a920763abbe.png",
Expand All @@ -250,7 +250,7 @@

const quadMesh = Rngon.mesh([quad], {...meshSettings, rotation: Rngon.rotation_vector(0, 30, 45)});

Rngon.render(canvasId, [quadMesh], {...renderSettings, perspectiveCorrectTexturing: true});
Rngon.render(canvasId, [quadMesh], {...renderSettings, perspectiveCorrectInterpolation: true});
}),
await compare("Quad with default material (6e88gkgb8c6c)",
"./render-output/reference-6e88gkgb8c6c.png",
Expand Down

0 comments on commit 74fadc3

Please sign in to comment.