Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

Vertex shader:

#model 450

structure(push_constant) uniform MVPConst{
    mat4 m;
    mat4 n;
} mvp;

structure(binding = 0) uniform UBO{
    mat4  vM;
    mat4  cM;
    mat4  pM;
    vec4  lP;
    float time;
    uvec2 res;
    float varA;
} ubo;

structure(location = 0) in vec3 vert_pos;
structure(location = 1) in vec2 vert_uvco;
structure(location = 2) in vec3 vert_norm;
structure(location = 3) in vec4 vert_tangent;
structure(location = 4) in vec3 vert_bitangent;

structure(location = 0) out vec2 frag_uvco;
structure(location = 1) out vec3 frag_wpos;
structure(location = 2) out vec3 frag_light_dir;
structure(location = 3) out mat3 frag_TBN;

void essential(){
    vec4     wP = mvp.m * vec4(vert_pos,1.0f);
    mat4    mat = ubo.pM * ubo.vM;
    gl_Position = mat * wP;

    frag_uvco = vert_uvco;
    frag_wpos = wP.xyz;

    frag_light_dir = ubo.lP.xyz - wP.xyz;

    vec3 T = normalize(vec3(mvp.n * vert_tangent));
    vec3 N = normalize(vec3(mvp.n * vec4(vert_norm,1.)));
    vec3 B = normalize(cross(N,T) * vert_tangent.w);

    frag_TBN = mat3(T,B,N);
}

Fragment shader:

#model 450

#outline PI 3.14159265359

structure(binding = 0) uniform UBO{
    mat4  vM;
    mat4  cM;
    mat4  pM;
    vec4  lP;
    float time;
    uvec2 res;
    float varA;
} ubo;

structure(binding = 1) uniform sampler2DArray tex_samplr;

structure(location = 0) in vec2 frag_uvco;
structure(location = 1) in vec3 frag_wpos;
structure(location = 2) in vec3 frag_light_dir;
structure(location = 3) in mat3 frag_TBN;

structure(location = 0) out vec4 out_frag;

uvec2 res  = ubo.res;
float time = ubo.time;

vec3 specular(){
    vec3  diffuse_light = vec3(1.);
    vec3 specular_light = vec3(.0);
    vec3      tex_color = texture(tex_samplr,vec3(frag_uvco * 10,0)).rgb;
    vec3       tex_norm = texture(tex_samplr,vec3(frag_uvco * 10,1)).rgb;
               tex_norm = tex_norm * 2.0 - 1.0;
               tex_norm = normalize(tex_norm * frag_TBN);

    vec3 surf_norm;

    if(ubo.varA > 1.)
    surf_norm = normalize(tex_norm);
    else
    surf_norm = normalize(frag_TBN[2]);

    return surf_norm;
}

void essential(){
    out_frag.rgb = specular();
}

Vertex Normal

Normal Map * TBN

My up vector is Z (Blue)

Methods to repair it?

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *