@@ -42,6 +42,9 @@ RadeonProRender::matrix CameraLookAtToMatrix( RadeonProRender::float3 pos , Rad
42
42
}
43
43
44
44
45
+ RPRGarbageCollector g_gc;
46
+
47
+
45
48
int main ()
46
49
{
47
50
// enable Radeon ProRender API trace
@@ -110,40 +113,11 @@ int main()
110
113
CHECK (rprShapeSetTransform (teapot01, RPR_TRUE, &m0.m00 ));
111
114
}
112
115
113
- // Create plane mesh
114
- rpr_shape plane = nullptr ;
115
- {
116
- CHECK (rprContextCreateMesh (context,
117
- (rpr_float const *)&plane_data[0 ], 4 , sizeof (vertex),
118
- (rpr_float const *)((char *)&plane_data[0 ] + sizeof (rpr_float) * 3 ), 4 , sizeof (vertex),
119
- (rpr_float const *)((char *)&plane_data[0 ] + sizeof (rpr_float) * 6 ), 4 , sizeof (vertex),
120
- (rpr_int const *)indices, sizeof (rpr_int),
121
- (rpr_int const *)indices, sizeof (rpr_int),
122
- (rpr_int const *)indices, sizeof (rpr_int),
123
- num_face_vertices, 2 , &plane));
124
- CHECK (rprSceneAttachShape (scene, plane));
125
- }
126
-
116
+ // create the floor
117
+ CHECK ( CreateAMDFloor (context, scene, matsys, g_gc, 1 .0f , 1 .0f ) );
127
118
128
- // Create an Environment Light light
129
- rpr_light lightEnv = nullptr ;
130
- rpr_image imgEnvLight = nullptr ;
131
- {
132
- CHECK (rprContextCreateEnvironmentLight (context, &lightEnv));
133
-
134
- const std::string pathImageFile = " ../../Resources/Textures/envLightImage.exr" ;
135
- rpr_status status = rprContextCreateImageFromFile (context, pathImageFile.c_str (), &imgEnvLight); // import image use by the Env light
136
- if (status == RPR_ERROR_IO_ERROR)
137
- {
138
- std::cout << " Error : " << pathImageFile << " not found.\n " ;
139
- return -1 ;
140
- }
141
- CHECK (status);
142
-
143
- CHECK (rprEnvironmentLightSetImage (lightEnv, imgEnvLight));
144
- CHECK (rprEnvironmentLightSetIntensityScale (lightEnv, 1 .0f ));
145
- CHECK (rprSceneAttachLight (scene, lightEnv));
146
- }
119
+ // Create an environment light
120
+ CHECK ( CreateNatureEnvLight (context, scene, g_gc, 0 .8f ) );
147
121
148
122
149
123
// create a DIFFUSE material for the Teapot
@@ -161,49 +135,9 @@ int main()
161
135
}
162
136
163
137
164
-
165
- // create a DIFFUSE material for the Floor
166
- //
167
- rpr_material_node uv_scaled_node = NULL ;
168
- rpr_material_node diffuse5 = nullptr ;
169
- rpr_image image2 = nullptr ;
170
- rpr_material_node materialImage2 = nullptr ;
171
- rpr_material_node uv_node = NULL ;
172
- {
173
-
174
-
175
- const std::string pathImageFileA = " ../../Resources/Textures/amd.png" ;
176
- rpr_status status = rprContextCreateImageFromFile (context, pathImageFileA.c_str (), &image2);
177
- if (status == RPR_ERROR_IO_ERROR)
178
- {
179
- std::cout << " Error : " << pathImageFileA << " not found.\n " ;
180
- return -1 ;
181
- }
182
- CHECK (status);
183
-
184
- CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_IMAGE_TEXTURE, &materialImage2));
185
- CHECK (rprMaterialNodeSetInputImageDataByKey (materialImage2, RPR_MATERIAL_INPUT_DATA, image2)); // Set image data
186
-
187
- CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse5));
188
- CHECK (rprMaterialNodeSetInputNByKey (diffuse5, RPR_MATERIAL_INPUT_COLOR, materialImage2)); // set image sampler as the color input of diffuse material
189
-
190
- CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_INPUT_LOOKUP, &uv_node));
191
- CHECK (rprMaterialNodeSetInputUByKey (uv_node, RPR_MATERIAL_INPUT_VALUE, RPR_MATERIAL_NODE_LOOKUP_UV));
192
-
193
- CHECK (rprMaterialSystemCreateNode (matsys, RPR_MATERIAL_NODE_ARITHMETIC, &uv_scaled_node));
194
- CHECK (rprMaterialNodeSetInputUByKey (uv_scaled_node, RPR_MATERIAL_INPUT_OP, RPR_MATERIAL_NODE_OP_MUL));
195
- CHECK (rprMaterialNodeSetInputNByKey (uv_scaled_node, RPR_MATERIAL_INPUT_COLOR0, uv_node));
196
- CHECK (rprMaterialNodeSetInputFByKey (uv_scaled_node, RPR_MATERIAL_INPUT_COLOR1, 2 .0f , 4 .0f , 0 , 0 ));
197
-
198
- CHECK (rprMaterialNodeSetInputNByKey (materialImage2, RPR_MATERIAL_INPUT_UV, uv_scaled_node));
199
-
200
- CHECK (rprShapeSetMaterial (plane, diffuse5));
201
- }
202
-
203
-
204
138
// First, Render scene without any motion
205
139
CHECK ( rprContextSetParameterByKey1f (context, RPR_CONTEXT_DISPLAY_GAMMA , 2 .2f ) ); // set display gamma
206
- CHECK ( rprContextSetParameterByKey1u (context,RPR_CONTEXT_ITERATIONS,NUM_ITERATIONS ));
140
+ CHECK ( rprContextSetParameterByKey1u (context,RPR_CONTEXT_ITERATIONS,200 ));
207
141
CHECK ( rprContextRender (context) );
208
142
CHECK ( rprContextResolveFrameBuffer (context,fb_color,fb_color_resolved,false ));
209
143
CHECK ( rprContextResolveFrameBuffer (context,fb_velocity,fb_velocity_resolved,false ));
@@ -267,22 +201,15 @@ int main()
267
201
//
268
202
CHECK (rprObjectDelete (img)); img=nullptr ;
269
203
CHECK (rprObjectDelete (imgSampler)); imgSampler=nullptr ;
270
- CHECK (rprObjectDelete (uv_scaled_node)); uv_scaled_node=nullptr ;
271
- CHECK (rprObjectDelete (diffuse5)); diffuse5=nullptr ;
272
- CHECK (rprObjectDelete (image2)); image2=nullptr ;
273
- CHECK (rprObjectDelete (materialImage2)); materialImage2=nullptr ;
274
- CHECK (rprObjectDelete (uv_node)); uv_node=nullptr ;
275
204
CHECK (rprObjectDelete (diffuse1)); diffuse1=nullptr ;
276
- CHECK (rprObjectDelete (lightEnv)); lightEnv=nullptr ;
277
- CHECK (rprObjectDelete (imgEnvLight)); imgEnvLight=nullptr ;
278
205
CHECK (rprObjectDelete (camera)); camera=nullptr ;
279
206
CHECK (rprObjectDelete (fb_color)); fb_color=nullptr ;
280
207
CHECK (rprObjectDelete (fb_color_resolved)); fb_color_resolved=nullptr ;
281
208
CHECK (rprObjectDelete (fb_velocity)); fb_velocity=nullptr ;
282
209
CHECK (rprObjectDelete (fb_velocity_resolved)); fb_velocity_resolved=nullptr ;
283
- CHECK (rprObjectDelete (scene)); scene=nullptr ;
284
210
CHECK (rprObjectDelete (teapot01)); teapot01=nullptr ;
285
- CHECK (rprObjectDelete (plane)); plane=nullptr ;
211
+ g_gc.GCClean ();
212
+ CHECK (rprObjectDelete (scene)); scene=nullptr ;
286
213
CHECK (rprObjectDelete (matsys)); matsys=nullptr ;
287
214
CheckNoLeak (context);
288
215
CHECK (rprObjectDelete (context));context=nullptr ; // Always delete the RPR Context in last.
0 commit comments