Loading...
  OR  Zero-K Name:    Password:   

Post edit history

New rocket plume rendering model - Xmas came early in 2022

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
10/5/2022 2:14:48 AMPLrankrookstoo before revert after revert
10/4/2022 11:22:59 PMPLrankrookstoo before revert after revert
Before After
1 I was like thinking(tm), and it came to me this. All rockets make exhaust, and its a lot of cpu thinking on how to make it look pwety, and it still sucks. It looks 2003. So i was like thinking. Lets GPU handle rockets and smoke. And before youll jump to navier stokes and such, what if each physics frame we would draw new lines where smoke is made from last physics frame, and then blur and swirl them per each physics frame. I would see it as this: 1 I was like thinking(tm), and it came to me this. All rockets make exhaust, and its a lot of cpu thinking on how to make it look pwety, and it still sucks. It looks 2003. So i was like thinking. Lets GPU handle rockets and smoke. And before youll jump to navier stokes and such, what if each physics frame we would draw new lines where smoke is made from last physics frame, and then blur and swirl them per each physics frame. I would see it as this:
2 \n 2 \n
3 After frame is rendered and smoke bitmap is rendered. 3 After frame is rendered and smoke bitmap is rendered.
4 \n 4 \n
5 Smoke bitmap contains UV velocity data per pixel and pressure, and pixel color. 5 Smoke bitmap contains UV velocity data per pixel and pressure, and pixel color.
6 color[] float3 6 { { { color[] float3
7 UVvel[] float3 7 UVvel[] float3} } }
8 \n 8 \n
9 there is a tillable noise texture made in blender with lots of swirls(distortion option), 9 there is a tillable noise texture made in blender with lots of swirls(distortion option),
10 and theres a normal map made out of it for bump. 10 and theres a normal map made out of it for bump.
11 \n 11 \n
12 swirls[] float3 12 { { { swirls[] float3} } }
13 \n 13 \n
14 The pitch consists of the main two buffers are sized third of monitor resolution, and it spans 3x the draw area. 14 The pitch consists of the main two buffers are sized third of monitor resolution, and it spans 3x the draw area.
15 ( so effectively its same sized as screen, but main is viewable in middle square of 3x3. 15 ( so effectively its same sized as screen, but main is viewable in middle square of 3x3.
16 \n 16 \n
17 Once the smoke happens from previous location, the line is drawn on UVvel, with UV velocity of 0 and pressure of set pressure, using width of line as needed per camera zoom, so its simple glline on texture using (u,v,pressure) as colors, with UV set as opposite of where the rocket is headed 17 Once the smoke happens from previous location, the line is drawn on UVvel, with UV velocity of 0 and pressure of set pressure, using width of line as needed per camera zoom, so its simple glline on texture using (u,v,pressure) as colors, with UV set as opposite of where the rocket is headed
18 \n 18 \n
19 Smoke is calculated per physics frame. 19 Smoke is calculated per physics frame.
20 \n 20 \n
21 - theres application of swirls. 21 - theres application of swirls.
22 swirlpos = mix ( UVvel[]. uv ; throw ( UVvel[]. uv at direction of swirls[]. yx with same lenght) ; using pressure ) 22 { { { swirlpos = mix ( UVvel[]. uv ; throw ( UVvel[]. uv at direction of swirls[]. yx with same lenght) ; using pressure )
23 swirled_UVvel[] = UVvel[ pos + swirlpos ] 23 swirled_UVvel[] = UVvel[ pos + swirlpos ]
24 swirled_color[] = color[ pos + swirlpos ] 24 swirled_color[] = color[ pos + swirlpos ]} } }
25 25
26 less pressure, more swirl aligned it becomes. same for color[] 26 less pressure, more swirl aligned it becomes. same for color[]
27 yes, yx so its perpendicular to bump slope 27 yes, yx so its perpendicular to bump slope
28 what happens here is we use existing swirls in the swirl texture 28 what happens here is we use existing swirls in the swirl texture
29 and throw the speed vector at perpendicular to slope of the swirl from bumpmap. 29 and throw the speed vector at perpendicular to slope of the swirl from bumpmap.
30 \n 30 \n
31 - blur_UVvel[], blur_color[], vector3 is made (half the size of the pitch) 31 - blur_UVvel[], blur_color[], vector3 is made (half the size of the pitch)
32 using gpu default blurring for mipmaps so its quick af. 32 using gpu default blurring for mipmaps so its quick af.
33 \n 33 \n
34 additionally there need to be adjustments to uv depending on pressure 34 additionally there need to be adjustments to uv depending on pressure
35 \n 35 \n
36 posN = pos+[ 0, 1]*epsylon; xN = blur_UVvel[ posN ] 36 { { { posN = pos+[ 0, 1]*epsylon; xN = blur_UVvel[ posN ]
37 posS = pos+[ 0,-1]*epsylon; xS = blur_UVvel[ posS ] 37 posS = pos+[ 0,-1]*epsylon; xS = blur_UVvel[ posS ]
38 posW = pos+[ 1, 0]*epsylon; xW = blur_UVvel[ posW ] 38 posW = pos+[ 1, 0]*epsylon; xW = blur_UVvel[ posW ]
39 posE = pos+[-1, 0]*epsylon; xE = blur_UVvel[ posE ] 39 posE = pos+[-1, 0]*epsylon; xE = blur_UVvel[ posE ]
40 \n 40 \n
41 pressures = ( posN*(1+xN.pressure) + posS*(1+xS.pressure) + posW*(1+xW.pressure) + posE*(1+xE.pressure) ) 41 pressures = ( posN*(1+xN.pressure) + posS*(1+xS.pressure) + posW*(1+xW.pressure) + posE*(1+xE.pressure) )
42 42
43 blur_UVvel[].uv = mix ( 43 blur_UVvel[].uv = mix (
44 blur_UVvel[].uv ; 44 blur_UVvel[].uv ;
45 pressures / ( xN.pressure + xS.pressure + xW.pressure + xE.pressure + 4) ; 45 pressures / ( xN.pressure + xS.pressure + xW.pressure + xE.pressure + 4) ;
46 blur_UVvel[]. pressure ) 46 blur_UVvel[]. pressure ) } } }
47 \n 47 \n
48 so it alters the direction, basing on the where the pressure is highest, 48 so it alters the direction, basing on the where the pressure is highest,
49 using pressure to figure out how strong the alteration is need to be made. 49 using pressure to figure out how strong the alteration is need to be made.
50 +4 because to avoid div/0 50 +4 because to avoid div/0
51 \n 51 \n
52 - next is calculated using: 52 - next is calculated using:
53 mixer = swirled_UVvel[ swirled_UVVel[]. uv ]. pressure + entropy 53 { { { mixer = swirled_UVvel[ swirled_UVVel[]. uv ]. pressure + entropy
54 UVvel[] = mix( swirled_UVvel[] ; blur_UVvel[] ; mixer ) 54 UVvel[] = mix( swirled_UVvel[] ; blur_UVvel[] ; mixer )
55 color[] = mix( swirled_color[] ; blur_color[] ; mixer ) 55 color[] = mix( swirled_color[] ; blur_color[] ; mixer ) } } }
56 \n 56 \n
57 - and viewport adjustments for perspective and moving it around, so UVvel and color move and scale using simple scale and transform. 57 - and viewport adjustments for perspective and moving it around, so UVvel and color move and scale using simple scale and transform.
58 \n 58 \n
59 higher pressure, the more towards blur it goes. 59 higher pressure, the more towards blur it goes.
60 entropy is constant to keep it going toward blur if there is no pressure, or uv next to a freshly drawn line. 60 entropy is constant to keep it going toward blur if there is no pressure, or uv next to a freshly drawn line.
61 thats why its needed to be done at physics frame 61 thats why its needed to be done at physics frame
62 \n 62 \n
63 so yeah. its not navier stokes, but. it does its job, at cost of 5 texture lookups and 2x mipmaped blured textures. 63 so yeah. its not navier stokes, but. it does its job, at cost of 5 texture lookups and 2x mipmaped blured textures.
64 \n 64 \n
65 as a bonus, you can add pressure eminating points with no color modifications where units are standing per each frame of physics, so you would have the effect of units walking through smoke. and smoke swirling around them. 65 as a bonus, you can add pressure eminating points with no color modifications where units are standing per each frame of physics, so you would have the effect of units walking through smoke. and smoke swirling around them.
66 \n 66 \n
67 and you can also use maps wind direction 67 and you can also use maps wind direction
68 \n 68 \n
69 so, at the end you have a smoke texture, that doesnt need constant calculations of ugly 3d lines, but it creates constant smoke effect that accumulates and swirls and dissipates 69 so, at the end you have a smoke texture, that doesnt need constant calculations of ugly 3d lines, but it creates constant smoke effect that accumulates and swirls and dissipates
70 \n 70 \n
71 prolly some improvements need to be done like if blurred UVvel to 1/16 of UVvel shows no action then drop whole procedure in quadrant, but still it might be cool smoke 71 prolly some improvements need to be done like if blurred UVvel to 1/16 of UVvel shows no action then drop whole procedure in quadrant, but still it might be cool smoke
72 \n 72 \n
73 :) 73 :)
74 \n 74 \n
75 i would so code it self but have other stuff to do rn. 75 i would so code it self but have other stuff to do rn.
76 \n 76 \n