mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 05:49:30 -07:00
Added orthographic projection and a profile angle to the volumetric mode when effects are off.
This commit is contained in:
@@ -156,7 +156,14 @@ export default (regl, config) => {
|
|||||||
const screenSize = [1, 1];
|
const screenSize = [1, 1];
|
||||||
const { mat4, vec3 } = glMatrix;
|
const { mat4, vec3 } = glMatrix;
|
||||||
const transform = mat4.create();
|
const transform = mat4.create();
|
||||||
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
if (config.effect === "none") {
|
||||||
|
mat4.rotateX(transform, transform, (Math.PI * 1) / 8);
|
||||||
|
mat4.rotateY(transform, transform, (Math.PI * 1) / 4);
|
||||||
|
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
||||||
|
mat4.scale(transform, transform, vec3.fromValues(1, 1, 2));
|
||||||
|
} else {
|
||||||
|
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
||||||
|
}
|
||||||
const camera = mat4.create();
|
const camera = mat4.create();
|
||||||
|
|
||||||
return makePass(
|
return makePass(
|
||||||
@@ -175,7 +182,15 @@ export default (regl, config) => {
|
|||||||
(w, h) => {
|
(w, h) => {
|
||||||
output.resize(w, h);
|
output.resize(w, h);
|
||||||
const aspectRatio = w / h;
|
const aspectRatio = w / h;
|
||||||
glMatrix.mat4.perspective(camera, (Math.PI / 180) * 90, aspectRatio, 0.0001, 1000);
|
if (config.effect === "none") {
|
||||||
|
if (aspectRatio > 1) {
|
||||||
|
mat4.ortho(camera, -1.5 * aspectRatio, 1.5 * aspectRatio, -1.5, 1.5, -1000, 1000);
|
||||||
|
} else {
|
||||||
|
mat4.ortho(camera, -1.5, 1.5, -1.5 / aspectRatio, 1.5 / aspectRatio, -1000, 1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mat4.perspective(camera, (Math.PI / 180) * 90, aspectRatio, 0.0001, 1000);
|
||||||
|
}
|
||||||
[screenSize[0], screenSize[1]] = aspectRatio > 1 ? [1, aspectRatio] : [1 / aspectRatio, 1];
|
[screenSize[0], screenSize[1]] = aspectRatio > 1 ? [1, aspectRatio] : [1 / aspectRatio, 1];
|
||||||
},
|
},
|
||||||
[msdf.loaded, rainPassCompute.loaded, rainPassVert.loaded, rainPassFrag.loaded]
|
[msdf.loaded, rainPassCompute.loaded, rainPassVert.loaded, rainPassFrag.loaded]
|
||||||
|
|||||||
@@ -52,7 +52,14 @@ export default (context, getInputs) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const transform = mat4.create();
|
const transform = mat4.create();
|
||||||
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
if (config.effect === "none") {
|
||||||
|
mat4.rotateX(transform, transform, (Math.PI * 1) / 8);
|
||||||
|
mat4.rotateY(transform, transform, (Math.PI * 1) / 4);
|
||||||
|
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
||||||
|
mat4.scale(transform, transform, vec3.fromValues(1, 1, 2));
|
||||||
|
} else {
|
||||||
|
mat4.translate(transform, transform, vec3.fromValues(0, 0, -1));
|
||||||
|
}
|
||||||
const camera = mat4.create();
|
const camera = mat4.create();
|
||||||
|
|
||||||
const linearSampler = device.createSampler({
|
const linearSampler = device.createSampler({
|
||||||
@@ -130,7 +137,15 @@ export default (context, getInputs) => {
|
|||||||
const setSize = (width, height) => {
|
const setSize = (width, height) => {
|
||||||
// Update scene buffer: camera and transform math for the volumetric mode
|
// Update scene buffer: camera and transform math for the volumetric mode
|
||||||
const aspectRatio = width / height;
|
const aspectRatio = width / height;
|
||||||
mat4.perspectiveZO(camera, (Math.PI / 180) * 90, aspectRatio, 0.0001, 1000);
|
if (config.effect === "none") {
|
||||||
|
if (aspectRatio > 1) {
|
||||||
|
mat4.orthoZO(camera, -1.5 * aspectRatio, 1.5 * aspectRatio, -1.5, 1.5, -1000, 1000);
|
||||||
|
} else {
|
||||||
|
mat4.orthoZO(camera, -1.5, 1.5, -1.5 / aspectRatio, 1.5 / aspectRatio, -1000, 1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mat4.perspectiveZO(camera, (Math.PI / 180) * 90, aspectRatio, 0.0001, 1000);
|
||||||
|
}
|
||||||
const screenSize = aspectRatio > 1 ? [1, aspectRatio] : [1 / aspectRatio, 1];
|
const screenSize = aspectRatio > 1 ? [1, aspectRatio] : [1 / aspectRatio, 1];
|
||||||
device.queue.writeBuffer(sceneBuffer, 0, sceneUniforms.write({ screenSize, camera, transform }));
|
device.queue.writeBuffer(sceneBuffer, 0, sceneUniforms.write({ screenSize, camera, transform }));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user