Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualChris_F

Posted 12 February 2013 - 08:05 PM

I'm trying to implement an anisotropic version of GGX in UDK. Here is what the shader looks like:

 

 

float3 H = normalize(L + V);
float NdotL = saturate(dot(N, L));
float NdotV = dot(N, V);
float NdotH = dot(N, H);
float LdotH = dot(L, H);
float HdotX = dot(H, X);
float HdotY = dot(H, Y);

float NdotH_2 = NdotH * NdotH;
float HdotX_2 = HdotX * HdotX;
float HdotY_2 = HdotY * HdotY;
float ax_2 = ax * ax;
float ay_2 = ay * ay;

float GGX = (ax * ay * pow(HdotX_2 / ax_2 + HdotY_2 / ay_2 + NdotH_2, 2.0));

float3 F = Ks + (1.0 - Ks) * exp(-6 * LdotH);

float3 Rs = F / (4 * GGX * LdotH * LdotH);
float3 Rd = Kd * (1 - Ks);

return (Rs + Rd) * NdotL;

 

The problem is I'm not sure what to use for vectors X and Y. Because this is UDK, vectors L and V are relative to the surface (tangent space), so would I simply use X = [1, 0, 0], Y = [0, 1, 0]?


#1Chris_F

Posted 12 February 2013 - 08:04 PM

I'm trying to implement an anisotropic version of GGX in UDK. Here is what the shader looks like:

 

float3 H = normalize(L + V);
float NdotL = saturate(dot(N, L));
float NdotV = dot(N, V);
float NdotH = dot(N, H);
float LdotH = dot(V, H);
float HdotX = dot(H, X);
float HdotY = dot(H, Y);

float NdotH_2 = NdotH * NdotH;
float HdotX_2 = HdotX * HdotX;
float HdotY_2 = HdotY * HdotY;
float ax_2 = ax * ax;
float ay_2 = ay * ay;

float GGX = (ax * ay * pow(HdotX_2 / ax_2 + HdotY_2 / ay_2 + NdotH_2, 2.0));

float3 F = Ks + (1.0 - Ks) * exp(-6 * LdotH);

float3 Rs = F / (4 * GGX * LdotH * LdotH);
float3 Rd = Kd * (1 - Ks);

return (Rs + Rd) * NdotL;

 

The problem is I'm not sure what to use for vectors X and Y. Because this is UDK, vectors L and V are relative to the surface (tangent space), so would I simply use X = [1, 0, 0], Y = [0, 1, 0]?


PARTNERS