Last active
December 31, 2015 00:59
-
-
Save eddietree/7910870 to your computer and use it in GitHub Desktop.
pseudocode for cloud shader. if you are billboarding the cloud quad, basically takes the direction the cloud is facing and changes the amount sampled per RGB channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// passed in variables | |
float3 billboard_normal; // defined - (where billboard is facing), [-1,1] range | |
float2 uv; // defined - the UV of the quad [0,1] range | |
float time; // defined - passed in | |
texsampler tex_cloud_0; // cloud tex, each channel in RGB stores different monochrome texture | |
texsampler tex_cloud_1; | |
// normalize to [0,1] range | |
float3 billboard_normal_normalized = billboard_normal * 0.5f + float3(0.5f); | |
// sample from the texture | |
// (you can do things like animating the uv slowly) | |
float4 tex_sample_0 = tex2D( tex_cloud_0, uv ); | |
float4 tex_sample_1 = tex2D( tex_cloud_1, uv ); | |
// this part basically uses the normal and weights each channel | |
float cloud_val_0 = dot( tex_sample_0, billboard_normal_normalized ) / 3.0f; | |
float cloud_val_1 = dot( tex_sample_1, billboard_normal_normalized ) / 3.0f; | |
float cloud_val_final = lerp( cloud_val_0, cloud_val_1, sin(time)*0.5+0.5 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
basically, store a different cloud texture in each of the three RGB channels!