fix Angle DX9 issue
This commit is contained in:
parent
9066ab5450
commit
7226636d12
115
src/Potree.js
115
src/Potree.js
@ -843,10 +843,12 @@ Potree.Shader = class Shader{
|
||||
this.name = name;
|
||||
this.vsSource = vsSource;
|
||||
this.fsSource = fsSource;
|
||||
|
||||
this.cache = new Map();
|
||||
|
||||
this.vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
this.fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
this.program = gl.createProgram();
|
||||
this.vs = null;
|
||||
this.fs = null;
|
||||
this.program = null;
|
||||
|
||||
this.uniformLocations = {};
|
||||
this.attributeLocations = {};
|
||||
@ -883,49 +885,77 @@ Potree.Shader = class Shader{
|
||||
this.attributeLocations = {};
|
||||
|
||||
gl.useProgram(null);
|
||||
|
||||
this.compileShader(this.vs, this.vsSource);
|
||||
this.compileShader(this.fs, this.fsSource);
|
||||
|
||||
let program = this.program;
|
||||
|
||||
gl.attachShader(program, this.vs);
|
||||
gl.attachShader(program, this.fs);
|
||||
|
||||
gl.linkProgram(program);
|
||||
|
||||
gl.detachShader(program, this.vs);
|
||||
gl.detachShader(program, this.fs);
|
||||
|
||||
let success = gl.getProgramParameter(program, gl.LINK_STATUS);
|
||||
if(!success){
|
||||
let info = gl.getProgramInfoLog (program);
|
||||
throw `could not link program ${this.name}: ${info}`;
|
||||
}
|
||||
|
||||
{ // attribute locations
|
||||
let numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
||||
|
||||
let cached = this.cache.get(`${this.vsSource}, ${this.fsSource}`);
|
||||
if(cached){
|
||||
this.program = cached.program;
|
||||
this.vs = cached.vs;
|
||||
this.fs = cached.fs;
|
||||
this.attributeLocations = cached.attributeLocations;
|
||||
this.uniformLocations = cached.uniformLocations;
|
||||
|
||||
return;
|
||||
}else{
|
||||
|
||||
this.vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
this.fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
this.program = gl.createProgram();
|
||||
|
||||
this.compileShader(this.vs, this.vsSource);
|
||||
this.compileShader(this.fs, this.fsSource);
|
||||
|
||||
for(let i = 0; i < numAttributes; i++){
|
||||
let attribute = gl.getActiveAttrib(program, i);
|
||||
|
||||
let location = gl.getAttribLocation(program, attribute.name);
|
||||
|
||||
this.attributeLocations[attribute.name] = location;
|
||||
let program = this.program;
|
||||
|
||||
gl.attachShader(program, this.vs);
|
||||
gl.attachShader(program, this.fs);
|
||||
|
||||
gl.linkProgram(program);
|
||||
|
||||
gl.detachShader(program, this.vs);
|
||||
gl.detachShader(program, this.fs);
|
||||
|
||||
let success = gl.getProgramParameter(program, gl.LINK_STATUS);
|
||||
if(!success){
|
||||
let info = gl.getProgramInfoLog (program);
|
||||
throw `could not link program ${this.name}: ${info}`;
|
||||
}
|
||||
|
||||
{ // attribute locations
|
||||
let numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
||||
|
||||
for(let i = 0; i < numAttributes; i++){
|
||||
let attribute = gl.getActiveAttrib(program, i);
|
||||
|
||||
let location = gl.getAttribLocation(program, attribute.name);
|
||||
|
||||
this.attributeLocations[attribute.name] = location;
|
||||
}
|
||||
}
|
||||
|
||||
{ // uniform locations
|
||||
let numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
||||
|
||||
for(let i = 0; i < numUniforms; i++){
|
||||
let uniform = gl.getActiveUniform(program, i);
|
||||
|
||||
let location = gl.getUniformLocation(program, uniform.name);
|
||||
|
||||
this.uniformLocations[uniform.name] = location;
|
||||
}
|
||||
}
|
||||
|
||||
let cached = {
|
||||
program: this.program,
|
||||
vs: this.vs,
|
||||
fs: this.fs,
|
||||
attributeLocations: this.attributeLocations,
|
||||
uniformLocations: this.uniformLocations
|
||||
};
|
||||
|
||||
this.cache.set(`${this.vsSource}, ${this.fsSource}`, cached);
|
||||
}
|
||||
|
||||
{ // uniform locations
|
||||
let numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
||||
|
||||
for(let i = 0; i < numUniforms; i++){
|
||||
let uniform = gl.getActiveUniform(program, i);
|
||||
|
||||
let location = gl.getUniformLocation(program, uniform.name);
|
||||
|
||||
this.uniformLocations[uniform.name] = location;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1471,7 +1501,6 @@ Potree.Renderer = class{
|
||||
shader.setUniformMatrix4("snapProj", material.uniforms.snapProj.value);
|
||||
|
||||
}
|
||||
shader.setUniform("snapEnabled", material.uniforms.snapEnabled.value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -270,7 +270,6 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
snapshot: { type: "t", value: null},
|
||||
snapView: { type: "Matrix4f", value: []},
|
||||
snapProj: { type: "Matrix4f", value: []},
|
||||
snapEnabled: { type: "b", value: this._snapEnabled},
|
||||
};
|
||||
|
||||
this.defaultAttributeValues.normal = [0, 0, 0];
|
||||
@ -332,9 +331,9 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
defines += '#define use_edl\n';
|
||||
}
|
||||
|
||||
//if (this._snapEnabled) {
|
||||
// defines += '#define snap_enabled\n';
|
||||
//}
|
||||
if (this._snapEnabled) {
|
||||
defines += '#define snap_enabled\n';
|
||||
}
|
||||
|
||||
if (this._pointColorType === Potree.PointColorType.RGB) {
|
||||
defines += '#define color_type_rgb\n';
|
||||
@ -509,8 +508,8 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
set snapEnabled(value){
|
||||
if(this._snapEnabled !== value){
|
||||
this._snapEnabled = value;
|
||||
this.uniforms.snapEnabled.value = value;
|
||||
//this.updateShaderSource();
|
||||
//this.uniforms.snapEnabled.value = value;
|
||||
this.updateShaderSource();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,4 +1035,14 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
copyFrom(from){
|
||||
|
||||
for(let name of this.uniforms){
|
||||
this.uniforms[name].value = from.uniforms[name].value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -30,12 +30,11 @@ varying float vLogDepth;
|
||||
varying vec3 vViewPosition;
|
||||
varying float vRadius;
|
||||
|
||||
//#if defined(snap_enabled)
|
||||
#if defined(snap_enabled)
|
||||
uniform sampler2D snapshot;
|
||||
uniform mat4 snapView;
|
||||
uniform mat4 snapProj;
|
||||
uniform bool snapEnabled;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
varying vec4 vSP;
|
||||
varying float vPointSize;
|
||||
@ -48,7 +47,7 @@ void main() {
|
||||
float depth = gl_FragCoord.z;
|
||||
|
||||
|
||||
if(snapEnabled){
|
||||
#if defined(snap_enabled)
|
||||
vec2 uv = 0.5 * (vSP.xy / vSP.w) + 0.5;
|
||||
|
||||
vec2 pc = vec2(
|
||||
@ -66,7 +65,7 @@ void main() {
|
||||
discard;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(circle_point_shape) || defined(paraboloid_point_shape)
|
||||
|
||||
@ -79,12 +79,11 @@ uniform sampler2D classificationLUT;
|
||||
uniform bool useShadowMap;
|
||||
uniform mat4 smWorldViewProj;
|
||||
|
||||
//#if defined(snap_enabled)
|
||||
#if defined(snap_enabled)
|
||||
uniform sampler2D snapshot;
|
||||
uniform mat4 snapView;
|
||||
uniform mat4 snapProj;
|
||||
uniform bool snapEnabled;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
varying float vOpacity;
|
||||
varying vec3 vColor;
|
||||
@ -529,7 +528,7 @@ void main() {
|
||||
#endif
|
||||
|
||||
|
||||
if(snapEnabled){
|
||||
#if defined(snap_enabled)
|
||||
//vColor = vec3(1.0, 0.0, 0.0);
|
||||
//vec4 snapPos = snapProj * snapView * modelMatrix * vec4( position, 1.0 );
|
||||
//vec2 uv = (snapPos.xy / snapPos.w) * 0.5 + 0.5;
|
||||
@ -545,5 +544,5 @@ void main() {
|
||||
vSP = sp;
|
||||
//vColor = vec3(uv, 0.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -20,6 +20,10 @@ class RepRenderer {
|
||||
target: null,
|
||||
matrix: null
|
||||
};
|
||||
|
||||
this.aug = {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -178,7 +182,7 @@ class RepRenderer {
|
||||
this.snap.camera = camera.clone();
|
||||
for(const octree of viewer.scene.pointclouds){
|
||||
octree.material.snapEnabled = false;
|
||||
//octree.material.needsUpdate = true;
|
||||
octree.material.needsUpdate = true;
|
||||
viewer.pRenderer.renderOctree(octree, octree.visibleNodes, camera, this.snap.target, {});
|
||||
}
|
||||
this.snapshotRequested = false;
|
||||
@ -188,7 +192,7 @@ class RepRenderer {
|
||||
viewer.renderer.setRenderTarget(this.rtColor);
|
||||
for(const octree of viewer.scene.pointclouds){
|
||||
octree.material.snapEnabled = true;
|
||||
//octree.material.needsUpdate = true;
|
||||
octree.material.needsUpdate = true;
|
||||
octree.material.uniforms.snapshot.value = this.snap.target.texture;
|
||||
octree.material.uniforms.snapView.value = this.snap.camera.matrixWorldInverse;
|
||||
octree.material.uniforms.snapProj.value = this.snap.camera.projectionMatrix;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user