Skip to content

Instantly share code, notes, and snippets.

@dnevera
Created May 19, 2018 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnevera/1182d4287cd0829f6ed905e126bfd7f2 to your computer and use it in GitHub Desktop.
Save dnevera/1182d4287cd0829f6ed905e126bfd7f2 to your computer and use it in GitHub Desktop.
///
/// Расчитываем средний цвет области текстуры
///
inline float3 avrgColor(int startx, // начало области по x
int endx, // конец области по x
int starty, // начало по y
int endy, // конец y
uint2 gid, // индекс семпла
texture2d<float> source // текстура
){
float3 color(0);
float3 c(0);
for(int i = startx; i<endx; i++ ){
for(int j = starty; j<endy; j++ ){
uint2 gid2 = uint2(int2(gid)+int2(i,j));
float3 s = source.read(gid2).rgb;
color += s;
c+=float3(1);
}
}
return color/c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment