# How to: Apply texture to each face of a shell (HPS)

**URL:** https://forum.techsoft3d.com/t/how-to-apply-texture-to-each-face-of-a-shell-hps/5187
**Category:** Visualization Solutions
**Tags:** how-to, code, knowledge-base, sample
**Created:** [July 17, 2026, 11:35pm UTC](https://forum.techsoft3d.com/t/how-to-apply-texture-to-each-face-of-a-shell-hps/5187 "2026-07-17T23:35:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.techsoft3d.com/u/simon)
#### Post date: [July 17, 2026, 11:35pm UTC](https://forum.techsoft3d.com/t/how-to-apply-texture-to-each-face-of-a-shell-hps/5187/1 "2026-07-17T23:35:31Z")

</div>

Following sample code apply texture to separate faces of a shell.  
You can copy/paste sample to hps\_mfc\_sandbox.

Screenshot:

 ![2026-07-17_16-10-05](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/2X/b/bd3db23616597a0b26b3f71e18477eb2817a8204.png)

Sample Code:

```auto
    SegmentKey modelKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey();
	PortfolioKey portfolio = GetCanvas().GetFrontView().GetPortfolioKey();

    // Import Jpeg file and setup texture

    HPS::Image::ImportOptionsKit iok;
    iok.SetFormat(HPS::Image::Format::Jpeg);

    //! [image_glyphs]
    // import the image into the database
	UTF8 filename = "D:/hmf_master/wood.jpg";
    HPS::ImageKit myImageKit = HPS::Image::File::Import(filename, iok);

    // define the image in a portfolio
    HPS::ImageDefinition patternImageDef = portfolio.DefineImage("wood_pattern", myImageKit);

    // Define texture
	TextureOptionsKit texture_options; // = TextureOptionsKit::GetDefault();
	texture_options.SetModulation(true).SetInterpolationFilter(Material::Texture::Interpolation::None);
	portfolio.DefineTexture("my_texture", patternImageDef, texture_options);

    
    // Insert shell with 3 faces	

    
    Point points[8] = { Point(0, 0, 0),
				   Point(2, 0, 0),
				   Point(2, 2, 0),
				   Point(0, 2, 0),
					Point(4, 2, 0),
				   Point(4, 0, 0),
				   Point(6, 2, 0),
				   Point(6, 0, 0) };

    int faceList[15] = { 4, 0, 1, 2, 3, 
                         4, 1, 5, 4, 2,
                         4, 5, 7, 6, 4};
	HPS::ShellKey myShellKey = modelKey.InsertShell(8, points, 15, faceList);

    // Setup texture settings 
	MaterialKitArray materialKitArray(3);
    //face1
	materialKitArray[0].SetDiffuseColor(RGBColor::White());
	materialKitArray[0].SetDiffuseTexture("my_texture"); // this material is now a texture
    //face2
	materialKitArray[1].SetDiffuseColor(HPS::RGBAColor(1, 0, 0, 1));
    //face3
	materialKitArray[2].SetDiffuseColor(RGBColor::White());
	materialKitArray[2].SetDiffuseTexture("my_texture"); // this material is now a texture

	HPS::MaterialPaletteDefinition mpd = portfolio.DefineMaterialPalette("ManualHighlight", materialKitArray);

    modelKey.SetMaterialPalette("ManualHighlight");

    // Apply texture to specific face
    // 
	//! [subentity_materials]
	HPS::SizeTArray faceIndices(3);
	faceIndices[0] = 0;
	faceIndices[1] = 1;
	faceIndices[2] = 2;

	HPS::FloatArray materialIndices(3);
	materialIndices[0] = 0;
	materialIndices[1] = 1;
	materialIndices[2] = 2;

	myShellKey.SetFaceIndexColorsByList(faceIndices, materialIndices);

    GetCanvas().UpdateWithNotifier().Wait();

```
