Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

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 sienaiwun   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.