Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 2170 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

float3[color=#000000]

P = mul[color=#000000]

(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
126equ02.jpg.

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!