DEMO.DESIGN
Frequently Asked Questions
 
оглавление | demo party в ex-СССР | infused bytes e-mag | новости от ib/news | другие проекты | письмо | win koi lat

следующий фpагмент (2)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 45 of 121 From : pochanay@cae.wisc.edu 2:5030/144.99 21 May 94 20:14:42 To : All 27 May 94 00:29:58 Subj : Cloud generating algorithms -------------------------------------------------------------------------------- I am looking for an algorithm to create realistic clouds for the background of a 3-d virtual world. The current method I am using is this: Treat each cloud as a collection of particles. Beginning with a seed particle on an x,y plane of a certain "priority" recursively send out several other seed particles with slight variations in x and y and brightness and priority-=1 until priority=0. Do this randomly for X = number of clouds. Then set this 2-d plane at a "perspective" angle in the sky (simple foreshortening transform). Final step = smooth the data to "fluff" the clouds. This creates very nice looking clouds when on the 2-d scape but when I do the 2-d -> perspective conversion it ends up looking like a "flat" plane. That is, the clouds still look nice but they look 2-d and tiltted back. adisak PS. If you post replies please send e-mail too. I don't read this group often. I will post a summary of helpfule replies and algorithms crediting anyone who helped when I fix this ;)
следующий фpагмент (3)|пpедыдущий фpагмент (1)
I need the formula for the color of a cloudy sky for a ray tracer. For now, a simple mapping from a point on a sphere (which represents the sky) to a color would be great. I got the following snippet of renderman code, but I'm writing my code in plain old C, and don't know what the "noise" function does exactly: ------------------------------------------------------------------------ /* Use signed Perlin noise */ #define snoise(x) ((2*noise(x))-1) surface puffyclouds (float Ka = 0, Kd = 0; float txtscale = 1; color skycolor = color(.15, .15, .6); color cloudcolor = color(1,1,1); float octaves = 8, omega = 0.5, lambda = 2; float threshold = 0; ) { float value; color Ct; /* Color of the surface */ point PP; /* Surface point in shader space */ float i, a, l, o; PP = txtscale * transform ("shader", P); /* Use fractional Brownian motion to compute a value for this point */ /* value = fBm (PP, omega, lambda, octaves); */ value = 0; l = 1; o = 1; a = 0; for (i = 0; i < octaves; i += 1) { a += o * snoise (PP*l); l *= 2; o *= omega; } value = a; Ct = mix (skycolor, cloudcolor, smoothstep (threshold, 1, value)); } ------ Can anyone shed some light on this code and explain what's going on? It looks like we're mapping a point 'P' to a value 'a', which value determines where along the line between blue and white 'P' should be. 'snoise()' is #define'd above, but what is the definition of 'noise(PP*l)'? Is it white noise using the point as a seed, or is it a gaussian displacement using the point as both a seed and the center? Or is it something else? Does anyone have the equation or algorithm for noise()? --------------- p.s. In case it helps, the entire RenderMan code is listed below: /* * puffyclouds.sl -- RenderMan compatible surface shader for puffy * clouds. * * DESCRIPTION: * Makes nice looking cumulous clouds like you would see in the sky * on a bright sunny day. Works as a basic thresholded fBm. Since * this texture is generally used as a backdrop, it does not take * lighting into account. If you wanted a lit surface that looked like * puffy clouds (like painted clouds on a wall), then it would be pretty * easy to add the lighting. * * PARAMETERS: * txtscale - overall scaling factor * skycolor, cloudcolor - the obvious meanings * octaves, omega, lambda - control the fractal appearance of the clouds * threshold - fBm sum below this level is just blue sky * * ANTIALIASING: * None, but should be easy to add antialiasing simply by adaptively * setting the "octaves" parameter based on distance from eye point. * * AUTHOR: * C language version by F. Kenton Musgrave * Translation to RenderMan Shading Language by Larry Gritz. * * REFERENCES: * _Texturing and Modeling: A Procedural Approach_, by David S. Ebert, ed., * F. Kenton Musgrave, Darwyn Peachey, Ken Perlin, and Steven Worley. * Academic Press, 1994. ISBN 0-12-228760-6. * * HISTORY: * ??? - original C language version by Ken Musgrave * Apr 94 - translation to Shading Language by L. Gritz * * this file last updated 18 Apr 1994 */ /* Use signed Perlin noise */ #define snoise(x) ((2*noise(x))-1) surface puffyclouds (float Ka = 0, Kd = 0; float txtscale = 1; color skycolor = color(.15, .15, .6); color cloudcolor = color(1,1,1); float octaves = 8, omega = 0.5, lambda = 2; float threshold = 0; ) { float value; color Ct; /* Color of the surface */ point PP; /* Surface point in shader space */ float i, a, l, o; PP = txtscale * transform ("shader", P); /* Use fractional Brownian motion to compute a value for this point */ /* value = fBm (PP, omega, lambda, octaves); */ value = 0; l = 1; o = 1; a = 0; for (i = 0; i < octaves; i += 1) { a += o * snoise (PP*l); l *= 2; o *= omega; } value = a; Ct = mix (skycolor, cloudcolor, smoothstep (threshold, 1, value)); /* Shade like matte, but use color Ct */ Oi = 1; /* Make it opaque */ Ci = Ct; /* This makes the color disregard the lighting */ /* Uncomment the next line if you want the surface to actually be lit */ /* Ci = Ct * (Ka * ambient() + Kd * diffuse(faceforward(N,I))); */ }

Всего 2 фpагмент(а/ов) |пpедыдущий фpагмент (2)

Если вы хотите дополнить FAQ - пожалуйста пишите.

design/collection/some content by Frog,
DEMO DESIGN FAQ (C) Realm Of Illusion 1994-2000,
При перепечатке материалов этой страницы пожалуйста ссылайтесь на источник: "DEMO.DESIGN FAQ, http://www.enlight.ru/demo/faq".