I try to make realistic water with offset texture shader but the result isn’t good.
How can i make a good offset texture to make realistic water( like the water seen in far-cry ) ?
This is the code i use to make the offset texture:
void CreateOffsetTexture ( GLuint texarray[], int textureID )
{
GLbyte OffsetData[8][8][2];
int x, y;
srand( GetTickCount() );
for ( x = 0; x < 8 - 1; x++ )
{
for ( y = 0; y < 8 - 1; y++ )
{
OffsetData[x][y][0] = rand()%( 256 );
OffsetData[x][y][1] = rand()%( 256 );
}
}
glGenTextures( 1, &texarray[textureID] );
glBindTexture( GL_TEXTURE_2D, texarray[textureID] );
glTexImage2D( GL_TEXTURE_2D, 0, GL_DSDT8_NV, 8, 8, 0, GL_DSDT_NV, GL_UNSIGNED_BYTE, OffsetData );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
}