mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [Raymarching] Add orthographic projection.
This commit is contained in:
parent
39acafebd7
commit
533fd6ec75
5 changed files with 22 additions and 14 deletions
Binary file not shown.
|
@ -7,8 +7,7 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_RM(_x, _y, _group) const
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 1] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ])
|
||||
.setVisible(false, false);
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]);
|
||||
|
||||
inputs[| 2] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 30)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 90, 1 ] });
|
||||
|
|
|
@ -59,10 +59,9 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 13] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ])
|
||||
.setVisible(false, false);
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]);
|
||||
|
||||
inputs[| 14] = nodeValue("Ortho Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 5.)
|
||||
inputs[| 14] = nodeValue("Ortho Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1.)
|
||||
|
||||
inputs[| 15] = nodeValue("Wave Amplitude", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4, 4 ])
|
||||
.setDisplay(VALUE_DISPLAY.vector);
|
||||
|
|
|
@ -7,8 +7,7 @@ function Node_RM_Render(_x, _y, _group = noone) : Node_RM(_x, _y, _group) constr
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 1] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ])
|
||||
.setVisible(false, false);
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]);
|
||||
|
||||
inputs[| 2] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 30)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 90, 1 ] });
|
||||
|
|
|
@ -780,16 +780,27 @@ vec4 scene() {
|
|||
mat3 camRotMatrix = rx * ry * rz;
|
||||
mat3 camIrotMatrix = inverse(camRotMatrix);
|
||||
|
||||
float dz = 1. / tan(radians(fov) / 2.);
|
||||
vec3 dir, eye;
|
||||
|
||||
vec2 cps = (v_vTexcoord - .5) * 2.;
|
||||
cps.x *= camRatio;
|
||||
|
||||
vec3 dir = vec3(cps, -dz);
|
||||
vec3 eye = vec3(0., 0., 5.);
|
||||
|
||||
cps.x *= camRatio;
|
||||
|
||||
if(ortho == 0) {
|
||||
float dz = 1. / tan(radians(fov) / 2.);
|
||||
|
||||
dir = vec3(cps, -dz);
|
||||
eye = vec3(0., 0., 5.);
|
||||
|
||||
} else if(ortho == 1) {
|
||||
|
||||
dir = vec3(0., 0., -1.);
|
||||
eye = vec3(cps * orthoScale, 5.);
|
||||
}
|
||||
|
||||
dir = normalize(camIrotMatrix * dir);
|
||||
eye = camIrotMatrix * eye;
|
||||
eye /= camScale;
|
||||
|
||||
eye /= camScale;
|
||||
|
||||
if(volumetric[0] == 1) {
|
||||
float _dens = clamp(marchDensity(eye, dir), 0., 1.);
|
||||
|
|
Loading…
Reference in a new issue