September 2018
Intermediate to advanced
472 pages
15h 36m
English
To modify the shadow mapping algorithm and to use this random sampling technique, perform the following steps. We'll build the offset texture within the main OpenGL program, and make use of it within the fragment shader:
void buildOffsetTex(int size, int samplesU, int samplesV) { int samples = samplesU * samplesV; int bufSize = size * size * samples * 2; float *data = new float[bufSize]; for( int i = 0; i< size; i++ ) { for(int j = 0; j < size; j++ ) { for( int k = 0; k < samples; k += 2 ) { int x1,y1,x2,y2; x1 = k % (samplesU); y1 = (samples - 1 - k) / samplesU; x2 ...Read now
Unlock full access