Jump to content

  • Log In with Google      Sign In   
  • Create Account

GPU Gems Chapter 8. "Simulating Diffraction"'s understanding


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1   Members   

141
Like
0Likes
Like

Posted 10 June 2012 - 08:48 AM

Hi:
All.
I do not quite understand diffraction's code in GPU Gems Chapter 8.http://http.develope...ugems_ch08.html.

float3 P = mul(ModelViewMatrix, position).xyz;
float3 L = normalize(lightPosition - P);
float3 V = normalize(eyePosition - P);
float3 H = L + V;
float3 N = mul((float3x3)ModelViewMatrixIT, normal);
float3 T = mul((float3x3)ModelViewMatrixIT, tangent);


//from here on,I do not quite understand the parameter u,w,e c. Can you give me some corresponding concept in the equation
Posted Image.

float u = dot(T, H) * d;
float w = dot(N, H);
float e = r * u / w;
float c = exp(-e * e);
float4 anis = hiliteColor * float4(c.x, c.y, c.z, 1);

if (u < 0) u = -u;

float4 cdiff = float4(0, 0, 0, 1);
for (int n = 1; n < 8; n++)
{
float y = 2 * u / n - 1;
cdiff.xyz += blend3(float3(4 * (y - 0.75), 4 * (y - 0.5),
4 * (y - 0.25)));
}

And also I do not understand the meaning of the for loop.

Edited by sienaiwun, 10 June 2012 - 08:49 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.