Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Turbochist

Member Since 26 Oct 2013
Offline Last Active Nov 02 2014 08:49 AM

Posts I've Made

In Topic: Normal map artifact still here.

02 November 2014 - 02:38 AM

Good day to do something!

 

And I've found nice article: 

http://www.geeks3d.com/20130122/normal-mapping-without-precomputed-tangent-space-vectors/


In Topic: Normal map artifact still here.

01 November 2014 - 01:11 AM

I think this is as you said before interpolation thing...


In Topic: Normal map artifact still here.

01 November 2014 - 01:09 AM

And one last thing - provide the second picture in your OP post with magnification NEAREST and minification NEAREST (no filtering). It can happen that your object space normals texure resulution is way too small to spectate such an atomic space on the mesh (in other words, triangle covers few pixels of texture). This is very unlikely though! But this issue is interesting. From my own experience, I can spectate a nose peak of a character without any edges, when object space normals are used (not tangenting ones of course)

101153_1414825675_normals.jpg

 

 

normals2.jpg


In Topic: Normal map artifact still here.

31 October 2014 - 12:07 PM

The shader seems to work in the very exact way I suggested. To be honest now, I do not know why there is hard interpolation visible, but try using only diffuseLightWeighting in output color.

 

gl_FragColor = vec4(tColor.rgb * diffuseLightWeighting , 1.0);

 

And see wheather it shows triangles still

still here 


In Topic: Normal map artifact still here.

31 October 2014 - 10:19 AM

What is your normal texture format?

 

Cheers!

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.generateMipmap(gl.TEXTURE_2D);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.texParameterf(gl.TEXTURE_2D, gl.ext.TEXTURE_MAX_ANISOTROPY_EXT, 4);
 
 

 

So to be clear, you're using per pixel bilinear interpolation directly from the texture of the normals you baked, and each one of those vertexes is one and only one pixel, correct?

And the only thing you're using to calculate the lighting is that normal?

And you don't have redundant vertices in there, it's all one completely coherent mesh with only one vertex at each position?

 

Can you post a snippet of your code?

attribute vec3 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat4 uPMatrix;
uniform mat4 uMVMatrix;
uniform mat3 uNMatrix;

varying vec4 vPosition;
varying vec2 vTextureCoord;
varying mat3 v_NMatrix;

void main(void) {
    vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
    gl_Position = uPMatrix * vPosition;
    vTextureCoord = vec2(aTextureCoord.s, 1.0 - aTextureCoord.t);
    v_NMatrix = uNMatrix;
}
precision highp float;

varying vec4 vPosition;
varying vec2 vTextureCoord;

	
uniform sampler2D uSampler;
uniform sampler2D uNormalsMap;
 
#define MAX_POINT_LIGHTS 1

uniform int pointLightsQuantity;
uniform vec3 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];

varying mat3 v_NMatrix;

void main(void) {
    vec3 lightWeighting;
    vec3 lightDirection;
    vec3 normal;
    vec3 eyeDirection;
    vec3 reflectionDirection;
    float specularLightWeighting;
    float diffuseLightWeighting;

    lightDirection = normalize(pointLightsPositions[0] - vPosition.xyz);
    vec4 normalColor = texture2D( uNormalsMap, vTextureCoord.st );	
    vec4 nc = (normalColor - 0.5) * 2.0;
    normal = normalize(v_NMatrix*normalize(nc.xyz));
	
    eyeDirection = normalize(-vPosition.xyz);

    reflectionDirection = reflect(-lightDirection, normal);	

    specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
    diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
    lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + pointLightsParamsv[2] * specularLightWeighting;
    
    vec4 tColor = vec4(1.0);
        
    gl_FragColor = vec4(tColor.rgb * lightWeighting, 1.0);
}

 

 

I've made simple terrain normals into texture rendering function(without tanget and bitangent calculations). And picture had became good.

So you are using object space normals. With those you do not have this artifact, but if you interpolate light direction vector in pixel shader, you do.

It is a known problem of that direction vectors do not linearily interpolate good on a triangle (on edges only 2 verticies donate interpolation, what can issue in a too big jump if third interpolator was away from zero attribute). But position vectors interpolate good.  So if you will compute light vector in pixel function from interpolated object space position and object space light position, your artefact should dissappear.

 

 

Thanks! Good idea! Checking


PARTNERS