c# - OPENGL how to use glTexImage3D function -


the following code used draw ocean, tried convert c# code, failed because didn't understand 3d functions do, want explanation on these functions (3d texture mean)...

int res = 64; int nr = res / 2; int nv = res * 2; int nb = res / 2; int na = 8; f = fopen("e:\\new folder\\consoleapplication1\\debug\\data\\inscatter.raw", "rb"); data = new float[nr*nv*nb*na*4]; fread(data, 1, nr*nv*nb*na*4*sizeof(float), f); fclose(f); glactivetexture(gl_texture0 + inscatter_unit); glgentextures(1, &inscattertex); glbindtexture(gl_texture_3d, inscattertex); gltexparameteri(gl_texture_3d, gl_texture_min_filter, gl_linear); gltexparameteri(gl_texture_3d, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_3d, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_3d, gl_texture_wrap_t, gl_clamp_to_edge); gltexparameteri(gl_texture_3d, gl_texture_wrap_r, gl_clamp_to_edge); glbindbuffer(gl_pixel_unpack_buffer_arb, 0); glteximage3d(gl_texture_3d, 0, gl_rgba16f_arb, na*nb, nv, nr, 0, gl_rgba, gl_float, data); delete[] data; 

3d textures volumetric images, i.e. they're sort of cuboid filled voxels of color. instead of picture of width × height · color_channels have picture of width × height × depth · color_channels.

this animation showing volumetric image (courtsey of research working group i'm member of): http://www.bmo.physik.uni-muenchen.de/~z19/octanimation.gif (unfortunately stackoverflow doesn't allow linking of animated gifs).

i saw sb. else ocean rendering in post. advised hugely nontrivial subject requiring sophisticated algorithms. use of 3d texture called "inscatter" suggests whatever code you've looked implements 1 of complex models, 3d texture used scattering term lookup table.

note without solid understanding of opengl , numerical methods implementing ocean renderer impossible perform task. i'd start understanding basics first.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -