我需要得到类似的东西:
关闭
缩小
到目前为止,我有类似的内容:
最明显的问题是凹凸贴图......它的扁平,为什么会这样? "相关"代码(在我看来):
vec2 c = TileDensity * gl_TexCoord[0].st;
vec2 p = fract( c ) - vec2( 0.5 );
// Some useful eye-space vectors.
vec3 ecNNormal = normalize( ecNormal );
vec3 ecViewVec = -normalize( ecPosition );
vec3 N = ecNNormal;
vec3 B = normalize( cross( N, ecTangent ) );
vec3 T = cross( B, N );
vec3 tanPerturbedNormal; // The perturbed normal vector in tangent space of fragment.
vec3 ecPerturbedNormal; // The perturbed normal vector in eye space.
vec3 ecReflectVec; // The mirror reflection vector in eye space.
...
vec3 lightPos = vec3( gl_LightSource[0].position ) / gl_LightSource[0].position.w;
vec3 lightVec = normalize( lightPos - ecPosition );
vec3 halfVector = normalize( lightVec + ecViewVec );
...
if (fractionalPart.s < TubeRadius
|| fractionalPart.s > 1-TubeRadius
|| fractionalPart.t < TubeRadius
|| fractionalPart.t > 1-TubeRadius) {
vec3 i = normalize(ecPosition);
vec3 n = normalize(vec3(p.x, p.y, 1.0));
tanPerturbedNormal.x = dot(T, n);
tanPerturbedNormal.y = dot(B, n);
tanPerturbedNormal.z = dot(N, n);
ecPerturbedNormal = n;
vec3 tanLightPos;
tanLightPos.x = dot(T, lightPos); // LightDir?
tanLightPos.y = dot(B, lightPos);
tanLightPos.z = dot(N, lightPos);
tanLightPos = normalize(tanLightPos);
ecReflectVec = reflect(-tanLightPos, tanPerturbedNormal);
float Ratio = F + (1.0 - F) * pow((1.0 - dot(-i, n)), FresnelPower);
vec3 reflectColor = vec3(textureCube(EnvMap, ecReflectVec));
gl_FragColor = vec4(reflectColor, 1.0);
}