|
@@ -298,13 +298,22 @@ let shader = {
|
|
//注:未加载好的话,depth为0,导致第一次漫游过去的时候许多mesh会立刻被遮挡,所以要确保加载完
|
|
//注:未加载好的话,depth为0,导致第一次漫游过去的时候许多mesh会立刻被遮挡,所以要确保加载完
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-
|
|
|
|
|
|
+ int unpack16(vec2 channels){
|
|
|
|
+ return int(round(channels.y * 255.0)) + (int(round(channels.x * 255.0)) << 8) ; //some phone needs round,such as vivo x30
|
|
|
|
+ }
|
|
|
|
|
|
int getIntFromColor(sampler2D map, vec3 dir){//uint16-> int 0-65536
|
|
int getIntFromColor(sampler2D map, vec3 dir){//uint16-> int 0-65536
|
|
|
|
+ //float texWidth = 1024.;
|
|
vec2 uv = getSamplerCoord2(dir.xyz);
|
|
vec2 uv = getSamplerCoord2(dir.xyz);
|
|
uv.x -= 0.25;
|
|
uv.x -= 0.25;
|
|
vec4 color = texture2D(map, uv);
|
|
vec4 color = texture2D(map, uv);
|
|
- return int(round(color.r * 255.0)) + (int(round(color.g * 255.0)) << 8) ; //some phone needs round,such as vivo x30
|
|
|
|
|
|
+ return unpack16(color.rg);
|
|
|
|
+ /* if( fract(uv.x * texWidth) > 0.5){
|
|
|
|
+ return unpack16(color.rg);
|
|
|
|
+ }else{
|
|
|
|
+ return unpack16(color.ba);
|
|
|
|
+ } */
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -465,7 +474,7 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
|
|
let {vs,fs} = Common.changeShaderToWebgl2(shader.vertexShader, shader.fragmentShader, 'RawShaderMaterial')
|
|
let {vs,fs} = Common.changeShaderToWebgl2(shader.vertexShader, shader.fragmentShader, 'RawShaderMaterial')
|
|
if(!Potree.settings.isWebgl2){
|
|
if(!Potree.settings.isWebgl2){
|
|
defines['round(x)'] = 'floor(x + 0.5)' //webgl1 unsupport round
|
|
defines['round(x)'] = 'floor(x + 0.5)' //webgl1 unsupport round
|
|
- fs = fs.replace('int(round(color.g * 255.0)) << 8', 'int(round(color.g * 255.0 * pow(2.0, 8.0)))') //unsupport <<
|
|
|
|
|
|
+ fs = fs.replace('int(round(channels.x * 255.0)) << 8', 'int(round(channels.x * 255.0 * pow(2.0, 8.0)))') //unsupport <<
|
|
}
|
|
}
|
|
super({
|
|
super({
|
|
fragmentShader: fs,
|
|
fragmentShader: fs,
|