1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
kgv 633084b809 0032862: Visualization, Graphic3d_TextureMap - add 3D texture definition
Image_PixMap has been extended to support definition of 3D bitmap (as an array of 2D slices).

Graphic3d_TypeOfTexture enumeration values have been renamed to include full enum prefix.
Added Graphic3d_TypeOfTexture_3D redirecting to GL_TEXTURE_3D.
OpenGl_Texture::Init() has been extended to allow initialization of 3D texture.

Graphic3d_Texture2Dmanual merged into Graphic3d_Texture2D and marked as deprecated alias.
Graphic3d_TOT_2D_MIPMAP has been deprecated in favor of dedicated Graphic3d_TextureRoot::SetMipMaps().

Added Graphic3d_Texture3D class.
vtexture - added argument -3d for uploading 3D texture.
2022-03-05 17:31:39 +03:00

61 lines
1.7 KiB
Plaintext

puts "========"
puts "0032862: Visualization, Graphic3d_TextureMap - add 3D texture definition"
puts "========"
pload MODELING VISUALIZATION
set aTex1 [locate_data_file SF_CubeMap_posx.jpg]
set aTex2 [locate_data_file SF_CubeMap_negx.jpg]
set aTex3 [locate_data_file SF_CubeMap_posy.jpg]
set aTex4 [locate_data_file SF_CubeMap_negy.jpg]
set aTex5 [locate_data_file SF_CubeMap_posz.jpg]
set aTex6 [locate_data_file SF_CubeMap_negz.jpg]
set aShaderVert "
THE_SHADER_OUT vec3 TexCoord;
uniform float uSlice;
void main() {
float aNbSlices = 6.0;
TexCoord = occVertex.xyz;
if (uSlice >= 0.0) { TexCoord = vec3(occTexCoord.xy, uSlice * 1.0 / aNbSlices + 0.5 / aNbSlices); }
if (occTextureTrsf_Scale().y < 0.0) { TexCoord.y = 1.0 - TexCoord.y; }
gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;
}"
set aShaderFrag "
#ifdef GL_ES
uniform mediump sampler3D occSampler0;
#else
uniform sampler3D occSampler0;
#endif
THE_SHADER_IN vec3 TexCoord;
void main() {
occFragColor = occTexture3D(occSampler0, TexCoord);
}"
set aGlslVer "#version 110"
if { [vdriver -default] == "TKOpenGles" } { set aGlslVer "#version 300 es" }
# draw a box
box b 1.0 1.0 1.0
vclear
vclose ALL
vinit View1
vaxo
vdisplay -dispMode 1 b
vfit
vrotate 0.2 0.0 0.0
# load 3D texture
vtexture b -3d $aTex1 $aTex2 $aTex3 $aTex4 $aTex5 $aTex6
# texture slices
foreach aSliceIter {0 1 2 3 4 5} {
vshaderprog b -vert $aShaderVert -frag $aShaderFrag -defaultSampler 0 -uniform "uSlice" ${aSliceIter} -header "$aGlslVer"
vdump $::imagedir/${::casename}_s${aSliceIter}.png
}
# texture interpolation
vshaderprog b -vert $aShaderVert -frag $aShaderFrag -defaultSampler 0 -uniform "uSlice" -1 -header "$aGlslVer"
vdump $::imagedir/${::casename}_def.png