Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

More details are available about PBR and related properties under the Materials documentation.

Instructions

  1. Add the following test function to a HOOPS 3DF application;:

    Code Block
    languagecpp
    int TestPBR ()
    {
    	if (!IsShaderDriver()) // make sure driver is ogl or dx11
    		return TEST_UNSUPPORTED;
    
        HC_Open_Segment ("a");
    		HC_Open_Segment("image"); {
    			HC_Set_Visibility("images=off");
    			auto load_png = [](const char * file_name, const char * image_name) -> bool {
    				FILE *file = fopen(file_name), "rb");
    				if (!file)
    					return false;
    				fseek(file, 0, SEEK_END);
    				int length = ftell(file);
    				fseek(file, 0, SEEK_SET);
    				unsigned char * buffer = new unsigned char[length];
    				fread(buffer, sizeof(unsigned char), length, file);
    				fclose(file);
    				HC_Insert_Compressed_Image(0, 0, 0, H_FORMAT_TEXT("png, name = %s", image_name), -1, -1, length, buffer);
    				delete[] buffer;
    				return true;
    			};
    
    			if (!load_png("IMAGE_PBR_PATH/sandstonecliff-albedo.png", "sandstonecliff-albedo"))
    				return TEST_IMAGE_MISSING;
    			if (!load_png("IMAGE_PBR_PATH/sandstonecliff-ao.png", "sandstonecliff-ao"))
    				return TEST_IMAGE_MISSING;
    			if (!load_png("IMAGE_PBR_PATH/sandstonecliff-metalness.png", "sandstonecliff-metalness"))
    				return TEST_IMAGE_MISSING;
    			if (!load_png("IMAGE_PBR_PATH/sandstonecliff-roughness.png", "sandstonecliff-roughness"))
    				return TEST_IMAGE_MISSING;
    			if (!load_png("IMAGE_PBR_PATH/sandstonecliff-normal-ue.png", "sandstonecliff-normal"))
    				return TEST_IMAGE_MISSING;
    		} HC_Close_Segment();
    
    		HC_Set_PBR_Material("sandstonecliff-albedo", "sandstonecliff-normal", nullptr,
    							"sandstonecliff-metalness", 0,
    							"sandstonecliff-roughness", 0,
    							"sandstonecliff-ao", 0,
    							nullptr,
    							1.0, 1.0, 1.0, 1.0, 1.0,
    							nullptr);
    		HC_Insert_Distant_Light(1, 1, -1);
    
    		HC_Open_Segment("shell"); {
    			float const quad_points[] = {
    				-0.75f, 0.75f, 0.0f,
    				0.75f, 0.75f, 0.0f,
    				0.75f, -0.75f, 0.0f,
    				-0.75f, -0.75f, 0.0f
    			};
    			int const quad_flist[] = {4, 0, 1, 2, 3};
    			float const quad_uvs[] = {
    				0.0f, 1.0f,
    				1.0f, 1.0f,
    				1.0f, 0.0f,
    				0.0f, 0.0f,
    			};
    
    			HC_Set_Visibility("no edges, no markers");
    			HC_KEY	shell_key = HC_Insert_Shell(4, quad_points, 5, quad_flist);
    			HC_MSet_Vertex_Parameters(shell_key, 0, 4, 2, quad_uvs);
    		} HC_Close_Segment();
    	
        HC_Close_Segment();
    
        return TEST_COMPLETE;
    }
    Do no worry about IsShaderDriver() or the specific return values.

  2. Download the Sand Stone Cliff images archive from FreePBR.com called sandstonecliff-ue and install it on your system.

  3. Replace “IMAGE_PBR_PATH” in the code with the actual path to the unzipped Sand Stone Cliff files.

Info

Do not worry about IsShaderDriver() or the specific return values.

 This should result in a scene similar to that shown below.:

...

Filter by label (Content by label)
labels
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@2318a5
showSpacefalse
sortmodified
typepage
reversetruekb-how-to-article
cqllabel in ( "kb-how-to-article" , "= "PBR" ) and type = "page" and space = "KBHV"
labelskb-how-to-article
Page Properties
hiddentrue

Related issues

Jira Legacy
serverId43f371d0-7091-3b3c-9683-94c0b791358d
keySDHV-10062