Advertisement

Weird visual glitch with custom Cook-Torrance shader

Started by August 02, 2017 08:06 AM
1 comment, last by Hodgman 7 years, 6 months ago

I already have a forum post in Unity's forum that contains most of the details and code regarding the problem I'm having so look at that one first.

So basically, I'm trying to write my own custom Cook-Torrance shader in Unity using Cg language. When I finished writing it up, the result shows a weird split halfway down the sphere where the first half looks correct and the second half being completely black. I don't know what's causing this weird visual glitch so I'm posting this here in case someone knows an answer.

I'm using Trowbridge-Reitz for Distribution, Schlick-GGX for Geometric and Schlick approximation for Fresnel.

You can see the result in the image below. The one after the image below is an image I found in this site that shows what I expected Cook-Torrance to look like.

Cook-Torrance.png

Specular.png

You don't seem be multiplying the result by dot(n,l) at all.

N dot L isn't part of the diffuse or specular BRDF - it's part of the rendering equation itself (projection of a light ray onto an area of the surface) so must be done outside of every possible BRDF.

This topic is closed to new replies.

Advertisement