takahirox / aframe-outline

Two-pass Outline effect component for A-Frame
https://cdn.rawgit.com/takahirox/aframe-outline/v1.1.0/index.html
MIT License
34 stars 4 forks source link

shader cant compile #1

Open imgntn opened 7 years ago

imgntn commented 7 years ago

i get this error in chrome and firefox when i add the outline property.

i'm on an AMD r9 390 -- curious as to whether you developed it on Nvidia.

thanks!

THREE.WebGLShader: Shader couldn't compile.aframe-master.min.js:30:338THREE.WebGLShader: gl.getShaderInfoLog() vertex ERROR: 0:67: 'transformed' : undeclared identifier 
ERROR: 0:67: 'constructor' : not enough data provided for construction 
 1: precision highp float;
2: precision highp int;
3: #define SHADER_NAME ShaderMaterial
4: #define VERTEX_TEXTURES
5: #define GAMMA_FACTOR 2
6: #define MAX_BONES 1019
7: #define FLIP_SIDED
8: #define NUM_CLIPPING_PLANES 0
9: uniform mat4 modelMatrix;
10: uniform mat4 modelViewMatrix;
11: uniform mat4 projectionMatrix;
12: uniform mat4 viewMatrix;
13: uniform mat3 normalMatrix;
14: uniform vec3 cameraPosition;
15: attribute vec3 position;
16: attribute vec3 normal;
17: attribute vec2 uv;
18: #ifdef USE_COLOR
19:     attribute vec3 color;
20: #endif
21: #ifdef USE_MORPHTARGETS
22:     attribute vec3 morphTarget0;
23:     attribute vec3 morphTarget1;
24:     attribute vec3 morphTarget2;
25:     attribute vec3 morphTarget3;
26:     #ifdef USE_MORPHNORMALS
27:         attribute vec3 morphNormal0;
28:         attribute vec3 morphNormal1;
29:         attribute vec3 morphNormal2;
30:         attribute vec3 morphNormal3;
31:     #else
32:         attribute vec3 morphTarget4;
33:         attribute vec3 morphTarget5;
34:         attribute vec3 morphTarget6;
35:         attribute vec3 morphTarget7;
36:     #endif
37: #endif
38: #ifdef USE_SKINNING
39:     attribute vec4 skinIndex;
40:     attribute vec4 skinWeight;
41: #endif
42: 
43: varying vec3 vWorldPosition;
44: uniform float outlineThickness;
45: vec4 calculateOutline( vec4 pos, vec3 objectNormal, vec4 skinned ) {
46:     float thickness = outlineThickness;
47:     float ratio = 1.0;
48:     vec4 pos2 = projectionMatrix * modelViewMatrix * vec4( skinned.xyz + objectNormal, 1.0 );
49:     vec4 norm = normalize( pos - pos2 );
50:     return pos + norm * thickness * pos.w * ratio;
51: }
52: void main() {
53: vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
54: vWorldPosition = worldPosition.xyz;
55: gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
56: #if ! defined( LAMBERT ) && ! defined( PHONG ) && ! defined( TOON ) && ! defined( PHYSICAL )
57:     #ifndef USE_ENVMAP
58:         vec3 objectNormal = normalize( normal );
59:         #ifdef FLIP_SIDED
60:             objectNormal = -objectNormal;
61:         #endif
62:     #endif
63: #endif
64: #ifdef USE_SKINNING
65:     gl_Position = calculateOutline( gl_Position, objectNormal, skinned );
66: #else
67:     gl_Position = calculateOutline( gl_Position, objectNormal, vec4( transformed, 1.0 ) );
68: #endif
69: }aframe-master.min.js:30:427THREE.WebGLProgram: shader error:  0 gl.VALIDATE_STATUS false gl.getProgramInfoLog Must have a compiled vertex shader attached. ERROR: 0:67: 'transformed' : undeclared identifier 
ERROR: 0:67: 'constructor' : not enough data provided for construction 
takahirox commented 7 years ago

Could I have an example page/code or something which shows this error?

imgntn commented 7 years ago

sure. yeah your example works but when i drop the library into my own page it gives me that error. it's not really mission critical i just wanted to try it out! thanks

https://github.com/imgntn/jBow/tree/outline

takahirox commented 7 years ago

It seems like a known issue of THREE.OutlineEffect used in aframe-outline that it won't work for some (Raw)ShaderMaterials. I found one RawShaderMaterial in your example.

I'll try to fix this THREE.OutlineEffect issue...

takahirox commented 7 years ago

The change to fix this issue has been merged into THREE.OutlineEffect.

https://github.com/mrdoob/three.js/pull/10498/files

Once npm three package including this change is released, I'll update aframe-outline.