I’m trying to implement matcap shader from this reference clicktorelease.com/blog/crea … ing-shader
I copied and modified litSolid shader and changed the cubemap, so it map to the sphere on emissive texture( because env unit is cube). Here is modification of fragment shader:
#ifdef ENVCUBEMAP
vec3 r =reflect(vReflectionVec, normal);
float m = 2. * sqrt( pow( r.x, 2. ) + pow( r.y, 2. ) + pow( r.z + 1., 2. ) );
vec2 vN = r.xy / m + .5;
finalColor += cMatEnvMapColor * texture2D( sEmissiveMap, vN ).rgb;
#endif
I got some nice results but it isn’t still what it should be - the matcap’s reflections are distorted. I suppose this is this because
vReflectionVec = worldPos-cCameraPos;
isn’t equivalent to
e = normalize( vec3( modelViewMatrix * vec4( position, 1.0 ) ) );
in Urho’s shader defines I can see cViewProj and cModel matrixes, but how can I get modelViewMatrix?