mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 12:34:06 +01:00
- [RM Primitive] Fix texture not fix to object position.
This commit is contained in:
parent
3ff3f6c3a3
commit
bef9953075
@ -130,6 +130,7 @@ function RM_Object() constructor {
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
shader_set_surface("texture1", textureAtl);
|
||||
shader_set_i("textureFilter", textureFilter);
|
||||
shader_set_i("useTexture", useTexture);
|
||||
shader_set_f("textureScale", textureScale);
|
||||
shader_set_f("triplanar", triplanar);
|
||||
@ -228,6 +229,7 @@ function RM_Environment() constructor {
|
||||
surface = noone;
|
||||
bgEnv = noone;
|
||||
|
||||
envFilter = false;
|
||||
projection = 0;
|
||||
fov = 0;
|
||||
orthoScale = 1;
|
||||
@ -256,6 +258,7 @@ function RM_Environment() constructor {
|
||||
shader_set_f("ambientIntns", ambInten);
|
||||
shader_set_f("lightPosition", light);
|
||||
|
||||
shader_set_i("envFilter", envFilter);
|
||||
shader_set_i("useEnv", is_surface(bgEnv));
|
||||
shader_set_i("drawGrid", false);
|
||||
|
||||
|
@ -20,7 +20,7 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_RM(_x, _y, _group) const
|
||||
inputs[| 5] = nodeValue("Depth", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 6] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
inputs[| 6] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 7] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
||||
|
||||
@ -136,8 +136,9 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_RM(_x, _y, _group) const
|
||||
object.flatten();
|
||||
object.setTexture(temp_surface[1]);
|
||||
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = _env;
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = _env;
|
||||
environ.envFilter = _eint;
|
||||
|
||||
environ.projection = _pro;
|
||||
environ.fov = _fov;
|
||||
|
@ -110,7 +110,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
||||
|
||||
inputs[| 30] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
||||
|
||||
inputs[| 31] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
inputs[| 31] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -683,8 +683,9 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
||||
|
||||
object.setTexture(temp_surface[1]);
|
||||
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = bgEnv;
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = bgEnv;
|
||||
environ.envFilter = _eint;
|
||||
|
||||
environ.projection = _ort;
|
||||
environ.fov = _fov;
|
||||
|
@ -20,7 +20,7 @@ function Node_RM_Render(_x, _y, _group = noone) : Node_RM(_x, _y, _group) constr
|
||||
inputs[| 5] = nodeValue("Depth", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 6] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
inputs[| 6] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 7] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
||||
|
||||
@ -104,8 +104,9 @@ function Node_RM_Render(_x, _y, _group = noone) : Node_RM(_x, _y, _group) constr
|
||||
object.flatten();
|
||||
object.setTexture(temp_surface[1]);
|
||||
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = _env;
|
||||
environ.surface = temp_surface[0];
|
||||
environ.bgEnv = _env;
|
||||
environ.envFilter = _eint;
|
||||
|
||||
environ.projection = _pro;
|
||||
environ.fov = _fov;
|
||||
|
@ -72,6 +72,7 @@ uniform int volumetric[MAX_SHAPES] ;
|
||||
uniform float volumeDensity[MAX_SHAPES] ;
|
||||
|
||||
uniform int useTexture[MAX_SHAPES] ;
|
||||
uniform int textureFilter[MAX_SHAPES] ;
|
||||
uniform float textureScale[MAX_SHAPES] ;
|
||||
uniform float triplanar[MAX_SHAPES] ;
|
||||
|
||||
@ -93,6 +94,7 @@ uniform float ambientIntns;
|
||||
uniform vec3 lightPosition;
|
||||
|
||||
uniform int useEnv;
|
||||
uniform int envFilter;
|
||||
uniform int drawGrid;
|
||||
uniform float gridStep;
|
||||
uniform float gridScale;
|
||||
@ -511,11 +513,11 @@ float influences[MAX_SHAPES];
|
||||
|
||||
#region ////=========== Texturing ============
|
||||
|
||||
vec4 boxmap( in int textureIndex, in vec3 p, in vec3 n, in float k ) {
|
||||
vec4 boxmap( in int textureIndex, in vec3 p, in vec3 n, in float k, int interpolation ) {
|
||||
// project+fetch
|
||||
vec4 x = sampleTexture( textureIndex, fract(p.yz), 0 );
|
||||
vec4 y = sampleTexture( textureIndex, fract(p.zx), 0 );
|
||||
vec4 z = sampleTexture( textureIndex, fract(p.xy), 0 );
|
||||
vec4 x = sampleTexture( textureIndex, fract(p.yz), interpolation );
|
||||
vec4 y = sampleTexture( textureIndex, fract(p.zx), interpolation );
|
||||
vec4 z = sampleTexture( textureIndex, fract(p.xy), interpolation );
|
||||
|
||||
// blend weights
|
||||
vec3 w = pow( abs(n), vec3(k) );
|
||||
@ -865,9 +867,16 @@ vec4 scene() {
|
||||
mat3 rotMatrix = rx * ry * rz;
|
||||
mat3 irotMatrix = inverse(rotMatrix);
|
||||
|
||||
vec3 _c = useTexture[i] == 1?
|
||||
boxmap(int(TEXTURE_S) + i, irotMatrix * coll * textureScale[i], irotMatrix * norm, triplanar[i]).rgb * diffuseColor[i].rgb :
|
||||
diffuseColor[i].rgb;
|
||||
vec3 _c = diffuseColor[i].rgb;
|
||||
|
||||
if(useTexture[i] == 1) {
|
||||
int indx = int(TEXTURE_S) + i;
|
||||
vec3 pos = irotMatrix * (coll - position[i]) * textureScale[i];
|
||||
vec3 nor = irotMatrix * norm;
|
||||
|
||||
_c = boxmap(indx, pos, nor, triplanar[i], textureFilter[i]).rgb;
|
||||
_c *= diffuseColor[i].rgb;
|
||||
}
|
||||
|
||||
c += _c * (influences[i] / totalInfluences);
|
||||
refl += reflective[i] * (influences[i] / totalInfluences);
|
||||
@ -891,7 +900,7 @@ vec4 scene() {
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
if(useEnv == 1) {
|
||||
vec4 refC = sampleTexture(0, equirectangularUv(ref), 0);
|
||||
vec4 refC = sampleTexture(0, equirectangularUv(ref), envFilter);
|
||||
c = mix(c, c * refC.rgb, refl);
|
||||
}
|
||||
|
||||
@ -939,7 +948,7 @@ void main() {
|
||||
dir = normalize(camIrotMatrix * dir);
|
||||
|
||||
vec2 envUV = equirectangularUv(dir);
|
||||
vec4 endC = sampleTexture(0, envUV, 0);
|
||||
vec4 endC = sampleTexture(0, envUV, envFilter);
|
||||
bg = endC;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user