Forum Replies Created
-
AuthorPosts
-
origginParticipant
You can also try changing the clones’ names. I THINK I got around this bug by doing this once..
This would not work for me because the object names are unique and got constructed using logic. Even the cloned ones are built in the scene using the clone index number as a reference for the floor.
Unfortunately this same naming logic is being used for other 900+ objects and their state info is eventually sent to other interfaces to be processed for calculations (the project is a product configurator).
So, changing their names would represent some big changes in the whole project across different environments :(
By the way, I tried to rename them to their same name (there could be some kind of hidden proxy or observer on the name property) and nothing changed :(
I will have to wait for a solution from the Verge3D team.
Thanks anyway ;)
origginParticipantnope, getting 403 Forbidden error
:(
Sorry, I am uploading them to the forum. Can you see them now?
Attachments:
You must be logged in to view attached files.origginParticipantlooks like the images were not attached
Weird, they appear to me, their link:
https://image.prntscr.com/image/DcVdjOVIR66BCXFNylcSwA.png
https://image.prntscr.com/image/Rs6w74TSTnOCfBv7FNxU-w.pngCan you open it?
origginParticipantcan you post a screenshot of your puzzles?
I did not get what you exactly need from my puzzles. I posted a screenshot in my last reply.
Here is another one with the puzzles that will play the animations in my scene
2020-09-10 at 12:43 pm in reply to: Register an ExternalInterface function in a Vue-Verge application ! #32680origginParticipantissue 1: the Functions registered in the “prepareExternalInterface” are not recognized in the Puzzle interface.
You need to declare your functions as below
app.ExternalInterface.logSum = function (value1, value2) { console.log(value1 + value2) }
and call them using their respective puzzles
issue 2: the app instance is not accessible through the V3DApp.vue.
This was not clear for me, but you can access you v3d app using
v3d.apps[0]
origginParticipantHi,
when an object is cloned, a new name is assigned to it automatically and returned by the clone puzzle.
So you can use this new name and the get animations puzzle to obtain a new animation clip to play.I had already tried this and it did not work :(
origginParticipantHi, Curious, Which browser dev tools are you using to show object relationships? Thanks
Sorry for the late response, I use chrome and everything logged there was generated in JS and puzzles.
origginParticipantHi,
what if you try unparenting first, then cloning the parent and the children separately, and finally parenting the clones?Yope, this worked fine, thank you ;)
origginParticipantHi,
you can possibly clone the child objects as well, and then unparent the original children and parent the newly cloned children to your parent object. This can be done with this puzzle: https://www.soft8soft.com/docs/manual/en/puzzles/Objects.html#parent (for unparenting just leave the second slot empty)Hi Yuri, I tried what you suggest but unfortunately did not work.
As you can see in the screenshot from the console, the original children objects keep appearing under the cloned parent object.
Is there a way to do the inverse from what you suggested? Removing the children from the parents instead removing the parent from the children?
Or did I do something wrong?
origginParticipantI created a variable called v3d inside the vue data object and then ran a function which waits until the global object v3d.apps gets created and when it is there, it references the v3d app external interface to the created variable, as below:
this.v3d = v3d.apps[0].ExternalInterface
So, every time when you need to run a function, you just need to run this.v3d.myFunction().
But this was the solution I found some time ago, before existing an official integration with vue.js available
origginParticipantJust to give my feedback: everything is working fine after the update. Thanks again ;)
origginParticipantI also tried this last week but I did not manage to do it.
This setup worked well in blender using shape keys but unfortunately not in Verge3D (looks like a kind of bug or limitation for me). The object does not change when I manipulate the shape keys values.
Maybe you can try to explore further in this direction or find another solution (what I did).
origginParticipantHi origgin, Thanks for the test example! We are able to reproduce this error. It’ll be fixed in the next 3.3.1 update, which is planned next monday.
Hi. Nice, I will test it again after the update and let you know if it worked, thanks for the nice support ;)
origginParticipantHi, looks like some shader bug. Can you isolate crashing material and send us the minimal Blend file with it?
If you need something else, let me know. Thank you ;)
PS: I am using more than one material because the plane was clipping only one object, so I added another material to the other object, which had to be clipped in order to work. But the problem exists since it was only one material and it clipped only one object.
Attachments:
You must be logged in to view attached files.origginParticipantI noticed that some time after I run this code, I get the following error
The code:
var localPlane = new v3d.Plane(new v3d.Vector3(0, -5, 0), 0.8); v3d.apps[0].renderer.localClippingEnabled = true v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'CHAINS_SIDE').clippingPlanes = [localPlane] v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'CHAINS_FRONT').clippingPlanes = [localPlane]
The error:
v3d.js:1 v3d.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog No compiled fragment shader when at least one graphics shader is attached. v3d.WebGLShader: gl.getShaderInfoLog() vertex ERROR: 0:348: 'vViewPosition' : redefinition 1: #version 300 es 2: 3: #define attribute in 4: #define varying out 5: #define texture2D texture 6: precision highp float; 7: precision highp int; 8: #define HIGH_PRECISION 9: #define SHADER_NAME MeshMaskMaterial 10: #define COMPAT_USE_SPEC_ENV_BLENDER_APPROX 11: #define VERTEX_TEXTURES 12: #define GAMMA_FACTOR 2 13: #define MAX_BONES 0 14: #define BONE_TEXTURE 15: #define USE_MORPHTARGETS 16: #define NUM_MORPH_TARGETS 1 17: #define DOUBLE_SIDED 18: uniform mat4 modelMatrix; 19: uniform mat4 modelViewMatrix; 20: uniform mat4 projectionMatrix; 21: uniform mat4 viewMatrix; 22: uniform mat3 normalMatrix; 23: uniform vec3 cameraPosition; 24: uniform bool isOrthographic; 25: #ifdef USE_INSTANCING 26: attribute mat4 instanceMatrix; 27: #endif 28: attribute vec3 position; 29: attribute vec3 normal; 30: attribute vec2 uv; 31: #ifdef USE_TANGENT 32: attribute vec4 tangent; 33: #endif 34: #ifdef USE_COLOR 35: attribute vec3 color; 36: #endif 37: #ifdef USE_MORPHTARGETS 38: attribute vec3 morphTarget0; 39: attribute vec3 morphTarget1; 40: attribute vec3 morphTarget2; 41: attribute vec3 morphTarget3; 42: attribute vec3 morphTarget4; 43: attribute vec3 morphTarget5; 44: #ifdef USE_MORPHNORMALS 45: attribute vec3 morphNormal0; 46: attribute vec3 morphNormal1; 47: attribute vec3 morphNormal2; 48: attribute vec3 morphNormal3; 49: attribute vec3 morphNormal4; 50: attribute vec3 morphNormal5; 51: #else 52: attribute vec3 morphTarget6; 53: attribute vec3 morphTarget7; 54: attribute vec3 morphTarget8; 55: attribute vec3 morphTarget9; 56: attribute vec3 morphTarget10; 57: attribute vec3 morphTarget11; 58: #endif 59: #endif 60: #ifdef USE_SKINNING 61: attribute vec4 skinIndex; 62: attribute vec4 skinWeight; 63: #endif 64: 65: #define MASK 66: #define PI 3.14159265359 67: #define PI2 6.28318530718 68: #define PI_HALF 1.5707963267949 69: #define RECIPROCAL_PI 0.31830988618 70: #define RECIPROCAL_PI2 0.15915494 71: #define LOG2 1.442695 72: #define EPSILON 1e-6 73: #ifndef saturate 74: #define saturate(a) clamp(a, 0.0, 1.0) 75: #endif 76: #define whiteComplement(a) (1.0 - saturate(a)) 77: #define RECIPROCAL_3 0.333333333333 78: float pow2(const in float x) { return x*x; } 79: float pow3(const in float x) { return x*x*x; } 80: float pow4(const in float x) { float x2 = x*x; return x2*x2; } 81: float average(const in vec3 color) { return dot(color, vec3(0.3333)); } 82: highp float rand(const in vec2 uv) { 83: const highp float a = 12.9898, b = 78.233, c = 43758.5453; 84: highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI); 85: return fract(sin(sn) * c); 86: } 87: #ifdef HIGH_PRECISION 88: float precisionSafeLength(vec3 v) { return length(v); } 89: #else 90: float max3(vec3 v) { return max(max(v.x, v.y), v.z); } 91: float precisionSafeLength(vec3 v) { 92: float maxComponent = max3(abs(v)); 93: return length(v / maxComponent) * maxComponent; 94: } 95: #endif 96: struct IncidentLight { 97: vec3 color; 98: vec3 direction; 99: bool visible; 100: }; 101: struct ReflectedLight { 102: vec3 directDiffuse; 103: vec3 directSpecular; 104: vec3 indirectDiffuse; 105: vec3 indirectSpecular; 106: }; 107: struct GeometricContext { 108: vec3 position; 109: vec3 normal; 110: vec3 viewDir; 111: #ifdef CLEARCOAT 112: vec3 clearcoatNormal; 113: #endif 114: }; 115: vec3 transformDirection(in vec3 dir, in mat4 matrix) { 116: return normalize((matrix * vec4(dir, 0.0)).xyz); 117: } 118: vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) { 119: return normalize((vec4(dir, 0.0) * matrix).xyz); 120: } 121: vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) { 122: float distance = dot(planeNormal, point - pointOnPlane); 123: return - distance * planeNormal + point; 124: } 125: float sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) { 126: return sign(dot(point - pointOnPlane, planeNormal)); 127: } 128: vec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) { 129: return lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine; 130: } 131: mat3 transposeMat3(const in mat3 m) { 132: mat3 tmp; 133: tmp[0] = vec3(m[0].x, m[1].x, m[2].x); 134: tmp[1] = vec3(m[0].y, m[1].y, m[2].y); 135: tmp[2] = vec3(m[0].z, m[1].z, m[2].z); 136: return tmp; 137: } 138: float linearToRelativeLuminance(const in vec3 color) { 139: vec3 weights = vec3(0.2126, 0.7152, 0.0722); 140: return dot(weights, color.rgb); 141: } 142: bool isPerspectiveMatrix(mat4 m) { 143: return m[2][3] == - 1.0; 144: } 145: highp vec3 rand3(const in vec3 v) { 146: const highp float c = 43758.5453; 147: const highp mat3 coeffs = mat3( 148: 165.15, 253.34, 323.22, 149: 241.49, 329.07, 147.79, 150: 376.31, 14 v3d.WebGLShader: gl.getShaderInfoLog() fragment ERROR: 0:589: 'vViewPosition' : redefinition 1: #version 300 es 2: 3: #define varying in 4: out highp vec4 pc_fragColor; 5: #define gl_FragColor pc_fragColor 6: #define gl_FragDepthEXT gl_FragDepth 7: #define texture2D texture 8: #define textureCube texture 9: #define texture2DProj textureProj 10: #define texture2DLodEXT textureLod 11: #define texture2DProjLodEXT textureProjLod 12: #define textureCubeLodEXT textureLod 13: #define texture2DGradEXT textureGrad 14: #define texture2DProjGradEXT textureProjGrad 15: #define textureCubeGradEXT textureGrad 16: precision highp float; 17: precision highp int; 18: #define HIGH_PRECISION 19: #define SHADER_NAME MeshMaskMaterial 20: #define COMPAT_USE_SPEC_ENV_BLENDER_APPROX 21: #define GAMMA_FACTOR 2 22: #define DOUBLE_SIDED 23: #define PHYSICALLY_CORRECT_LIGHTS 24: #define UNITS_SCALE_FACTOR 1.0 25: uniform mat4 viewMatrix; 26: uniform vec3 cameraPosition; 27: uniform bool isOrthographic; 28: #define TONE_MAPPING 29: #ifndef saturate 30: #define saturate(a) clamp(a, 0.0, 1.0) 31: #endif 32: #ifndef PI 33: #define PI 3.14159265359 34: #endif 35: uniform float toneMappingExposure; 36: uniform float toneMappingMidTones; 37: uniform float toneMappingPhysicalScale; 38: uniform float toneMappingWhitePoint; 39: uniform float toneMappingBrightness; 40: uniform float toneMappingContrast; 41: uniform bool toneMappingChromaticAdaptation; 42: uniform vec3 toneMappingWhiteColor; 43: uniform bool toneMappingColorDifferentiation; 44: uniform bool toneMappingExteriorDaylight; 45: uniform vec3 toneMappingWhiteBalance; 46: uniform float toneMappingHighlights; 47: uniform float toneMappingShadows; 48: uniform float toneMappingSaturation; 49: uniform float toneMappingAperture; 50: uniform float toneMappingShutter; 51: uniform float toneMappingISO; 52: uniform float toneMappingVignetting; 53: uniform vec2 toneMappingResolution; 54: const float FILMIC_BLENDER_LOG_MIN = -12.473931188; 55: const float FILMIC_BLENDER_LOG_MAX = 12.526068812; 56: const float FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO = 0.66; 57: vec3 LinearToneMapping(vec3 color) { 58: return toneMappingExposure * color; 59: } 60: vec3 ReinhardToneMapping(vec3 color) { 61: color *= toneMappingExposure; 62: return saturate(color / (vec3(1.0) + color)); 63: } 64: #define Uncharted2Helper(x) max(((x * (0.15 * x + 0.10 * 0.50) + 0.20 * 0.02) / (x * (0.15 * x + 0.50) + 0.20 * 0.30)) - 0.02 / 0.30, vec3(0.0)) 65: vec3 Uncharted2ToneMapping(vec3 color) { 66: color *= toneMappingExposure; 67: return saturate(Uncharted2Helper(color) / Uncharted2Helper(vec3(toneMappingWhitePoint))); 68: } 69: vec3 OptimizedCineonToneMapping(vec3 color) { 70: color *= toneMappingExposure; 71: color = max(vec3(0.0), color - 0.004); 72: return pow((color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06), vec3(2.2)); 73: } 74: vec3 ACESFilmicToneMapping(vec3 color) { 75: color *= toneMappingExposure; 76: return saturate((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14)); 77: } 78: #define ORDERS_OF_MAG 5.0 79: float toneCalcBrightness(in vec3 color) 80: { 81: return (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082); 82: } 83: float toneApproximateScotopicLuminance(vec3 color) 84: { 85: return (0.062 * color.r + 0.608 * color.g + 0.330 * color.b); 86: } 87: vec3 LogarithmicMaxToneMapping(vec3 color) { 88: float inputScaleFactor = toneMappingPhysicalScale / PI; 89: float brightness = (toneMappingBrightness < 0.0) ? 0.0 : (toneMappingBrightness * 0.7); 90: float powerBot = toneMappingExteriorDaylight ? 4.0 : 2.0; 91: float res = 100.0 / ORDERS_OF_MAG; 92: float mag = floor((50.0 / res)); 93: float power = ((brightness / 20.0 - ORDERS_OF_MAG) - powerBot) + mag; 94: float stepsize = 9.0 / res; 95: float step = 50.0 - (mag * res); 96: float param_c = (0.02 * toneMappingContrast) * 2.0; 97: float param_b = pow(10.0, power) * (1.0 + (stepsize * step)); 98: float param_a = param_b * (1.0 + param_c); 99: param_c /= pow(2.0, toneMappingMidTones - 1.0); 100: param_b *= PI; 101: vec3 whiteConstancyFactor = toneMappingWhiteColor; 102: if (toneMappingChromaticAdaptation) { 103: float luminance = toneCalcBrightness(whiteConstancyFactor); 104: whiteConstancyFactor.r = (whiteConstancyFactor.r > 0.001) ? luminance / whiteConstancyFactor.r : luminance / 0.001; 105: whiteConstancyFactor.g = (whiteConstancyFactor.g > 0.001) ? luminance / whiteConstancyFactor.g : luminance / 0.001; 106: whiteConstancyFactor.b = (whiteConstancyFactor.b > 0.001) ? luminance / whiteConstancyFactor.b : luminance / 0.001; 107: } 108: vec3 outColor = inputScaleFactor * color; 109: if (toneMappingChromaticAdaptation) { 110: outColor *= whiteConstancyFactor.rgb; 111: } 112: float luminance = toneCalcBrightness(outColor); 113: if (toneMappingColorDifferentiation && (luminance < 5.62)) { 114: float sLuminance = toneApproximateScotopicLuminance(outColor); 115: if (luminance <= 5.62e-3) { 116: outColor = vec3(sLuminance); 117: } else { 118: float w = (luminance - 5.62e-3) / 5.61438; 119: outColor = outColor * w + sLuminance * (1.0 - w); 120: } 121: } 122: outColor = outColor * (param_a / (param_b * outColor + param_c)); 123: return outColor; 124: } 125: float maxExposurePhotographic(in vec4 color1, in vec4 color2) 126: { 127: return ((color1.r * color2.r) + (color1.g * color2.g)) + (color1.b * color2.b); 128: } 129: vec3 PhysicalMaxToneMapping(vec3 color) { 130: float vignettingInfluence = 1.0; 131: if (toneMappingVignetting > 0.0) { 132: vec3 vignettingCoords = vec3(0.0, 0.0, 0.0); 133: float aspect = toneMappingResolution.x / toneMappingResolution.y; 134: vignettingCoords.x = gl_FragCoord.x / toneMappingResolution.x - 0.5; 135: vignettingCoords.y = (gl_FragCoord.y / toneMappingResolution.y - 0.5) / aspect; 136: vignettingCoords.z = 1.0; 137: vignettingCoords = normalize(vignettingCoords); 138: vignettingInfluence = pow(vignettingCoords.z, toneMappingVignetting); 139: } 140: float inputScaleFactor = toneMappingPhysicalScale / PI; 141: float filmISO = toneMappingISO; 142: float camShutter = 1.0 / toneMappingShutter; 143: float fNumber = toneMappingAperture; 144: float cm2 = 1.0; 145: float burnHighlights = toneMappingHighlights; 146: float crushBlacks = toneMappingShadows; 147: float saturation = toneMappingSaturation; 148: vec3 whitePointInfluence = toneMappingWhiteBalance; 149: if (whitePointInfluence.r > 0.0) { 150: whitePointInfluence.r = 1.0 / whitePointInfluence.r; 151: } else { 152: whitePointInfluence.r = 1.0; 153: } 154: if (whitePointInfluence.g > 0.0) { 155: whitePointInfluence.g = 1.0 / whitePointInfluence.g; 156: } else { 157: whitePointInfluence.g = 1.0; 158: } 159: if (whitePointInfluence.b > 0.0) { 160: whitePointInfluence.b = 1.0 / whitePointInfluence.b; 161: } else { 162: whitePointInfluence.b = 1.0; 163: } 164: vec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0); 165: float whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0)); 166: whitePointInfluence.r /= whiteLumFactor; 167: whitePointInfluence.g /= whiteLumFactor; 168: whitePointInfluence.b /= whiteLumFactor; 169: float isoInfluence = 0.0; 170: float camShutterInv = 1.0 / camShutter; 171: if (filmISO > 0.0) { 172: isoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber); 173: } else { 174: isoInfluence = cm2; 175: } 176: vec3 outColor = inputScaleFactor * color; 177: outColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence; 178: outColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence; 179: outColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence; 180: outColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r); 181: outColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g); 182: outColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b); 183: float lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)); 184: float tmpFloat = 1.0 - saturation; 185: outColor.r = outColor.r * saturation + lumFactor2 * tmpFloat; 186: outColor.g = outColor.g * saturation + lumFactor2 * tmpFloat; 187: outColor.b = outColor.b * saturation + lumFactor2 * tmpFloat; 188: outColor = max(vec3(0.0), outColor); 189: float crushBlacksFac = crushBlacks * 2.0 + 1.0; 190: float crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5); 191: tmpFloat = (1.0 - crushBlacksFac2); 192: if (crushBlacksFac2 < 1.0) { 193: outColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat; 194: outColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat; 195: outColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat; 196: } 197: return outColor; 198: } 199: float filmicBlenderDesaturationMinIntensity(vec3 color) { 200: float maxChannel = max(color.r, max(color.g, color.b)); 201: float x = max(maxChannel, 0.6251); 202: return (1.2192868 * x - 0.63221059) 203: * ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231); 204: } 205: vec3 filmicBlenderDesaturationTransform(vec3 color) { 206: const float CURVE_SMOOTHNESS = 0.03; 207: float minIntensity = filmicBlenderDesaturationMinIntensity(color); 208: vec4 x = vec4(color, 1.0) - minIntensity; 209: x = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS); 210: return (x.rgb - x.a + color + 1.0) / 2.0; 211: } 212: vec3 filmicBlenderDynamicRangeTransform(vec3 color) { 213: return pow( 214: (0.28882259 * color - 0.15880336) 215: / (pow(color - 0.6229693, vec3(2.0)) + 0.16965022) 216: + 0.20453365 * color + 0.37847142, 217: vec3(3.0) 218: ); 219: } 220: vec3 FilmicBlenderToneMapping(vec3 color) { 221: color *= toneMappingExposure; 222: color = max(color, 0.000175); 223: color = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN) 224: / (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0); 225: color = filmicBlenderDesaturationTransform(color); 226: color = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0); 227: color = filmicBlenderDynamicRangeTransform(color); 228: return color; 229: } 230: vec3 toneMapping(vec3 color) { return LinearToneMapping(color); } 231: 232: vec4 LinearToLinear(in vec4 value) { 233: return value; 234: } 235: vec4 GammaToLinear(in vec4 value, in float gammaFactor) { 236: value = max(value, vec4(0.0)); 237: return vec4(pow(value.rgb, vec3(gammaFactor)), value.a); 238: } 239: vec4 LinearToGamma(in vec4 value, in float gammaFactor) { 240: value = max(value, vec4(0.0)); 241: return vec4(pow(value.rgb, vec3(1.0 / gammaFactor)), value.a); 242: } 243: vec4 sRGBToLinear(in vec4 value) { 244: value = max(value, vec4(0.0)); 245: return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.a); 246: } 247: vec4 LinearTosRGB(in vec4 value) { 248: value = max(value, vec4(0.0)); 249: return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.a); 250: } 251: vec4 RGBEToLinear(in vec4 value) { 252: return vec4(value.rgb * exp2(value.a * 255.0 - 128.0), 1.0); 253: } 254: vec4 LinearToRGBE(in vec4 value) { 255: float maxComponent = max(max(value.r, value.g), value.b); 256: float fExp = clamp(ceil(log2(maxComponent)), -128.0, 127.0); 257: return vec4(value.rgb / exp2(fExp), (fExp + 128.0) / 255.0); 258: } 259: vec4 RGBMToLinear(in vec4 value, in float maxRange) { 260: return vec4(value.rgb * value.a * maxRange, 1.0); 261: } 262: vec4 LinearToRGBM(in vec4 value, in float maxRange) { 263: float maxRGB = max(value.r, max(value.g, value.b)); 264: float M = clamp(maxRGB / maxRange, 0.0, 1.0); 265: M = ceil(M * 255.0) / 255.0; 266: return vec4(value.rgb / (M * maxRange), M); 267: } 268: vec4 RGBDToLinear(in vec4 value, in float maxRange) { 269: return vec4(value.rgb * ((maxRange / 255.0) / value.a), 1.0); 270: } 271: vec4 LinearToRGBD(in vec4 value, in float maxRange) { 272: float maxRGB = max(value.r, max(value.g, value.b)); 273: float D = max(maxRange / maxRGB, 1.0); 274: D = clamp(floor(D) / 255.0, 0.0, 1.0); 275: return vec4(value.rgb * (D * (255.0 / maxRange)), D); 276: } 277: const mat3 cLogLuvM = mat3(0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969); 278: vec4 LinearToLogLuv(in vec4 value) { 279: vec3 Xp_Y_XYZp = cLogLuvM * value.rgb; 280: Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6)); 281: vec4 vResult; 282: vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z; 283: float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0; 284: vResult.w = fract(Le); 285: vResult.z = (Le - (floor(vResult.w * 255.0)) / 255.0) / 255.0; 286: return vResult; 287: } 288: const mat3 cLogLuvInverseM = mat3(6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268); 289: vec4 LogLuvToLinear(in vec4 value) { 290: float Le = value.z * 255.0 + value.w; 291: vec3 Xp_Y_XYZp; 292: Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0); 293: Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y; 294: Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z; 295: vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb; 296: return vec4(max(vRGB, 0.0), 1.0); 297: } 298: vec4 mapTexelToLinear(vec4 value) { return LinearToLinear(value); } 299: vec4 matcapTexelToLinear(vec4 value) { return LinearToLinear(value); } 300: vec4 envMapTexelToLinear(vec4 value) { return LinearToLinear(value); } 301: vec4 emissiveMapTexelToLinear(vec4 value) { return LinearToLinear(value); } 302: vec4 lightMapTexelToLinear(vec4 value) { return LinearToLinear(value); } 303: vec4 linearToOutputTexel(vec4 value) { return LinearToLinear(value); } 304: 305: #define MASK 306: #define PI 3.14159265359 307: #define PI2 6.28318530718 308: #define PI_HALF 1.5707963267949 309: #define RECIPROCAL_PI 0.31830988618 310: #define RECIPROCAL_PI2 0.15915494 311: #define LOG2 1.442695 312: #define EPSILON 1e-6 313: #ifndef saturate 314: #define saturate(a) clamp(a, 0.0, 1.0) 315: #endif 316: #define whiteComplement(a) (1.0 - saturate(a)) 317: #define RECIPROCAL_3 0.333333333333 318: float pow2(const in float x) { return x*x; } 319: float pow3(const in float x) { return x*x*x; } 320: float pow4(const in float x) { float x2 = x*x; return x2*x2; } 321: float average(const in vec3 color) { return dot(color, vec3(0.3333)); } 322: highp float rand(const in vec2 uv) { 323: const highp float a = 12.9898, b = 78.233, c = 43758.5453; 324: highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI); 325: return fract(sin(sn) * c); 326: } 327: #ifdef HIGH_PRECISION 328: float precisionSafeLength(vec3 v) { return length(v); } 329: #else 330: float max3(vec3 v) { return max(max(v.x, v.y), v.z); } 331: float precisionSafeLength(vec3 v) { 332: float maxComponent = max3(abs(v)); 333: return length(v / maxComponent) * maxComponent; 334: } 335: #endif 336: struct IncidentLight { 337: vec3 color; 338: vec3 direction; 339: bool visible; 340: }; 341: struct ReflectedLight { 342: vec3 directDiffuse; 343: vec3 directSpecular; 344: vec3 indirectDiffuse; 345: vec3 indirectSpecular; 346: }; 347: struct GeometricContext { 348: vec3 position; 349: vec3 normal; 350: vec3 viewDir; 351: #ifdef CLEARCOAT 352: vec3 clearcoatNormal; 353: #endif 354: }; 355: vec3 transformDirection(in vec3 dir, in mat4 matrix) { 356: return normalize((matrix * vec4(dir, 0.0)).xyz); 357: } 358: vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) { 359: return normalize((vec4(dir, 0.0) * matrix).xyz); 360: } 361: vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) { 362: float distance = dot(planeNormal, point - pointOnPlane); 363: return - distance * planeNormal + point; 364: } 365: float sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) { 366: return sign(dot(point - pointOnPlane, planeNormal)); 367: } 368: vec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) { 369: return lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine; 370: } 371: mat3 transposeMat3(const in mat3 m) { 372: mat3 tmp; 373: tmp[0] = vec3(m[0].x, m[1].x, m[2].x); 374: tmp[1] = vec3(m[0].y, m[1].y, m[2].y); 375: tmp[2] = vec3(m[0].z, m[1].z, m[2].z); 376: return tmp; 377: } 378: float linearToRelativeLuminance(const in vec3 color) { 379: vec3 weights = vec3(0.2126, 0.7152, 0.0722); 380: return dot(weights, color.rgb); 381: } 382: bool isPerspectiveMatrix(mat4 m) { 383: return m[2][3] == - 1.0; 384: } 385: highp vec3 rand3(const in vec3 v) { 386: const highp float c = 43758.5453; 387: const highp mat3 coeffs = mat3( 388: 165.15, 253.34, 323.22, 389: 241.49, 329.07, 147.79, 390: 376.31, 143.45, 281.63 391: ); 392: highp vec3 sn = mod(coeffs * v, PI); 393: return fract(sin(sn) * c); 394: } 395: float powCompat(const in float val, const in float power) { 396: if (power == 0.0) 397: return 1.0; 398: else if (val < 0.0) { 399: if (mod(-power, 2.0) == 0.0) 400: return pow(abs(val), power); 401: else 402: return -pow(abs(val), power); 403: } else if (val == 0.0) 404: return 0.0; 405: return pow(abs(val), power); 406: } 407: float maxFromRGB(vec3 rgb) { 408: return max(max(rgb.r, rgb.g), rgb.b); 409: } 410: bool isOrtho(const in mat4 m) { 411: if (m[3][3] != 0.0) 412: return true; 413: else 414: return false; 415: } 416: vec3 swizzleUpZ(const vec3 vec) { 417: return vec3(vec[0], -vec[2], vec[1]); 418: } 419: vec3 swizzleUpY(const vec3 vec) { 420: return vec3(vec[0], vec[2], -vec[1]); 421: } 422: vec3 xyz_to_sRGB(vec3 xyz) { 423: mat3 convMat = mat3( 424: 3.2406, -0.9689, 0.0557, 425: -1.5372, 1.8758, -0.2040, 426: -0.4986, 0.0415, 1.0570 427: ); 428: return convMat * xyz; 429: } 430: vec3 xyY_to_XYZ(float x, float y, float Y) { 431: float X = 0.0; 432: float Z = 0.0; 433: if (y != 0.0) { 434: X = (Y / y) * x; 435: Z = (Y / y) * (1.0 - x - y); 436: } 437: return vec3(X, Y, Z); 438: } 439: vec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) { 440: octUV = (1.0 + 2.0 * texelSize) * octUV - texelSize; 441: octUV = octUV * 2.0 - 1.0; 442: float x = octUV.x; 443: float z = -octUV.y; 444: float absX = abs(x); 445: float absZ = abs(z); 446: vec3 cubeVec = vec3(x, 1.0 - absX - absZ, z); 447: if (absX + absZ > 1.0) { 448: cubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z)); 449: } 450: return cubeVec; 451: } 452: vec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) { 453: cubeVec /= dot(vec3(1.0), abs(cubeVec)); 454: vec2 octUV = vec2(cubeVec.x, -cubeVec.z); 455: if (cubeVec.y < 0.0) { 456: octUV = sign(octUV) * (1.0 - abs(octUV.ts)); 457: } 458: octUV = (octUV + 1.0) / 2.0; 459: octUV = (1.0 - 2.0 * texelSize) * octUV + texelSize; 460: return octUV; 461: } 462: #if __VERSION__ == 100 463: float cosh(float x) { 464: return (exp(x) + exp(-x)) / 2.0; 465: } 466: vec2 cosh(vec2 x) { 467: return (exp(x) + exp(-x)) / 2.0; 468: } 469: vec3 cosh(vec3 x) { 470: return (exp(x) + exp(-x)) / 2.0; 471: } 472: vec4 cosh(vec4 x) { 473: return (exp(x) + exp(-x)) / 2.0; 474: } 475: float sinh(float x) { 476: return (exp(x) - exp(-x)) / 2.0; 477: } 478: vec2 sinh(vec2 x) { 479: return (exp(x) - exp(-x)) / 2.0; 480: } 481: vec3 sinh(vec3 x) { 482: return (exp(x) - exp(-x)) / 2.0; 483: } 484: vec4 sinh(vec4 x) { 485: return (exp(x) - exp(-x)) / 2.0; 486: } 487: float tanh(float x) { 488: float exp2x = exp(2.0 * x); 489: return (exp2x - 1.0) / (exp2x + 1.0); 490: } 491: vec2 tanh(vec2 x) { 492: vec2 exp2x = exp(2.0 * x); 493: return (exp2x - 1.0) / (exp2x + 1.0); 494: } 495: vec3 tanh(vec3 x) { 496: vec3 exp2x = exp(2.0 * x); 497: return (exp2x - 1.0) / (exp2x + 1.0); 498: } 499: vec4 tanh(vec4 x) { 500: vec4 exp2x = exp(2.0 * x); 501: return (exp2x - 1.0) / (exp2x + 1.0); 502: } 503: float trunc(float x) { 504: return floor(abs(x)) * sign(x); 505: } 506: vec2 trunc(vec2 x) { 507: return floor(abs(x)) * sign(x); 508: } 509: vec3 trunc(vec3 x) { 510: return floor(abs(x)) * sign(x); 511: } 512: vec4 trunc(vec4 x) { 513: return floor(abs(x)) * sign(x); 514: } 515: #endif 516: float getSmoothFactor(float a, float b, float smoothness) { 517: return max(smoothness - abs(a - b), 0.0) / smoothness; 518: } 519: float smoothMin(float a, float b, float smoothness) { 520: float smoothFac = getSmoothFactor(a, b, smoothness); 521: return min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0); 522: } 523: float smoothMax(float a, float b, float smoothness) { 524: float smoothFac = getSmoothFactor(a, b, smoothness); 525: return max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0); 526: } 527: vec3 packNormalToRGB(const in vec3 normal) { 528: return normalize(normal) * 0.5 + 0.5; 529: } 530: vec3 unpackRGBToNormal(const in vec3 rgb) { 531: return 2.0 * rgb.xyz - 1.0; 532: } 533: const float PackUpscale = 256. / 255.; 534: const float UnpackDownscale = 255. / 256.; 535: const vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.); 536: const vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.); 537: const float ShiftRight8 = 1. / 256.; 538: vec4 packDepthToRGBA(const in float v) { 539: vec4 r = vec4(fract(v * PackFactors), v); 540: r.yzw -= r.xyz * ShiftRight8; 541: return r * PackUpscale; 542: } 543: float unpackRGBAToDepth(const in vec4 v) { 544: return dot(v, UnpackFactors); 545: } 546: vec4 pack2HalfToRGBA(vec2 v) { 547: vec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0)); 548: return vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w); 549: } 550: vec2 unpackRGBATo2Half(vec4 v) { 551: return vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0)); 552: } 553: float viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) { 554: return (viewZ + near) / (near - far); 555: } 556: float orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) { 557: return linearClipZ * (near - far) - near; 558: } 559: float viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) { 560: return ((near + viewZ) * far) / ((far - near) * viewZ); 561: } 562: float perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) { 563: return (near * far) / ((far - near) * invClipZ - far); 564: } 565: #if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY)) 566: varying vec2 vUv; 567: #endif 568: #ifdef USE_MAP 569: uniform sampler2D map; 570: #endif 571: #ifdef USE_ALPHAMAP 572: uniform sampler2D alphaMap; 573: #endif 574: #if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT) 575: uniform float logDepthBufFC; 576: varying float vFragDepth; 577: varying float vIsPerspective; 578: #endif 579: #if 1 > 0 580: #if !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP)&& !defined(NODE) && !defined(LAMBERT) && !defined(DEPTH) 581: varying vec3 vViewPosition; 582: #endif 583: uniform vec4 clippingPlanes[1]; 584: #endif 585: uniform mat4 projectionMatrix; 586: uniform float opacity; 587: uniform sampler2D depthTexture; 588: uniform vec2 cameraNearFar; 589: varying vec3 vViewPosition; 590: varying vec4 projTexCoord; 591: void main() { 592: #if 1 > 0 593: vec4 plane; 594: { 595: plane = clippingPlanes[0]; 596: if (dot(vViewPosition, plane.xyz) > plane.w) discard; 597: } 598: #if 1 < 1 599: bool clipped = true; 600: 601: if (clipped) discard; 602: #endif 603: #endif 604: vec4 diffuseColor = vec4(1.0); 605: diffuseColor.a = opacity; 606: #ifdef USE_MAP 607: vec4 texelColor = texture2D(map, vUv); 608: texelColor = mapTexelToLinear(texelColor); 609: diffuseColor *= texelColor; 610: #endif 611: #ifdef USE_ALPHAMAP 612: diffuseColor.a *= texture2D(alphaMap, vUv).g; 613: #endif 614: #ifdef ALPHATEST 615: if (diffuseColor.a < ALPHATEST) 616: discard; 617: else 618: diffuseColor.a = 1.0; 619: #endif 620: #if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT) 621: gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2(vFragDepth) * logDepthBufFC * 0.5; 622: #endif 623: float depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord)); 624: float viewZ; 625: if (isOrtho(projectionMatrix)) 626: viewZ = -orthographicDepthToViewZ(depth, 627: cameraNearFar.x, cameraNearFar.y); 628: else 629: viewZ = -perspectiveDepthToViewZ(depth, 630: cameraNearFar.x, cameraNearFar.y); 631: float depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0; 632: gl_FragColor = vec4(0.0, depthTest, 1.0, 0.0); 633: }
Do you have any idea why?
-
AuthorPosts