@rings-webgpu/core 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2088,11 +2088,7 @@ function RegisterComponent(cls, key, p1, p2, p3) {
2088
2088
  if (!dic) {
2089
2089
  dic = window["__Component__"] = {};
2090
2090
  }
2091
- if (key) {
2092
- dic[key] = cls;
2093
- } else {
2094
- dic[cls.name] = cls;
2095
- }
2091
+ dic[key] = cls;
2096
2092
  }
2097
2093
  function GetComponentClass(name) {
2098
2094
  let coms = window["__Component__"];
@@ -2106,11 +2102,7 @@ function RegisterShader(cls, key, p1, p2, p3) {
2106
2102
  if (!dic) {
2107
2103
  dic = window["__shader__"] = {};
2108
2104
  }
2109
- if (key) {
2110
- dic[key] = cls;
2111
- } else {
2112
- dic[cls.name] = cls;
2113
- }
2105
+ dic[key] = cls;
2114
2106
  }
2115
2107
  function GetShader(name) {
2116
2108
  let coms = window["__shader__"];
@@ -2132,6 +2124,10 @@ var __decorateClass$i = (decorators, target, key, kind) => {
2132
2124
  const _Struct = class _Struct {
2133
2125
  __refection;
2134
2126
  __size = 0;
2127
+ /**
2128
+ * get reflection name
2129
+ * @returns
2130
+ */
2135
2131
  getValueType() {
2136
2132
  if (!this.__refection) {
2137
2133
  let self = this;
@@ -2149,6 +2145,11 @@ const _Struct = class _Struct {
2149
2145
  }
2150
2146
  return this.__refection;
2151
2147
  }
2148
+ /**
2149
+ * get any type value memory size
2150
+ * @param value any type value
2151
+ * @returns
2152
+ */
2152
2153
  static getValueSize(value) {
2153
2154
  let type = value.constructor.name;
2154
2155
  switch (type) {
@@ -2195,6 +2196,10 @@ const _Struct = class _Struct {
2195
2196
  }
2196
2197
  return struct;
2197
2198
  }
2199
+ /**
2200
+ * get any struct memory size
2201
+ * @returns
2202
+ */
2198
2203
  static GetSize(c) {
2199
2204
  let struct = this.Get(c);
2200
2205
  if (struct.__size == 0) {
@@ -3993,511 +3998,559 @@ let ClusterDebug_frag = `
3993
3998
  `;
3994
3999
 
3995
4000
  class CubeSky_Shader {
3996
- static sky_vs_frag_wgsl = `
3997
- #include "WorldMatrixUniform"
3998
- #include "GlobalUniform"
4001
+ static sky_vs_frag_wgsl = (
4002
+ /* wgsl */
4003
+ `
4004
+ #include "WorldMatrixUniform"
4005
+ #include "GlobalUniform"
3999
4006
 
4000
- struct VertexOutput {
4001
- @location(auto) fragUV: vec2<f32>,
4002
- @location(auto) vClipPos: vec4<f32>,
4003
- @location(auto) vWorldPos: vec4<f32>,
4004
- @location(auto) vWorldNormal: vec3<f32>,
4005
- @builtin(position) member: vec4<f32>
4006
- };
4007
+ struct VertexOutput {
4008
+ @location(auto) fragUV: vec2<f32>,
4009
+ @location(auto) vClipPos: vec4<f32>,
4010
+ @location(auto) vWorldPos: vec4<f32>,
4011
+ @location(auto) vWorldNormal: vec3<f32>,
4012
+ @builtin(position) member: vec4<f32>
4013
+ };
4007
4014
 
4008
- var<private> ORI_VertexOut: VertexOutput;
4015
+ var<private> ORI_VertexOut: VertexOutput ;
4009
4016
 
4010
- @vertex
4011
- fn main {
4012
- @builtin(instance_index) index: u32,
4013
- @location(auto) position: vec3<f32>,
4014
- @location(auto) normal: vec3<f32>,
4015
- @location(auto) uv: vec2<f32>
4016
- } -> VertexOutput {
4017
- ORI_VertexOut.fragUV = uv;
4018
- let modelMat = models.matrix[u32(index)];
4019
- let vm = modelMat;
4020
- let normalMatrix = mat3x3<f32>(vm[0].xyz,vm[1].xyz,vm[2].xyz);
4021
- ORI_VertexOut.vWorldNormal = normalize(normalMatrix * normal);
4022
- ORI_VertexOut.vWorldPos = modelMat * vec4<f32>(position.xyz, 1.0);
4023
-
4024
- var fixProjMat = globalUniform.projMat;
4025
- fixProjMat[2].z = 1.0;
4026
- fixProjMat[3].z = -1.0;
4017
+ @vertex
4018
+ fn main(
4019
+ @builtin(instance_index) index : u32,
4020
+ @location(auto) position: vec3<f32>,
4021
+ @location(auto) normal: vec3<f32>,
4022
+ @location(auto) uv: vec2<f32>
4023
+ ) -> VertexOutput {
4024
+ ORI_VertexOut.fragUV = uv;
4025
+ let modelMat = models.matrix[u32(index)];
4026
+ let vm = modelMat;
4027
+ let normalMatrix = mat3x3<f32>(vm[0].xyz,vm[1].xyz,vm[2].xyz);
4028
+ ORI_VertexOut.vWorldNormal = normalize( normalMatrix * normal );
4029
+ ORI_VertexOut.vWorldPos = modelMat * vec4<f32>(position.xyz,1.0) ;
4030
+
4031
+ var fixProjMat = globalUniform.projMat ;
4032
+ fixProjMat[2].z = 1.0 ;//99999.0 / (99999.0 - 1.0) ;
4033
+ fixProjMat[3].z = -1.0 ;//(-1.0 * 99999.0) / (99999.0 - 1.0) ;
4027
4034
 
4028
- var fixViewMat = globalUniform.viewMat;
4029
- fixViewMat[3].x = 0.0;
4030
- fixViewMat[3].y = 0.0;
4031
- fixViewMat[3].z = 0.0;
4035
+ var fixViewMat = globalUniform.viewMat ;
4036
+ fixViewMat[3].x = 0.0 ;
4037
+ fixViewMat[3].y = 0.0 ;
4038
+ fixViewMat[3].z = 0.0 ;
4032
4039
 
4033
- var clipPos = fixProjMat * fixViewMat * ORI_VertexOut.vWorldPos;
4034
- ORI_VertexOut.vClipPos = clipPos;
4035
- ORI_VertexOut.member = clipPos;
4036
- return ORI_VertexOut;
4037
- }
4038
- `;
4039
- static sky_fs_frag_wgsl = `
4040
- #include "GlobalUniform"
4041
- #include "MathShader"
4042
- #include "BitUtil"
4043
- #include "ColorUtil_frag"
4044
- #include "FragmentOutput"
4040
+ var clipPos = fixProjMat * fixViewMat * ORI_VertexOut.vWorldPos;
4041
+ ORI_VertexOut.vClipPos = clipPos ;
4042
+ ORI_VertexOut.member = clipPos;
4043
+ return ORI_VertexOut;
4044
+ }
4045
+ `
4046
+ );
4047
+ static sky_fs_frag_wgsl = (
4048
+ /* wgsl */
4049
+ `
4050
+ #include "GlobalUniform"
4051
+ #include "MathShader"
4052
+ #include "BitUtil"
4053
+ #include "ColorUtil_frag"
4054
+ #include "FragmentOutput"
4045
4055
 
4046
- struct uniformData {
4047
- exposure: f32,
4048
- roughness: f32
4049
- }
4056
+ struct uniformData {
4057
+ exposure: f32,
4058
+ roughness: f32
4059
+ };
4050
4060
 
4051
- @group(1) @binding(0)
4052
- var baseMapSampler: sampler;
4053
- @group(1) @binding(1)
4054
- var baseMap: texture_cube<f32>;
4061
+ @group(1) @binding(0)
4062
+ var baseMapSampler: sampler;
4063
+ @group(1) @binding(1)
4064
+ var baseMap: texture_cube<f32>;
4055
4065
 
4056
- @group(2) @binding(0)
4057
- var<uniform> global: uniformData;
4066
+ @group(2) @binding(0)
4067
+ var<uniform> global: uniformData;
4058
4068
 
4059
- @fragment
4060
- fn main(@location(auto) fragUV: vec2<f32>,@location(auto) vClipPos: vec4<f32>, @location(auto) vWorldPos: vec4<f32>, @location(auto) vWorldNormal: vec3<f32>, @builtin(position) fragCoord: vec4<f32>) ->FragmentOutPut {
4061
- let maxLevel: u32 = textureNumLevels(baseMap);
4062
- let dir = normalize(vWorldPos.xyz);
4063
- var textureColor: vec3<f32> = textureSampleLevel(baseMap, baseMapSampler, normalize(dir.xyz), global.roughness * f32(maxLevel)).xyz;
4064
- #if IS_HDR_SKY
4065
- textureColor = LinearToGammaSpace(textureColor);
4066
- #endif
4069
+ @fragment
4070
+ fn main(@location(auto) fragUV: vec2<f32>,@location(auto) vClipPos: vec4<f32>, @location(auto) vWorldPos: vec4<f32>, @location(auto) vWorldNormal: vec3<f32> , @builtin(position) fragCoord : vec4<f32> ) -> FragmentOutput {
4071
+ let maxLevel: u32 = textureNumLevels(baseMap);
4072
+ let dir = normalize(vWorldPos.xyz);
4073
+ var textureColor:vec3<f32> = textureSampleLevel(baseMap, baseMapSampler, normalize(dir.xyz), global.roughness * f32(maxLevel) ).xyz;
4074
+ #if IS_HDR_SKY
4075
+ textureColor = LinearToGammaSpace(textureColor);
4076
+ #endif
4067
4077
 
4068
- let o_Target: vec4<f32> = vec4<f32>(textureColor, 1.0) * globalUniform.skyExposure;
4069
- let finalMatrix = globalUniform.projMat * globalUniform.viewMat;
4070
- let nMat = mat3x3<f32>(finalMatrix[0].xyz, finalMatrix[1].xyz, finalMatrix[2].xyz);
4071
- let ORI_NORMALMATRIX = transpose(inverse(nMat));
4078
+ // let o_Target: vec4<f32> = globalUniform.hdrExposure * vec4<f32>(textureColor, 1.0) * globalUniform.skyExposure ;
4079
+ let o_Target: vec4<f32> = vec4<f32>(textureColor, 1.0) * globalUniform.skyExposure;
4080
+ let finalMatrix = globalUniform.projMat * globalUniform.viewMat ;
4081
+ let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,finalMatrix[2].xyz) ;
4082
+ let ORI_NORMALMATRIX = transpose(inverse( nMat ));
4083
+
4084
+ var vNormal = (ORI_NORMALMATRIX * -vWorldNormal );
4085
+ var gBuffer = packGBuffer(
4086
+ -globalUniform.far,
4087
+ vec3f(0.0),
4088
+ o_Target.rgb,
4089
+ vec3f(0.0),
4090
+ vNormal
4091
+ ) ;
4092
+ var fragmentOutput:FragmentOutput;
4093
+ #if USE_CASTREFLECTION
4094
+ fragmentOutput.gBuffer = gBuffer ;
4095
+ #else
4096
+ fragmentOutput.color = o_Target ;
4097
+ fragmentOutput.gBuffer = gBuffer ;
4098
+ #endif
4099
+ return fragmentOutput;
4100
+ }
4072
4101
 
4073
- var vNormal = (ORI_NORMALMATRIX - vWorldNormal);
4074
- var gBuffer = packGBuffer(
4075
- -globalUniform.far,
4076
- vec3f(0.0),
4077
- o_Target.rgb,
4078
- vec3f(0.0),
4079
- vNormal
4080
- );
4102
+ fn packGBuffer(depth:f32, albedo:vec3f,hdrLighting:vec3f,rmao:vec3f,normal:vec3f) -> vec4f{
4103
+ var gBuffer : vec4f ;
4104
+ var octUVNormal = (octEncode(normalize(normal)) + 1.0) * 0.5 ;
4081
4105
 
4082
- var fragmentOutput: FragmentOutput;
4083
- #if USE_CASTREFLECTION
4084
- fragmentOutput.gBuffer = gBuffer;
4085
- #else
4086
- fragmentOutput.color = o_Target;
4087
- fragmentOutput.gBuffer = gBuffer;
4088
- #endif
4089
- return fragmentOutput;
4090
- }
4106
+ var yc = f32(r11g11b9_to_float(vec3f(octUVNormal,0.0))) ;
4107
+ #if USE_CASTREFLECTION
4108
+ var rgbm = EncodeRGBM(hdrLighting);
4109
+ var zc = f32(pack4x8unorm(vec4f(rgbm.rgb,0.0))) ;
4110
+ var wc = f32(pack4x8unorm(vec4f(rmao.rg,rgbm.a,0.0)));
4111
+ #else
4112
+ var zc = f32(vec4fToFloat_7bits(vec4f(albedo.rgb,0.0)));
4113
+ var wc = f32(r22g8_to_float(vec2f(f32(0.0),rmao.g)));
4114
+ #endif
4115
+
4116
+ gBuffer.x = depth ;
4117
+ gBuffer.y = yc ;
4118
+ gBuffer.z = zc ;
4119
+ gBuffer.w = wc ;
4120
+ return gBuffer ;
4121
+ }
4122
+ `
4123
+ );
4124
+ }
4091
4125
 
4092
- fn packGBuffer(depth:f32, albedo:vec3f, hdrLighting:vec3f, ramo:vec3f, normal:vec3f) -> vec4f{
4093
- var gBuffer: vec4f;
4094
- var octUVNormal = (octEncode(normalize(normal)) + 1.0) * 0.5;
4095
- var yc = f32(r11g11b9_to_float(vec3f(octUVNormal,0.0)));
4096
-
4097
- #if USE_CASTREFLECTION
4098
- var rgbm = EncodeRGBM(hdrLighting);
4099
- var zc = f32(pack4x8unorm(vec4f(rgbm.rgb,0.0)));
4100
- var wc = f32(pack4x8unorm(vec4f(rmao.rg,rgbm.a,0.0)));
4101
- #else
4102
- var zc = f32(vec4ToFloat_7bits(vec4f(albedo.rgb,0.0)));
4103
- var wc = f32(r22g8_to_float(vec2f(f32(0.0),rmao.g)))
4104
- #endif
4126
+ let LightingFunction_frag = (
4127
+ /*wgsl*/
4128
+ `
4129
+ #include "BRDF_frag"
4130
+ #include "ClusterLight"
4131
+ #include "ShadowMapping_frag"
4105
4132
 
4106
- gBuffer.x = depth;
4107
- gBuffer.y = yc;
4108
- gBuffer.z = zc;
4109
- gBuffer.w = wc;
4110
- return gBuffer;
4111
- }
4112
- `;
4113
- }
4133
+ #if USE_IES_PROFILE
4134
+ #include "IESProfiles_frag"
4135
+ #endif
4114
4136
 
4115
- let LightingFunction_frag = `
4116
- #include "BRDF_frag"
4117
- #include "ClusterLight"
4118
- #include "ShadowMapping_frag"
4137
+ const PI2 = 3.1415926 * 3.1415926 ;
4119
4138
 
4120
- #if USE_IES_PROFILE
4121
- #include "IESProfiles_frag"
4122
- #endif
4139
+ fn sampleLighting(light:LightData,direction:vec3f,iblSpecularResult:vec3f , intensity :f32 , shadow:f32 ) -> vec3f{
4140
+ var ret = vec3f(0.0);
4141
+ var normalDir = fragData.N;
4142
+ var viewDir = fragData.V;
4123
4143
 
4124
- const PI2 = 3.1415926 * 3.1415926;
4125
-
4126
- fn sampleLighting(light:LightData, direction:vec3f, iblSpecularResult:vec3f, intensity: f32, shadow: f32) -> vec3f {
4127
- var ret = vec3f(0.0);
4128
- var normalDir = fragData.N;
4129
- var viewDir = fragData.V;
4130
- var lightDir = normalize(-direction.xyz);
4131
- var halfDir = normalize(lightDir + viewDir);
4132
- var reflectDir = normalize(reflect(-viewDir,normalDir));
4133
- var NdotH = max(0.00001,dot(normalDir,halfDir));
4134
- var NdotL = max(0.00001,dot(normalDir,lightDir));
4135
- var NdotV = max(0.00001,dot(normalDir,viewDir));
4136
- var HdotL = max(0.00001,dot(halfDir,lightDir));
4137
- var baseColor = fragData.Albedo.rgb ;
4138
- var metallic = fragData.Metallic;
4139
- var roughness = fragData.Roughness;
4140
- var lightColor = getHDRColor( light.lightColor.rgb , light.linear ) ;
4141
- var att = max(0.0,intensity);
4142
- var lighting:vec3f = lightContribution(NdotH,NdotL,NdotV,HdotL,fragData.Roughness,fragData.Albedo.rgb / 3.14, metallic ,shadow,fragData.F0,lightColor.rgb);
4143
- lighting = ACESToneMapping(lighting,att);
4144
- return lighting;
4145
- }
4146
-
4147
- fn directLighting(light: LightData, ibSpecularResult: vec3f) -> vec3f<f32> {
4148
- var color = vec3<f32>(0.0);
4149
- #if USE_LIGHT
4150
- var L = normalize(light.direction.xyz);
4151
- #if USE_BRDF
4152
- var shadow = directShadowVisibility[(light.castShadow)];
4153
- var att = light.intensity;
4154
- color = sampleLighting(light,L,iblSpecularResult,att,shadow);
4155
- #endif
4144
+ var lightDir = normalize(-direction.xyz);
4145
+ var halfDir = normalize(lightDir + viewDir);
4146
+ var reflectDir = normalize(reflect(-viewDir,normalDir));
4147
+
4148
+ var NdotH = max(0.00001,dot(normalDir,halfDir));
4149
+ var NdotL = max(0.00001,dot(normalDir,lightDir));
4150
+ var NdotV = max(0.00001,dot(normalDir,viewDir));
4151
+ var HdotL = max(0.00001,dot(halfDir,lightDir));
4152
+
4153
+ var baseColor = fragData.Albedo.rgb ;
4154
+ var metallic = fragData.Metallic ;
4155
+ var roughness = fragData.Roughness ;
4156
+
4157
+ var lightColor = getHDRColor( light.lightColor.rgb , light.linear ) ;
4158
+ var att = max(0.0,intensity);
4159
+
4160
+ var lighting:vec3f = lightContribution(NdotH,NdotL,NdotV,HdotL,fragData.Roughness,fragData.Albedo.rgb / 3.14, metallic ,shadow,fragData.F0,lightColor.rgb);
4161
+
4162
+ lighting = ACESToneMapping(lighting,att);
4163
+ return lighting ;
4164
+ }
4165
+
4166
+ fn directLighting( light:LightData , iblSpecularResult : vec3f) -> vec3<f32> {
4167
+ var color = vec3<f32>(0.0) ;
4168
+ #if USE_LIGHT
4169
+ var L = normalize(light.direction.xyz) ;
4170
+ #if USE_BRDF
4171
+ var shadow = directShadowVisibility[(light.castShadow)] ;
4172
+ var att = light.intensity;
4173
+ color = sampleLighting(light,L,iblSpecularResult,att, shadow);
4174
+ #endif
4175
+ #endif
4176
+ return color;
4177
+ }
4178
+
4179
+ fn directDulLighting( albedo:vec3<f32>, N:vec3<f32>, V:vec3<f32>, roughness:f32 , metallic:f32 , light:LightData , shadowBias:f32 ) -> vec3<f32> {
4180
+ var color = vec3<f32>(0.0) ;
4181
+ #if USE_LIGHT
4182
+ var L = -normalize(light.direction.xyz) ;
4183
+ let lightCC = pow( light.lightColor.rgb,vec3<f32>(2.2));
4184
+ var lightColor = getHDRColor( lightCC.rgb , light.linear ) ;
4185
+ var att = light.intensity;
4186
+ if(light.castShadow>=0){
4187
+ #if USE_SHADOWMAPING
4188
+ for (var j: i32 = 0; j < 8; j += 1) {
4189
+ if(j == light.castShadow){
4190
+ att *= directShadowVisibility[j] ;
4191
+ }
4192
+ }
4156
4193
  #endif
4157
- return color;
4158
4194
  }
4195
+ #if USE_LAMBERT
4196
+ color = vec3<f32>(1.0,1.0,1.0) ;
4197
+ #endif
4198
+
4199
+ #if USE_BRDF
4200
+ color = 0.85 * simpleBRDF(albedo,N,V,L,att,lightColor,0.85 * roughness,metallic) ;
4201
+ color += 0.15 * simpleBRDF(albedo,N,V,L,att,lightColor,0.15 * roughness,metallic) ;
4202
+ #endif
4203
+ #endif
4204
+ return color;
4205
+ }
4159
4206
 
4160
- fn directDulLighting(albedo:vec3<f32>, N:vec3<f32>, V:vec3<f32>, roughness:f32 , metallic:f32 , light:LightData , shadowBias:f32) -> vec3<f32> {
4161
- var color = vec3<f32>(0.0);
4162
- #if USE_LIGHT
4163
- var L = -normalize(light.direction.xyz);
4164
- let lightCC = pow(light.lightColor.rgb, vec3<f32>(2.2));
4165
- var lightColor = getHDRColor(lightCC.rgb, light.linear);
4166
- var att = light.intensity;
4167
- if(light.castShadow>=0){
4168
- #if USE_SHADOWMAPING
4169
- for(var j: i32 = 0; j < 8; j+=1){
4170
- if(j == light.castShadow){
4171
- att *= directShadowVisibility[j];
4172
- }
4173
- }
4174
- #endif
4175
- }
4176
- #if USE_LAMBERT
4177
- color = vec3<f32>(1.0,1.0,1.0);
4207
+ fn directHairLighting( albedo:vec3<f32>, N:vec3<f32>, V:vec3<f32>, roughness:f32 , metallic:f32 , light:LightData , shadowBias:f32 ) -> vec3<f32> {
4208
+ var color = vec3<f32>(0.0) ;
4209
+ #if USE_LIGHT
4210
+ var L = -normalize(light.direction.xyz) ;
4211
+ let lightCC = pow( light.lightColor.rgb,vec3<f32>(2.2));
4212
+ var lightColor = getHDRColor( lightCC.rgb , light.linear ) ;
4213
+ var att = light.intensity;
4214
+ if(light.castShadow>=0){
4215
+ #if USE_SHADOWMAPING
4216
+ for (var j: i32 = 0; j < 8; j += 1) {
4217
+ if(j == light.castShadow){
4218
+ att *= directShadowVisibility[j] ;
4219
+ }
4220
+ }
4178
4221
  #endif
4222
+ }
4223
+ #if USE_LAMBERT
4224
+ color = vec3<f32>(1.0,1.0,1.0) ;
4225
+ #endif
4226
+
4227
+ #if USE_BRDF
4228
+ color = 0.5 * simpleBRDF(albedo,N,V,L,att,lightColor,0.85 ,metallic) ;
4229
+ color += 0.5 * simpleBRDF(albedo,N,V,L,att,lightColor,0.15 ,metallic) ;
4230
+ #endif
4231
+ #endif
4232
+ return color;
4233
+ }
4179
4234
 
4180
- #if USE_BRDF
4181
- color = 0.85 * simpleBRDF(albedo,N,V,L,att,lightColor,0.85 * roughness,metallic);
4182
- color += 0.15 * simpleBRDF(albedo,N,V,L,att,lightColor,0.15 * roughness,metallic);
4183
- #endif
4184
- #endif
4185
- return color;
4235
+
4236
+ fn pointLighting( WP:vec3<f32>, light:LightData , iblSpecularResult : vec3f ) -> vec3<f32> {
4237
+ var color = vec3<f32>(0.0) ;
4238
+ let lightPos = light.position.xyz;
4239
+ var dir = lightPos.xyz - WP ;
4240
+ let dist = length(dir);
4241
+ if(dist != 0.0){
4242
+ dir *= 1.0 / dist ;
4186
4243
  }
4244
+ if( abs(dist) < light.range ){
4245
+ var L = dir ;
4246
+ var atten = 1.0 ;
4247
+ atten = 1.0 - smoothstep(0.0,light.range,dist) ;
4248
+ atten *= 1.0 / max(light.radius,0.001) ;
4187
4249
 
4188
- fn directHairLighting ( albedo:vec3<f32>, N:vec3<f32>, V:vec3<f32>, roughness:f32 , metallic:f32 , light:LightData , shadowBias:f32 ) -> vec3<f32> {
4189
- var color = vec3<f32>(0.0);
4190
- #if USE_LIGHT
4191
- var L = -normalize(light.direction.xyz);
4192
- let lightCC = pow( light.lightColor.rgb, vec3<f32>(2.2) );
4193
- var lightColor = getHDRColor(lightCC.rgb, light.linear);
4194
- var att = light.intensity;
4195
- if(light.castShadow>=0){
4196
- #if USE_SHADOWMAPING
4197
- for (var j: i32 = 0; j < 8; j += 1) {
4198
- if(j == light.castShadow){
4199
- att *= directShadowVisibility[j];
4200
- }
4201
- }
4202
- #endif
4203
- }
4204
- #if USE_LAMBERT
4205
- color = vec3<f32>(1.0,1.0,1.0) ;
4250
+ var shadow = pointShadows[i32(light.castShadow)] ;
4251
+
4252
+ #if USE_IES_PROFILE
4253
+ atten *= getLightIESProfileAtt(WP,light);
4206
4254
  #endif
4207
4255
 
4208
- #if USE_BRDF
4209
- color = 0.5 * simpleBRDF(albedo,N,V,L,att,lightColor,0.85 ,metallic) ;
4210
- color += 0.5 * simpleBRDF(albedo,N,V,L,att,lightColor,0.15 ,metallic) ;
4211
- #endif
4212
- #endif
4213
- return color
4214
- }
4256
+ atten *= sphere_unit(light.range,light.intensity) ;
4215
4257
 
4216
- fn pointLighting ( WP: vec3<f32>, light: LightData, iblSpecularResult: vec3f ) -> vec3f<f32> {
4217
- var color = vec3<f32>(0.0);
4218
- let lightPos = light.position.xyz;
4219
- var dir = lightPos.xyz - WP;
4220
- let dist = length(dir);
4221
- if(dist != 0.0){
4222
- dir *= 1.0 / dist;
4223
- }
4224
- if(abs(dist) < light.range){
4225
- var L = dir;
4226
- var atten = 1.0;
4227
- atten = 1.0 - smoothstep(0.0, light.range, dist);
4228
- atten *= 1.0 / max(light.radius, 0.001);
4229
- var shadow = pointShadows[i32(light.castShadow)];
4230
-
4231
- #if USE_IES_PROFILE
4232
- atten *= getLightIESProfileAtt(WP, light);
4233
- #endif
4258
+ color = sampleLighting(light,-L,iblSpecularResult,atten,shadow);
4259
+ }
4260
+ return color ;
4261
+ }
4234
4262
 
4235
- atten *= sphere_unit(light.range, light.intensity);
4236
- color = sampleLighting(light, -L, iblSpecularResult, atten, shadow);
4237
- }
4238
- return color;
4239
- }
4263
+ fn pointAtt( WP:vec3<f32>, light:LightData ) -> f32 {
4264
+ var atten = 0.0 ;
4265
+ let lightPos = light.position.xyz;
4266
+ var dir = lightPos.xyz - WP ;
4267
+ let dist = length(dir);
4268
+ if(dist != 0.0){
4269
+ dir *= 1.0 / dist ;
4270
+ }
4271
+ if( abs(dist) < light.range ){
4272
+ var L = dir ;
4273
+ atten = 1.0 - smoothstep(0.0,light.range,dist) ;
4274
+ atten *= 1.0 / max(light.radius,0.001) ;
4275
+ var shadow = pointShadows[i32(light.castShadow)] ;
4276
+ #if USE_IES_PROFILE
4277
+ atten *= getLightIESProfileAtt(WP,light);
4278
+ #endif
4279
+ atten *= sphere_unit(light.range,light.intensity) ;
4280
+ }
4281
+ return atten ;
4282
+ }
4240
4283
 
4241
- fn pointAtt(WP:vec3<f32>, light:LightData) -> f32 {
4242
- var atten = 0.0;
4243
- let lightPos = light.position.xyz;
4244
- var dir = lightPos.xyz - WP;
4245
- let dist = length(dir);
4246
- if(dist != 0.0){
4247
- dir *= 1.0 / dist;
4248
- }
4249
- if(abs(dist) < light.range){
4250
- var L = dir;
4251
- atten = 1.0 - smoothstep(0.0, light.range, dist);
4252
- atten *= 1.0 / max(light.radius, 0.001);
4253
- var shadow = pointShadows[i32(light.castShadow)];
4254
- #if USE_IES_PROFILE
4255
- atten *= getLightIESProfileAtt(WP, light);
4256
- #endif
4257
- atten *= sphere_unit(light.range, light.intensity);
4258
- }
4259
- return atten;
4260
- }
4284
+ fn getDistanceAtten( light:LightData , dist : f32 ) -> f32 {
4285
+ return 1.0 - smoothstep(0.0,light.range,dist) ;
4286
+ }
4261
4287
 
4262
- fn getDistanceAtten(light:LightData, dist:f32) -> f32 {
4263
- return 1.0 - smoothstep(0.0, light.range, dist);
4288
+ fn spotLighting( WP:vec3<f32>, light:LightData , iblSpecularResult : vec3f) -> vec3<f32> {
4289
+ let lightPos = light.position.xyz;
4290
+ var dir = lightPos.xyz - WP ;
4291
+ let dist = length(dir) ;
4292
+ if(dist != 0.0){
4293
+ dir *= 1.0 / dist ;
4264
4294
  }
4265
4295
 
4266
- fn spotLighting(WP:vec3<f32>, light:LightData, iblSpecularResult: vec3f) -> vec3f<f32> {
4267
- let lightPos = light.position.xyz;
4268
- var dir = lightPos.xyz - WP;
4269
- let dist = length(dir);
4270
- if(dist != 0.0){
4271
- dir *= 1.0 / dist
4296
+ var color = vec3<f32>(0.0) ;
4297
+ if( abs(dist) < light.range * 2.0 ){
4298
+ var L = dir ;
4299
+ let theta = dot(-L, normalize(light.direction));
4300
+ let angle = acos(theta) ;
4301
+ var atten = 1.0 ;
4302
+ var lightColor = light.lightColor.rgb ;
4303
+
4304
+ atten = 1.0 - smoothstep(0.0,light.range,dist) ;
4305
+ atten *= 1.0 / max(light.radius,0.001) ;
4306
+ if(angle < light.outerCutOff){
4307
+ if(angle > light.innerCutOff){
4308
+ atten *= 1.0 - smoothstep(light.innerCutOff, light.outerCutOff, angle) ;
4309
+ }
4310
+ }else{
4311
+ atten = 0.0 ;
4272
4312
  }
4273
4313
 
4274
- var color = vec3<f32>(0.0);
4275
- if(abs(dist) < light.range * 2.0){
4276
- var L = dir;
4277
- let theta = dot(-L, normalize(light.direction));
4278
- let angle = acos(theta);
4279
- var atten = 1.0;
4280
- var lightColor = light.lightColor.rgb;
4281
-
4282
- atten = 1.0 - smoothstep(0.0, light.range, dist);
4283
- atten *= 1.0 / max(light.radius, 0.001);
4284
- if(angle < light.outerCutOff){
4285
- if(angle > light.innerCutOff){
4286
- atten *= 1.0 - smoothstep(light.innerCutOff, light.outerCutOff, angle);
4287
- }
4288
- }else{
4289
- atten = 0.0;
4290
- }
4314
+ var shadow = pointShadows[i32(light.castShadow)] ;
4291
4315
 
4292
- var shadow = pointShadows[i32(light.castShadow)];
4316
+ #if USE_IES_PROFILE
4317
+ atten *= getLightIESProfileAtt(WP,light);
4318
+ #endif
4293
4319
 
4294
- #if USE_IES_PROFILE
4295
- atten *= getLightIESProfileAtt(WP, light);
4296
- #endif
4320
+ atten *= sphere_unit(light.range, light.intensity) ;
4297
4321
 
4298
- atten *= sphere_unit(light.range, light.intensity);
4299
- color = sampleLighting(light, -L, iblSpecularResult, atten, shadow);
4300
- }
4301
- return color;
4322
+ color = sampleLighting(light,-L,iblSpecularResult,atten,shadow);
4302
4323
  }
4324
+ return color ;
4325
+ }
4303
4326
 
4304
- fn sphere_unit( radius:f32, intensity: f32 ) -> f32 {
4305
- return intensity / (4.0 * PI2 * radius * radius);
4306
- }
4307
- `;
4327
+ fn sphere_unit( radius:f32 , intensity:f32 ) -> f32 {
4328
+ return intensity / (4.0 * PI2 * radius * radius) ;
4329
+ }
4330
+ `
4331
+ );
4308
4332
 
4309
- let MathShader = `
4310
- #include 'BitUtil'
4333
+ let MathShader = (
4334
+ /* wgsl */
4335
+ `
4336
+ #include 'BitUtil'
4311
4337
 
4312
- struct TBN_ret{
4313
- tan:vec3f,
4314
- bit:vec3f,
4338
+ struct TBN_ret{
4339
+ tan:vec3f,
4340
+ bit:vec3f,
4341
+ }
4342
+
4343
+ fn TBN( N:vec3f) -> mat3x3<f32>{
4344
+ //Returns the simple tangent space matrix
4345
+ var Nb : vec3f;
4346
+ var Nt : vec3f;
4347
+ if (abs(N.y)>0.999) {
4348
+ Nb = vec3f(1.0,0.0,0.0);
4349
+ Nt = vec3f(0.0,0.0,1.0);
4350
+ } else {
4351
+ Nb = normalize(cross(N,vec3f(0.0,1.0,0.0)));
4352
+ Nt = normalize(cross(Nb,N));
4315
4353
  }
4316
4354
 
4317
- fn TBN(N:vec3f) -> mat3x3<f32>{
4318
- var Nb: vec3f;
4319
- var Nt: vec3f;
4320
- if(abs(N.y)>0.999){
4321
- Nb = vec3f(1.0,0.0,0.0);
4322
- Nt = vec3f(0.0,0.0,1.0)
4323
- }else{
4324
- Nb = normalize(cross(N,vec3f(0.0,1.0,0.0)));
4325
- Nt = normalize(cross(Nb,N));
4326
- }
4355
+ var mat3 = mat3x3<f32>(
4356
+ Nb.x,Nt.x,N.x,
4357
+ Nb.y,Nt.y,N.y,
4358
+ Nb.z,Nt.z,N.z
4359
+ );
4327
4360
 
4328
- var mat3 = mat3x3<f32>(
4329
- Nb.x,Nt.x,N.x,
4330
- Nb.y,Nt.y,N.y,
4331
- Nb.z,Nt.z,N.z
4332
- );
4361
+ return mat3;
4362
+ }
4333
4363
 
4334
- return mat3;
4335
- }
4364
+ fn TBN_out( N : vec3f ) -> TBN_ret {
4365
+ var tbn_ret : TBN_ret;
4366
+ //Returns the simple tangent space directions
4367
+ if (abs(N.y)>0.999) {
4368
+ tbn_ret.tan = vec3f(1.0,0.0,0.0);
4369
+ tbn_ret.bit = vec3f(0.0,0.0,1.0);
4370
+ } else {
4371
+ tbn_ret.tan = normalize(cross(N,vec3f(0.0,1.0,0.0)));
4372
+ tbn_ret.bit = normalize(cross(tbn_ret.tan,N));
4373
+ }
4336
4374
 
4337
- fn TBN_out(N:vec3f) -> TBN_ret {
4338
- var tbn_ret: TBN_ret;
4339
- if(abs(N.y)>0.999) {
4340
- tbn_ret.tan = vec3f(1.0,0.0,0.0);
4341
- tbn_ret.bit = vec3f(0.0,0.0,1.0);
4342
- }else{
4343
- tbn_ret.tan = normalize(cross(N,vec3f(0.0,1.0,0.0)));
4344
- tbn_ret.bit = normalize(cross(tbn_ret.tan,N));
4345
- }
4375
+ return tbn_ret;
4376
+ }
4346
4377
 
4347
- return tbn_ret;
4348
- }
4349
4378
 
4350
- fn ARand21(uv:vec2f) -> f32 {
4351
- return fract(sin(uv.x*uv.y)*403.125+cos(dot(uv,vec2f(13.18273,51.2134)))*173.137);
4352
- }
4379
+ fn ARand21( uv: vec2f) -> f32 {
4380
+ //Returns 1D noise from 2D
4381
+ return fract(sin(uv.x*uv.y)*403.125+cos(dot(uv,vec2f(13.18273,51.2134)))*173.137);
4382
+ }
4353
4383
 
4354
- fn applyQuaternion(position:vec3<f32>,q:vec4<f32>) -> vec3<f32>{
4355
- let x:f32 = position.x;
4356
- let y:f32 = position.y;
4357
- let z:f32 = position.z;
4384
+ fn applyQuaternion(position:vec3<f32>, q:vec4<f32>) -> vec3<f32>{
4385
+ let x:f32 = position.x;
4386
+ let y:f32 = position.y;
4387
+ let z:f32 = position.z;
4358
4388
 
4359
- let qx:f32 = q.x;
4360
- let qy:f32 = q.y;
4361
- let qz:f32 = q.z;
4362
- let qw:f32 = q.w;
4389
+ let qx:f32 = q.x;
4390
+ let qy:f32 = q.y;
4391
+ let qz:f32 = q.z;
4392
+ let qw:f32 = q.w;
4363
4393
 
4364
- let ix:f32 = qw*x + qy*z - qz*y;
4365
- let iy:f32 = qw*y + qz*x - qx*z;
4366
- let iz:f32 = qw*z + qx*y - qy*x;
4367
- let iw:f32 = -qx*x - qy*y - qz*z;
4394
+ let ix:f32 = qw * x + qy * z - qz * y;
4395
+ let iy:f32 = qw * y + qz * x - qx * z;
4396
+ let iz:f32 = qw * z + qx * y - qy * x;
4397
+ let iw:f32 = -qx * x - qy * y - qz * z;
4368
4398
 
4369
- var ret: vec3<f32>;
4370
- ret.x = ix*qw + iw*-qx + iy*-qz - iz*-qy;
4371
- ret.y = iy*qw + iw*-qy + iz*-qx - ix*-qz;
4372
- ret.z = iz*qw + iw*-qz + ix*-qy - iy*-qx;
4399
+ var ret: vec3<f32>;
4400
+ ret.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
4401
+ ret.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
4402
+ ret.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
4373
4403
 
4374
- return ret;
4375
- }
4404
+ return ret;
4405
+ }
4376
4406
 
4377
- fn inverse(m:mat3x3<f32>) -> mat3*3<f32>{
4378
- var a00 = m[0][0];
4379
- var a01 = m[0][1];
4380
- var a02 = m[0][2];
4381
- var a10 = m[1][0];
4382
- var a11 = m[1][1];
4383
- var a12 = m[1][2];
4384
- var a20 = m[2][0];
4385
- var a21 = m[2][1];
4386
- var a22 = m[2][2];
4387
-
4388
- var b01 = a22*a11 - a12*a21;
4389
- var b11 = -a22*a10 + a12*a20;
4390
- var b21 = a21*a10 - a11*a20;
4391
-
4392
- var det =a00*b01 + a01*b11 + a02*b21;
4393
- return mat3x3<f32>(
4394
- vec3<f32>(b01/ det, (-a22 * a01 + a02 * a21)/ det, (a12 * a01 - a02 * a11)/ det),
4395
- vec3<f32>(b11/ det, (a22 * a00 - a02 * a20)/ det, (-a12 * a00 + a02 * a10)/ det),
4396
- vec3<f32>(b21/ det, (-a21 * a00 + a01 * a20)/ det, (a11 * a00 - a01 * a10)/ det)
4397
- );
4398
- }
4407
+ fn inverse( m:mat3x3<f32>) -> mat3x3<f32>{
4408
+ var a00 = m[0][0];
4409
+ var a01 = m[0][1];
4410
+ var a02 = m[0][2];
4411
+ var a10 = m[1][0];
4412
+ var a11 = m[1][1];
4413
+ var a12 = m[1][2];
4414
+ var a20 = m[2][0];
4415
+ var a21 = m[2][1];
4416
+ var a22 = m[2][2];
4399
4417
 
4400
- fn dir_to_faceId(pt:vec3<f32>) -> i32 {
4401
- var abs_x = abs(pt.x);
4402
- var abs_y = abs(pt.y);
4403
- var abs_z = abs(pt.z);
4404
- var coord = max(max(abs_x, abs_y),abs_z);
4405
- if(coord == -pt.x){
4406
- return 0;
4407
- }
4408
- if(coord == pt.x){
4409
- return 1;
4410
- }
4411
- if(coord == -pt.y){
4412
- return 2;
4413
- }
4414
- if(coord == pt.y){
4415
- return 3;
4416
- }
4417
- if(coord == -pt.z){
4418
- return 4;
4419
- }
4420
- return 5;
4421
- }
4418
+ var b01 = a22 * a11 - a12 * a21;
4419
+ var b11 = -a22 * a10 + a12 * a20;
4420
+ var b21 = a21 * a10 - a11 * a20;
4422
4421
 
4423
- const us = 1.0/6.0;
4424
- fn uv_2_xyz(u:f32,v:f32) -> vec3f{
4425
- let face = floor(u/us);
4426
- var uu = (u - face*us)/us;
4427
- var uc = 2.0*uu - 1.0;
4428
- var vc = 2.0*v - 1.0;
4429
- var xyz = vec3f(0,0,0);
4430
- if(face == 0.0){
4431
- xyz = vec3f(1.0,-vc,uc);
4432
- }else if(face == 1.0){
4433
- xyz = vec3f(-1.0,-vc,-uc);
4434
- }else if(face == 2.0){
4435
- xyz = vec3f(uc,1.0,-vc);
4436
- }else if(face == 3.0){
4437
- xyz = vec3f(uc,-1.0,vc);
4438
- }else if(face == 4.0){
4439
- xyz = vec3f(-uc,-vc,1.0);
4440
- }else if(face == 5.0){
4441
- xyz = vec3f(uc,-vc,-1.0);
4442
- }
4443
- return xyz;
4444
- }
4445
-
4446
- fn convert_xyz_to_cube_uv(x:f32, y:f32, z:f32) -> vec2f{
4447
- var dir = vec3f(x,y,z);
4448
- var absX = abs(dir.x);
4449
- var absY = abs(dir.y);
4450
- var absZ = abs(dir.z);
4451
-
4452
- var isXPositive = 0;
4453
- if(dir.x > 0.0){isXPositive=1};
4454
- var isYPositive = 0;
4455
- if(dir.y > 0.0){isXPositive=1};
4456
- var isZPositive = 0;
4457
- if(dir.z > 0.0){isZPositive=1};
4458
-
4459
- var maxAxis:f32 = 0.0;
4460
- var uc:f32 = 0.0;
4461
- var vc:f32 = 0.0;
4462
-
4463
- if(isXPositive == 1 && absX >= absY && absX >= absZ){
4464
- maxAxis = absX;
4465
- uc = -z;
4466
- vc = y;
4467
- }
4468
- if(isXPositive == 0 && absX >= absY && absX >= absZ){
4469
- maxAxis = absX;
4470
- uc = z;
4471
- vc = y;
4472
- }
4473
- if(isYPositive == 1 && absY >= absX && absY >= absZ){
4474
- maxAxis = absY;
4475
- uc = x;
4476
- vc = -z;
4477
- }
4478
- if(isYPositive == 0 && absY >= absX && absY >= absZ){
4479
- maxAxis = absY;
4480
- uc = x;
4481
- vc = z;
4482
- }
4483
- if (isZPositive == 1 && absZ >= absX && absZ >= absY) {
4484
- maxAxis = absZ;
4485
- uc = x;
4486
- vc = y;
4487
- }
4488
- if (isZPositive ==0 && absZ >= absX && absZ >= absY) {
4489
- maxAxis = absZ;
4490
- uc = -x;
4491
- vc = y;
4492
- }
4493
-
4494
- var u = 0.5f*(uc / maxAxis + 1.0f);
4495
- var v = 0.5f*(vc / maxAxis + 1.0f);
4496
-
4497
- return vec2f(u, v);
4498
- }
4499
-
4500
- fn signNotZero(v1:vec2<f32>) -> vec2<f32>{
4422
+ var det = a00 * b01 + a01 * b11 + a02 * b21 ;
4423
+ return mat3x3<f32>(
4424
+ vec3<f32>(b01/ det, (-a22 * a01 + a02 * a21)/ det, (a12 * a01 - a02 * a11)/ det),
4425
+ vec3<f32>(b11/ det, (a22 * a00 - a02 * a20)/ det, (-a12 * a00 + a02 * a10)/ det),
4426
+ vec3<f32>(b21/ det, (-a21 * a00 + a01 * a20)/ det, (a11 * a00 - a01 * a10)/ det)
4427
+ );
4428
+ }
4429
+
4430
+ fn dir_to_faceId(pt:vec3<f32>) -> i32 {
4431
+ //**** nx px ny py nz pz
4432
+ var abs_x = abs(pt.x);
4433
+ var abs_y = abs(pt.y);
4434
+ var abs_z = abs(pt.z);
4435
+ var coord = max(max(abs_x, abs_y), abs_z);
4436
+ if(coord == -pt.x){ return 0;}
4437
+ if(coord == pt.x) { return 1;}
4438
+
4439
+ if(coord == -pt.y){ return 2;}
4440
+ if(coord == pt.y) { return 3;}
4441
+
4442
+ if(coord == -pt.z) { return 4;}
4443
+ return 5;
4444
+ }
4445
+
4446
+ const us = 1.0 /6.0 ;
4447
+ fn uv_2_xyz(u:f32,v:f32) -> vec3f
4448
+ {
4449
+ let face = floor(u / us);
4450
+ var uu = (u - face * us) / us ;
4451
+
4452
+ var uc = 2.0 * uu - 1.0;
4453
+ var vc = 2.0 * v - 1.0;
4454
+ var xyz = vec3f(0,0,0);
4455
+
4456
+ if(face == 0.0){
4457
+ // x,y,z = 1.0,vc,-uc
4458
+ xyz = vec3f(1.0,-vc,uc);
4459
+ }else if(face == 1.0){
4460
+ // x,y,z = -1.0,vc,uc
4461
+ xyz = vec3f(-1.0,-vc,-uc);
4462
+ }else if(face == 2.0){
4463
+ // x,y,z = uc,1.0,-vc
4464
+ xyz = vec3f(uc,1.0,-vc);
4465
+ }else if(face == 3.0){
4466
+ // x,y,z = uc,-1.0,vc
4467
+ xyz = vec3f(uc,-1.0,vc);
4468
+ }else if(face == 4.0){
4469
+ // x,y,z = uc,vc,1.0
4470
+ xyz = vec3f(-uc,-vc,1.0);
4471
+ }else if(face == 5.0){
4472
+ // x,y,z = -uc,vc,-1.0
4473
+ xyz = vec3f(uc,-vc,-1.0);
4474
+ }
4475
+ return xyz ;
4476
+ }
4477
+
4478
+ fn convert_xyz_to_cube_uv(x:f32, y:f32, z:f32 ) -> vec2f
4479
+ {
4480
+ var dir = vec3f(x, y, z);
4481
+ var absX = abs(dir.x);
4482
+ var absY = abs(dir.y);
4483
+ var absZ = abs(dir.z);
4484
+
4485
+ var isXPositive = 0;
4486
+ if(dir.x > 0.0){isXPositive = 1;}
4487
+ var isYPositive = 0;
4488
+ if(dir.y > 0.0){isYPositive = 1;}
4489
+ var isZPositive = 0;
4490
+ if(dir.z > 0.0){isZPositive = 1;}
4491
+
4492
+ var maxAxis:f32 = 0.0;
4493
+ var uc:f32 = 0.0;
4494
+ var vc:f32 = 0.0;
4495
+
4496
+ // POSITIVE X
4497
+ if (isXPositive == 1 && absX >= absY && absX >= absZ) {
4498
+ // u (0 to 1) goes from +z to -z
4499
+ // v (0 to 1) goes from -y to +y
4500
+ maxAxis = absX;
4501
+ uc = -z;
4502
+ vc = y;
4503
+ }
4504
+ // NEGATIVE X
4505
+ if (isXPositive ==0 && absX >= absY && absX >= absZ) {
4506
+ // u (0 to 1) goes from -z to +z
4507
+ // v (0 to 1) goes from -y to +y
4508
+ maxAxis = absX;
4509
+ uc = z;
4510
+ vc = y;
4511
+ }
4512
+ // POSITIVE Y
4513
+ if (isYPositive==1 && absY >= absX && absY >= absZ) {
4514
+ // u (0 to 1) goes from -x to +x
4515
+ // v (0 to 1) goes from +z to -z
4516
+ maxAxis = absY;
4517
+ uc = x;
4518
+ vc = -z;
4519
+ }
4520
+ // NEGATIVE Y
4521
+ if (isYPositive ==0 && absY >= absX && absY >= absZ) {
4522
+ // u (0 to 1) goes from -x to +x
4523
+ // v (0 to 1) goes from -z to +z
4524
+ maxAxis = absY;
4525
+ uc = x;
4526
+ vc = z;
4527
+ }
4528
+ // POSITIVE Z
4529
+ if (isZPositive == 1&& absZ >= absX && absZ >= absY) {
4530
+ // u (0 to 1) goes from -x to +x
4531
+ // v (0 to 1) goes from -y to +y
4532
+ maxAxis = absZ;
4533
+ uc = x;
4534
+ vc = y;
4535
+ }
4536
+ // NEGATIVE Z
4537
+ if (isZPositive ==0 && absZ >= absX && absZ >= absY) {
4538
+ // u (0 to 1) goes from +x to -x
4539
+ // v (0 to 1) goes from -y to +y
4540
+ maxAxis = absZ;
4541
+ uc = -x;
4542
+ vc = y;
4543
+ }
4544
+
4545
+ // Convert range from -1 to 1 to 0 to 1
4546
+ var u = 0.5f * (uc / maxAxis + 1.0f);
4547
+ var v = 0.5f * (vc / maxAxis + 1.0f);
4548
+
4549
+ return vec2f(u, v);
4550
+ }
4551
+
4552
+ // Returns ±1
4553
+ fn signNotZero( v1:vec2<f32>) -> vec2<f32> {
4501
4554
  var v:vec2<f32> = v1;
4502
4555
  if(v.x >= 0.0){
4503
4556
  v.x = 1.0;
@@ -4507,118 +4560,123 @@ let MathShader = `
4507
4560
  if(v.y >= 0.0){
4508
4561
  v.y = 1.0;
4509
4562
  }else{
4510
- v.y = -1.0;
4563
+ v.y= -1.0;
4511
4564
  }
4512
4565
  return v;
4513
4566
  }
4514
4567
 
4515
- fn octEncode(v:vec3<f32>) -> vec2<f32> {
4568
+ fn octEncode( v:vec3<f32> ) -> vec2<f32> {
4516
4569
  var l1norm = abs(v.x) + abs(v.y) + abs(v.z);
4517
4570
  var result = v.xy * (1.0 / l1norm);
4518
- if(v.z < 0.0){
4571
+ if (v.z < 0.0) {
4519
4572
  result = (1.0 - abs(result.yx)) * signNotZero(result.xy);
4520
4573
  }
4521
4574
  return result;
4522
4575
  }
4523
4576
 
4524
- fn octDecode(o:vec2<f32>) -> vec3<f32> {
4577
+ // Returns a unit vector. Argument o is an octahedral vector packed via octEncode,on the [-1, +1] square*/
4578
+ fn octDecode( o:vec2<f32> ) -> vec3<f32> {
4525
4579
  var v = vec3<f32>(o.x, o.y, 1.0 - abs(o.x) - abs(o.y));
4526
- if(v.z < 0.0) {
4527
- var tmp = (1.0 -abs(v.yx))*signNotZero(v.xy);
4580
+ if (v.z < 0.0) {
4581
+ var tmp = (1.0 - abs(v.yx)) * signNotZero(v.xy);
4528
4582
  v.x = tmp.x;
4529
4583
  v.y = tmp.y;
4530
4584
  }
4531
4585
  return normalize(v);
4532
4586
  }
4533
4587
 
4534
- fn Linear01Depth(z:f32,near:f32,far:f32) -> f32{
4535
- let ZBufferZ = (-1.0+(far/near))/far;
4536
- let ZBufferW = near/far;
4537
- return 1.0 / (ZBufferZ * z + ZBufferW);
4588
+ fn Linear01Depth(z:f32,near:f32,far:f32)-> f32{
4589
+ let ZBufferZ = (-1.0+(far/near)) / far;
4590
+ let ZBufferW = near /far ;
4591
+ return 1.0 / (ZBufferZ * z + ZBufferW) ;
4538
4592
  }
4539
4593
 
4540
- fn LinearizeDepth(depth:f32, nearPlane:f32, farPlane:f32) -> f32 {
4541
- var z = depth * 2.0 - 1.0;
4542
- return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
4594
+
4595
+ fn LinearizeDepth( depth:f32 , nearPlane:f32 , farPlane:f32 )-> f32 {
4596
+ var z = depth * 2.0 - 1.0;
4597
+ return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
4543
4598
  }
4544
4599
 
4545
- fn logDepth(depth:f32, far:f32) -> f32 {
4546
- return log2(depth + 1.0) * 2.0 / (log(far + 1.0) / 0.6931471805599453) * 0.5;
4600
+ fn logDepth(depth : f32, far:f32) -> f32 {
4601
+ return log2(depth + 1.0) * 2.0 / (log(far + 1.0) / 0.6931471805599453) * 0.5;
4547
4602
  }
4548
4603
 
4549
4604
  fn log2Depth(depth:f32, near:f32, far:f32) -> f32 {
4550
- let Fcoef:f32 = 2.0 / log2(far + 1.0);
4551
- var result:f32 = (log2(max(1e-6, 1.0 + depth)) * Fcoef - 1.0);
4552
- result = (1.0 + result) / 2.0;
4553
- return result * depth;
4605
+ let Fcoef:f32 = 2.0 / log2(far + 1.0);
4606
+ var result:f32 = (log2(max(1e-6, 1.0 + depth)) * Fcoef - 1.0);
4607
+ result = (1.0 + result) / 2.0;
4608
+ return result * depth;
4554
4609
  }
4555
4610
 
4556
4611
  fn log2DepthFixPersp(depth:f32, near:f32, far:f32) -> f32 {
4557
- let flogz:f32 = 1.0 + depth;
4558
- let Fcoef_half:f32 = (2.0 / log2(far + 1.0)) * 0.5;
4559
- var result:f32 = log2(flogz) * Fcoef_half;
4560
- result = (1.0 + result) / 2.0;
4561
- return result;
4612
+ let flogz:f32 = 1.0 + depth;
4613
+ let Fcoef_half:f32 = (2.0 / log2(far + 1.0)) * 0.5;
4614
+ var result:f32 = log2(flogz) * Fcoef_half;
4615
+ result = (1.0 + result) / 2.0;
4616
+ return result;
4562
4617
  }
4563
4618
 
4564
- fn QuaternionToMatrix(q:vec4<f32>) -> mat4x4<f32> {
4565
- var result: mat4x4<f32>;
4566
-
4567
- let x = q.x * 2.0;
4568
- let y = q.y * 2.0;
4569
- let z = q.z * 2.0;
4570
- let xx = q.x * x;
4571
- let yy = q.y * y;
4572
- let zz = q.z * z;
4573
- let xy = q.x * y;
4574
- let xz = q.x * z;
4575
- let yz = q.y * z;
4576
- let wx = q.w * x;
4577
- let wy = q.w * y;
4578
- let wz = q.w * z;
4579
-
4580
- result[0][0] = 1.0 - (yy + zz);
4581
- result[0][1] = xy + wz;
4582
- result[0][2] = xz - wy;
4583
- result[0][3] = 0.0;
4584
-
4585
- result[1][0] = xy - wz;
4586
- result[1][1] = 1.0 - (xx + zz);
4587
- result[1][2] = yz + wx;
4588
- result[1][3] = 0.0;
4589
-
4590
- result[2][0] = xz + wy;
4591
- result[2][1] = yz - wx;
4592
- result[2][2] = 1.0 - (xx + yy);
4593
- result[2][3] = 0.0;
4594
-
4595
- result[3][0] = 0.0;
4596
- result[3][1] = 0.0;
4597
- result[3][2] = 0.0;
4598
- result[3][3] = 1.0;
4599
4619
 
4600
- return result;
4620
+ fn QuaternionToMatrix(q: vec4<f32>) -> mat4x4<f32> {
4621
+ var result: mat4x4<f32>;
4622
+
4623
+ // Precalculate coordinate products
4624
+ let x = q.x * 2.0;
4625
+ let y = q.y * 2.0;
4626
+ let z = q.z * 2.0;
4627
+ let xx = q.x * x;
4628
+ let yy = q.y * y;
4629
+ let zz = q.z * z;
4630
+ let xy = q.x * y;
4631
+ let xz = q.x * z;
4632
+ let yz = q.y * z;
4633
+ let wx = q.w * x;
4634
+ let wy = q.w * y;
4635
+ let wz = q.w * z;
4636
+
4637
+ // Calculate 3x3 matrix from orthonormal basis
4638
+ result[0][0] = 1.0 - (yy + zz);
4639
+ result[0][1] = xy + wz;
4640
+ result[0][2] = xz - wy;
4641
+ result[0][3] = 0.0;
4642
+
4643
+ result[1][0] = xy - wz;
4644
+ result[1][1] = 1.0 - (xx + zz);
4645
+ result[1][2] = yz + wx;
4646
+ result[1][3] = 0.0;
4647
+
4648
+ result[2][0] = xz + wy;
4649
+ result[2][1] = yz - wx;
4650
+ result[2][2] = 1.0 - (xx + yy);
4651
+ result[2][3] = 0.0;
4652
+
4653
+ result[3][0] = 0.0;
4654
+ result[3][1] = 0.0;
4655
+ result[3][2] = 0.0;
4656
+ result[3][3] = 1.0;
4657
+
4658
+ return result;
4601
4659
  }
4602
4660
 
4603
4661
  fn MakeScaleMatrix(scale: vec3<f32>) -> mat4x4<f32> {
4604
4662
  return mat4x4<f32>(
4605
- scale.x, 0.0, 0.0, 0.0,
4606
- 0.0, scale.y, 0.0, 0.0,
4607
- 0.0, 0.0, scale.z, 0.0,
4608
- 0.0, 0.0, 0.0, 1.0,
4663
+ scale.x, 0.0, 0.0, 0.0,
4664
+ 0.0, scale.y, 0.0, 0.0,
4665
+ 0.0, 0.0, scale.z, 0.0,
4666
+ 0.0, 0.0, 0.0, 1.0,
4609
4667
  );
4610
4668
  }
4611
-
4669
+
4612
4670
  fn MakeRotationMatrix(rotationQuaternion: vec4<f32>) -> mat4x4<f32> {
4613
- return QuaternionToMatrix(rotationQuaternion);
4671
+ return QuaternionToMatrix(rotationQuaternion);
4614
4672
  }
4615
4673
 
4616
4674
  fn MakeTranslationMatrix(translation: vec3<f32>) -> mat4x4<f32> {
4617
4675
  return mat4x4<f32>(
4618
- 1.0, 0.0, 0.0, 0.0,
4619
- 0.0, 1.0, 0.0, 0.0,
4620
- 0.0, 0.0, 1.0, 0.0,
4621
- translation.x, translation.y, translation.z, 1.0,
4676
+ 1.0, 0.0, 0.0, 0.0,
4677
+ 0.0, 1.0, 0.0, 0.0,
4678
+ 0.0, 0.0, 1.0, 0.0,
4679
+ translation.x, translation.y, translation.z, 1.0,
4622
4680
  );
4623
4681
  }
4624
4682
 
@@ -4630,191 +4688,206 @@ let MathShader = `
4630
4688
  }
4631
4689
 
4632
4690
  fn mixMatrix4x4(a: mat4x4<f32>, b: mat4x4<f32>, t:f32) -> mat4x4<f32> {
4633
- return a * (1.0 - t) + b * t;
4691
+ return a * (1.0 - t) + b * t;
4634
4692
  }
4635
4693
 
4636
- fn decodeDepth(color:vec4<f32>) -> f32{
4637
- var depth = 0.0;
4638
- const bitShifts = vec4f<f32>(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);
4639
- depth = dot(color, bitShifts);
4640
- return depth;
4694
+ fn decodeDepth( color:vec4<f32> ) -> f32{
4695
+ var depth = 0.0 ;
4696
+ const bitShifts = vec4<f32>(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);
4697
+ depth = dot(color, bitShifts);
4698
+ return depth;
4641
4699
  }
4642
4700
 
4643
- fn encodeDepth(depth:f32) -> vec4<f32>{
4644
- const bitSh = vec4<f32>(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);
4645
- const bitMsk = vec4<f32>(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
4646
- var comp: vec4<f32>;
4647
- comp = depth * bitSh;
4648
- comp = fract(comp);
4649
- comp -= comp.xxyz * bitMsk;
4650
- return comp;
4701
+ fn encodeDepth( depth:f32 ) -> vec4<f32>{
4702
+ const bitSh = vec4<f32>(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);
4703
+ const bitMsk = vec4<f32>(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
4704
+ var comp:vec4<f32>;
4705
+ comp = depth * bitSh;
4706
+ comp = fract(comp);
4707
+ comp -= comp.xxyz * bitMsk;
4708
+ return comp;
4651
4709
  }
4652
4710
 
4653
- fn calculateBillboardMatrix2(eye:vec3f, pos:vec3f, up:vec3f) -> mat3x3<f32> {
4654
- let zAxis: vec3f = -normalize(pos.xyz - eye);
4655
- var xAxis: vec3f = cross(up, zAxis);
4656
- xAxis = normalize(cross(zAxis, xAxis));
4657
- let yAxis = normalize(cross(zAxis, xAxis));
4658
- return mat3x3<f32>(xAxis, yAxis, zAxis);
4711
+ fn calculateBillboardMatrix2(eye:vec3f,pos:vec3f,up:vec3f) -> mat3x3<f32> {
4712
+
4713
+ let zAxis: vec3f = -normalize(pos.xyz - eye);
4714
+ var xAxis: vec3f = cross(up,zAxis);
4715
+ xAxis = normalize(cross(zAxis,xAxis));
4716
+ let yAxis = normalize(cross(zAxis, xAxis));
4717
+ return mat3x3<f32>(xAxis, yAxis, zAxis);
4659
4718
  }
4660
4719
 
4661
- struct SH9Struct {
4662
- SHAr:vec4f,
4663
- SHAg:vec4f,
4664
- SHAb:vec4f,
4665
- SHBr:vec4f,
4666
- SHBg:vec4f,
4667
- SHBb:vec4f,
4668
- SHC:vec4f,
4720
+ struct SH9Struct{
4721
+ SHAr:vec4f,
4722
+ SHAg:vec4f,
4723
+ SHAb:vec4f,
4724
+ SHBr:vec4f,
4725
+ SHBg:vec4f,
4726
+ SHBb:vec4f,
4727
+ SHC:vec4f,
4669
4728
  }
4670
4729
 
4671
- fn ShadeSH9(normal: vec4f, sh9: SH9Struct) -> vec3f {
4672
- var x1:vec3f = vec3f(0.0);
4673
- var x2:vec3f = vec3f(0.0);
4674
- var x3:vec3f = vec3f(0.0);
4675
-
4676
- x1.r = dot(sh9.SHAr,normal);
4677
- x1.g = dot(sh9.SHAg,normal);
4678
- x1.b = dot(sh9.SHAb,normal);
4679
-
4680
- var vB = normal.xyzz * normal.yzzx;
4681
- x2.r = dot(sh9.SHBr,vB);
4682
- x2.g = dot(sh9.SHBg,vB);
4683
- x2.b = dot(sh9.SHBb,vB);
4684
-
4685
- var vC = normal.x*normal.x - normal.y*normal.y;
4686
- x3 = sh9.SHC.rgb * vC;
4687
- return x1 + x2 + x3;
4688
- }
4730
+ fn ShadeSH9 ( normal:vec4f , sh9:SH9Struct) -> vec3f
4731
+ {
4732
+ var x1:vec3f = vec3f(0.0);
4733
+ var x2:vec3f = vec3f(0.0);
4734
+ var x3:vec3f = vec3f(0.0);
4735
+
4736
+ // Linear + constant polynomial terms
4737
+ x1.r = dot(sh9.SHAr,normal);
4738
+ x1.g = dot(sh9.SHAg,normal);
4739
+ x1.b = dot(sh9.SHAb,normal);
4740
+
4741
+ // 4 of the quadratic polynomials
4742
+ var vB = normal.xyzz * normal.yzzx;
4743
+ x2.r = dot(sh9.SHBr,vB);
4744
+ x2.g = dot(sh9.SHBg,vB);
4745
+ x2.b = dot(sh9.SHBb,vB);
4746
+
4747
+ // Final quadratic polynomial
4748
+ var vC = normal.x*normal.x - normal.y*normal.y;
4749
+ x3 = sh9.SHC.rgb * vC;
4750
+ return x1 + x2 + x3;
4751
+ }
4689
4752
 
4690
- fn clipViewUV(viewRectangle:vec4f, size:vec2f, fragCoord:vec2f) -> vec2u {
4691
- let subViewUV = (fragCoord - viewRectangle.xy) / viewRectangle.zw;
4692
- return vec2u(subViewUV*size);
4753
+ fn clipViewUV(viewRectangle:vec4f,size:vec2f,fragCoord:vec2f) -> vec2u {
4754
+ let subViewUV = (fragCoord - viewRectangle.xy) / viewRectangle.zw ;
4755
+ return vec2u(subViewUV*size) ;
4693
4756
  }
4694
4757
 
4695
- fn insideRectangle(point:vec2f, rec:vec4f) -> bool {
4696
- if( point.x > rec.x && point.y > rec.y && point.x < (rec.x + rec.z ) && point.y < (rec.y + rec.w ) ){
4697
- return true ;
4698
- }
4699
- return false;
4758
+ fn insideRectangle( point:vec2f , rec:vec4f) -> bool {
4759
+ if( point.x > rec.x && point.y > rec.y && point.x < (rec.x + rec.z ) && point.y < (rec.y + rec.w ) ){
4760
+ return true ;
4761
+ }
4762
+ return false;
4700
4763
  }
4701
4764
 
4702
- fn convert_cube_uv_to_xyz(index:i32, u:f32, v:f32) -> vec3f {
4703
- var ret: vec3f;
4704
- var uc = 2.0f * u - 1.0f;
4705
- var vc = 2.0f * v - 1.0f;
4706
- switch(index){
4707
- case 0: {
4708
- ret.x = 1.0f;
4709
- ret.y = vc;
4710
- ret.z = -uc;
4711
- break;
4712
- }
4713
- case 1: {
4714
- ret.x = -1.0f;
4715
- ret.y = vc;
4716
- ret.z = uc;
4717
- break;
4718
- }
4719
- case 2: {
4720
- ret.x = uc;
4721
- ret.y = 1.0f;
4722
- ret.z = -vc;
4723
- break;
4724
- }
4725
- case 3: {
4726
- ret.x = uc;
4727
- ret.y = -1.0f;
4728
- ret.z = vc;
4729
- break;
4730
- }
4731
- case 4: {
4732
- ret.x = uc;
4733
- ret.y = vc;
4734
- ret.z = 1.0f;
4735
- break;
4736
- }
4737
- case 5: {
4738
- ret.x = -uc;
4739
- ret.y = vc;
4740
- ret.z = -1.0f;
4741
- break;
4742
- }
4743
- default: {
4744
- ret = vec3f(0.0);
4745
- }
4765
+ fn convert_cube_uv_to_xyz( index:i32, u:f32, v:f32) -> vec3f
4766
+ {
4767
+ var ret : vec3f ;
4768
+ // convert range 0 to 1 to -1 to 1
4769
+ var uc = 2.0f * u - 1.0f;
4770
+ var vc = 2.0f * v - 1.0f;
4771
+ switch (index)
4772
+ {
4773
+ case 0: {
4774
+ ret.x = 1.0f;
4775
+ ret.y = vc;
4776
+ ret.z = -uc;
4777
+ break;
4778
+ } // POSITIVE X
4779
+ case 1: {
4780
+ ret.x = -1.0f;
4781
+ ret.y = vc;
4782
+ ret.z = uc;
4783
+ break;
4784
+ } // NEGATIVE X
4785
+ case 2: {
4786
+ ret.x = uc;
4787
+ ret.y = 1.0f;
4788
+ ret.z = -vc;
4789
+ break;
4790
+ } // POSITIVE Y
4791
+ case 3: {
4792
+ ret.x = uc;
4793
+ ret.y = -1.0f;
4794
+ ret.z = vc;
4795
+ break;
4796
+ } // NEGATIVE Y
4797
+ case 4: {
4798
+ ret.x = uc;
4799
+ ret.y = vc;
4800
+ ret.z = 1.0f;
4801
+ break;
4802
+ } // POSITIVE Z
4803
+ case 5: {
4804
+ ret.x = -uc;
4805
+ ret.y = vc;
4806
+ ret.z = -1.0f;
4807
+ break;
4808
+ } // NEGATIVE Z
4809
+ default:{
4810
+ ret = vec3f(0.0);
4746
4811
  }
4747
- return ret;
4812
+ }
4813
+ return ret ;
4748
4814
  }
4749
4815
 
4750
- fn convert_cube_uv_to_normal(index:i32, u:f32, v:f32) -> vec3f{
4751
- var ret: vec3f;
4752
- var uc = 2.0f * u - 1.0f;
4753
- var vc = 2.0f * v - 1.0f;
4754
- switch(index){
4755
- case 0: {
4756
- ret.x = 1.0f;
4757
- ret.y = vc;
4758
- ret.z = -uc;
4759
- break;
4760
- } // POSITIVE X
4761
- case 1: {
4762
- ret.x = -1.0f;
4763
- ret.y = vc;
4764
- ret.z = uc;
4765
- break;
4766
- } // NEGATIVE X
4767
- case 2: {
4768
- ret.x = uc;
4769
- ret.y = 1.0f;
4770
- ret.z = -vc;
4771
- break;
4772
- } // POSITIVE Y
4773
- case 3: {
4774
- ret.x = uc;
4775
- ret.y = -1.0f;
4776
- ret.z = vc;
4777
- break;
4778
- } // NEGATIVE Y
4779
- case 4: {
4780
- ret.x = uc;
4781
- ret.y = vc;
4782
- ret.z = 1.0f;
4783
- break;
4784
- } // POSITIVE Z
4785
- case 5: {
4786
- ret.x = -uc;
4787
- ret.y = vc;
4788
- ret.z = -1.0f;
4789
- break;
4790
- } // NEGATIVE Z
4791
- default:{
4792
- ret = vec3f(0.0);
4793
- }
4816
+ fn convert_cube_uv_to_normal( index:i32, u:f32, v:f32) -> vec3f
4817
+ {
4818
+ var ret : vec3f ;
4819
+ // convert range 0 to 1 to -1 to 1
4820
+ var uc = 2.0f * u - 1.0f;
4821
+ var vc = 2.0f * v - 1.0f;
4822
+ switch (index)
4823
+ {
4824
+ case 0: {
4825
+ ret.x = 1.0f;
4826
+ ret.y = vc;
4827
+ ret.z = -uc;
4828
+ break;
4829
+ } // POSITIVE X
4830
+ case 1: {
4831
+ ret.x = -1.0f;
4832
+ ret.y = vc;
4833
+ ret.z = uc;
4834
+ break;
4835
+ } // NEGATIVE X
4836
+ case 2: {
4837
+ ret.x = uc;
4838
+ ret.y = 1.0f;
4839
+ ret.z = -vc;
4840
+ break;
4841
+ } // POSITIVE Y
4842
+ case 3: {
4843
+ ret.x = uc;
4844
+ ret.y = -1.0f;
4845
+ ret.z = vc;
4846
+ break;
4847
+ } // NEGATIVE Y
4848
+ case 4: {
4849
+ ret.x = uc;
4850
+ ret.y = vc;
4851
+ ret.z = 1.0f;
4852
+ break;
4853
+ } // POSITIVE Z
4854
+ case 5: {
4855
+ ret.x = -uc;
4856
+ ret.y = vc;
4857
+ ret.z = -1.0f;
4858
+ break;
4859
+ } // NEGATIVE Z
4860
+ default:{
4861
+ ret = vec3f(0.0);
4794
4862
  }
4795
- return ret;
4863
+ }
4864
+ return ret ;
4796
4865
  }
4797
4866
 
4798
- fn UvToDir(uv1:vec2f) -> vec3f{
4799
- var uv = uv1;
4800
- uv *= vec2f(2.0*3.1415926535897932384626433832795, 3.1415926535897932384626433832795);
4801
- var theta = uv.y;
4802
- var phi = uv.x + 3.1415926535897932384626433832795 * 0.5 ;
4803
- var dir = vec3f(0.0,0.0,0.0);
4804
- dir.x = sin(phi) * sin(theta) * -1;
4805
- dir.y = cos(theta) * -1;
4806
- dir.z = cos(phi) * sin(theta);
4807
- return dir;
4867
+ fn UvToDir( uv1:vec2f) -> vec3f{
4868
+ var uv = uv1 ;
4869
+ uv *= vec2f(2.0*3.1415926535897932384626433832795, 3.1415926535897932384626433832795);
4870
+ var theta = uv.y;
4871
+ var phi = uv.x + 3.1415926535897932384626433832795 * 0.5 ;
4872
+ // var phi = uv.x ;
4873
+ var dir = vec3f(0.0,0.0,0.0);
4874
+ dir.x = sin(phi) * sin(theta) * -1;
4875
+ dir.y = cos(theta) * -1;
4876
+ dir.z = cos(phi) * sin(theta);
4877
+ return dir;
4808
4878
  }
4809
4879
 
4810
- fn DirTOUV(a_coords:vec3f) -> vec2f {
4811
- var coords = normalize(a_coords);
4812
- var lon = atan2(coords.z, coords.x);
4813
- var lat = acos(coords.y);
4814
- var sphereCoords = vec2f(lon, lat) * (1.0 / 3.1415926535897932384626433832795);
4815
- return vec2f(sphereCoords.x * 0.5 + 0.5, 1.0 - sphereCoords.y);
4880
+ fn DirTOUV( a_coords:vec3f ) ->vec2f
4881
+ {
4882
+ var coords = normalize(a_coords);
4883
+ var lon = atan2(coords.z, coords.x);
4884
+ var lat = acos(coords.y);
4885
+ var sphereCoords = vec2f(lon, lat) * (1.0 / 3.1415926535897932384626433832795);
4886
+ return vec2f(sphereCoords.x * 0.5 + 0.5 , 1.0 - sphereCoords.y);
4816
4887
  }
4817
- `;
4888
+
4889
+ `
4890
+ );
4818
4891
 
4819
4892
  let PhysicMaterialUniform_frag = `
4820
4893
  #if USE_CUSTOMUNIFORM
@@ -5165,7 +5238,9 @@ let IrradianceVolumeData_frag = `
5165
5238
  }
5166
5239
  `;
5167
5240
 
5168
- let Inline_vert = `
5241
+ let Inline_vert = (
5242
+ /*wgsl*/
5243
+ `
5169
5244
  #include "MathShader"
5170
5245
  #include "FastMathShader"
5171
5246
  #include "InstanceUniform"
@@ -5186,35 +5261,35 @@ let Inline_vert = `
5186
5261
  }
5187
5262
 
5188
5263
  fn TIME_frame() -> f32 {
5189
- return globalUniform.frame;
5264
+ return globalUniform.frame ;
5190
5265
  }
5191
5266
 
5192
5267
  fn TIME_time() -> f32 {
5193
- return globalUniform.time;
5268
+ return globalUniform.time ;
5194
5269
  }
5195
5270
 
5196
5271
  fn TIME_delta() -> f32 {
5197
- return globalUniform.delta;
5272
+ return globalUniform.delta ;
5198
5273
  }
5199
5274
 
5200
5275
  fn MOUSE() -> vec2f {
5201
- return vec2f( globalUniform.mouseX, globalUniform.mouseY);
5276
+ return vec2f( globalUniform.mouseX, globalUniform.mouseY) ;
5202
5277
  }
5203
5278
 
5204
5279
  fn SCREEN() -> vec2f {
5205
- return vec2f( globalUniform.windowWidth, globalUniform.windowHeight);
5280
+ return vec2f( globalUniform.windowWidth, globalUniform.windowHeight) ;
5206
5281
  }
5207
5282
 
5208
5283
  fn ProjectionParams() -> vec3f {
5209
- return vec3f( globalUniform.near, globalUniform.far,1.0 + 1.0 / globalUniform.far);
5284
+ return vec3f( globalUniform.near, globalUniform.far,1.0 + 1.0 / globalUniform.far) ;
5210
5285
  }
5211
5286
 
5212
5287
  fn vertex_inline(vertex:VertexAttributes){
5213
- ORI_MATRIX_P = globalUniform.projMat;
5214
- ORI_MATRIX_V = globalUniform.viewMat;
5215
- ORI_MATRIX_PV = ORI_MATRIX_P * ORI_MATRIX_V;
5216
- ORI_MATRIX_PVInv = globalUniform.pvMatrixInv;
5217
- ORI_CAMERAMATRIX = globalUniform.cameraWorldMatrix;
5288
+ ORI_MATRIX_P = globalUniform.projMat ;
5289
+ ORI_MATRIX_V = globalUniform.viewMat ;
5290
+ ORI_MATRIX_PV = ORI_MATRIX_P * ORI_MATRIX_V ;
5291
+ ORI_MATRIX_PVInv = globalUniform.pvMatrixInv ;
5292
+ ORI_CAMERAMATRIX = globalUniform.cameraWorldMatrix ;
5218
5293
 
5219
5294
  ORI_MATRIX_M = models.matrix[u32(vertex.index)];
5220
5295
 
@@ -5223,7 +5298,8 @@ let Inline_vert = `
5223
5298
  ORI_MATRIX_M = models.matrix[modelID];
5224
5299
  #endif
5225
5300
  }
5226
- `;
5301
+ `
5302
+ );
5227
5303
 
5228
5304
  let Common_frag = `
5229
5305
  #include "GlobalUniform"
@@ -5288,7 +5364,9 @@ let Common_frag = `
5288
5364
  }
5289
5365
  `;
5290
5366
 
5291
- let Common_vert = `
5367
+ let Common_vert = (
5368
+ /*wgsl*/
5369
+ `
5292
5370
  #include "WorldMatrixUniform"
5293
5371
  #include "VertexAttributes_vert"
5294
5372
  #include "GlobalUniform"
@@ -5297,9 +5375,10 @@ let Common_vert = `
5297
5375
  fn VertMain( vertex:VertexAttributes ) -> VertexOutput {
5298
5376
  vertex_inline(vertex);
5299
5377
  vert(vertex);
5300
- return ORI_VertexOut;
5378
+ return ORI_VertexOut ;
5301
5379
  }
5302
- `;
5380
+ `
5381
+ );
5303
5382
 
5304
5383
  let BrdfLut_frag = (
5305
5384
  /*wgsl*/
@@ -5329,103 +5408,122 @@ class CSM {
5329
5408
  static Cascades = 4;
5330
5409
  }
5331
5410
 
5332
- let GlobalUniform = `
5411
+ let GlobalUniform = (
5412
+ /*wgsl*/
5413
+ `
5333
5414
 
5334
- #include "MathShader"
5415
+ #include "MathShader"
5335
5416
 
5336
- struct GlobalUniform {
5337
-
5338
- projMat: mat4x4<f32>,
5339
- viewMat: mat4x4<f32>,
5340
- cameraWorldMatrix: mat4x4<f32>,
5341
- pvMatrixInv: mat4x4<f32>,
5342
- viewToWorld: mar4x4<f32>,
5343
- shadowMatrix: array<mat4x4<f32>, 8u>,
5344
- csmShadowBias: vec4<f32>,
5345
- csmMatrix: array<mat4x4<f32>,${CSM.Cascades}>,
5346
- shadowLights:mat4x4<f32>,
5347
- reflectionProbeSize:f32,
5348
- reflectionProbeMaxCount:f32,
5349
- reflectionMapWidth:f32,
5350
- reflectionMapHeight:f32,
5351
- reflectionCount:f32,
5352
- test2:f32,
5353
- test3:f32,
5354
- test4:f32,
5355
- CameraPos: vec3<f32>,
5356
- frame: f32,
5357
- SH: array<vec4f,9u>,
5358
- time: f32,
5359
- delta: f32,
5360
- shadowBias: f32,
5361
- skyExposure: f32,
5362
- renderPassState: f32,
5363
- quadScale: f32,
5364
- hdrExposure: f32,
5365
- renderState_left: i32,
5366
- renderState_right: i32,
5367
- renderState_split: f32,
5368
- mouseX: f32,
5369
- mouseY: f32,
5370
- windowWidth: f32,
5371
- windowHeight: f32,
5372
- near: f32,
5373
- far: f32,
5374
- pointShadowBias: f32,
5375
- shadowMapSize: f32,
5376
- shadowSoft: f32,
5377
- enableCSM:f32,
5378
- csmMargin:f32,
5379
- nDirShadowStart: i32,
5380
- nDirShadowEnd: i32,
5381
- nPointShadowStart: i32,
5382
- nPointShadowEnd: i32,
5383
- cameraForward:vec3f,
5384
- frustumPlanes: array<vec4f, 6u>,
5385
- };
5417
+ struct GlobalUniform {
5386
5418
 
5387
- @group(0) @binding(0)
5388
- var<uniform> globalUniform: GlobalUniform;
5419
+ projMat: mat4x4<f32>,
5420
+ viewMat: mat4x4<f32>,
5421
+ cameraWorldMatrix: mat4x4<f32>,
5422
+ pvMatrixInv : mat4x4<f32>,
5423
+ viewToWorld : mat4x4<f32>,
5424
+ shadowMatrix: array<mat4x4<f32>, 8u>,
5389
5425
 
5390
- fn getViewPosition(z:f32,uv:vec2f) -> vec3f {
5391
- let pvMatrixInv = globalUniform.pvMatrixInv;
5392
- let clip = vec4<f32>((uv * 2.0 - 1.0), z, 1.0);
5393
- var viewPos = pvMatrixInv * clip;
5394
- return viewPos.xyz / viewPos.w;
5395
- }
5426
+ csmShadowBias: vec4<f32>,
5396
5427
 
5397
- fn getWorldPosition(z:f32,uv:vec2f) -> vec3f {
5398
- let viewToWorld = globalUniform.viewToWorld;
5399
- let clip = vec4<f32>((uv * 2.0 -1.0), z, 1.0);
5400
- var worldPos = viewToWorld * clip;
5401
- worldPos = worldPos / worldPos.w;
5402
- return worldPos.xyz;
5403
- }
5428
+ csmMatrix: array<mat4x4<f32>,${CSM.Cascades}>,
5429
+
5430
+ shadowLights:mat4x4<f32>,
5404
5431
 
5405
- var<private> NORMALMATRIX_INV : mat3x3<f32>;
5406
- var<private> NORMALMATRIX : mat3x3<f32>;
5407
- fn useNormalMatrix() {
5408
- let finalMatrix = globalUniform.projMat * globalUniform.viewMat;
5409
- let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,fianlMatrix[2].xyz);
5410
- NORMALMATRIX = transpose(inverse(nMat));
5411
- }
5432
+ reflectionProbeSize:f32,
5433
+ reflectionProbeMaxCount:f32,
5434
+ reflectionMapWidth:f32,
5435
+ reflectionMapHeight:f32,
5412
5436
 
5413
- fn useNormalMatrixInv() {
5414
- let finalMatrix = globalUniform.projMat * globalUniform.viewMat;
5415
- let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,finalMatrix[2].xyz);
5416
- NORMALMATRIX_INV = transpose((nMat));
5417
- }
5437
+ reflectionCount:f32,
5438
+ test2:f32,
5439
+ test3:f32,
5440
+ test4:f32,
5418
5441
 
5419
- fn getWorldNormal(viewNormal:vec3f) -> vec3f {
5420
- var worldNormal = NORMALMATRIX_INV * viewNormal;
5421
- return normalize(worldNormal.xyz);
5422
- }
5442
+ CameraPos: vec3<f32>,
5443
+ frame: f32,
5444
+ SH: array<vec4f, 9u> ,
5423
5445
 
5424
- fn getViewNormal(worldNormal:vec3f) -> vec3f {
5425
- var viewNormal = globalUniform.viewMat * vec4f(worldNormal,0.0);
5426
- return normalize(viewNormal.xyz);
5427
- }
5428
- `;
5446
+ time: f32,
5447
+ delta: f32,
5448
+ shadowBias: f32,
5449
+ skyExposure: f32,
5450
+
5451
+ renderPassState:f32,
5452
+ quadScale: f32,
5453
+ hdrExposure: f32,
5454
+ renderState_left: i32,
5455
+
5456
+ renderState_right: i32,
5457
+ renderState_split: f32,
5458
+ mouseX: f32,
5459
+ mouseY: f32,
5460
+
5461
+ windowWidth: f32,
5462
+ windowHeight: f32,
5463
+ near: f32,
5464
+ far: f32,
5465
+
5466
+ pointShadowBias: f32,
5467
+ shadowMapSize: f32,
5468
+ shadowSoft: f32,
5469
+ enableCSM:f32,
5470
+
5471
+
5472
+ csmMargin:f32,
5473
+ nDirShadowStart: i32,
5474
+ nDirShadowEnd: i32,
5475
+ nPointShadowStart: i32,
5476
+
5477
+ nPointShadowEnd: i32,
5478
+ cameraForward:vec3f,
5479
+
5480
+ frustumPlanes: array<vec4f, 6u>,
5481
+
5482
+ };
5483
+
5484
+ @group(0) @binding(0)
5485
+ var<uniform> globalUniform: GlobalUniform;
5486
+
5487
+ fn getViewPosition(z:f32,uv:vec2f) -> vec3f {
5488
+ let pvMatrixInv = globalUniform.pvMatrixInv ;
5489
+ let clip = vec4<f32>((uv * 2.0 - 1.0) , z , 1.0);
5490
+ var viewPos = pvMatrixInv * clip ;
5491
+ return viewPos.xyz / viewPos.w ;
5492
+ }
5493
+
5494
+ fn getWorldPosition(z:f32,uv:vec2f) -> vec3f {
5495
+ let viewToWorld = globalUniform.viewToWorld ;
5496
+ let clip = vec4<f32>((uv * 2.0 - 1.0) , z , 1.0);
5497
+ var worldPos = viewToWorld * clip ;
5498
+ worldPos = worldPos / worldPos.w ;
5499
+ return worldPos.xyz ;
5500
+ }
5501
+
5502
+ var<private> NORMALMATRIX_INV : mat3x3<f32> ;
5503
+ var<private> NORMALMATRIX : mat3x3<f32> ;
5504
+ fn useNormalMatrix() {
5505
+ let finalMatrix = globalUniform.projMat * globalUniform.viewMat ;
5506
+ let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,finalMatrix[2].xyz) ;
5507
+ NORMALMATRIX = transpose(inverse( nMat ));
5508
+ }
5509
+
5510
+ fn useNormalMatrixInv() {
5511
+ let finalMatrix = globalUniform.projMat * globalUniform.viewMat ;
5512
+ let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,finalMatrix[2].xyz) ;
5513
+ NORMALMATRIX_INV = transpose(( nMat ));
5514
+ }
5515
+
5516
+ fn getWorldNormal(viewNormal:vec3f) -> vec3f {
5517
+ var worldNormal = NORMALMATRIX_INV * viewNormal ;
5518
+ return normalize(worldNormal.xyz);
5519
+ }
5520
+
5521
+ fn getViewNormal(worldNormal:vec3f) -> vec3f {
5522
+ var viewNormal = globalUniform.viewMat * vec4f(worldNormal,0.0) ;
5523
+ return normalize(viewNormal.xyz);
5524
+ }
5525
+ `
5526
+ );
5429
5527
 
5430
5528
  let InstanceUniform = `
5431
5529
  #if USE_INSTANCEDRAW
@@ -5437,14 +5535,17 @@ let InstanceUniform = `
5437
5535
  #endif
5438
5536
  `;
5439
5537
 
5440
- let WorldMatrixUniform = `
5538
+ let WorldMatrixUniform = (
5539
+ /*wgsl*/
5540
+ `
5441
5541
  struct Uniforms {
5442
- matrix: array<mat4x4<f32>>
5542
+ matrix : array<mat4x4<f32>>
5443
5543
  };
5444
5544
 
5445
- @group(0) @building(1)
5446
- var<storage, read> models: Uniforms;
5447
- `;
5545
+ @group(0) @binding(1)
5546
+ var<storage, read> models : Uniforms;
5547
+ `
5548
+ );
5448
5549
 
5449
5550
  let FastMathShader = `
5450
5551
  fn pow2(x:f32) -> f32 {
@@ -5515,7 +5616,7 @@ let FastMathShader = `
5515
5616
  return res ;
5516
5617
  }else{
5517
5618
  return PI - res ;
5518
- }
5619
+ };
5519
5620
  }
5520
5621
 
5521
5622
  fn acosFast4( inX : f32 )-> f32
@@ -5534,12 +5635,15 @@ let FastMathShader = `
5534
5635
  return s ;
5535
5636
  }else{
5536
5637
  return PI - s ;
5537
- }
5638
+ };
5538
5639
  }
5539
5640
  `;
5540
5641
 
5541
- let NormalMap_frag = `
5542
- fn perturbNormal( worldPos:vec3<f32>, surf_norm:vec3<f32>, mapN:vec3<f32>, normalScale:f32, face:f32 ) -> vec3<f32> {
5642
+ let NormalMap_frag = (
5643
+ /*wgsl*/
5644
+ `
5645
+
5646
+ fn perturbNormal( worldPos:vec3<f32>, surf_norm:vec3<f32>, mapN:vec3<f32> , normalScale:f32 , face:f32 ) -> vec3<f32> {
5543
5647
  var q0 = vec3<f32>( dpdx( worldPos.x ), dpdx( worldPos.y ), dpdx( worldPos.z ) );
5544
5648
  var q1 = vec3<f32>( dpdy( worldPos.x ), dpdy( worldPos.y ), dpdy( worldPos.z ) );
5545
5649
  var st0 = dpdx( ORI_VertexVarying.fragUV0.xy );
@@ -5547,12 +5651,17 @@ let NormalMap_frag = `
5547
5651
  var N = surf_norm;
5548
5652
  var q0perp = cross( N, q0 );
5549
5653
  var q1perp = cross( q1, N );
5654
+
5655
+ var T = q1perp * st0.x + q0perp * st1.x;
5656
+
5550
5657
  var B = q1perp * st0.y + q0perp * st1.y;
5658
+
5551
5659
  var det = max( dot( T, T ), dot( B, B ) );
5552
5660
  var scale = 1.0 ;
5553
5661
  if( det != 0.0 ){
5554
5662
  scale = inverseSqrt( det ) ;
5555
5663
  }
5664
+
5556
5665
  scale *= normalScale;
5557
5666
  return normalize( (T * ( -mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ) * face ) ;
5558
5667
  }
@@ -5593,7 +5702,8 @@ let NormalMap_frag = `
5593
5702
  var outN = perturbNormal(ORI_VertexVarying.vWorldPos.xyz,ORI_VertexVarying.vWorldNormal,mapNormal,1.0,face) ;
5594
5703
  return outN ;
5595
5704
  }
5596
- `;
5705
+ `
5706
+ );
5597
5707
 
5598
5708
  let FragmentVarying = `
5599
5709
  struct FragmentVarying {
@@ -5687,7 +5797,7 @@ let IESProfiles_frag = `
5687
5797
  return textureSampleLevel(iesTextureArrayMap, iesTextureArrayMapSampler, vec2<f32>(normAngle , normTangentAngle) , i32(light.ies) , 0.0).r ;
5688
5798
  }else{
5689
5799
  return 1.0;
5690
- }
5800
+ };
5691
5801
  #else
5692
5802
  return 1.0;
5693
5803
  #endif
@@ -5755,12 +5865,12 @@ let ShadowMapping_frag = `
5755
5865
  weight *= 1.0 - totalWeight;
5756
5866
  visibility += csmShadowResult.x * weight;
5757
5867
  totalWeight += weight;
5758
- }
5868
+ };
5759
5869
 
5760
5870
  if(validCount >= 2 || totalWeight >= 0.99){
5761
5871
  csmLevel = csm;
5762
5872
  break;
5763
- }
5873
+ };
5764
5874
  }
5765
5875
  }
5766
5876
 
@@ -5769,7 +5879,7 @@ let ShadowMapping_frag = `
5769
5879
  visibility = 1.0;
5770
5880
  }else{
5771
5881
  visibility = visibility / totalWeight ;
5772
- }
5882
+ };
5773
5883
  } else {
5774
5884
  shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
5775
5885
  if(enableCSM) {
@@ -5818,7 +5928,7 @@ let ShadowMapping_frag = `
5818
5928
  totalWeight += weight;
5819
5929
  }else{
5820
5930
  totalWeight += 1.0;
5821
- }
5931
+ };
5822
5932
  }
5823
5933
  }
5824
5934
  visibility /= totalWeight;
@@ -6631,7 +6741,9 @@ let BRDF_frag = `
6631
6741
  }
6632
6742
  `;
6633
6743
 
6634
- let BxDF_frag = `
6744
+ let BxDF_frag = (
6745
+ /*wgsl*/
6746
+ `
6635
6747
  #include "Clearcoat_frag"
6636
6748
  #include "BRDF_frag"
6637
6749
  #include "MathShader"
@@ -6649,7 +6761,9 @@ let BxDF_frag = `
6649
6761
  #include "BxdfDebug_frag"
6650
6762
  #include "ReflectionCG"
6651
6763
 
6764
+ //ORI_ShadingInput
6652
6765
  fn initFragData() {
6766
+ // fragData.Albedo = vec4f(gammaToLiner(ORI_ShadingInput.BaseColor.rgb),ORI_ShadingInput.BaseColor.w) ;
6653
6767
  fragData.Albedo = vec4f((ORI_ShadingInput.BaseColor.rgb),ORI_ShadingInput.BaseColor.w) ;
6654
6768
  fragData.Ao = clamp( pow(ORI_ShadingInput.AmbientOcclusion,materialUniform.ao) , 0.0 , 1.0 ) ;
6655
6769
  fragData.Roughness = clamp((ORI_ShadingInput.Roughness),0.0001,1.0) * 1.85 ;
@@ -6665,13 +6779,19 @@ let BxDF_frag = `
6665
6779
 
6666
6780
  let R = 2.0 * dot( fragData.V , fragData.N ) * fragData.N - fragData.V ;
6667
6781
  fragData.R = R ;//reflect( fragData.V , fragData.N ) ;
6782
+
6668
6783
  fragData.NoV = saturate(dot(fragData.N, fragData.V)) ;
6784
+
6669
6785
  fragData.F0 = mix(vec3<f32>(0.04), fragData.Albedo.rgb , fragData.Metallic);
6786
+ // fragData.F0 = gammaToLiner(fragData.F0);
6787
+
6670
6788
  fragData.F = computeFresnelSchlick(fragData.NoV, fragData.F0);
6671
6789
  fragData.KD = vec3<f32>(fragData.F) ;
6672
6790
  fragData.KS = vec3<f32>(0.0) ;
6791
+
6673
6792
  fragData.Indirect = 0.0 ;
6674
6793
  fragData.Reflectance = 1.0 ;
6794
+
6675
6795
  fragData.ClearcoatRoughness = materialUniform.clearcoatRoughnessFactor ;
6676
6796
  fragData.ClearcoatIor = materialUniform.clearcoatIor ;
6677
6797
  fragData.ClearcoatFactor = materialUniform.clearcoatFactor;
@@ -6684,7 +6804,9 @@ let BxDF_frag = `
6684
6804
 
6685
6805
  fn BxDFShading(){
6686
6806
  initFragData();
6807
+
6687
6808
  let sunLight = lightBuffer[0] ;
6809
+
6688
6810
  var irradiance = vec3<f32>(0.0) ;
6689
6811
  #if USEGI
6690
6812
  irradiance += getIrradiance().rgb ;
@@ -6745,6 +6867,7 @@ let BxDF_frag = `
6745
6867
  }
6746
6868
 
6747
6869
  //***********indirect-ambient part*********
6870
+ // var kdLast = (1.0 - 0.04) * (1.0 - fragData.Metallic);
6748
6871
  var iblDiffuseResult : vec3f ;
6749
6872
 
6750
6873
  let MAX_LOD = i32(textureNumLevels(prefilterMap)) ;
@@ -6758,7 +6881,8 @@ let BxDF_frag = `
6758
6881
  indirectionSpec *= globalUniform.hdrExposure ;
6759
6882
  #endif
6760
6883
 
6761
- var color = vec3f(iblDiffuseResult + indirectionSpec + specColor);
6884
+ var color = vec3f(iblDiffuseResult + indirectionSpec + specColor) ;
6885
+ // var color = vec3f(indirectionDiffuse ) ;
6762
6886
 
6763
6887
  var clearCoatColor = vec3<f32>(0.0);
6764
6888
  #if USE_CLEARCOAT
@@ -6783,6 +6907,9 @@ let BxDF_frag = `
6783
6907
  break;
6784
6908
  }
6785
6909
  case SpotLightType: {
6910
+ // var lightColor = light.lightColor.rgb ;
6911
+ // var att = pointAtt(ORI_VertexVarying.vWorldPos.xyz, light);
6912
+ // clearCoatColor += ClearCoat_BRDF( color , materialUniform.clearcoatColor.rgb , 1.5 , clearNormal , light.direction , fragData.V , clearcoatRoughness , lightColor, att );
6786
6913
  break;
6787
6914
  }
6788
6915
  default: {
@@ -6821,7 +6948,9 @@ let BxDF_frag = `
6821
6948
  ORI_FragmentOutput.color = viewColor ;
6822
6949
  #endif
6823
6950
  }
6824
- `;
6951
+
6952
+ `
6953
+ );
6825
6954
 
6826
6955
  let BsDF_frag = `
6827
6956
  #include "Clearcoat_frag"
@@ -7021,7 +7150,9 @@ let Lit_shader = `
7021
7150
  }
7022
7151
  `;
7023
7152
 
7024
- let PBRLItShader = `
7153
+ let PBRLItShader = (
7154
+ /*wgsl*/
7155
+ `
7025
7156
  #include "Common_vert"
7026
7157
  #include "Common_frag"
7027
7158
  #include "BxDF_frag"
@@ -7036,10 +7167,10 @@ let PBRLItShader = `
7036
7167
  @group(1) @binding(auto)
7037
7168
  var normalMap: texture_2d<f32>;
7038
7169
 
7039
- @group(1) @binding(auto)
7040
- var maskMapSampler: sampler;
7041
- @group(1) @binding(auto)
7042
- var maskMap: texture_2d<f32>;
7170
+ @group(1) @binding(auto)
7171
+ var maskMapSampler: sampler;
7172
+ @group(1) @binding(auto)
7173
+ var maskMap: texture_2d<f32>;
7043
7174
 
7044
7175
  #if USE_AOTEX
7045
7176
  @group(1) @binding(auto)
@@ -7053,38 +7184,39 @@ let PBRLItShader = `
7053
7184
  @group(1) @binding(auto)
7054
7185
  var emissiveMap: texture_2d<f32>;
7055
7186
 
7056
- var<private> debugOut: vec4f = vec4f(0.0);
7187
+ var<private> debugOut : vec4f = vec4f(0.0) ;
7057
7188
 
7058
7189
  fn vert(inputData:VertexAttributes) -> VertexOutput {
7059
- ORI_Vert(inputData);
7060
- return ORI_VertextOut;
7190
+ ORI_Vert(inputData) ;
7191
+ return ORI_VertexOut ;
7061
7192
  }
7062
7193
 
7063
7194
  fn frag(){
7195
+
7064
7196
  let baseMapOffsetSize = materialUniform.baseMapOffsetSize;
7065
- var uv = transformUV(ORI_VertexVarying.fragUV0, baseMapOffsetSize);
7197
+ var uv = transformUV(ORI_VertexVarying.fragUV0,baseMapOffsetSize) ;
7066
7198
 
7067
7199
  #if USE_SRGB_ALBEDO
7068
- ORI_ShadingInput.BaseColor = textureSample(baseMap, baseMapSampler, uv);
7069
- ORI_ShadingInput.BaseColor = vec4<f32>(ORI_ShadingInput.BaseColor * materialUniform.baseColor.rgb, ORI_ShadingInput.BaseColor.w * materialUniform.baseColor.a);
7200
+ ORI_ShadingInput.BaseColor = textureSample(baseMap, baseMapSampler, uv ) ;
7201
+ ORI_ShadingInput.BaseColor = vec4<f32>( ORI_ShadingInput.BaseColor * materialUniform.baseColor.rgb, ORI_ShadingInput.BaseColor.w * materialUniform.baseColor.a) ;
7070
7202
  #else
7071
- ORI_ShadingInput.BaseColor = textureSampler(baseMap, baseMapSampler, uv);
7072
- ORI_ShadingInput.BaseColor = vec4f(gammaToLiner(ORI_ShadingInput.BaseColor.rgb), ORI_ShadingInput.BaseColor.a);
7073
- ORI_ShadingInput.BaseColor *= vec4f(materialUniform.baseColor.rgba);
7203
+ ORI_ShadingInput.BaseColor = textureSample(baseMap, baseMapSampler, uv ) ;
7204
+ ORI_ShadingInput.BaseColor = vec4f(gammaToLiner(ORI_ShadingInput.BaseColor.rgb),ORI_ShadingInput.BaseColor.a) ;
7205
+ ORI_ShadingInput.BaseColor *= vec4f(materialUniform.baseColor.rgba) ;
7074
7206
  #endif
7075
7207
 
7076
7208
  let roughnessMapOffsetSize = materialUniform.roughnessMapOffsetSize;
7077
- var uv4 = transformUV(ORI_VertexVarying.fragUV0, roughnessMapOffsetSize);
7078
- var maskTex = textureSample(maskMap, maskMapSampler, uv4);
7079
-
7209
+ var uv4 = transformUV(ORI_VertexVarying.fragUV0,roughnessMapOffsetSize);
7210
+ var maskTex = textureSample(maskMap, maskMapSampler, uv4 );
7211
+
7080
7212
  #if USE_ALPHA_A
7081
- ORI_ShadingInput.BaseColor.a = ORI_ShadingInput.BaseColor.a * (maskTex.a);
7213
+ ORI_ShadingInput.BaseColor.a = ORI_ShadingInput.BaseColor.a * (maskTex.a) ;
7082
7214
  #endif
7083
7215
 
7084
- #if USE_ALPHACUT
7216
+ #if USE_ALPHACUT
7085
7217
  if( (ORI_ShadingInput.BaseColor.a - materialUniform.alphaCutoff) <= 0.0 ){
7086
7218
  ORI_FragmentOutput.color = vec4<f32>(0.0,0.0,0.0,1.0);
7087
-
7219
+
7088
7220
  #if USEGBUFFER
7089
7221
  ORI_FragmentOutput.worldPos = vec4<f32>(0.0,0.0,0.0,1.0);
7090
7222
  ORI_FragmentOutput.worldNormal = vec4<f32>(0.0,0.0,0.0,1.0);
@@ -7097,7 +7229,7 @@ let PBRLItShader = `
7097
7229
 
7098
7230
  useShadow();
7099
7231
 
7100
- var roughnessChannel: f32 = 1.0;
7232
+ var roughnessChannel:f32 = 1.0 ;
7101
7233
  #if USE_ROUGHNESS_A
7102
7234
  roughnessChannel = maskTex.a ;
7103
7235
  #else if USE_ROUGHNESS_R
@@ -7108,16 +7240,16 @@ let PBRLItShader = `
7108
7240
  roughnessChannel = maskTex.b ;
7109
7241
  #else if USE_ALBEDO_A
7110
7242
  roughnessChannel = ORI_ShadingInput.BaseColor.a ;
7111
- #endif
7243
+ #endif
7112
7244
 
7113
7245
  #if USE_SMOOTH
7114
7246
  var roughness = ( 1.0 - roughnessChannel ) * materialUniform.roughness;
7115
- ORI_ShadingInput.Roughness = clamp(roughness, 0.0001, 1.0);
7247
+ ORI_ShadingInput.Roughness = clamp(roughness , 0.0001 , 1.0);
7116
7248
  #else
7117
- ORI_ShadingInput.Roughness = clamp(roughness * materialUniform.roughness, 0.0001, 1.0);
7118
- #endif
7249
+ ORI_ShadingInput.Roughness = clamp(roughnessChannel * materialUniform.roughness ,0.0001,1.0);
7250
+ #endif
7119
7251
 
7120
- var metallicChannel:f32 = 1.0;
7252
+ var metallicChannel:f32 = 1.0 ;
7121
7253
  #if USE_METALLIC_A
7122
7254
  metallicChannel = maskTex.a ;
7123
7255
  #else if USE_METALLIC_R
@@ -7126,16 +7258,16 @@ let PBRLItShader = `
7126
7258
  metallicChannel = maskTex.g ;
7127
7259
  #else if USE_METALLIC_B
7128
7260
  metallicChannel = maskTex.b ;
7129
- #endif
7130
-
7131
- ORI_ShadingInput.Metallic = metallicChannel * materialUniform.metallic;
7261
+ #endif
7132
7262
 
7133
- var aoChannel: f32 = 1.0;
7134
- #if USE_AOTEX;
7263
+ ORI_ShadingInput.Metallic = metallicChannel * materialUniform.metallic ;
7264
+
7265
+ var aoChannel:f32 = 1.0 ;
7266
+ #if USE_AOTEX
7135
7267
  let aoMapOffsetSize = materialUniform.aoMapOffsetSize;
7136
7268
  var aoMapOffsetSizeUV = transformUV(ORI_VertexVarying.fragUV0,aoMapOffsetSize);
7137
7269
  var aoMap = textureSample(aoMap, aoMapSampler, ORI_VertexVarying.fragUV0 );
7138
- aoChannel = aoMap.g;
7270
+ aoChannel = aoMap.g ;
7139
7271
  #else
7140
7272
  #if USE_AO_A
7141
7273
  aoChannel = maskTex.a ;
@@ -7148,12 +7280,11 @@ let PBRLItShader = `
7148
7280
  #endif
7149
7281
  #endif
7150
7282
 
7151
- ORI_ShadingInput.AmbientOcclusion = aoChannel;
7152
- ORI_ShadingInput.Specular = 1.0;
7283
+ ORI_ShadingInput.AmbientOcclusion = aoChannel ;
7284
+ ORI_ShadingInput.Specular = 1.0 ;
7153
7285
 
7154
7286
  let emissiveMapOffsetSize = materialUniform.emissiveMapOffsetSize;
7155
- var emissiveUV = transformUV(ORI_VertexVarying.fragUV0,emissiveMapOffsetSize);
7156
-
7287
+ var emissiveUV = transformUV(ORI_VertexVarying.fragUV0,emissiveMapOffsetSize) ;
7157
7288
  #if USE_EMISSIVEMAP
7158
7289
  var emissiveMapColor = textureSample(emissiveMap, emissiveMapSampler , emissiveUV ) ;
7159
7290
  let emissiveColor = materialUniform.emissiveColor.rgb * emissiveMapColor.rgb * materialUniform.emissiveIntensity ;
@@ -7164,23 +7295,66 @@ let PBRLItShader = `
7164
7295
  #endif
7165
7296
 
7166
7297
  let normalMapOffsetSize = materialUniform.normalMapOffsetSize;
7167
- var nomralUV = transformUV(ORI_VertexVarying.fragUV0,normalMapOffsetSize);
7168
- var Normal = textureSample(normalMap,normalMapSampler,nomralUV).rgb;
7169
- let normal = unPackRGNormal(Normal,1.0,1.0);
7170
- ORI_ShadingInput.Normal = normal;
7171
-
7298
+ var nomralUV = transformUV(ORI_VertexVarying.fragUV0,normalMapOffsetSize) ;
7299
+ var Normal = textureSample(normalMap,normalMapSampler,nomralUV).rgb ;
7300
+ let normal = unPackRGNormal(Normal,1.0,1.0) ;
7301
+ ORI_ShadingInput.Normal = normal ;
7302
+
7172
7303
  BxDFShading();
7304
+
7173
7305
  }
7174
- `;
7306
+ `
7307
+ );
7308
+
7309
+ let BxdfDebug_frag = (
7310
+ /*wgsl*/
7311
+ `
7312
+ #include "ClusterDebug_frag"
7175
7313
 
7176
- let BxdfDebug_frag = `
7177
- #include "ClusterDebug_frag"
7314
+ fn debugPosition(){
7315
+ }
7178
7316
 
7179
7317
  fn debugMeshID(){
7180
7318
  let meshIDColor = u32(round(ORI_VertexVarying.vWorldPos.w) ) ;
7181
7319
  let color = colorSet[ meshIDColor % 9u] ;
7182
7320
  }
7183
7321
 
7322
+ fn debugNormal(){
7323
+ }
7324
+
7325
+ fn debugUV(){
7326
+ }
7327
+
7328
+ fn debugColor(){
7329
+ }
7330
+
7331
+ fn debugDiffuse(){
7332
+ }
7333
+
7334
+ fn debugAmbient(){
7335
+ }
7336
+
7337
+ fn debugEmissive(){
7338
+ }
7339
+
7340
+ fn debugEnvment(){
7341
+ }
7342
+
7343
+ fn debugAo(){
7344
+ }
7345
+
7346
+ fn debugRoughness(){
7347
+ }
7348
+
7349
+ fn debugMetallic(){
7350
+ }
7351
+
7352
+ fn debugIrradiance(){
7353
+ }
7354
+
7355
+ fn debugTangent(){
7356
+ }
7357
+
7184
7358
  fn debugFragmentOut(){
7185
7359
  if(ORI_VertexVarying.fragCoord.x > globalUniform.renderState_split) {
7186
7360
  switch (globalUniform.renderState_right)
@@ -7310,17 +7484,20 @@ let BxdfDebug_frag = `
7310
7484
  }
7311
7485
  }
7312
7486
  }
7313
- `;
7487
+ `
7488
+ );
7314
7489
 
7315
- let FullQuad_vert_wgsl = `
7490
+ let FullQuad_vert_wgsl = (
7491
+ /*wgsl*/
7492
+ `
7316
7493
  #include "WorldMatrixUniform"
7317
7494
  #include "GlobalUniform"
7318
7495
 
7319
7496
  struct MaterialUniform {
7320
- x:f32,
7321
- y:f32,
7322
- width:f32,
7323
- height:f32,
7497
+ x:f32,
7498
+ y:f32,
7499
+ width:f32,
7500
+ height:f32,
7324
7501
  };
7325
7502
 
7326
7503
  struct VertexOutput {
@@ -7329,39 +7506,51 @@ let FullQuad_vert_wgsl = `
7329
7506
  };
7330
7507
 
7331
7508
  @vertex
7332
- fn main(@builtin(vertex_index) vertexIndex: u32, @builtin(instance_index) index){
7333
- const pos = array(vec2(-1.0, -1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(1.0, -1.0), vec2(1.0, 1.0));
7334
- const uv = array(vec2(1.0, 0.0), vec2(1.0, 1.0), vec2(0.0, 1.0), vec2(1.0, 0.0), vec2(0.0, 1.0), vec2(0.0, 0.0));
7335
- let id = u32(index);
7336
- var output: VertexOutput;
7337
- output.fragUV = uv[vertexIndex];
7338
- output.position = vec4<f32>(pos[vertexIndex] , 0.0, 1.0);
7339
- return output;
7509
+ fn main(@builtin(vertex_index) vertexIndex : u32, @builtin(instance_index) index : u32 ) -> VertexOutput {
7510
+ const pos = array(
7511
+ vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0),
7512
+ vec2(-1.0, 1.0), vec2(1.0, -1.0), vec2(1.0, 1.0),
7513
+ );
7514
+ const uv = array(
7515
+ vec2(1.0, 0.0), vec2(1.0, 1.0), vec2(0.0, 1.0),
7516
+ vec2(1.0, 0.0), vec2(0.0, 1.0), vec2(0.0, 0.0),
7517
+ );
7518
+ let id = u32(index) ;
7519
+ var output : VertexOutput;
7520
+ output.fragUV = uv[vertexIndex] ;
7521
+ output.position = vec4<f32>(pos[vertexIndex] , 0.0, 1.0) ;
7522
+ return output ;
7340
7523
  }
7341
- `;
7342
- let Quad_vert_wgsl = `
7343
- #include "WorldMatrixUniform"
7344
- #include "GlobalUniform"
7345
-
7346
- struct MaterialUniform {
7347
- x: f32,
7348
- y: f32,
7524
+ `
7525
+ );
7526
+ let Quad_vert_wgsl = (
7527
+ /*wgsl*/
7528
+ `
7529
+ #include "WorldMatrixUniform"
7530
+ #include "GlobalUniform"
7531
+
7532
+ struct MaterialUniform {
7533
+ x:f32,
7534
+ y:f32,
7349
7535
  width:f32,
7350
7536
  height:f32,
7351
- };
7537
+ };
7352
7538
 
7353
- struct VertexOutput {
7354
- @location(auto) fragUV: vec2<f32>,
7355
- @builtin(position) member: vec4<f32>
7356
- };
7539
+ struct VertexOutput {
7540
+ @location(auto) fragUV: vec2<f32>,
7541
+ @builtin(position) member: vec4<f32>
7542
+ };
7357
7543
 
7358
- @vertex
7359
- fn main(@builtin(instance_index) index: u32, @location(auto) position: vec3<f32>, @location(auto) TEXCOORD_1: vec2<f32>) -> VertexOutput {
7360
- let uv = vec2(((TEXCOORD_1.xy * 2.0) - vec2<f32>(1.0)));
7361
- return VertexOutput(TEXCOORD_1, vec4<f32>(uv, 0.0, 1.0));
7362
- }
7363
- `;
7364
- let Quad_frag_wgsl = `
7544
+ @vertex
7545
+ fn main(@builtin(instance_index) index : u32,@location(auto) position: vec3<f32>, @location(auto) TEXCOORD_1: vec2<f32>) -> VertexOutput {
7546
+ let uv = vec2(((TEXCOORD_1.xy * 2.0) - vec2<f32>(1.0))) ;// / windowSize * size - offset ;
7547
+ return VertexOutput(TEXCOORD_1, vec4<f32>(uv, 0.0, 1.0));
7548
+ }
7549
+ `
7550
+ );
7551
+ let Quad_frag_wgsl = (
7552
+ /*wgsl*/
7553
+ `
7365
7554
  struct FragmentOutput {
7366
7555
  @location(auto) o_Target: vec4<f32>
7367
7556
  };
@@ -7370,22 +7559,25 @@ let Quad_frag_wgsl = `
7370
7559
  var<private> o_Target: vec4<f32>;
7371
7560
  @group(1) @binding(0)
7372
7561
  var baseMapSampler: sampler;
7373
- @group(1) @binding(0)
7562
+ @group(1) @binding(1)
7374
7563
  var baseMap: texture_2d<f32>;
7375
7564
 
7376
7565
  @fragment
7377
7566
  fn main(@location(auto) fragUV: vec2<f32>) -> FragmentOutput {
7378
- var uv = fragUV;
7379
- uv.y = 1.0 -uv.y;
7380
- var color: vec4<f32> = textureSample(baseMap, baseMapSampler, uv);
7567
+ var uv = fragUV ;
7568
+ uv.y = 1.0 - uv.y ;
7569
+ var color: vec4<f32> = textureSample(baseMap, baseMapSampler, uv );
7381
7570
 
7382
7571
  return FragmentOutput(color);
7383
7572
  }
7384
- `;
7385
- let Quad_depth2d_frag_wgsl = `
7573
+ `
7574
+ );
7575
+ let Quad_depth2d_frag_wgsl = (
7576
+ /*wgsl*/
7577
+ `
7386
7578
  struct FragmentOutput {
7387
7579
  @location(auto) o_Target: vec4<f32>
7388
- };
7580
+ };
7389
7581
 
7390
7582
  var<private> fragUV1: vec2<f32>;
7391
7583
  var<private> o_Target: vec4<f32>;
@@ -7393,21 +7585,25 @@ let Quad_depth2d_frag_wgsl = `
7393
7585
  @group(1) @binding(0)
7394
7586
  var baseMapSampler: sampler;
7395
7587
  @group(1) @binding(1)
7396
- var baseMap: texture_depth_2d;
7588
+ var baseMap: texture_depth_2d ;
7397
7589
 
7398
- fn Linear01Depth(z:f32) -> f32 {
7590
+ fn Linear01Depth( z : f32 ) -> f32
7591
+ {
7399
7592
  return 1.0 / (1.0 * z + 5000.0);
7400
7593
  }
7401
7594
 
7402
7595
  @fragment
7403
7596
  fn main(@location(auto) fragUV: vec2<f32>) -> FragmentOutput {
7404
- var uv = fragUV;
7405
- uv.y = 1.0 - uv.y;
7406
- var depth = textureSample(baseMap, baseMapSampler, uv, vec2<i32>(0));
7407
- return FragmentOutput(vec4<f32>(depth, 0.0, 0.0, 1.0));
7597
+ var uv = fragUV ;
7598
+ uv.y = 1.0 - uv.y ;
7599
+ var depth = textureSample(baseMap, baseMapSampler, uv , vec2<i32>(0) ) ;
7600
+ return FragmentOutput(vec4<f32>(depth,0.0,0.0,1.0));
7408
7601
  }
7409
- `;
7410
- let Quad_depthCube_frag_wgsl = `
7602
+ `
7603
+ );
7604
+ let Quad_depthCube_frag_wgsl = (
7605
+ /*wgsl*/
7606
+ `
7411
7607
  struct FragmentOutput {
7412
7608
  @location(auto) o_Target: vec4<f32>
7413
7609
  };
@@ -7417,10 +7613,11 @@ let Quad_depthCube_frag_wgsl = `
7417
7613
 
7418
7614
  @group(1) @binding(0)
7419
7615
  var baseMapSampler: sampler;
7420
- @group(1) @binding(0)
7421
- var baseMap: texture_depth_cube;
7616
+ @group(1) @binding(1)
7617
+ var baseMap: texture_depth_cube ;
7422
7618
 
7423
- fn uvToXYZ(face: i32, uv: vec2<f32>) -> vec3<f32> {
7619
+ fn uvToXYZ( face : i32 , uv : vec2<f32> ) -> vec3<f32>
7620
+ {
7424
7621
  var out : vec3<f32> ;
7425
7622
  if(face == 0){
7426
7623
  out = vec3<f32>( 1.0, uv.y, -uv.x);
@@ -7440,12 +7637,12 @@ let Quad_depthCube_frag_wgsl = `
7440
7637
 
7441
7638
  @fragment
7442
7639
  fn main(@location(auto) fragUV: vec2<f32>) -> FragmentOutput {
7443
- var uv = fragUV;
7444
- uv.y = 1.0 - uv.y;
7445
- var ii = 0.16;
7640
+ var uv = fragUV ;
7641
+ uv.y = 1.0 - uv.y ;
7642
+ var ii = 0.16 ;
7446
7643
  var ouv = vec3<f32>(0.0);
7447
7644
  if(uv.x < ii * 6.0){
7448
- ouv = uvToXYZ(5, uv/ii);
7645
+ ouv = uvToXYZ(5,uv/ii);
7449
7646
  }
7450
7647
  if(uv.x < ii * 5.0){
7451
7648
  ouv = uvToXYZ(4,uv/ii);
@@ -7462,15 +7659,19 @@ let Quad_depthCube_frag_wgsl = `
7462
7659
  if(uv.x < ii * 1.0){
7463
7660
  ouv = uvToXYZ(0,uv/ii);
7464
7661
  }
7465
- var depth = textureSample(baseMap, baseMapSampler, ouv);
7466
- depth = 1.0 - depth;
7467
- return FragmentOutput(vec4<f32>(depth, 0.0, 0.0, 1.0));
7662
+ var depth = textureSample(baseMap, baseMapSampler, ouv ) ;
7663
+ depth = 1.0 - depth;
7664
+
7665
+ return FragmentOutput(vec4<f32>(depth,0.0,0.0,1.0));
7468
7666
  }
7469
- `;
7470
- let Quad_depth2dArray_frag_wgsl = `
7667
+ `
7668
+ );
7669
+ let Quad_depth2dArray_frag_wgsl = (
7670
+ /*wgsl*/
7671
+ `
7471
7672
  struct FragmentOutput {
7472
7673
  @location(auto) o_Target: vec4<f32>
7473
- }
7674
+ };
7474
7675
 
7475
7676
  var<private> fragUV1: vec2<f32>;
7476
7677
  var<private> o_Target: vec4<f32>;
@@ -7478,7 +7679,7 @@ let Quad_depth2dArray_frag_wgsl = `
7478
7679
  @group(1) @binding(0)
7479
7680
  var baseMapSampler: sampler;
7480
7681
  @group(1) @binding(1)
7481
- var baseMap: texture_2d_array;
7682
+ var baseMap: texture_2d_array ;
7482
7683
 
7483
7684
  struct MaterialData{
7484
7685
  index:f32;
@@ -7486,15 +7687,16 @@ let Quad_depth2dArray_frag_wgsl = `
7486
7687
 
7487
7688
  @fragment
7488
7689
  fn main(@location(auto) fragUV: vec2<f32>) -> FragmentOutput {
7489
- var uv = fragUV;
7490
- uv.y = 1.0 - uv.y;
7491
-
7492
- var depth = textureSample(baseMap, baseMapSampler, ouv);
7493
- depth = 1.0 - depth;
7690
+ var uv = fragUV ;
7691
+ uv.y = 1.0 - uv.y ;
7692
+
7693
+ var depth = textureSample(baseMap, baseMapSampler, ouv ) ;
7694
+ depth = 1.0 - depth;
7494
7695
 
7495
- return FragmentOutput(vec4<f32>(depth, 0.0, 0.0, 1.0));
7696
+ return FragmentOutput(vec4<f32>(depth,0.0,0.0,1.0));
7496
7697
  }
7497
- `;
7698
+ `
7699
+ );
7498
7700
 
7499
7701
  let ColorUtil = `
7500
7702
  fn getHDRColor(color: vec3<f32>, exposure: f32) -> vec3<f32> {
@@ -7641,25 +7843,31 @@ let ColorUtil = `
7641
7843
  }
7642
7844
  `;
7643
7845
 
7644
- let GenerayRandomDir = `
7645
- fn madfrac(A:f32, B:f32) -> f32 {
7646
- return A*B-floor(A*B);
7846
+ let GenerayRandomDir = (
7847
+ /*wgsl*/
7848
+ `
7849
+ fn madfrac(A:f32, B:f32)-> f32 {
7850
+ return A*B-floor(A*B) ;
7647
7851
  }
7648
7852
 
7649
- fn sampleRandomDir(count:u32, SAMPLE_COUNT: u32) -> vec3<f32> {
7650
- var ray_dir = sphericalFibonacci(f32((count)), f32(SAMPLE_COUNT));
7651
- return normalize(ray_dir);
7853
+ fn sampleRandomDir(count:u32,SAMPLE_COUNT:u32) -> vec3<f32>{
7854
+ var ray_dir = sphericalFibonacci(f32((count)), f32(SAMPLE_COUNT) );
7855
+ return normalize(ray_dir) ;
7652
7856
  }
7653
7857
 
7654
- fn sphericalFibonacci(i:f32, n:f32) -> vec3<f32> {
7655
- constPHI = sqrt(5.0) * 0.5 + 0.5;
7858
+ fn sphericalFibonacci( i : f32 , n : f32 ) -> vec3<f32>{
7859
+ const PHI = sqrt(5.0) * 0.5 + 0.5;
7656
7860
  let phi = 2.0 * PI * madfrac(i, PHI - 1);
7657
7861
  let cosTheta = 1.0 - (2.0 * i + 1.0) * (1.0 / n);
7658
7862
  let sinTheta = sqrt(saturate(1.0 - cosTheta*cosTheta));
7659
7863
 
7660
- return vec3<f32>(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
7864
+ return vec3<f32>(
7865
+ cos(phi) * sinTheta,
7866
+ sin(phi) * sinTheta,
7867
+ cosTheta);
7661
7868
  }
7662
- `;
7869
+ `
7870
+ );
7663
7871
 
7664
7872
  let MatrixShader = `
7665
7873
  #include "MathShader"
@@ -7914,7 +8122,7 @@ let Hair_frag = `
7914
8122
  face = 1.0 ;
7915
8123
  }else{
7916
8124
  face = -1.0 ;
7917
- }
8125
+ };
7918
8126
  #if USE_TANGENT
7919
8127
  let T = ORI_VertexVarying.TANGENT.xyz;
7920
8128
  let N = ORI_VertexVarying.vWorldNormal ;
@@ -8781,15 +8989,18 @@ let ZPassShader_fs = `
8781
8989
  }
8782
8990
  `;
8783
8991
 
8784
- let BitUtil = `
8992
+ let BitUtil = (
8993
+ /* wgsl */
8994
+ `
8995
+
8785
8996
  const inv256:f32 = 1.0/256.0;
8786
8997
  const inv1024:f32 = 1.0/1024.0;
8787
8998
 
8788
- const bit7_inv128:f32 = 1.0/128.0;
8999
+ const bit7_inv128:f32 = 1.0 / 128.0;
8789
9000
  const bit7_128:f32 = 128.0;
8790
-
9001
+
8791
9002
  const r10g10b10 = vec2i(0x3FFFFF,0xFF);
8792
- fn floatToVec3f(v:f32) -> vec3f {
9003
+ fn floatToVec3f( v:f32 ) -> vec3f {
8793
9004
  var VPInt:i32 = bitcast<i32>(v);
8794
9005
  var VPInt1024:i32 = VPInt%1024;
8795
9006
  var VPInt10241024:i32 = ((VPInt-VPInt1024)/1024)%1024;
@@ -8816,6 +9027,11 @@ let BitUtil = `
8816
9027
  return vec4f(f32(VPInt128),f32(VPInt128128),f32(VPInt128128128),f32(VPInt128128128128))*vec4f(bit7_inv128);
8817
9028
  }
8818
9029
 
9030
+
9031
+
9032
+
9033
+
9034
+
8819
9035
  const i_r11g11b11 = vec3i(0x7FF,0x7FF,0x7FF);
8820
9036
  const f_r11g11b11 = vec3f(f32(0x7FF),f32(0x7FF),f32(0x7FF));
8821
9037
  fn r11g11b11_to_float( v:vec3f) -> f32{
@@ -8864,6 +9080,9 @@ let BitUtil = `
8864
9080
  return vec3f(r,g,b);
8865
9081
  }
8866
9082
 
9083
+
9084
+
9085
+
8867
9086
  fn floatToRGBA(v:f32) -> vec4f{
8868
9087
  var iv = bitcast<u32>(v);
8869
9088
  var color = vec4f(0.0);
@@ -8878,7 +9097,9 @@ let BitUtil = `
8878
9097
  var f = dot(v, bitShift);
8879
9098
  return f;
8880
9099
  }
8881
- `;
9100
+
9101
+ `
9102
+ );
8882
9103
 
8883
9104
  let GBufferStand = `
8884
9105
  #include "MathShader"
@@ -22173,7 +22394,7 @@ class Reference {
22173
22394
  }
22174
22395
  /**
22175
22396
  * current instance attached from parent instance
22176
- * @param ref reference current
22397
+ * @param ref reference current
22177
22398
  * @param target reference parent
22178
22399
  */
22179
22400
  attached(ref, target) {
@@ -22185,7 +22406,7 @@ class Reference {
22185
22406
  }
22186
22407
  /**
22187
22408
  * current instance detached from parent instance
22188
- * @param ref reference current
22409
+ * @param ref reference current
22189
22410
  * @param target reference parent
22190
22411
  */
22191
22412
  detached(ref, target) {
@@ -22195,7 +22416,7 @@ class Reference {
22195
22416
  }
22196
22417
  }
22197
22418
  /**
22198
- * current instance has reference
22419
+ * current instance has reference
22199
22420
  */
22200
22421
  hasReference(ref) {
22201
22422
  let refMap = this.reference.get(ref);
@@ -22206,8 +22427,8 @@ class Reference {
22206
22427
  }
22207
22428
  /**
22208
22429
  * get current instance reference count
22209
- * @param ref
22210
- * @returns
22430
+ * @param ref
22431
+ * @returns
22211
22432
  */
22212
22433
  getReferenceCount(ref) {
22213
22434
  let refMap = this.reference.get(ref);
@@ -22217,10 +22438,10 @@ class Reference {
22217
22438
  return 0;
22218
22439
  }
22219
22440
  /**
22220
- * get current instance reference from where
22221
- * @param ref
22222
- * @returns
22223
- */
22441
+ * get current instance reference from where
22442
+ * @param ref
22443
+ * @returns
22444
+ */
22224
22445
  getReference(ref) {
22225
22446
  let refMap = this.reference.get(ref);
22226
22447
  if (refMap) {
@@ -24852,8 +25073,7 @@ class GeometryIndicesBuffer {
24852
25073
  this.indicesGPUBuffer = new IndicesGPUBuffer(indicesData.data);
24853
25074
  }
24854
25075
  upload(data) {
24855
- const buffer = data.buffer instanceof ArrayBuffer ? data.buffer : new Uint8Array(data.buffer).buffer;
24856
- this.indicesGPUBuffer.indicesNode.setArrayBuffer(0, buffer);
25076
+ this.indicesGPUBuffer.indicesNode.setArrayBuffer(0, data);
24857
25077
  this.indicesGPUBuffer.apply();
24858
25078
  }
24859
25079
  compute() {
@@ -24866,6 +25086,22 @@ class GeometryIndicesBuffer {
24866
25086
  this.indicesGPUBuffer.destroy();
24867
25087
  this.indicesGPUBuffer = null;
24868
25088
  }
25089
+ /**
25090
+ * Get indices from geometry data
25091
+ * Get position attribute from geometry data
25092
+ * Get normal attribute from geometry data
25093
+ * Get tangent attribute from geometry data
25094
+ * Get uv0 attribute from geometry data
25095
+ * Get uv1 attribute from geometry data
25096
+ * Get uv2 attribute from geometry data
25097
+ *
25098
+ * Change position data to GPUBuffer and apply
25099
+ * Change normal data to GPUBuffer and apply
25100
+ * Change tangent data to GPUBuffer and apply
25101
+ * Change uv0 data to GPUBuffer and apply
25102
+ * Change uv1 data to GPUBuffer and apply
25103
+ * Change uv2 data to GPUBuffer and apply
25104
+ */
24869
25105
  }
24870
25106
 
24871
25107
  class SubGeometry {
@@ -25675,7 +25911,7 @@ let QuadShader = class extends Shader {
25675
25911
  }
25676
25912
  };
25677
25913
  QuadShader = __decorateClass$e([
25678
- RegisterShader
25914
+ RegisterShader(QuadShader, "QuadShader")
25679
25915
  ], QuadShader);
25680
25916
 
25681
25917
  class ViewQuad extends Object3D {
@@ -28033,131 +28269,147 @@ class CubeCamera extends Object3D {
28033
28269
  }
28034
28270
  }
28035
28271
 
28036
- let PreFilteredEnvironment_cs = `
28272
+ let PreFilteredEnvironment_cs = (
28273
+ /*wgsl*/
28274
+ `
28037
28275
  #include "GenerayRandomDir"
28038
28276
  #include "BitUtil"
28039
28277
  #include "MathShader"
28040
28278
  #include "ColorUtil_frag"
28041
-
28042
- struct UniformData {
28043
- probeSize: f32,
28044
- probeCount: f32,
28045
- width: f32,
28046
- height: f32,
28279
+
28280
+ struct UniformData{
28281
+ probeSize : f32 ,
28282
+ probeCount : f32 ,
28283
+ width : f32 ,
28284
+ height : f32 ,
28047
28285
  }
28048
28286
 
28049
- @group(0) @binding(0) var inputTex: texture_2d<f32>;
28050
- @group(0) @binding(1) var outputTexture: texture_storage_2d<rgba16float,write>;
28051
- @group(1) @binding(0) var<uniform> uniformData: UniformData;
28287
+ @group(0) @binding(0) var inputTex : texture_2d<f32>;
28288
+ @group(0) @binding(1) var outputTexture : texture_storage_2d<rgba16float, write>;//rgba32float rgba16float
28289
+ @group(1) @binding(0) var<uniform> uniformData:UniformData;//rgba32float
28052
28290
 
28053
- var<private> reflectionSize: vec2f;
28054
- var<private> PROBE_SOURCESIZE: vec2f;
28055
- var<private> PROBEMAP_SOURCESIZE: vec2f;
28056
- var<private> aspect: vec2f;
28057
- var<private> spaceV: f32;
28291
+ var<private> reflectionSize : vec2f ;
28292
+ var<private> PROBE_SOURCESIZE : vec2f ;
28293
+ var<private> PROBEMAP_SOURCESIZE : vec2f ;
28294
+ var<private> aspect : vec2f ;
28295
+ var<private> spaceV : f32 ;
28058
28296
 
28059
28297
  var<private> i32InputFragCoord : vec2i;
28060
28298
  var<private> PI_2 : f32 = 3.1415926 * 2.0 ;
28061
28299
  var<private> PI : f32 = 3.1415926 ;
28062
28300
 
28063
- var<private> probeSize: f32 = 256.0;
28064
- var<private> probeCount: f32 = 8.0;
28065
- var<private> faceCount: f32 = 6.0;
28066
- var<private> mipCount: f32 = 8.0;
28301
+ var<private> probeSize : f32 = 256.0 ;
28302
+ var<private> probeCount : f32 = 8.0 ;
28303
+ var<private> faceCount : f32 = 6.0 ;
28304
+ var<private> mipCount : f32 = 8.0 ;
28067
28305
 
28068
28306
  const NUM_SAMPLES = 256u;
28069
- var<private> inputSize: vec2f;
28070
- var<private> outSize: vec2f;
28307
+ var<private> inputSize : vec2f ;
28308
+ var<private> outSize : vec2f ;
28071
28309
 
28072
28310
  fn useSphereReflection(){
28073
- probeSize = uniformData.probeSize;
28311
+ probeSize = uniformData.probeSize ;
28074
28312
  probeCount = uniformData.probeCount;
28075
28313
  reflectionSize = vec2f(textureDimensions(inputTex).xy);
28076
28314
  PROBE_SOURCESIZE = reflectionSize / vec2f(faceCount,probeCount);
28077
- PROBEMAP_SOURCESIZE = reflectionSize;
28315
+ PROBEMAP_SOURCESIZE = reflectionSize ;
28078
28316
  aspect = PROBE_SOURCESIZE / PROBEMAP_SOURCESIZE;
28079
- spaceV = 1.0 / probeCount;
28317
+ spaceV = 1.0 / probeCount ;
28080
28318
  }
28081
28319
 
28082
- @compute @workgroup_size(16, 16, 1)
28083
- fn CsMain(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(global_invocation_id) globalInvocation_id: vec3<u32>){
28084
- var color: vec4f;
28320
+ @compute @workgroup_size( 16 , 16 , 1 )
28321
+ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_invocation_id) globalInvocation_id : vec3<u32>)
28322
+ {
28323
+ var color : vec4f ;
28085
28324
  useSphereReflection();
28086
28325
  inputSize = vec2f(textureDimensions(inputTex).xy);
28087
28326
  outSize = vec2f(textureDimensions(outputTexture).xy);
28088
- i32InputFragCoord = vec2<i32>(globalInvocation_id.xy);
28089
- let i = f32(globalInvocation_id.z);
28090
- let count = floor(i/mipCount);
28091
- preOneMip(count, floor(i%mipCount));
28327
+
28328
+ i32InputFragCoord = vec2<i32>( globalInvocation_id.xy ) ;
28329
+
28330
+ let i = f32(globalInvocation_id.z) ;
28331
+ let count = floor(i / mipCount) ;
28332
+ preOneMip(count,floor(i % mipCount));
28092
28333
  }
28093
28334
 
28094
- fn preOneMip(gid: f32, mip: f32){
28095
- let isuv = vec2f(i32InputFragCoord);
28335
+ fn preOneMip( gid:f32,mip:f32 ){
28336
+ let isuv = vec2f(i32InputFragCoord) ;
28096
28337
  let suv = isuv * (inputSize/outSize);
28097
28338
  let probeID = i32(floor(suv.y / probeSize));
28098
28339
  let mipID = i32((isuv.x / probeSize));
28099
28340
  if(probeID == i32(gid) && mipID == i32(mip)){
28100
- let sphereUV = vec2f((isuv.x+0.5)%(probeSize), (isuv.y+0.5)%probeSize/vec2f((probeSize),probeSize));
28101
- var dir: vec3<f32> = octDecode(sphereUV * 2.0 - 1.0);
28102
- var preColor = PreFilterEnvMap(mip/mipCount + 0.05, dir, gid);
28103
- textureStore(outputTexture, vec2i(i32InputFragCoord), preColor);
28341
+
28342
+ let sphereUV = vec2f((isuv.x+0.5) % (probeSize),(isuv.y+0.5) % probeSize) / vec2f( (probeSize), probeSize ) ;
28343
+ var dir: vec3<f32> = octDecode(sphereUV * 2.0 - 1.0) ;
28344
+ var preColor = PreFilterEnvMap(mip/mipCount + 0.05,dir,gid);
28345
+ textureStore(outputTexture,vec2i(i32InputFragCoord),preColor);
28104
28346
  }
28105
28347
  }
28106
28348
 
28107
- fn PreFilterEnvMap(roughness2:f32, R:vec3f , gid:f32) -> vec4f {
28108
- var resColor = vec3f(0.0f);
28109
- var resDepth = 0.0;
28349
+ fn PreFilterEnvMap( roughness2:f32, R:vec3f , gid:f32 ) -> vec4f
28350
+ {
28351
+ var resColor = vec3f(0.0f);
28352
+ var resDepth = 0.0;
28353
+
28110
28354
  var totalColorWeight = 0.0f;
28111
28355
  var totalDepthWeight = 0.0f;
28356
+
28112
28357
  var normal = normalize(R);
28113
28358
  var toEye = normal;
28359
+
28114
28360
  var roughness = roughness2;
28115
-
28361
+
28116
28362
  for(var i=1u;i<=NUM_SAMPLES;i+=1u)
28117
28363
  {
28118
- var xi:vec2f = hammersley(i, NUM_SAMPLES);
28364
+ var xi:vec2f = hammersley(i, NUM_SAMPLES) ;
28365
+
28119
28366
  var halfway = ImportanceSampleGGX(xi,roughness,normal);
28120
- var lightVec = 2.0f * dot(toEye,halfway) * halfway - toEye;
28121
- var NdotL = dot(normal, lightVec);
28122
- var NdotH = max(0.0,dot( normal, halfway ));
28123
- var HdotV = max(0.0,dot( halfway, toEye ));
28367
+ var lightVec = 2.0f * dot( toEye,halfway ) * halfway - toEye;
28368
+
28369
+ var NdotL = dot( normal, lightVec ) ;
28370
+ var NdotH = max(0.0,dot( normal, halfway )) ;
28371
+ var HdotV = max(0.0,dot( halfway, toEye )) ;
28372
+
28124
28373
  if( NdotL > 0.0 )
28125
28374
  {
28126
28375
  var D = specularD(roughness,NdotH);
28127
- var pdf = (D * NdotH / (4.0 * HdotV)) + 0.0001f;
28376
+ var pdf = (D * NdotH / (4.0 * HdotV)) + 0.0001f ;
28377
+
28128
28378
  var saSample = 1.0f / (f32(NUM_SAMPLES) * pdf + 0.00001f);
28129
28379
  lightVec = normalize(lightVec);
28380
+
28130
28381
  var buffer = getReflectionsMap(lightVec,gid);
28131
28382
  var rgb = unpack4x8unorm(u32(buffer.z)).rgb;
28132
28383
  var m = unpack4x8unorm(u32(buffer.w)).z;
28133
28384
  var rgbmColor = DecodeRGBM(vec4f(rgb,m));
28134
- resDepth += buffer.x;
28385
+ resDepth += buffer.x ;
28135
28386
  resColor += rgbmColor * NdotL;
28387
+
28136
28388
  totalColorWeight += NdotL;
28137
28389
  totalDepthWeight += 1.0;
28138
28390
  }
28139
28391
  }
28140
-
28392
+
28141
28393
  resDepth = resDepth / max(totalDepthWeight,0.001f);
28142
28394
  resColor = resColor / max(totalColorWeight,0.001f);
28143
-
28395
+
28144
28396
  let rgbm = EncodeRGBM(resColor) ;
28145
28397
  let gBuffer = vec4f(
28146
28398
  resDepth,
28147
28399
  0.0,
28148
28400
  f32(pack4x8unorm(vec4f(rgbm.rgb,0.0))),
28149
28401
  f32(pack4x8unorm(vec4f(0.0,0.0,rgbm.w,0.0))),
28150
- );
28151
- return vec4f(resColor, 1.0);
28152
- }
28402
+ ) ;
28403
+ return vec4f(resColor,1.0) ;
28404
+ }
28153
28405
 
28154
- fn getReflectionsMap(n: vec3<f32>,gid: f32) -> vec4f {
28406
+ fn getReflectionsMap(n:vec3<f32>,gid:f32) -> vec4f {
28155
28407
  var uv = getSampleProbeUV(n,gid);
28156
- let color = textureLoad(inputTex, vec2i(uv*inputSize), 0);
28157
- return color;
28408
+ let color = textureLoad(inputTex, vec2i(uv*inputSize) , 0);
28409
+ return color ;
28158
28410
  }
28159
28411
 
28160
- fn getSampleProbeUV(dir: vec3<f32>,gid: f32) -> vec2<f32> {
28412
+ fn getSampleProbeUV(dir:vec3<f32>,gid:f32) -> vec2<f32> {
28161
28413
  let faceId = dir_to_faceId(dir);
28162
28414
  var targetUV:vec2<f32> = convert_xyz_to_cube_uv(dir.x, dir.y, dir.z);
28163
28415
  targetUV.x = 1.0 - targetUV.x;
@@ -28167,17 +28419,18 @@ let PreFilteredEnvironment_cs = `
28167
28419
  let aspect:vec2f = PROBE_SOURCESIZE / PROBEMAP_SOURCESIZE;
28168
28420
  targetUV = targetUV * aspect ;
28169
28421
  targetUV.y = targetUV.y + (spaceV * gid);
28170
- return targetUV;
28171
- }
28422
+ return targetUV ;
28423
+ }
28172
28424
 
28173
- fn radicalInverse_VdC(bits2:u32) -> f32 {
28425
+ fn radicalInverse_VdC( bits2:u32) -> f32
28426
+ {
28174
28427
  var bits = bits2;
28175
28428
  bits = (bits << 16u) | (bits >> 16u);
28176
28429
  bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
28177
28430
  bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
28178
28431
  bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
28179
28432
  bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
28180
- return f32(bits) * 2.3283064365386963e-10f;
28433
+ return f32(bits) * 2.3283064365386963e-10f; // / 0x100000000
28181
28434
  }
28182
28435
 
28183
28436
  fn hammersley( i:u32, N:u32) -> vec2f
@@ -28188,21 +28441,25 @@ let PreFilteredEnvironment_cs = `
28188
28441
  fn ImportanceSampleGGX( xi:vec2f, roughness:f32, N:vec3f) -> vec3f
28189
28442
  {
28190
28443
  var alpha2 = roughness * roughness * roughness * roughness;
28444
+
28191
28445
  var phi = 2.0f * 3.1415926 * xi.x ;
28192
28446
  var cosTheta = sqrt( (1.0f - xi.y) / (1.0f + (alpha2 - 1.0f) * xi.y ));
28193
28447
  var sinTheta = sqrt( 1.0f - cosTheta*cosTheta );
28194
- var h: vec3f ;
28448
+
28449
+ var h : vec3f ;
28195
28450
  h.x = sinTheta * cos( phi );
28196
28451
  h.y = sinTheta * sin( phi );
28197
28452
  h.z = cosTheta;
28453
+
28198
28454
  var up = vec3f(1,0,0) ;
28199
28455
  if(abs(N.z) < 0.9999){
28200
28456
  up = vec3f(0,0,1) ;
28201
28457
  }
28458
+
28202
28459
  var tangentX = normalize( cross( up, N ) );
28203
28460
  var tangentY = cross( N, tangentX );
28204
28461
  return (tangentX * h.x + tangentY * h.y + N * h.z);
28205
- }
28462
+ }
28206
28463
 
28207
28464
  fn specularD( roughness:f32, NoH:f32) -> f32
28208
28465
  {
@@ -28210,7 +28467,9 @@ let PreFilteredEnvironment_cs = `
28210
28467
  var r2 = roughness * roughness;
28211
28468
  return r2 / pow(NoH2 * (r2 - 1.0) + 1.0, 2.0);
28212
28469
  }
28213
- `;
28470
+
28471
+ `
28472
+ );
28214
28473
 
28215
28474
  class ReflectionRenderer extends RendererBase {
28216
28475
  cubeCamera;
@@ -28469,8 +28728,10 @@ class ReflectionRenderer extends RendererBase {
28469
28728
  }
28470
28729
  }
28471
28730
 
28472
- let FXAAShader = `
28473
- @include 'BitUtil'
28731
+ let FXAAShader = (
28732
+ /*wgsl*/
28733
+ `
28734
+ #include 'BitUtil'
28474
28735
  struct FragmentOutput {
28475
28736
  @location(auto) o_Target: vec4<f32>
28476
28737
  };
@@ -28489,6 +28750,7 @@ let FXAAShader = `
28489
28750
  @group(2) @binding(0)
28490
28751
  var<uniform> materialUniform: MaterialUniform;
28491
28752
 
28753
+
28492
28754
  fn LinearToGammaSpace(linRGB0: vec3<f32>) -> vec3<f32> {
28493
28755
  var linRGB = max(linRGB0, vec3(0.0, 0.0, 0.0));
28494
28756
  linRGB.r = pow(linRGB.r,0.416666667);
@@ -28497,30 +28759,35 @@ let FXAAShader = `
28497
28759
  return max(1.055 * linRGB - 0.055, vec3(0.0, 0.0, 0.0));
28498
28760
  }
28499
28761
 
28500
- fn texture2D(uv:vec2<f32>, offset:vec2<f32>) -> vec4<f32> {
28501
- let buffer = textureSample(baseMap, baseMapSampler, uv.xy + offset).rgba;
28502
- return buffer;
28762
+ fn texture2D( uv:vec2<f32> , offset:vec2<f32> ) -> vec4<f32> {
28763
+ let buffer = textureSample(baseMap, baseMapSampler, uv.xy + offset ).rgba ;
28764
+ return buffer ;
28503
28765
  }
28504
28766
 
28505
28767
  @fragment
28506
28768
  fn main(@location(auto) fragUV: vec2<f32>) -> FragmentOutput {
28507
- var v_vTexcoord = fragUV;
28769
+ var v_vTexcoord = fragUV ;
28508
28770
  v_vTexcoord.y = 1.0 - v_vTexcoord.y ;
28771
+
28509
28772
  var reducemul = 1.0 / 8.0;
28510
28773
  var reducemin = 1.0 / 128.0;
28774
+
28511
28775
  var basecol = texture2D(v_vTexcoord , vec2<f32>(0.0)).rgba;
28512
28776
  var baseNW = texture2D(v_vTexcoord , -materialUniform.u_texel).rgb;
28513
28777
  var baseNE = texture2D(v_vTexcoord , vec2<f32>(materialUniform.u_texel.x, -materialUniform.u_texel.y)).rgb;
28514
28778
  var baseSW = texture2D(v_vTexcoord , vec2<f32>(-materialUniform.u_texel.x, materialUniform.u_texel.y)).rgb;
28515
28779
  var baseSE = texture2D(v_vTexcoord , materialUniform.u_texel ).rgb;
28780
+
28516
28781
  var gray = vec3<f32>(0.213, 0.715, 0.072);
28517
28782
  var monocol = dot(basecol.rgb, gray);
28518
28783
  var monoNW = dot(baseNW, gray);
28519
28784
  var monoNE = dot(baseNE, gray);
28520
28785
  var monoSW = dot(baseSW, gray);
28521
28786
  var monoSE = dot(baseSE, gray);
28787
+
28522
28788
  var monomin = min(monocol, min(min(monoNW, monoNE), min(monoSW, monoSE)));
28523
28789
  var monomax = max(monocol, max(max(monoNW, monoNE), max(monoSW, monoSE)));
28790
+
28524
28791
  var dir = vec2<f32>(-((monoNW + monoNE) - (monoSW + monoSE)), ((monoNW + monoSW) - (monoNE + monoSE)));
28525
28792
  var dirreduce = max((monoNW + monoNE + monoSW + monoSE) * reducemul * 0.25, reducemin);
28526
28793
  var dirmin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirreduce);
@@ -28528,9 +28795,11 @@ let FXAAShader = `
28528
28795
 
28529
28796
  var resultA = 0.5 * (texture2D(v_vTexcoord , dir * -0.166667).rgb +
28530
28797
  texture2D(v_vTexcoord , dir * 0.166667).rgb);
28798
+
28531
28799
  var resultB = resultA * 0.5 + 0.25 * (texture2D( v_vTexcoord , dir * -0.5).rgb +
28532
28800
  texture2D( v_vTexcoord , dir * 0.5).rgb);
28533
28801
  var monoB = dot(resultB.rgb, gray);
28802
+
28534
28803
  var color:vec3<f32> ;
28535
28804
  if(monoB < monomin || monoB > monomax) {
28536
28805
  color = resultA ;//* v_vColour;
@@ -28539,7 +28808,8 @@ let FXAAShader = `
28539
28808
  }
28540
28809
  return FragmentOutput(vec4<f32>(color.rgb,basecol.a));
28541
28810
  }
28542
- `;
28811
+ `
28812
+ );
28543
28813
 
28544
28814
  class FXAAPost extends PostBase {
28545
28815
  postQuad;
@@ -28958,12 +29228,12 @@ let DDGIIrradiance_shader = `
28958
29228
  cornerCoord.x = sideBorderCnt - 1;
28959
29229
  }else{
28960
29230
  cornerCoord.x = 0;
28961
- }
29231
+ };
28962
29232
  if(modeXY.y == 0){
28963
29233
  cornerCoord.y = sideBorderCnt - 1;
28964
29234
  }else{
28965
29235
  cornerCoord.y = 0;
28966
- }
29236
+ };
28967
29237
  cornerCoord = indexXY * sideBorderCnt + cornerCoord;
28968
29238
  textureStore(texture, cornerCoord, color);
28969
29239
  }
@@ -29485,7 +29755,7 @@ fn directShadowMaping(P:vec3<f32>, N:vec3<f32>, shadowBias: f32) {
29485
29755
  }else{
29486
29756
  shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
29487
29757
  visibility = directShadowMapingIndex(light, shadowMatrix, P, N, shadowIndex, shadowBias).x;
29488
- }
29758
+ };
29489
29759
  }
29490
29760
  shadowStrut.directShadowVisibility = visibility;
29491
29761
  }
@@ -29594,7 +29864,7 @@ fn spotLight( albedo:vec3<f32>,WP:vec3<f32>, N:vec3<f32>, V:vec3<f32>, light:Lig
29594
29864
  }
29595
29865
  }else{
29596
29866
  atten = 0.0 ;
29597
- }
29867
+ };
29598
29868
  var lightColor = light.lightColor.rgb ;
29599
29869
  lightColor = getHDRColor(lightColor , light.linear ) * light.intensity / LUMEN * 2.0;
29600
29870
  color = (albedo / PI) * lightColor.rgb * atten ;
@@ -37305,16 +37575,16 @@ let BRDFLUT = `
37305
37575
  return 4.0 * vec2<f32>(A, B) / f32(numSamples);
37306
37576
  }
37307
37577
 
37308
- @group(0) @binding(0) var brdfluTexture: texture_storage_2d<rgba8unorm, write>;
37578
+ @group(0) @binding(0) var brdflutTexture: texture_storage_2d<rgba8unorm, write>;
37309
37579
  @compute @workgroup_size(8,8,1)
37310
- fn CsMain(@builtin(global_invocation_id) workgroup_id: vec3<u32>, @builtin(local_invocation_id) local_invocation_id: vec3<u32>){
37311
- var fragCoord = vec2<u32>(global_invocation_id.x, global_invocation_id.y);
37312
- var fragColor = vec4<f32>(0,0);
37313
- var res = integrateBRDF(f32(fragCoord.y + 1u) / 256.0, f32(fragCoord.x + 1u) / 256.0);
37314
- fragColor = vec4<f32>(res.x, res.y, 0.0, 1.0);
37315
-
37316
- textureStore(brdflutTexture, vec2<i32>(fragCoord.xy), fragColor);
37317
- }
37580
+ fn CsMain(@builtin(global_invocation_id) global_invocation_id : vec3<u32>){
37581
+ var fragCoord = vec2<u32>(global_invocation_id.x, global_invocation_id.y);
37582
+ var fragColor = vec4<f32>(0.0);
37583
+ // Output to screen
37584
+ var res = integrateBRDF(f32(fragCoord.y + 1u) / 256.0, f32(fragCoord.x + 1u) / 256.0);
37585
+ fragColor = vec4<f32>(res.x, res.y, 0.0, 1.0);
37586
+ textureStore(brdflutTexture, vec2<i32>(fragCoord.xy), fragColor);
37587
+ }
37318
37588
  `;
37319
37589
 
37320
37590
  class BRDFLUTGenerate {
@@ -38159,7 +38429,7 @@ class PostProcessingComponent extends ComponentBase {
38159
38429
  }
38160
38430
  }
38161
38431
 
38162
- const version = "1.0.0";
38432
+ const version = "1.0.3";
38163
38433
 
38164
38434
  class Engine3D {
38165
38435
  /**
@@ -39158,7 +39428,7 @@ let GodRay_cs = (
39158
39428
  }else{
39159
39429
  shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
39160
39430
  visibility = directShadowMapingIndex(light, shadowMatrix, P, N, shadowIndex, shadowBias).x;
39161
- }
39431
+ };
39162
39432
  }
39163
39433
  shadowStruct.directShadowVisibility = visibility;
39164
39434
  }
@@ -39363,7 +39633,7 @@ let OutLineBlendColor_cs = (
39363
39633
  blendColor = inColor.xyz + outLineColor.xyz * outLineColor.w;
39364
39634
  }else{
39365
39635
  blendColor = mix(inColor.xyz, outLineColor.xyz, outLineColor.w);
39366
- }
39636
+ };
39367
39637
  textureStore(outlineTex, fragCoord, vec4<f32>(blendColor, inColor.w));
39368
39638
  }
39369
39639
  `
@@ -40091,7 +40361,7 @@ let SSGI2_cs = (
40091
40361
 
40092
40362
  }else{
40093
40363
  Output = vec4f(wColor.xyz, 1.0);
40094
- }
40364
+ };
40095
40365
 
40096
40366
  return Output;
40097
40367
  }
@@ -40360,12 +40630,12 @@ struct SSRUniformData {
40360
40630
  }
40361
40631
  }else{
40362
40632
  rayTraceRet.alpha = 0.0;
40363
- }
40633
+ };
40364
40634
  rayTraceRet.skyColor = getSkyColor();
40365
40635
  }else{
40366
40636
  rayTraceRet.alpha = -1.0;
40367
40637
  rayTraceRet.skyColor = vec3<f32>(0.0);
40368
- }
40638
+ };
40369
40639
 
40370
40640
  rayTraceRet.roughness = roughness;
40371
40641
  rayTraceRet.fresnel = fresnel;
@@ -40517,7 +40787,7 @@ struct SSRUniformData {
40517
40787
  hitData.hitCoord = uv;
40518
40788
  return 1;
40519
40789
  }
40520
- }
40790
+ };
40521
40791
  }
40522
40792
  return 0;
40523
40793
  }
@@ -40669,7 +40939,7 @@ fn blendColor() -> vec4<f32>{
40669
40939
  preCoord = vec2<i32>(reProjectionCoord);
40670
40940
  }else{
40671
40941
  mixWeight = 1.0;
40672
- }
40942
+ };
40673
40943
  }
40674
40944
 
40675
40945
  var curUV01 = fragUV;
@@ -40742,7 +41012,7 @@ fn minmax4(coord:vec2<i32>) {
40742
41012
  return vec4<f32>(p_clip, color_avg.w) + v_clip / ma_unit;
40743
41013
  }else{
40744
41014
  return input_texel;
40745
- }
41015
+ };
40746
41016
  }
40747
41017
  `
40748
41018
  );
@@ -41231,7 +41501,7 @@ fn containsBox( size:vec3<f32> , center:vec3<f32> ) -> f32 {
41231
41501
  return 2.0 ;
41232
41502
  }else{
41233
41503
  return 1.0 ;
41234
- }
41504
+ };
41235
41505
  }
41236
41506
 
41237
41507
  @compute @workgroup_size(128)
@@ -41986,11 +42256,13 @@ let PBRLitSSSShader = (
41986
42256
  );
41987
42257
 
41988
42258
  let UnLitTextureArray = (
41989
- /*wgsl */
42259
+ /*wgsl*/
41990
42260
  `
42261
+ // #include "Common_vert"
41991
42262
  #include "Common_frag"
41992
42263
  #include "UnLit_frag"
41993
42264
  #include "UnLitMaterialUniform_frag"
42265
+
41994
42266
  #include "WorldMatrixUniform"
41995
42267
  #include "VertexAttributeIndexShader"
41996
42268
  #include "GlobalUniform"
@@ -41998,8 +42270,8 @@ let UnLitTextureArray = (
41998
42270
  #include "EnvMap_frag"
41999
42271
  #include "ColorUtil_frag"
42000
42272
 
42001
- const DEGREES_TO_RADIANS: f32 = 3.1415926 / 180.0;
42002
- const PI: f32 = 3.1415926;
42273
+ const DEGREES_TO_RADIANS : f32 = 3.1415926 / 180.0 ;
42274
+ const PI : f32 = 3.1415926 ;
42003
42275
 
42004
42276
  #if USE_CUSTOMUNIFORM
42005
42277
  struct MaterialUniform {
@@ -42010,15 +42282,19 @@ let UnLitTextureArray = (
42010
42282
  };
42011
42283
  #endif
42012
42284
 
42013
- @group(1) @binding(0) var baseMapSampler: sampler;
42014
- @group(1) @binding(1) var baseMap: texture_2d_array<f32>;
42015
- @group(2) @binding(5) var<storage,read> graphicBuffer: array<GraphicNodeStruct>;
42285
+ @group(1) @binding(0)
42286
+ var baseMapSampler: sampler;
42287
+ @group(1) @binding(1)
42288
+ var baseMap: texture_2d_array<f32>;
42016
42289
 
42290
+ @group(2) @binding(5)
42291
+ var<storage,read> graphicBuffer : array<GraphicNodeStruct>;
42292
+
42017
42293
  @vertex
42018
- fn VertMain(vertex: VertexAttributes) -> VertexOutput {
42294
+ fn VertMain( vertex:VertexAttributes ) -> VertexOutput {
42019
42295
  vertex_inline(vertex);
42020
42296
  vert(vertex);
42021
- return ORI_VertexOut;
42297
+ return ORI_VertexOut ;
42022
42298
  }
42023
42299
 
42024
42300
  fn vert(inputData:VertexAttributes) -> VertexOutput {
@@ -42029,9 +42305,15 @@ let UnLitTextureArray = (
42029
42305
  fn frag(){
42030
42306
  var transformUV1 = materialUniform.transformUV1;
42031
42307
  var transformUV2 = materialUniform.transformUV2;
42308
+
42309
+ // var irradiance = vec3<f32>(0.0) ;
42310
+ // let MAX_REFLECTION_LOD = f32(textureNumLevels(prefilterMap)) ;
42311
+ // irradiance += (globalUniform.skyExposure * textureSampleLevel(prefilterMap, prefilterMapSampler, ORI_VertexVarying.vWorldNormal.xyz, 0.8 * (MAX_REFLECTION_LOD) ).rgb);
42312
+
42032
42313
  graphicNode = graphicBuffer[u32(round(ORI_VertexVarying.index))];
42033
42314
 
42034
42315
  var uv = transformUV1.zw * ORI_VertexVarying.fragUV0 + transformUV1.xy;
42316
+ //The fragUV1.x is 1.0 when the vertex belongs to line.
42035
42317
  if(ORI_VertexVarying.fragUV1.x > 0.5){
42036
42318
  uv = graphicNode.uvRect2.zw * uv.xy + graphicNode.uvRect2.xy;
42037
42319
  uv += graphicNode.uvSpeed.zw * globalUniform.time;
@@ -42047,7 +42329,7 @@ let UnLitTextureArray = (
42047
42329
  );
42048
42330
  uv = (zrot * vec3f(uv, 0.0)).xy;
42049
42331
  }
42050
- }
42332
+ };
42051
42333
  var graphicTextureID = graphicNode.texIndex;
42052
42334
  var graphicNodeColor = graphicNode.baseColor;
42053
42335
  if(ORI_VertexVarying.fragUV1.x > 0.5){
@@ -42055,12 +42337,23 @@ let UnLitTextureArray = (
42055
42337
  graphicNodeColor = graphicNode.lineColor;
42056
42338
  }
42057
42339
  var color = textureSample(baseMap,baseMapSampler,uv, u32(round(graphicTextureID)) ) * materialUniform.baseColor * graphicNodeColor ;
42058
- color += graphicNode.emissiveColor;
42340
+ // let color = textureSample(baseMap,baseMapSampler,uv, u32(round(ORI_VertexVarying.index)));
42341
+
42342
+ // ORI_ViewDir = normalize( globalUniform.CameraPos.xyz - ORI_VertexVarying.vWorldPos.xyz);
42343
+ // let att = dot( ORI_ViewDir , ORI_VertexVarying.vWorldNormal.xyz );
42344
+
42345
+ // irradiance = LinearToGammaSpace(irradiance.rgb) * color.rgb ;//* att ;
42346
+
42347
+ color += graphicNode.emissiveColor ;
42059
42348
  if(color.w < materialUniform.alphaCutoff){
42060
- discard;
42349
+ discard ;
42061
42350
  }
42062
- let outColor = vec4f( color.rgb , 1.0 ) * materialUniform.baseColor;
42063
- ORI_ShadingInput.BaseColor = vec4f(outColor.xyz,1.0);
42351
+
42352
+ // let outColor = vec4f( color.rgb * (att * 0.5 + 0.5 ) , 1.0 ) * materialUniform.baseColor ;
42353
+ let outColor = vec4f( color.rgb , 1.0 ) * materialUniform.baseColor ;
42354
+
42355
+ // ORI_ShadingInput.BaseColor = color ;
42356
+ ORI_ShadingInput.BaseColor = vec4f(outColor.xyz,1.0) ;
42064
42357
  UnLit();
42065
42358
  }
42066
42359
  `
@@ -42195,7 +42488,7 @@ let GlobalFog_shader = (
42195
42488
  let sunLight = lightBuffer[0] ;
42196
42489
  var inScatteringValue = inScatterIng(sunLight.direction, texPosition.xyz, sunLight.lightColor);
42197
42490
  opColor += inScatteringValue;
42198
- }
42491
+ };
42199
42492
 
42200
42493
  textureStore(outTex, fragCoord , vec4<f32>(opColor.xyz, texColor.a));
42201
42494
  }
@@ -42585,14 +42878,16 @@ class AtmosphericScatteringSky extends LDRTextureCube {
42585
42878
  _internalTexture;
42586
42879
  _cubeSize;
42587
42880
  setting;
42881
+ /**
42882
+ * @constructor
42883
+ * @param setting AtmosphericScatteringSkySetting
42884
+ * @returns
42885
+ */
42588
42886
  constructor(setting) {
42589
42887
  super();
42590
42888
  this.setting = setting;
42591
42889
  this._cubeSize = setting.defaultTextureCubeSize;
42592
- this._internalTexture = new AtmosphericTexture2D(
42593
- setting.defaultTexture2DSize,
42594
- setting.defaultTexture2DSize * 0.5
42595
- );
42890
+ this._internalTexture = new AtmosphericTexture2D(setting.defaultTexture2DSize, setting.defaultTexture2DSize * 0.5);
42596
42891
  this._internalTexture.update(this.setting);
42597
42892
  this.createFromTexture(this._cubeSize, this._internalTexture);
42598
42893
  return this;
@@ -42600,6 +42895,10 @@ class AtmosphericScatteringSky extends LDRTextureCube {
42600
42895
  get texture2D() {
42601
42896
  return this._internalTexture;
42602
42897
  }
42898
+ /**
42899
+ * @internal
42900
+ * @returns
42901
+ */
42603
42902
  apply() {
42604
42903
  this._internalTexture.update(this.setting);
42605
42904
  this._faceData.uploadErpTexture(this._internalTexture);
@@ -42610,13 +42909,7 @@ class AtmosphericTexture2D extends VirtualTexture {
42610
42909
  _computeShader;
42611
42910
  _uniformBuffer;
42612
42911
  constructor(width, height) {
42613
- super(
42614
- width,
42615
- height,
42616
- GPUTextureFormat.rgba16float,
42617
- false,
42618
- GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING
42619
- );
42912
+ super(width, height, GPUTextureFormat.rgba16float, false, GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING);
42620
42913
  this.initCompute(width, height);
42621
42914
  }
42622
42915
  initCompute(w, h) {
@@ -42676,7 +42969,7 @@ let SkyShader = class extends Shader {
42676
42969
  }
42677
42970
  };
42678
42971
  SkyShader = __decorateClass$a([
42679
- RegisterShader
42972
+ RegisterShader(SkyShader, "SkyShader")
42680
42973
  ], SkyShader);
42681
42974
 
42682
42975
  class SkyMaterial extends Material {
@@ -47646,7 +47939,7 @@ class GUIShader {
47646
47939
  s = border.x + (s / centerPartMax) * centerPartMin;
47647
47940
  }else{
47648
47941
  s = s - centerPartMax + border.x + centerPartMin;
47649
- }
47942
+ };
47650
47943
  }
47651
47944
  return s;
47652
47945
  }
@@ -47798,12 +48091,12 @@ class GUIShader {
47798
48091
  ret.x = quad.x;
47799
48092
  }else{
47800
48093
  ret.x = quad.z;
47801
- }
48094
+ };
47802
48095
  if(index == 0 || index == 1){
47803
48096
  ret.y = quad.w;
47804
48097
  }else{
47805
48098
  ret.y = quad.y;
47806
- }
48099
+ };
47807
48100
  return ret;
47808
48101
  }
47809
48102
  `
@@ -56742,7 +57035,7 @@ let LitSSSShader = class extends Shader {
56742
57035
  }
56743
57036
  };
56744
57037
  LitSSSShader = __decorateClass$3([
56745
- RegisterShader
57038
+ RegisterShader(LitSSSShader, "LitSSSShader")
56746
57039
  ], LitSSSShader);
56747
57040
 
56748
57041
  var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
@@ -56844,7 +57137,7 @@ let LitShader = class extends Shader {
56844
57137
  }
56845
57138
  };
56846
57139
  LitShader = __decorateClass$2([
56847
- RegisterShader
57140
+ RegisterShader(LitShader, "LitShader")
56848
57141
  ], LitShader);
56849
57142
 
56850
57143
  class ComData {
@@ -57080,7 +57373,7 @@ let UnLitShader = class extends Shader {
57080
57373
  }
57081
57374
  };
57082
57375
  UnLitShader = __decorateClass$1([
57083
- RegisterShader
57376
+ RegisterShader(UnLitShader, "UnLitShader")
57084
57377
  ], UnLitShader);
57085
57378
 
57086
57379
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -57169,7 +57462,7 @@ let UnLitTexArrayShader = class extends Shader {
57169
57462
  }
57170
57463
  };
57171
57464
  UnLitTexArrayShader = __decorateClass([
57172
- RegisterShader
57465
+ RegisterShader(UnLitTexArrayShader, "UnLitTexArrayShader")
57173
57466
  ], UnLitTexArrayShader);
57174
57467
 
57175
57468
  class TileSet {
@@ -58047,253 +58340,23 @@ class OrderMap extends Map {
58047
58340
  }
58048
58341
  }
58049
58342
 
58050
- class PlaneClassification {
58051
- /**
58052
- * @language zh_CN
58053
- * 背面
58054
- * @platform Web,Native
58055
- */
58056
- static BACK = 0;
58057
- /**
58058
- * @language zh_CN
58059
- * 正面
58060
- * @platform Web,Native
58061
- */
58062
- static FRONT = 1;
58063
- /**
58064
- * @language zh_CN
58065
- * 在法线朝上的一面
58066
- * @platform Web,Native
58067
- */
58068
- static IN = 0;
58069
- /**
58070
- * @language zh_CN
58071
- * 在法线朝下的一面
58072
- * @platform Web,Native
58073
- */
58074
- static OUT = 1;
58075
- /**
58076
- * @language zh_CN
58077
- * 相交
58078
- * @platform Web,Native
58079
- */
58080
- static INTERSECT = 2;
58081
- }
58082
-
58083
- class Plane3D {
58084
- /**
58085
- * @language en_US
58086
- * The A coefficient of this plane. (Also the x dimension of the plane normal)
58087
- */
58088
- /**
58089
- * @language zh_CN
58090
- * 平面中的a分量
58091
- * @platform Web,Native
58092
- */
58093
- a;
58094
- /**
58095
- * @language en_US
58096
- * The B coefficient of this plane. (Also the y dimension of the plane normal)
58097
- */
58098
- /**
58099
- * @language zh_CN
58100
- * 平面中的b分量
58101
- * @platform Web,Native
58102
- */
58103
- b;
58104
- /**
58105
- * @language en_US
58106
- * The C coefficient of this plane. (Also the z dimension of the plane normal)
58107
- */
58108
- /**
58109
- * @language zh_CN
58110
- * 平面中的c分量
58111
- * @platform Web,Native
58112
- */
58113
- c;
58114
- /**
58115
- * @language en_US
58116
- * The D coefficient of this plane. (Also the inverse dot product between normal and point)
58117
- */
58118
- /**
58119
- * @language zh_CN
58120
- * 平面中的d分量
58121
- * @platform Web,Native
58122
- */
58123
- d;
58124
- // indicates the alignment of the plane
58125
- /**
58126
- * @private
58127
- */
58128
- static ALIGN_ANY = 0;
58129
- /**
58130
- * @private
58131
- */
58132
- static ALIGN_XY_AXIS = 1;
58133
- /**
58134
- * @private
58135
- */
58136
- static ALIGN_YZ_AXIS = 2;
58137
- /**
58138
- * @private
58139
- */
58140
- static ALIGN_XZ_AXIS = 3;
58141
- /**
58142
- * @language en_US
58143
- * Create a Plane3D with ABCD coefficients
58144
- */
58145
- /**
58146
- * @language zh_CN
58147
- * 创建一个平面实例
58148
- * @param a
58149
- * @param b
58150
- * @param c
58151
- * @param d
58152
- * @platform Web,Native
58153
- */
58154
- constructor(a = 0, b = 0, c = 0, d = 0) {
58155
- this.a = a;
58156
- this.b = b;
58157
- this.c = c;
58158
- this.d = d;
58159
- }
58160
- /**
58161
- * @language zh_CN
58162
- * 填充平面的各分量的值
58163
- * @param a
58164
- * @param b
58165
- * @param c
58166
- * @param d
58167
- * @platform Web,Native
58168
- */
58169
- setTo(a = 0, b = 0, c = 0, d = 0) {
58170
- this.a = a;
58171
- this.b = b;
58172
- this.c = c;
58173
- this.d = d;
58174
- }
58175
- /**
58176
- * @language en_US
58177
- * Fills this Plane3D with the coefficients from 3 points in 3d space.
58178
- * @param p0 Vector3
58179
- * @param p1 Vector3
58180
- * @param p2 Vector3
58181
- */
58182
- /**
58183
- * @language zh_CN
58184
- * 由3个坐标来创建一个3d平面
58185
- * @param p0 Vector3
58186
- * @param p1 Vector3
58187
- * @param p2 Vector3
58188
- * @platform Web,Native
58189
- */
58190
- fromPoints(p0, p1, p2) {
58191
- var d1x = p1.x - p0.x;
58192
- var d1y = p1.y - p0.y;
58193
- var d1z = p1.z - p0.z;
58194
- var d2x = p2.x - p0.x;
58195
- var d2y = p2.y - p0.y;
58196
- var d2z = p2.z - p0.z;
58197
- this.a = d1y * d2z - d1z * d2y;
58198
- this.b = d1z * d2x - d1x * d2z;
58199
- this.c = d1x * d2y - d1y * d2x;
58200
- this.d = -(this.a * p0.x + this.b * p0.y + this.c * p0.z);
58201
- }
58202
- /**
58203
- * @language en_US
58204
- * Fills this Plane3D with the coefficients from the plane's normal and a point in 3d space.
58205
- * @param normal Vector3
58206
- * @param point Vector3
58207
- */
58208
- /**
58209
- * @language zh_CN
58210
- * 由一条normal向量和一个坐标创建一个3d平面
58211
- * @param normal Vector3
58212
- * @param point Vector3
58213
- * @platform Web,Native
58214
- */
58215
- fromNormalAndPoint(normal, point) {
58216
- this.a = normal.x;
58217
- this.b = normal.y;
58218
- this.c = normal.z;
58219
- this.d = -(this.a * point.x + this.b * point.y + this.c * point.z);
58220
- }
58221
- /**
58222
- * @language en_US
58223
- * Normalize this Plane3D
58224
- * @returns Plane3D This Plane3D.
58225
- */
58226
- /**
58227
- * @language zh_CN
58228
- * 单位化3d平面
58229
- * @returns number 返回平面长度
58230
- * @platform Web,Native
58231
- */
58232
- normalize() {
58233
- var len = Math.sqrt(
58234
- this.a * this.a + this.b * this.b + this.c * this.c
58235
- );
58236
- if (len > 0) {
58237
- var invLength = 1 / len;
58238
- this.a *= invLength;
58239
- this.b *= invLength;
58240
- this.c *= invLength;
58241
- this.d *= invLength;
58242
- }
58243
- return len;
58244
- }
58245
- /**
58246
- * @language en_US
58247
- * Returns the signed distance between this Plane3D and the point p.
58248
- * @param p Vector3
58249
- * @returns Number
58250
- */
58251
- /**
58252
- * @language zh_CN
58253
- * 计算3d平面到点p的距离
58254
- * @param p Vector3
58255
- * @returns number 返回计算后的距离
58256
- * @platform Web,Native
58257
- */
58258
- distance(p) {
58259
- return this.a * p.x + this.b * p.y + this.c * p.z + this.d;
58260
- }
58261
- /**
58262
- * @language en_US
58263
- * Classify a point against this Plane3D. (in front, back or intersecting)
58264
- * @param p Vector3
58265
- * @param epsilon
58266
- * @returns PlaneClassification.FRONT在平面正面
58267
- * PlaneClassification.BACK在平面背面面
58268
- * PlaneClassification.INTERSECT在平面上
58269
- */
58270
- /**
58271
- * @language zh_CN
58272
- * 计算3d平面和点p的空间关系
58273
- * @param p Vector3
58274
- * @param epsilon 相对偏移值
58275
- * @returns number int Plane3.FRONT or Plane3D.BACK or Plane3D.INTERSECT
58276
- * @platform Web,Native
58277
- */
58278
- classifyPoint(p, epsilon = 0.01) {
58279
- var dis = this.distance(p);
58280
- if (dis < -epsilon) {
58281
- return PlaneClassification.BACK;
58282
- } else if (dis > epsilon) {
58283
- return PlaneClassification.FRONT;
58284
- }
58285
- return PlaneClassification.INTERSECT;
58286
- }
58287
- /**
58288
- * @language zh_CN
58289
- * 当前Plane3D以字符串形式返回
58290
- * @returns string
58291
- * @platform Web,Native
58292
- */
58293
- toString() {
58294
- return "Plane3D [a:" + this.a + ", b:" + this.b + ", c:" + this.c + ", d:" + this.d + "]";
58295
- }
58296
- }
58343
+ var ParticleSystemRandomnessIds = /* @__PURE__ */ ((ParticleSystemRandomnessIds2) => {
58344
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemClampVelocityCurveId"] = 322376503] = "kParticleSystemClampVelocityCurveId";
58345
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemForceCurveId"] = 306581307] = "kParticleSystemForceCurveId";
58346
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemRotationCurveId"] = 1793934638] = "kParticleSystemRotationCurveId";
58347
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemRotationBySpeedCurveId"] = 3737431713] = "kParticleSystemRotationBySpeedCurveId";
58348
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemStartSpeedCurveId"] = 2527743459] = "kParticleSystemStartSpeedCurveId";
58349
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemSizeCurveId"] = 2368504881] = "kParticleSystemSizeCurveId";
58350
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemSizeBySpeedCurveId"] = 4085612399] = "kParticleSystemSizeBySpeedCurveId";
58351
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemVelocityCurveId"] = 3774601268] = "kParticleSystemVelocityCurveId";
58352
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemUVCurveId"] = 326370691] = "kParticleSystemUVCurveId";
58353
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemColorGradientId"] = 1494990940] = "kParticleSystemColorGradientId";
58354
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemColorByVelocityGradientId"] = 1089181156] = "kParticleSystemColorByVelocityGradientId";
58355
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemMeshSelectionId"] = 3159510623] = "kParticleSystemMeshSelectionId";
58356
+ ParticleSystemRandomnessIds2[ParticleSystemRandomnessIds2["kParticleSystemUVRowSelectionId"] = 2941263940] = "kParticleSystemUVRowSelectionId";
58357
+ return ParticleSystemRandomnessIds2;
58358
+ })(ParticleSystemRandomnessIds || {});
58359
+ const kPI = 3.141592653589793;
58297
58360
 
58298
58361
  class Polynomials {
58299
58362
  }
@@ -58571,6 +58634,403 @@ function integrateSegment(coeff) {
58571
58634
  coeff[3] /= 1;
58572
58635
  }
58573
58636
 
58637
+ var ParticleSystemCurveEvalMode = /* @__PURE__ */ ((ParticleSystemCurveEvalMode2) => {
58638
+ ParticleSystemCurveEvalMode2[ParticleSystemCurveEvalMode2["kEMScalar"] = 0] = "kEMScalar";
58639
+ ParticleSystemCurveEvalMode2[ParticleSystemCurveEvalMode2["kEMOptimized"] = 1] = "kEMOptimized";
58640
+ ParticleSystemCurveEvalMode2[ParticleSystemCurveEvalMode2["kEMOptimizedMinMax"] = 2] = "kEMOptimizedMinMax";
58641
+ ParticleSystemCurveEvalMode2[ParticleSystemCurveEvalMode2["kEMSlow"] = 3] = "kEMSlow";
58642
+ return ParticleSystemCurveEvalMode2;
58643
+ })(ParticleSystemCurveEvalMode || {});
58644
+ var MinMaxCurveState = /* @__PURE__ */ ((MinMaxCurveState2) => {
58645
+ MinMaxCurveState2[MinMaxCurveState2["kMMCScalar"] = 0] = "kMMCScalar";
58646
+ MinMaxCurveState2[MinMaxCurveState2["kMMCCurve"] = 1] = "kMMCCurve";
58647
+ MinMaxCurveState2[MinMaxCurveState2["kMMCTwoCurves"] = 2] = "kMMCTwoCurves";
58648
+ MinMaxCurveState2[MinMaxCurveState2["kMMCTwoConstants"] = 3] = "kMMCTwoConstants";
58649
+ return MinMaxCurveState2;
58650
+ })(MinMaxCurveState || {});
58651
+ class MinMaxAnimationCurves {
58652
+ // public SupportsProcedural ();
58653
+ max;
58654
+ min;
58655
+ }
58656
+ class MinMaxPolyCurves {
58657
+ max;
58658
+ min;
58659
+ integrate() {
58660
+ this.max.integrate();
58661
+ this.min.integrate();
58662
+ }
58663
+ doubleIntegrate() {
58664
+ this.max.doubleIntegrate();
58665
+ this.min.doubleIntegrate();
58666
+ }
58667
+ findMinMaxIntegrated() {
58668
+ return null;
58669
+ }
58670
+ findMinMaxDoubleIntegrated() {
58671
+ return null;
58672
+ }
58673
+ }
58674
+ class MinMaxCurve {
58675
+ minMaxState;
58676
+ // see enum MinMaxCurveState
58677
+ minCurve;
58678
+ maxCurve;
58679
+ _scalar = 1;
58680
+ // Since scalar is baked into the optimized curve we use the setter function to modify it.
58681
+ _minScalar;
58682
+ constructor(scalarValue = 1) {
58683
+ this._scalar = scalarValue;
58684
+ this.minMaxState = 0 /* kMMCScalar */;
58685
+ this.minCurve = new AnimationCurve();
58686
+ this.maxCurve = new AnimationCurve();
58687
+ }
58688
+ setScalar(value) {
58689
+ this._scalar = value;
58690
+ }
58691
+ getScalar() {
58692
+ return this._scalar;
58693
+ }
58694
+ static evaluateSlow(curve, t, factor) {
58695
+ let v = curve.maxCurve.getValue(t) * curve.getScalar();
58696
+ if (curve.minMaxState == 2 /* kMMCTwoCurves */) {
58697
+ return lerp(curve.minCurve.getValue(t) * curve.getScalar(), v, factor);
58698
+ } else return v;
58699
+ }
58700
+ static evaluate(curve, t, randomValue = 1) {
58701
+ if (curve.minMaxState == 0 /* kMMCScalar */) {
58702
+ return curve.getScalar();
58703
+ }
58704
+ let v = curve.maxCurve.getValue(t) * curve.getScalar();
58705
+ if (curve.minMaxState == 1 /* kMMCCurve */) {
58706
+ return lerp(curve.minCurve.getValue(t) * curve.getScalar(), v, randomValue);
58707
+ }
58708
+ if (curve.minMaxState == 3 /* kMMCTwoConstants */) {
58709
+ return lerp(curve._minScalar, curve._scalar, randomValue);
58710
+ }
58711
+ if (curve.minMaxState == 2 /* kMMCTwoCurves */) {
58712
+ return lerp(curve.minCurve.getValue(t) * curve.getScalar(), v, 1 * Math.random());
58713
+ }
58714
+ return this.evaluateSlow(curve, t, 1);
58715
+ }
58716
+ unSerialized(data) {
58717
+ this.minMaxState = data["minMaxState"];
58718
+ this._scalar = data["scalar"];
58719
+ this._minScalar = data["minScalar"];
58720
+ this.maxCurve.unSerialized(data["maxCurve"]);
58721
+ this.minCurve.unSerialized(data["minCurve"]);
58722
+ }
58723
+ }
58724
+ class ValueSpread {
58725
+ value = 0;
58726
+ mode = 0;
58727
+ spread = 0;
58728
+ speed = new MinMaxCurve();
58729
+ unSerialized(data) {
58730
+ this.value = data["value"];
58731
+ this.mode = data["mode"];
58732
+ this.spread = data["spread"];
58733
+ this.speed.unSerialized(data["speed"]);
58734
+ }
58735
+ }
58736
+ function curvesSupportProcedural(editorCurves, minMaxState) {
58737
+ let isValid = PolynomialCurve.isValidCurve(editorCurves.max);
58738
+ if (minMaxState != 2 /* kMMCTwoCurves */ && minMaxState != 3 /* kMMCTwoConstants */) {
58739
+ return isValid;
58740
+ } else {
58741
+ return isValid && PolynomialCurve.isValidCurve(editorCurves.min);
58742
+ }
58743
+ }
58744
+ function buildCurves(polyCurves, editorCurves, scalar, minMaxState) {
58745
+ polyCurves.max.buildCurve(editorCurves.max, scalar);
58746
+ if (minMaxState != 2 /* kMMCTwoCurves */ && minMaxState != 3 /* kMMCTwoConstants */) {
58747
+ polyCurves.min.buildCurve(editorCurves.max, scalar);
58748
+ } else {
58749
+ polyCurves.min.buildCurve(editorCurves.min, scalar);
58750
+ }
58751
+ }
58752
+ function calculateCurveRangesValue(minMaxValue, curve) {
58753
+ let keyCount = curve.getKeyCount();
58754
+ if (keyCount == 0) {
58755
+ return;
58756
+ }
58757
+ if (keyCount == 1) {
58758
+ calculateMinMax(minMaxValue, curve.getKey(0).value);
58759
+ } else {
58760
+ let segmentCount = keyCount - 1;
58761
+ calculateMinMax(minMaxValue, curve.getKey(0).value);
58762
+ for (let i = 0; i < segmentCount; i++) {
58763
+ let cache = new FrameCache();
58764
+ curve.calculateCacheData(cache, i, i + 1, 0);
58765
+ let a = 3 * cache.coeff[0];
58766
+ let b = 2 * cache.coeff[1];
58767
+ let c = 1 * cache.coeff[2];
58768
+ let start = curve.getKey(i).time;
58769
+ let end = curve.getKey(i + 1).time;
58770
+ let roots = [];
58771
+ let numRoots = quadraticPolynomialRootsGeneric(a, b, c, { r0: roots[0], r1: roots[1] });
58772
+ for (let r = 0; r < numRoots; r++) {
58773
+ if (roots[r] >= 0 && roots[r] + start < end) {
58774
+ calculateMinMax(minMaxValue, Polynomial.EvalSegment(roots[r], cache.coeff));
58775
+ }
58776
+ }
58777
+ calculateMinMax(minMaxValue, Polynomial.EvalSegment(end - start, cache.coeff));
58778
+ }
58779
+ }
58780
+ }
58781
+ function calculateMinMax(minmax, value) {
58782
+ minmax.x = Math.min(minmax.x, value);
58783
+ minmax.y = Math.max(minmax.y, value);
58784
+ }
58785
+
58786
+ class PlaneClassification {
58787
+ /**
58788
+ * @language zh_CN
58789
+ * 背面
58790
+ * @platform Web,Native
58791
+ */
58792
+ static BACK = 0;
58793
+ /**
58794
+ * @language zh_CN
58795
+ * 正面
58796
+ * @platform Web,Native
58797
+ */
58798
+ static FRONT = 1;
58799
+ /**
58800
+ * @language zh_CN
58801
+ * 在法线朝上的一面
58802
+ * @platform Web,Native
58803
+ */
58804
+ static IN = 0;
58805
+ /**
58806
+ * @language zh_CN
58807
+ * 在法线朝下的一面
58808
+ * @platform Web,Native
58809
+ */
58810
+ static OUT = 1;
58811
+ /**
58812
+ * @language zh_CN
58813
+ * 相交
58814
+ * @platform Web,Native
58815
+ */
58816
+ static INTERSECT = 2;
58817
+ }
58818
+
58819
+ class Plane3D {
58820
+ /**
58821
+ * @language en_US
58822
+ * The A coefficient of this plane. (Also the x dimension of the plane normal)
58823
+ */
58824
+ /**
58825
+ * @language zh_CN
58826
+ * 平面中的a分量
58827
+ * @platform Web,Native
58828
+ */
58829
+ a;
58830
+ /**
58831
+ * @language en_US
58832
+ * The B coefficient of this plane. (Also the y dimension of the plane normal)
58833
+ */
58834
+ /**
58835
+ * @language zh_CN
58836
+ * 平面中的b分量
58837
+ * @platform Web,Native
58838
+ */
58839
+ b;
58840
+ /**
58841
+ * @language en_US
58842
+ * The C coefficient of this plane. (Also the z dimension of the plane normal)
58843
+ */
58844
+ /**
58845
+ * @language zh_CN
58846
+ * 平面中的c分量
58847
+ * @platform Web,Native
58848
+ */
58849
+ c;
58850
+ /**
58851
+ * @language en_US
58852
+ * The D coefficient of this plane. (Also the inverse dot product between normal and point)
58853
+ */
58854
+ /**
58855
+ * @language zh_CN
58856
+ * 平面中的d分量
58857
+ * @platform Web,Native
58858
+ */
58859
+ d;
58860
+ // indicates the alignment of the plane
58861
+ /**
58862
+ * @private
58863
+ */
58864
+ static ALIGN_ANY = 0;
58865
+ /**
58866
+ * @private
58867
+ */
58868
+ static ALIGN_XY_AXIS = 1;
58869
+ /**
58870
+ * @private
58871
+ */
58872
+ static ALIGN_YZ_AXIS = 2;
58873
+ /**
58874
+ * @private
58875
+ */
58876
+ static ALIGN_XZ_AXIS = 3;
58877
+ /**
58878
+ * @language en_US
58879
+ * Create a Plane3D with ABCD coefficients
58880
+ */
58881
+ /**
58882
+ * @language zh_CN
58883
+ * 创建一个平面实例
58884
+ * @param a
58885
+ * @param b
58886
+ * @param c
58887
+ * @param d
58888
+ * @platform Web,Native
58889
+ */
58890
+ constructor(a = 0, b = 0, c = 0, d = 0) {
58891
+ this.a = a;
58892
+ this.b = b;
58893
+ this.c = c;
58894
+ this.d = d;
58895
+ }
58896
+ /**
58897
+ * @language zh_CN
58898
+ * 填充平面的各分量的值
58899
+ * @param a
58900
+ * @param b
58901
+ * @param c
58902
+ * @param d
58903
+ * @platform Web,Native
58904
+ */
58905
+ setTo(a = 0, b = 0, c = 0, d = 0) {
58906
+ this.a = a;
58907
+ this.b = b;
58908
+ this.c = c;
58909
+ this.d = d;
58910
+ }
58911
+ /**
58912
+ * @language en_US
58913
+ * Fills this Plane3D with the coefficients from 3 points in 3d space.
58914
+ * @param p0 Vector3
58915
+ * @param p1 Vector3
58916
+ * @param p2 Vector3
58917
+ */
58918
+ /**
58919
+ * @language zh_CN
58920
+ * 由3个坐标来创建一个3d平面
58921
+ * @param p0 Vector3
58922
+ * @param p1 Vector3
58923
+ * @param p2 Vector3
58924
+ * @platform Web,Native
58925
+ */
58926
+ fromPoints(p0, p1, p2) {
58927
+ var d1x = p1.x - p0.x;
58928
+ var d1y = p1.y - p0.y;
58929
+ var d1z = p1.z - p0.z;
58930
+ var d2x = p2.x - p0.x;
58931
+ var d2y = p2.y - p0.y;
58932
+ var d2z = p2.z - p0.z;
58933
+ this.a = d1y * d2z - d1z * d2y;
58934
+ this.b = d1z * d2x - d1x * d2z;
58935
+ this.c = d1x * d2y - d1y * d2x;
58936
+ this.d = -(this.a * p0.x + this.b * p0.y + this.c * p0.z);
58937
+ }
58938
+ /**
58939
+ * @language en_US
58940
+ * Fills this Plane3D with the coefficients from the plane's normal and a point in 3d space.
58941
+ * @param normal Vector3
58942
+ * @param point Vector3
58943
+ */
58944
+ /**
58945
+ * @language zh_CN
58946
+ * 由一条normal向量和一个坐标创建一个3d平面
58947
+ * @param normal Vector3
58948
+ * @param point Vector3
58949
+ * @platform Web,Native
58950
+ */
58951
+ fromNormalAndPoint(normal, point) {
58952
+ this.a = normal.x;
58953
+ this.b = normal.y;
58954
+ this.c = normal.z;
58955
+ this.d = -(this.a * point.x + this.b * point.y + this.c * point.z);
58956
+ }
58957
+ /**
58958
+ * @language en_US
58959
+ * Normalize this Plane3D
58960
+ * @returns Plane3D This Plane3D.
58961
+ */
58962
+ /**
58963
+ * @language zh_CN
58964
+ * 单位化3d平面
58965
+ * @returns number 返回平面长度
58966
+ * @platform Web,Native
58967
+ */
58968
+ normalize() {
58969
+ var len = Math.sqrt(
58970
+ this.a * this.a + this.b * this.b + this.c * this.c
58971
+ );
58972
+ if (len > 0) {
58973
+ var invLength = 1 / len;
58974
+ this.a *= invLength;
58975
+ this.b *= invLength;
58976
+ this.c *= invLength;
58977
+ this.d *= invLength;
58978
+ }
58979
+ return len;
58980
+ }
58981
+ /**
58982
+ * @language en_US
58983
+ * Returns the signed distance between this Plane3D and the point p.
58984
+ * @param p Vector3
58985
+ * @returns Number
58986
+ */
58987
+ /**
58988
+ * @language zh_CN
58989
+ * 计算3d平面到点p的距离
58990
+ * @param p Vector3
58991
+ * @returns number 返回计算后的距离
58992
+ * @platform Web,Native
58993
+ */
58994
+ distance(p) {
58995
+ return this.a * p.x + this.b * p.y + this.c * p.z + this.d;
58996
+ }
58997
+ /**
58998
+ * @language en_US
58999
+ * Classify a point against this Plane3D. (in front, back or intersecting)
59000
+ * @param p Vector3
59001
+ * @param epsilon
59002
+ * @returns PlaneClassification.FRONT在平面正面
59003
+ * PlaneClassification.BACK在平面背面面
59004
+ * PlaneClassification.INTERSECT在平面上
59005
+ */
59006
+ /**
59007
+ * @language zh_CN
59008
+ * 计算3d平面和点p的空间关系
59009
+ * @param p Vector3
59010
+ * @param epsilon 相对偏移值
59011
+ * @returns number int Plane3.FRONT or Plane3D.BACK or Plane3D.INTERSECT
59012
+ * @platform Web,Native
59013
+ */
59014
+ classifyPoint(p, epsilon = 0.01) {
59015
+ var dis = this.distance(p);
59016
+ if (dis < -epsilon) {
59017
+ return PlaneClassification.BACK;
59018
+ } else if (dis > epsilon) {
59019
+ return PlaneClassification.FRONT;
59020
+ }
59021
+ return PlaneClassification.INTERSECT;
59022
+ }
59023
+ /**
59024
+ * @language zh_CN
59025
+ * 当前Plane3D以字符串形式返回
59026
+ * @returns string
59027
+ * @platform Web,Native
59028
+ */
59029
+ toString() {
59030
+ return "Plane3D [a:" + this.a + ", b:" + this.b + ", c:" + this.c + ", d:" + this.d + "]";
59031
+ }
59032
+ }
59033
+
58574
59034
  function uniform_real_distribution(min, max) {
58575
59035
  return Math.random() * max + Math.random() * min + (max - min) * Math.random();
58576
59036
  }
@@ -63070,4 +63530,4 @@ const __viteBrowserExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.def
63070
63530
  __proto__: null
63071
63531
  }, Symbol.toStringTag, { value: 'Module' }));
63072
63532
 
63073
- export { AccelerateDecelerateInterpolator, AccelerateInterpolator, AnimationCurve, AnimationCurveT, AnimationMonitor, AnimatorComponent, AnimatorEventKeyframe, AnticipateInterpolator, AnticipateOvershootInterpolator, ArrayHas, ArrayItemIndex, AtlasParser, AtmosphericComponent, AtmosphericScatteringSky, AtmosphericScatteringSkySetting, AtmosphericScatteringSky_shader, AttributeAnimCurve, AxisObject, B3DMLoader, B3DMLoaderBase, B3DMParseUtil, B3DMParser, BRDFLUT, BRDFLUTGenerate, BRDF_frag, BatchTable, BiMap, BillboardComponent, BillboardType, BitUtil, BitmapTexture2D, BitmapTexture2DArray, BitmapTextureCube, Blend, BlendFactor, BlendMode, BlendShapeData, BlendShapePropertyData, BloomPost, BlurEffectCreatorBlur_cs, BlurEffectCreatorSample_cs, BlurTexture2DBufferCreator, BounceInterpolator, BoundUtil, BoundingBox, BoundingSphere, BoxColliderShape, BoxGeometry, BrdfLut_frag, BsDF_frag, BxDF_frag, BxdfDebug_frag, BytesArray, CEvent, CEventDispatcher, CEventListener, CResizeEvent, CSM, Camera3D, CameraControllerBase, CameraType, CameraUtil, CapsuleColliderShape, CastPointShadowMaterialPass, CastShadowMaterialPass, Clearcoat_frag, ClusterBoundsSource_cs, ClusterConfig, ClusterDebug_frag, ClusterLight, ClusterLightingBuffer, ClusterLightingRender, ClusterLighting_cs, CollectInfo, ColliderComponent, ColliderShape, ColliderShapeType, Color, ColorGradient, ColorLitMaterial, ColorLitShader, ColorPassFragmentOutput, ColorPassRenderer, ColorUtil, ComData, Combine_cs, Common_frag, Common_vert, ComponentBase, ComponentCollect, ComputeGPUBuffer, ComputeShader, Context3D, CubeCamera, CubeMapFaceEnum, CubeSky_Shader, CubicBezierCurve, CubicBezierPath, CubicBezierType, CycleInterpolator, CylinderGeometry, DDGIIrradianceComputePass, DDGIIrradianceGPUBufferReader, DDGIIrradianceVolume, DDGIIrradiance_shader, DDGILightingPass, DDGILighting_shader, DDGIMultiBouncePass, DDGIProbeRenderer, DEGREES_TO_RADIANS, DecelerateInterpolator, Denoising_cs, Depth2DTextureArray, DepthCubeArrayTexture, DepthMaterialPass, DepthOfFieldPost, DepthOfView_cs, DirectLight, DoubleArray, EditorInspector, Engine3D, Entity, EntityBatchCollect, EntityCollect, EnvMap_frag, ErpImage2CubeMap, ErpImage2CubeMapCreateCube_cs, ErpImage2CubeMapRgbe2rgba_cs, ExtrudeGeometry, FASTFLOOR, FXAAPost, FXAAShader, FastMathShader, FeatureTable, FileLoader, FirstPersonCameraController, Float16ArrayTexture, Float32ArrayTexture, FlyCameraController, FontChar, FontInfo, FontPage, FontParser, ForwardRenderJob, FragmentOutput, FragmentVarying, FrameCache, Frustum, FrustumCSM, FrustumCulling_cs, FullQuad_vert_wgsl, GBufferFrame, GBufferPass, GBufferPost, GBufferStand, GBuffer_pass, GILighting, GIProbeMaterial, GIProbeMaterialType, GIProbeShader, GIRenderCompleteEvent, GIRenderStartEvent, GLBChunk, GLBHeader, GLBParser, GLSLLexer, GLSLLexerToken, GLSLPreprocessor, GLSLSyntax, GLTFBinaryExtension, GLTFMaterial, GLTFParser, GLTFSubParser, GLTFSubParserCamera, GLTFSubParserConverter, GLTFSubParserMaterial, GLTFSubParserMesh, GLTFSubParserSkeleton, GLTFSubParserSkin, GLTFType, GLTF_Accessors, GLTF_Info, GLTF_Light, GLTF_Mesh, GLTF_Node, GLTF_Primitives, GLTF_Scene, GPUAddressMode, GPUBlendFactor, GPUBufferBase, GPUBufferType, GPUCompareFunction, GPUContext, GPUCullMode, GPUFilterMode, GPUPrimitiveTopology, GPUTextureFormat, GPUVertexFormat, GPUVertexStepMode, GTAOPost, GTAO_cs, GUIAtlasTexture, GUICanvas, GUIConfig, GUIGeometry, GUIGeometryRebuild, GUIMaterial, GUIPassRenderer, GUIPick, GUIPickHelper, GUIQuad, GUIQuadAttrEnum, GUIRenderer, GUIShader, GUISpace, GUISprite, GUITexture, GenerayRandomDir, GeoJsonParser, GeoJsonUtil, GeoType, GeometryBase, GeometryIndicesBuffer, GeometryUtil, GeometryVertexBuffer, GeometryVertexType, GetComponentClass, GetCountInstanceID, GetRepeat, GetShader, GlassShader, GlobalBindGroup, GlobalBindGroupLayout, GlobalFog, GlobalFog_shader, GlobalIlluminationComponent, GlobalUniform, GlobalUniformGroup, GodRayPost, GodRay_cs, GridObject, HDRTexture, HDRTextureCube, Hair_frag, Hair_shader_op, Hair_shader_tr, HaltonSeq, Horizontal, HoverCameraController, I3DMLoader, I3DMLoaderBase, I3DMParser, IBLEnvMapCreator, IBLEnvMapCreator_cs, IESProfiles, IESProfiles_frag, IKDTreeUserData, ImageType, IndicesGPUBuffer, Inline_vert, InputSystem, InstanceDrawComponent, InstanceUniform, InstancedMesh, Interpolator, InterpolatorEnum, IrradianceDataReaderCompleteEvent, IrradianceVolumeData_frag, Irradiance_frag, IsEditorInspector, IsNonSerialize, Joint, JointPose, JumperInterpolator, KDTreeEntity, KDTreeNode, KDTreeRange, KDTreeSpace, KDTreeUUID, KHR_draco_mesh_compression, KHR_lights_punctual, KHR_materials_clearcoat, KHR_materials_emissive_strength, KHR_materials_ior, KHR_materials_unlit, KV, KelvinUtil, KeyCode, KeyEvent, Keyframe, KeyframeT, LDRTextureCube, LambertMaterial, Lambert_shader, Light, LightBase, LightData, LightEntries, LightType, LightingFunction_frag, Line, LineClassification, LinearInterpolator, LitMaterial, LitSSSShader, LitShader, Lit_shader, LoaderBase, LoaderEvent, LoaderManager, MAX_VALUE, MIN_VALUE, Material, MaterialDataUniformGPUBuffer, MaterialUtilities, MathShader, MathUtil, Matrix3, Matrix4, MatrixBindGroup, MatrixGPUBuffer, MatrixShader, MemoryDO, MemoryInfo, MergeRGBACreator, MergeRGBA_cs, MeshColliderShape, MeshFilter, MeshRenderer, MorePassParser, MorePassShader, MorphTargetBlender, MorphTargetData, MorphTargetFrame, MorphTargetTransformKey, MorphTarget_shader, MouseCode, MultiBouncePass_cs, Navi3DAstar, Navi3DConst, Navi3DEdge, Navi3DFunnel, Navi3DMaskType, Navi3DMesh, Navi3DPoint, Navi3DPoint2D, Navi3DPointFat, Navi3DRouter, Navi3DTriangle, NonSerialize, NormalMap_frag, OAnimationEvent, OBJParser, Object3D, Object3DEvent, Object3DTransformTools, Object3DUtil, ObjectAnimClip, OcclusionSystem, Octree, OctreeEntity, OrbitController, OrderMap, Orientation3D, OutLineBlendColor_cs, OutlineCalcOutline_cs, OutlinePass, OutlinePost, OutlinePostData, OutlinePostManager, OutlinePostSlot, Outline_cs, OvershootInterpolator, PBRLItShader, PBRLitSSSShader, ParserBase, ParserFormat, PassGenerate, PassShader, PassType, PhysicMaterialUniform_frag, PickCompute, PickFire, PickGUIEvent3D, PickResult, Picker_cs, PingPong, PipelinePool, Plane3D, PlaneClassification, PlaneGeometry, PointClassification, PointLight, PointLightShadowRenderer, PointShadowCubeCamera, PointerEvent3D, Polynomial, PolynomialCurve, Polynomials, PoolNode, PostBase, PostProcessingComponent, PostRenderer, PreDepthPassRenderer, PreFilteredEnvironment_cs, PreFilteredEnvironment_cs2, PreIntegratedLut, PreIntegratedLutCompute, PrefabAvatarData, PrefabAvatarParser, PrefabBoneData, PrefabMaterialParser, PrefabMeshData, PrefabMeshParser, PrefabNode, PrefabParser, PrefabStringUtil, PrefabTextureData, PrefabTextureParser, Preprocessor, Probe, ProbeEntries, ProbeGBufferFrame, ProfilerUtil, PropertyAnimClip, PropertyAnimTag, PropertyAnimation, PropertyAnimationClip, PropertyAnimationClipState, PropertyAnimationEvent, PropertyHelp, QuadAABB, QuadGlsl_fs, QuadGlsl_vs, QuadRoot, QuadShader, QuadTree, QuadTreeCell, Quad_depth2dArray_frag_wgsl, Quad_depth2d_frag_wgsl, Quad_depthCube_frag_wgsl, Quad_frag_wgsl, Quad_vert_wgsl, Quaternion, RADIANS_TO_DEGREES, RGBEErrorCode, RGBEHeader, RGBEParser, RTDescriptor, RTFrame, RTResourceConfig, RTResourceMap, Rand, RandomSeed, Ray, RayCastMeshDetail, Reader, Rect, Reference, Reflection, ReflectionCG, ReflectionEntries, ReflectionMaterial, ReflectionRenderer, ReflectionShader, ReflectionShader_shader, RegisterComponent, RegisterShader, RenderContext, RenderLayer, RenderLayerUtil, RenderNode, RenderShaderCollect, RenderShaderCompute, RenderShaderPass, RenderTexture, RendererBase, RendererJob, RendererMap, RendererMask, RendererMaskUtil, RendererPassState, RepeatSE, Res, RotationControlComponents, SHCommon_frag, SN_ArrayConstant, SN_BinaryOperation, SN_Break, SN_CodeBlock, SN_Constant, SN_Continue, SN_Declaration, SN_Discard, SN_DoWhileLoop, SN_Expression, SN_ForLoop, SN_Function, SN_FunctionArgs, SN_FunctionCall, SN_IFBranch, SN_Identifier, SN_IndexOperation, SN_Layout, SN_ParenExpression, SN_Precision, SN_Return, SN_SelectOperation, SN_Struct, SN_TernaryOperation, SN_UnaryOperation, SN_WhileLoop, SSAO_cs, SSGI2_cs, SSGIPost, SSRPost, SSR_BlendColor_cs, SSR_IS_Kernel, SSR_IS_cs, SSR_RayTrace_cs, ScaleControlComponents, Scene3D, Shader, ShaderAttributeInfo, ShaderConverter, ShaderConverterResult, ShaderLib, ShaderPassBase, ShaderReflection, ShaderStage, ShaderState, ShaderUniformInfo, ShaderUtil, ShadingInput, ShadowLightsCollect, ShadowMapPassRenderer, ShadowMapping_frag, Skeleton, SkeletonAnimationClip, SkeletonAnimationClipState, SkeletonAnimationComponent, SkeletonAnimationCompute, SkeletonAnimation_shader, SkeletonBlendComputeArgs, SkeletonPose, SkeletonTransformComputeArgs, SkinnedMeshRenderer, SkinnedMeshRenderer2, SkyGBufferPass, SkyGBuffer_pass, SkyMaterial, SkyRenderer, SkyShader, SolidColorSky, SphereColliderShape, SphereGeometry, SphereReflection, SpotLight, StandShader, StatementNode, StorageGPUBuffer, StringUtil, Struct, StructStorageGPUBuffer, SubGeometry, TAACopyTex_cs, TAAPost, TAASharpTex_cs, TAA_cs, TestComputeLoadBuffer, TextAnchor, TextFieldLayout, TextFieldLine, Texture, TextureCube, TextureCubeFaceData, TextureCubeStdCreator, TextureCubeUtils, TextureMipmapCompute, TextureMipmapGenerator, TextureScaleCompute, ThirdPersonCameraController, TileSet, TileSetChild, TileSetChildContent, TileSetChildContentMetaData, TileSetRoot, TilesRenderer, Time, TokenType, TorusGeometry, TouchData, TrailGeometry, Transform, TransformAxisEnum, TransformControllerBaseComponent, TransformMode, TransformSpaceMode, TranslationControlComponents, TranslatorContext, TriGeometry, Triangle, UIButton, UIButtonTransition, UIComponentBase, UIEvent, UIImage, UIImageGroup, UIInteractive, UIInteractiveStyle, UIPanel, UIRenderAble, UIShadow, UITextField, UITransform, UUID, UV, Uint8ArrayTexture, UnLit, UnLitMaterial, UnLitMaterialUniform_frag, UnLitShader, UnLitTexArrayMaterial, UnLitTexArrayShader, UnLitTextureArray, UnLit_frag, UniformGPUBuffer, UniformNode, UniformType, ValueEnumType, ValueOp, ValueParser, Vector2, Vector3, Vector3Ex, Vector4, VertexAttribute, VertexAttributeIndexShader, VertexAttributeName, VertexAttributeSize, VertexAttributeStride, VertexAttributes_vert, VertexBufferLayout, VertexFormat, VertexGPUBuffer, Vertical, VideoUniform_frag, View3D, ViewPanel, ViewQuad, VirtualTexture, WGSLTranslator, WebGPUDescriptorCreator, WorldMatrixUniform, WorldPanel, WrapMode, WrapTimeMode, ZCullingCompute, ZPassShader_cs, ZPassShader_fs, ZPassShader_vs, ZSorterUtil, append, arrayToString, blendComponent, castPointShadowMap_vert, clamp, clampRepeat, cos, crossProduct, cubicPolynomialRoot, cubicPolynomialRootsGeneric, deg2Rad, directionShadowCastMap_frag, dot, doubleIntegrateSegment, downSample, fastInvSqrt, floorfToIntPos, fonts, generateRandom, generateRandom3, getFloatFromInt, getGLTypeFromTypedArray, getGLTypeFromTypedArrayType, getGlobalRandomSeed, getTypedArray, getTypedArrayTypeFromGLType, grad1, grad2, grad3, grad4, integrateSegment, irradianceDataReader, lerp, lerpByte, lerpColor, lerpVector3, magnitude, makeAloneSprite, makeGUISprite, makeMatrix44, matrixMultiply, matrixRotate, matrixRotateY, mergeFunctions, multiplyMatrices4x4REF, normal_distribution, normalizeFast, normalizeSafe, normalizedToByte, normalizedToWord, outlinePostData, outlinePostManager, perm, post, quadraticPolynomialRootsGeneric, rad2Deg, random01, randomBarycentricCoord, randomPointBetweenEllipsoid, randomPointBetweenSphere, randomPointInsideCube, randomPointInsideEllipsoid, randomPointInsideUnitCircle, randomPointInsideUnitSphere, randomQuaternion, randomQuaternionUniformDistribution, randomSeed, randomUnitVector, randomUnitVector2, rangedRandomFloat, rangedRandomInt, readMagicBytes, registerMaterial, repeat, rotMatrix, rotateVectorByQuat, roundfToIntPos, scale, shadowCastMap_frag, shadowCastMap_vert, simplex, sin, snoise1, snoise2, snoise3, snoise4, sqrMagnitude, sqrtImpl, stencilStateFace, swap, textureCompress, threshold, toHalfFloat, tw, uniform_real_distribution, uniform_real_distribution2, upSample$1 as upSample, webGPUContext, zSorterUtil };
63533
+ export { AccelerateDecelerateInterpolator, AccelerateInterpolator, AnimationCurve, AnimationCurveT, AnimationMonitor, AnimatorComponent, AnimatorEventKeyframe, AnticipateInterpolator, AnticipateOvershootInterpolator, ArrayHas, ArrayItemIndex, AtlasParser, AtmosphericComponent, AtmosphericScatteringSky, AtmosphericScatteringSkySetting, AtmosphericScatteringSky_shader, AttributeAnimCurve, AxisObject, B3DMLoader, B3DMLoaderBase, B3DMParseUtil, B3DMParser, BRDFLUT, BRDFLUTGenerate, BRDF_frag, BatchTable, BiMap, BillboardComponent, BillboardType, BitUtil, BitmapTexture2D, BitmapTexture2DArray, BitmapTextureCube, Blend, BlendFactor, BlendMode, BlendShapeData, BlendShapePropertyData, BloomPost, BlurEffectCreatorBlur_cs, BlurEffectCreatorSample_cs, BlurTexture2DBufferCreator, BounceInterpolator, BoundUtil, BoundingBox, BoundingSphere, BoxColliderShape, BoxGeometry, BrdfLut_frag, BsDF_frag, BxDF_frag, BxdfDebug_frag, BytesArray, CEvent, CEventDispatcher, CEventListener, CResizeEvent, CSM, Camera3D, CameraControllerBase, CameraType, CameraUtil, CapsuleColliderShape, CastPointShadowMaterialPass, CastShadowMaterialPass, Clearcoat_frag, ClusterBoundsSource_cs, ClusterConfig, ClusterDebug_frag, ClusterLight, ClusterLightingBuffer, ClusterLightingRender, ClusterLighting_cs, CollectInfo, ColliderComponent, ColliderShape, ColliderShapeType, Color, ColorGradient, ColorLitMaterial, ColorLitShader, ColorPassFragmentOutput, ColorPassRenderer, ColorUtil, ComData, Combine_cs, Common_frag, Common_vert, ComponentBase, ComponentCollect, ComputeGPUBuffer, ComputeShader, Context3D, CubeCamera, CubeMapFaceEnum, CubeSky_Shader, CubicBezierCurve, CubicBezierPath, CubicBezierType, CycleInterpolator, CylinderGeometry, DDGIIrradianceComputePass, DDGIIrradianceGPUBufferReader, DDGIIrradianceVolume, DDGIIrradiance_shader, DDGILightingPass, DDGILighting_shader, DDGIMultiBouncePass, DDGIProbeRenderer, DEGREES_TO_RADIANS, DecelerateInterpolator, Denoising_cs, Depth2DTextureArray, DepthCubeArrayTexture, DepthMaterialPass, DepthOfFieldPost, DepthOfView_cs, DirectLight, DoubleArray, EditorInspector, Engine3D, Entity, EntityBatchCollect, EntityCollect, EnvMap_frag, ErpImage2CubeMap, ErpImage2CubeMapCreateCube_cs, ErpImage2CubeMapRgbe2rgba_cs, ExtrudeGeometry, FASTFLOOR, FXAAPost, FXAAShader, FastMathShader, FeatureTable, FileLoader, FirstPersonCameraController, Float16ArrayTexture, Float32ArrayTexture, FlyCameraController, FontChar, FontInfo, FontPage, FontParser, ForwardRenderJob, FragmentOutput, FragmentVarying, FrameCache, Frustum, FrustumCSM, FrustumCulling_cs, FullQuad_vert_wgsl, GBufferFrame, GBufferPass, GBufferPost, GBufferStand, GBuffer_pass, GILighting, GIProbeMaterial, GIProbeMaterialType, GIProbeShader, GIRenderCompleteEvent, GIRenderStartEvent, GLBChunk, GLBHeader, GLBParser, GLSLLexer, GLSLLexerToken, GLSLPreprocessor, GLSLSyntax, GLTFBinaryExtension, GLTFMaterial, GLTFParser, GLTFSubParser, GLTFSubParserCamera, GLTFSubParserConverter, GLTFSubParserMaterial, GLTFSubParserMesh, GLTFSubParserSkeleton, GLTFSubParserSkin, GLTFType, GLTF_Accessors, GLTF_Info, GLTF_Light, GLTF_Mesh, GLTF_Node, GLTF_Primitives, GLTF_Scene, GPUAddressMode, GPUBlendFactor, GPUBufferBase, GPUBufferType, GPUCompareFunction, GPUContext, GPUCullMode, GPUFilterMode, GPUPrimitiveTopology, GPUTextureFormat, GPUVertexFormat, GPUVertexStepMode, GTAOPost, GTAO_cs, GUIAtlasTexture, GUICanvas, GUIConfig, GUIGeometry, GUIGeometryRebuild, GUIMaterial, GUIPassRenderer, GUIPick, GUIPickHelper, GUIQuad, GUIQuadAttrEnum, GUIRenderer, GUIShader, GUISpace, GUISprite, GUITexture, GenerayRandomDir, GeoJsonParser, GeoJsonUtil, GeoType, GeometryBase, GeometryIndicesBuffer, GeometryUtil, GeometryVertexBuffer, GeometryVertexType, GetComponentClass, GetCountInstanceID, GetRepeat, GetShader, GlassShader, GlobalBindGroup, GlobalBindGroupLayout, GlobalFog, GlobalFog_shader, GlobalIlluminationComponent, GlobalUniform, GlobalUniformGroup, GodRayPost, GodRay_cs, GridObject, HDRTexture, HDRTextureCube, Hair_frag, Hair_shader_op, Hair_shader_tr, HaltonSeq, Horizontal, HoverCameraController, I3DMLoader, I3DMLoaderBase, I3DMParser, IBLEnvMapCreator, IBLEnvMapCreator_cs, IESProfiles, IESProfiles_frag, IKDTreeUserData, ImageType, IndicesGPUBuffer, Inline_vert, InputSystem, InstanceDrawComponent, InstanceUniform, InstancedMesh, Interpolator, InterpolatorEnum, IrradianceDataReaderCompleteEvent, IrradianceVolumeData_frag, Irradiance_frag, IsEditorInspector, IsNonSerialize, Joint, JointPose, JumperInterpolator, KDTreeEntity, KDTreeNode, KDTreeRange, KDTreeSpace, KDTreeUUID, KHR_draco_mesh_compression, KHR_lights_punctual, KHR_materials_clearcoat, KHR_materials_emissive_strength, KHR_materials_ior, KHR_materials_unlit, KV, KelvinUtil, KeyCode, KeyEvent, Keyframe, KeyframeT, LDRTextureCube, LambertMaterial, Lambert_shader, Light, LightBase, LightData, LightEntries, LightType, LightingFunction_frag, Line, LineClassification, LinearInterpolator, LitMaterial, LitSSSShader, LitShader, Lit_shader, LoaderBase, LoaderEvent, LoaderManager, MAX_VALUE, MIN_VALUE, Material, MaterialDataUniformGPUBuffer, MaterialUtilities, MathShader, MathUtil, Matrix3, Matrix4, MatrixBindGroup, MatrixGPUBuffer, MatrixShader, MemoryDO, MemoryInfo, MergeRGBACreator, MergeRGBA_cs, MeshColliderShape, MeshFilter, MeshRenderer, MinMaxAnimationCurves, MinMaxCurve, MinMaxCurveState, MinMaxPolyCurves, MorePassParser, MorePassShader, MorphTargetBlender, MorphTargetData, MorphTargetFrame, MorphTargetTransformKey, MorphTarget_shader, MouseCode, MultiBouncePass_cs, Navi3DAstar, Navi3DConst, Navi3DEdge, Navi3DFunnel, Navi3DMaskType, Navi3DMesh, Navi3DPoint, Navi3DPoint2D, Navi3DPointFat, Navi3DRouter, Navi3DTriangle, NonSerialize, NormalMap_frag, OAnimationEvent, OBJParser, Object3D, Object3DEvent, Object3DTransformTools, Object3DUtil, ObjectAnimClip, OcclusionSystem, Octree, OctreeEntity, OrbitController, OrderMap, Orientation3D, OutLineBlendColor_cs, OutlineCalcOutline_cs, OutlinePass, OutlinePost, OutlinePostData, OutlinePostManager, OutlinePostSlot, Outline_cs, OvershootInterpolator, PBRLItShader, PBRLitSSSShader, ParserBase, ParserFormat, ParticleSystemCurveEvalMode, ParticleSystemRandomnessIds, PassGenerate, PassShader, PassType, PhysicMaterialUniform_frag, PickCompute, PickFire, PickGUIEvent3D, PickResult, Picker_cs, PingPong, PipelinePool, Plane3D, PlaneClassification, PlaneGeometry, PointClassification, PointLight, PointLightShadowRenderer, PointShadowCubeCamera, PointerEvent3D, Polynomial, PolynomialCurve, Polynomials, PoolNode, PostBase, PostProcessingComponent, PostRenderer, PreDepthPassRenderer, PreFilteredEnvironment_cs, PreFilteredEnvironment_cs2, PreIntegratedLut, PreIntegratedLutCompute, PrefabAvatarData, PrefabAvatarParser, PrefabBoneData, PrefabMaterialParser, PrefabMeshData, PrefabMeshParser, PrefabNode, PrefabParser, PrefabStringUtil, PrefabTextureData, PrefabTextureParser, Preprocessor, Probe, ProbeEntries, ProbeGBufferFrame, ProfilerUtil, PropertyAnimClip, PropertyAnimTag, PropertyAnimation, PropertyAnimationClip, PropertyAnimationClipState, PropertyAnimationEvent, PropertyHelp, QuadAABB, QuadGlsl_fs, QuadGlsl_vs, QuadRoot, QuadShader, QuadTree, QuadTreeCell, Quad_depth2dArray_frag_wgsl, Quad_depth2d_frag_wgsl, Quad_depthCube_frag_wgsl, Quad_frag_wgsl, Quad_vert_wgsl, Quaternion, RADIANS_TO_DEGREES, RGBEErrorCode, RGBEHeader, RGBEParser, RTDescriptor, RTFrame, RTResourceConfig, RTResourceMap, Rand, RandomSeed, Ray, RayCastMeshDetail, Reader, Rect, Reference, Reflection, ReflectionCG, ReflectionEntries, ReflectionMaterial, ReflectionRenderer, ReflectionShader, ReflectionShader_shader, RegisterComponent, RegisterShader, RenderContext, RenderLayer, RenderLayerUtil, RenderNode, RenderShaderCollect, RenderShaderCompute, RenderShaderPass, RenderTexture, RendererBase, RendererJob, RendererMap, RendererMask, RendererMaskUtil, RendererPassState, RepeatSE, Res, RotationControlComponents, SHCommon_frag, SN_ArrayConstant, SN_BinaryOperation, SN_Break, SN_CodeBlock, SN_Constant, SN_Continue, SN_Declaration, SN_Discard, SN_DoWhileLoop, SN_Expression, SN_ForLoop, SN_Function, SN_FunctionArgs, SN_FunctionCall, SN_IFBranch, SN_Identifier, SN_IndexOperation, SN_Layout, SN_ParenExpression, SN_Precision, SN_Return, SN_SelectOperation, SN_Struct, SN_TernaryOperation, SN_UnaryOperation, SN_WhileLoop, SSAO_cs, SSGI2_cs, SSGIPost, SSRPost, SSR_BlendColor_cs, SSR_IS_Kernel, SSR_IS_cs, SSR_RayTrace_cs, ScaleControlComponents, Scene3D, Shader, ShaderAttributeInfo, ShaderConverter, ShaderConverterResult, ShaderLib, ShaderPassBase, ShaderReflection, ShaderStage, ShaderState, ShaderUniformInfo, ShaderUtil, ShadingInput, ShadowLightsCollect, ShadowMapPassRenderer, ShadowMapping_frag, Skeleton, SkeletonAnimationClip, SkeletonAnimationClipState, SkeletonAnimationComponent, SkeletonAnimationCompute, SkeletonAnimation_shader, SkeletonBlendComputeArgs, SkeletonPose, SkeletonTransformComputeArgs, SkinnedMeshRenderer, SkinnedMeshRenderer2, SkyGBufferPass, SkyGBuffer_pass, SkyMaterial, SkyRenderer, SkyShader, SolidColorSky, SphereColliderShape, SphereGeometry, SphereReflection, SpotLight, StandShader, StatementNode, StorageGPUBuffer, StringUtil, Struct, StructStorageGPUBuffer, SubGeometry, TAACopyTex_cs, TAAPost, TAASharpTex_cs, TAA_cs, TestComputeLoadBuffer, TextAnchor, TextFieldLayout, TextFieldLine, Texture, TextureCube, TextureCubeFaceData, TextureCubeStdCreator, TextureCubeUtils, TextureMipmapCompute, TextureMipmapGenerator, TextureScaleCompute, ThirdPersonCameraController, TileSet, TileSetChild, TileSetChildContent, TileSetChildContentMetaData, TileSetRoot, TilesRenderer, Time, TokenType, TorusGeometry, TouchData, TrailGeometry, Transform, TransformAxisEnum, TransformControllerBaseComponent, TransformMode, TransformSpaceMode, TranslationControlComponents, TranslatorContext, TriGeometry, Triangle, UIButton, UIButtonTransition, UIComponentBase, UIEvent, UIImage, UIImageGroup, UIInteractive, UIInteractiveStyle, UIPanel, UIRenderAble, UIShadow, UITextField, UITransform, UUID, UV, Uint8ArrayTexture, UnLit, UnLitMaterial, UnLitMaterialUniform_frag, UnLitShader, UnLitTexArrayMaterial, UnLitTexArrayShader, UnLitTextureArray, UnLit_frag, UniformGPUBuffer, UniformNode, UniformType, ValueEnumType, ValueOp, ValueParser, ValueSpread, Vector2, Vector3, Vector3Ex, Vector4, VertexAttribute, VertexAttributeIndexShader, VertexAttributeName, VertexAttributeSize, VertexAttributeStride, VertexAttributes_vert, VertexBufferLayout, VertexFormat, VertexGPUBuffer, Vertical, VideoUniform_frag, View3D, ViewPanel, ViewQuad, VirtualTexture, WGSLTranslator, WebGPUDescriptorCreator, WorldMatrixUniform, WorldPanel, WrapMode, WrapTimeMode, ZCullingCompute, ZPassShader_cs, ZPassShader_fs, ZPassShader_vs, ZSorterUtil, append, arrayToString, blendComponent, buildCurves, calculateCurveRangesValue, calculateMinMax, castPointShadowMap_vert, clamp, clampRepeat, cos, crossProduct, cubicPolynomialRoot, cubicPolynomialRootsGeneric, curvesSupportProcedural, deg2Rad, directionShadowCastMap_frag, dot, doubleIntegrateSegment, downSample, fastInvSqrt, floorfToIntPos, fonts, generateRandom, generateRandom3, getFloatFromInt, getGLTypeFromTypedArray, getGLTypeFromTypedArrayType, getGlobalRandomSeed, getTypedArray, getTypedArrayTypeFromGLType, grad1, grad2, grad3, grad4, integrateSegment, irradianceDataReader, kPI, lerp, lerpByte, lerpColor, lerpVector3, magnitude, makeAloneSprite, makeGUISprite, makeMatrix44, matrixMultiply, matrixRotate, matrixRotateY, mergeFunctions, multiplyMatrices4x4REF, normal_distribution, normalizeFast, normalizeSafe, normalizedToByte, normalizedToWord, outlinePostData, outlinePostManager, perm, post, quadraticPolynomialRootsGeneric, rad2Deg, random01, randomBarycentricCoord, randomPointBetweenEllipsoid, randomPointBetweenSphere, randomPointInsideCube, randomPointInsideEllipsoid, randomPointInsideUnitCircle, randomPointInsideUnitSphere, randomQuaternion, randomQuaternionUniformDistribution, randomSeed, randomUnitVector, randomUnitVector2, rangedRandomFloat, rangedRandomInt, readMagicBytes, registerMaterial, repeat, rotMatrix, rotateVectorByQuat, roundfToIntPos, scale, shadowCastMap_frag, shadowCastMap_vert, simplex, sin, snoise1, snoise2, snoise3, snoise4, sqrMagnitude, sqrtImpl, stencilStateFace, swap, textureCompress, threshold, toHalfFloat, tw, uniform_real_distribution, uniform_real_distribution2, upSample$1 as upSample, webGPUContext, zSorterUtil };