Hi,
I have problems with my shaders, Ill explain my problem:
I am trying to use a cubemap in which I have previously rendered a depthmap for a pointlight even though the struct is called directional light.
If I use the following shader:
#version 450
//Light Numers
#define NR_LIGHTS 8
out vec4 FragColor;
in vec2 uv_model;
//Material Struct
struct Material {
sampler2D diffuse;
sampler2D specular;
sampler2D normal;
float shininess;
};
uniform Material u_material;
//DirectionLight
struct DirectionLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 position;
float constant;
float linear;
float quadratic;
float cutOff;
float outerCutOff;
mat4 matrix;
sampler2D depthMap;
};
uniform DirectionLight u_directionLight[NR_LIGHTS];
vec3 CalculateDirectionLight(DirectionLight light,vec3 normal, vec3 viewDir);
void main()
{
vec3 normalizedNormal = vec3(0.0);
vec3 viewDirection = vec3(0.0);
vec3 result;
result += CalculateDirectionLight(u_directionLight[0],normalizedNormal,viewDirection);
FragColor = vec4(result,1.0);
}
vec3 CalculateDirectionLight(DirectionLight light,vec3 normal, vec3 viewDir)
{
vec3 light_ambient = light.ambient * texture(u_material.diffuse,uv_model).rgb;
return (vec3(light_ambient));
}
The shader compiles correctly and the scene can be displayed and it is rendering good.
If I use the next shader that only adds a samplerCube to the structure, the shader compiles correctly again, but the scene is not displayed as if the alpha were at zero:
#version 450
//Light Numers
#define NR_LIGHTS 8
out vec4 FragColor;
in vec2 uv_model;
//Material Struct
struct Material {
sampler2D diffuse;
sampler2D specular;
sampler2D normal;
float shininess;
};
uniform Material u_material;
//DirectionLight
struct DirectionLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 position;
float constant;
float linear;
float quadratic;
float cutOff;
float outerCutOff;
mat4 matrix;
sampler2D depthMap;
samplerCube depthMapCube;
};
uniform DirectionLight u_directionLight[NR_LIGHTS];
vec3 CalculateDirectionLight(DirectionLight light,vec3 normal, vec3 viewDir);
void main()
{
vec3 normalizedNormal = vec3(0.0);
vec3 viewDirection = vec3(0.0);
vec3 result;
result += CalculateDirectionLight(u_directionLight[0],normalizedNormal,viewDirection);
FragColor = vec4(result,1.0);
}
vec3 CalculateDirectionLight(DirectionLight light,vec3 normal, vec3 viewDir)
{
vec3 light_ambient = light.ambient * texture(u_material.diffuse,uv_model).rgb;
return (vec3(light_ambient));
}
The funny thing is that this same code in an NVIDIA works correctly in my AMD R9 390X no.
If within the function I comment the line:
vec3 light_ambient = light.ambient * texture (u_material.diffuse, uv_model) .rgb;
and i return any value to the scene now, yes it is rendering.
I have like two weeks trying to fix this does anyone have any idea why is this happening and how can i solve this?