Skip to content

Glossy and Diffuse Shaders (How to?) #246

Answered by pragma37
adamwparker asked this question in Q&A
Discussion options

You must be logged in to vote

I'd like to provide at least basic PBR support, but I haven't got into it yet.

Here are some quickly put together hdri helper functions. (Just keep in mind this is completely wrong from a phsyical standpoint):

/*  META
    @normal: default=NORMAL;
*/
vec3 random_normal_offset(vec3 normal, float angle, float seed)
{
    vec3 random_vec = random_per_pixel(seed).xyz;
    random_vec.xyz = random_vec.xyz * 2.0 - 1.0;

    vec3 tangent = normalize(random_vec - normal * dot(random_vec, normal));
    vec3 bitangent = cross(normal, tangent);
    mat3 TBN = mat3(tangent, bitangent, normal);

    angle = random_per_pixel(seed).w * angle;
    return TBN * vec3(0, sin(angle), cos(angle));
}

/*  META

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@adamwparker
Comment options

@Psi25
Comment options

@Psi25
Comment options

@Psi25
Comment options

Answer selected by adamwparker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants