@@ -192,18 +192,20 @@ int main()
192
192
//
193
193
// We are going to take the frame_buffer_resolved data, and use it as a material texture for a plane.
194
194
195
+ // access framebuffer data.
195
196
size_t size = 0 ;
196
197
CHECK (rprFrameBufferGetInfo (frame_buffer_resolved, RPR_FRAMEBUFFER_DATA, 0 , NULL , &size));
197
198
float * buffer = new float [size / sizeof (float )];
198
199
CHECK (rprFrameBufferGetInfo (frame_buffer_resolved, RPR_FRAMEBUFFER_DATA, size, buffer, 0 ));
199
200
200
201
201
- // Apply this buffer as a texture
202
+ // Apply this data as a texture material to the plane.
202
203
203
204
rpr_material_node diffuse1=nullptr ;
204
205
rpr_material_node tex=nullptr ;
205
206
rpr_image img1=nullptr ;
206
207
{
208
+ // create the image from the data of the previous framebuffer
207
209
rpr_image_format format;
208
210
format.num_components = 4 ;
209
211
format.type = RPR_COMPONENT_TYPE_FLOAT32;
@@ -213,17 +215,21 @@ int main()
213
215
desc2.image_row_pitch = 0 ;
214
216
desc2.image_slice_pitch = 0 ;
215
217
desc2.image_depth = 0 ;
216
-
217
218
CHECK (rprContextCreateImage (context, format, &desc2, buffer, &img1));
219
+
220
+ // create the image sampler material
218
221
CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_IMAGE_TEXTURE, &tex));
222
+
219
223
// Set image data
220
224
CHECK (rprMaterialNodeSetInputImageDataByKey (tex, RPR_MATERIAL_INPUT_DATA, img1));
221
- CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse1));
222
- // Set diffuse color parameter to gray
223
225
226
+ // create a simple diffuse material
227
+ CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse1));
228
+
229
+ // apply the built texture as color
224
230
CHECK (rprMaterialNodeSetInputNByKey (diffuse1, RPR_MATERIAL_INPUT_COLOR, tex));
225
- // CHECK(rprMaterialNodeSetInputFByKey(diffuse1, RPR_MATERIAL_INPUT_COLOR, 1,0,0,0));
226
-
231
+
232
+ // plane now uses this diffuse as material.
227
233
CHECK (rprShapeSetMaterial (plane, diffuse1));
228
234
}
229
235
0 commit comments