I am trying to apply a random texture with a number on it based on the tile input. My efforts thus far cause patterns to emerge in the number selected.
My method for going about it has been multiplying each tile value by a random scalar and then either multiplying or adding them together. Call the operations I do to each tile "salt".
Example:
float seed = fract(fract((tile.x+23.42f)*189.28148f) + (tile.y*92001.302+1.235801f));
When I add the two "salted" tile values together a pattern emerges. The numbers are the same along the diagonal.
When I multipy the two "salted" tile values together the numbers are mirrored along the diagonal.
I want a little more randomness out of these tile values, can someone decent at math help?
Shader code segment:
vec2 tile = vec2(floor(texCoord_vs.x), floor(texCoord_vs.y));
float seed = fract(fract((tile.x+23.42f)*189.28148f) + (tile.y*92001.302+1.235801f));
vec2 offset = offset_vs;
offset.x += floor(seed*7.0f)*TYPE_UNIT_SIZE;
vec3 diffuseColor = materialDiffuseColor * texture(
typesheet, vec2((texCoord_vs.x - tile.x)*TYPE_UNIT_SIZE,
(texCoord_vs.y - tile.y)*TYPE_UNIT_SIZE) + offset);