Simplify Phytagoras in the wave shader(s)
pow() is expensive and abs() is redundand. pow(abs(x),2) equals x*x
This commit is contained in:
parent
6cc0f6c27c
commit
874a693e96
3 changed files with 4 additions and 4 deletions
|
@ -54,8 +54,8 @@ void relWind(out float rel_wind_speed_kts, out float rel_wind_from_rad)
|
|||
float rel_wind_speed_from_north_kts = WindN*fps2kts + speed_north_kts;
|
||||
|
||||
//combine relative speeds north and east to get relative windspeed in kts
|
||||
rel_wind_speed_kts = sqrt(pow(abs(rel_wind_speed_from_east_kts), 2)
|
||||
+ pow(abs(rel_wind_speed_from_north_kts), 2));
|
||||
rel_wind_speed_kts = sqrt(rel_wind_speed_from_east_kts*rel_wind_speed_from_east_kts
|
||||
+ rel_wind_speed_from_north_kts*rel_wind_speed_from_north_kts);
|
||||
|
||||
//calculate the relative wind direction
|
||||
float rel_wind_from_deg = degrees(atan(rel_wind_speed_from_east_kts, rel_wind_speed_from_north_kts));
|
||||
|
|
|
@ -72,7 +72,7 @@ void main(void)
|
|||
//bool Status = true;
|
||||
|
||||
|
||||
float windEffect = sqrt(pow(abs(WindE),2)+pow(abs(WindN),2)) * 0.6; //wind speed in kt
|
||||
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
||||
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
||||
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
||||
float waveRoughness = 0.05 + smoothstep(0.0, 20.0, windEffect); //wave roughness filter
|
||||
|
|
|
@ -143,7 +143,7 @@ void main(void)
|
|||
float cover = 0.0;
|
||||
//bool Status = true;
|
||||
|
||||
float windEffect = sqrt(pow(abs(WindE),2)+pow(abs(WindN),2)) * 0.6; //wind speed in kt
|
||||
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
||||
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
||||
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
||||
float waveRoughness = 0.01 + smoothstep(0.0, 40.0, windEffect); //wave roughness filter
|
||||
|
|
Loading…
Add table
Reference in a new issue