PDA

View Full Version : Canīt view shadows in amd hardware



aguuzr
06-19-2016, 04:12 PM
Hi! iīm a student and iīm working with opengl and glsl.
I have problems with shadow mapping. In pcīs with AMD hardware canīt see them.
here is the fragment shader of my program.. it works with INTEL and NVidia..
any ideas????

Fragment Shader:


in vec3 vLE;
in vec3 vV;
in vec3 vN;

in vec2 fragTexCoor;

uniform vec4 ka;
uniform vec4 kd;
uniform vec4 ks;

uniform float CoefEsp;

uniform sampler2D uTextureSampler;

uniform struct Light {
vec4 position;
vec3 intensity;
} luz;

// --- SHADOW MAPPING ---
// Sampler del shadow map.
uniform sampler2D uShadowSampler;

in vec4 fragPosLightSpace; //shadow coord

out vec4 fColor;


float ShadowCalculation(vec4 fragPosLightSpace)
{
vec3 lightDir = normalize(luz.position.xyz - fragPosLightSpace.xyz);

float bias = max(0.05 * (1.0 - dot(vN, lightDir)), 0.005);

float shadowDepth = texture(uShadowSampler, vec2(fragPosLightSpace)).r;

float fragDepth = fragPosLightSpace.z;



if (fragDepth > 1.0)
return 1.0;

if ((fragDepth - bias)<=shadowDepth)
return 1.0f;
else
return 0.0f;

}


void main()
{

vec4 colorTex = texture2D(uTextureSampler, fragTexCoor);

float dist = length(vLE);
float fatt = 1 / (0.3 + 0.007 * dist + 0.000008 * dist * dist);

vec3 L = normalize(vLE);
vec3 V = normalize(vV);
vec3 N = normalize(vN);
vec3 R = normalize(-reflect(L,N));

float dif = max(dot(L,N), 0.0);
float specPhong = pow(max(dot(R, V), 0.0), CoefEsp);

if (dot(L,N) < 0.0) {
specPhong = 0.0;
}

vec4 ambiente = ka;
vec4 difuso = kd * dif * colorTex;
vec4 especular = ks * specPhong;

float visibility = ShadowCalculation(fragPosLightSpace);

fColor = vec4(luz.intensity, 1.0) * fatt * (ambiente + visibility * (especular + difuso));

}

Spoops
06-20-2016, 12:58 PM
I know that Nvidia drivers are permissive and allow things to be rendered on screen even if there was an OpenGL error, but it could be the case with Intel too. Check with APItrace or glIntercept to know if your code does generate errors.