|
42 | 42 | // simple garbage collector for RPR objects.
|
43 | 43 | RPRGarbageCollector g_gc;
|
44 | 44 |
|
45 |
| -// vertices data |
46 |
| -struct vertexP3N3T2 |
47 |
| -{ |
48 |
| - rpr_float pos[3]; |
49 |
| - rpr_float norm[3]; |
50 |
| - rpr_float tex[2]; |
51 |
| -}; |
52 |
| - |
53 | 45 |
|
54 | 46 | // Convert Color Space :
|
55 | 47 | // From Linear sRGB to ACEScg
|
@@ -79,83 +71,6 @@ RadeonProRender::float4 sRGB_to_ACEScg(const RadeonProRender::float4& srgb)
|
79 | 71 | }
|
80 | 72 |
|
81 | 73 |
|
82 |
| -// create a simple quad shape |
83 |
| -rpr_shape CreateQuad(rpr_context context, rpr_scene scene, vertexP3N3T2* meshVertices, unsigned int meshVertices_nbOfElement ) |
84 |
| -{ |
85 |
| - rpr_int indices[] = { 3,2,1,0, }; |
86 |
| - rpr_int num_face_vertices[] = { 4, }; |
87 |
| - |
88 |
| - const unsigned int num_face_vertices_nbOfElement = sizeof(num_face_vertices)/sizeof(num_face_vertices[0]); |
89 |
| - |
90 |
| - rpr_shape mesh = nullptr; |
91 |
| - |
92 |
| - CHECK( rprContextCreateMesh(context, |
93 |
| - (rpr_float const*)&meshVertices[0], meshVertices_nbOfElement , sizeof(vertexP3N3T2), |
94 |
| - (rpr_float const*)((char*)&meshVertices[0] + sizeof(rpr_float)*3), meshVertices_nbOfElement, sizeof(vertexP3N3T2), |
95 |
| - (rpr_float const*)((char*)&meshVertices[0] + sizeof(rpr_float)*6), meshVertices_nbOfElement, sizeof(vertexP3N3T2), |
96 |
| - (rpr_int const*)indices, sizeof(rpr_int), |
97 |
| - (rpr_int const*)indices, sizeof(rpr_int), |
98 |
| - (rpr_int const*)indices, sizeof(rpr_int), |
99 |
| - num_face_vertices, num_face_vertices_nbOfElement, &mesh) ); |
100 |
| - |
101 |
| - if ( scene ) { CHECK( rprSceneAttachShape(scene, mesh) ); } |
102 |
| - |
103 |
| - return mesh; |
104 |
| -} |
105 |
| - |
106 |
| -// Create a Quad shape on the YZ plane |
107 |
| -rpr_shape CreateQuad_YZ(rpr_context context, rpr_scene scene, float ax, float ay, float bx, float by, float X) |
108 |
| -{ |
109 |
| - vertexP3N3T2 meshVertices[] = |
110 |
| - { |
111 |
| - { X, ax, by, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, |
112 |
| - { X, bx, by, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }, |
113 |
| - { X, bx, ay, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f }, |
114 |
| - { X, ax, ay, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }, |
115 |
| - }; |
116 |
| - |
117 |
| - const unsigned int meshVertices_nbOfElement = sizeof(meshVertices)/sizeof(meshVertices[0]); |
118 |
| - |
119 |
| - rpr_shape mesh = CreateQuad(context, scene, meshVertices, meshVertices_nbOfElement); |
120 |
| - return mesh; |
121 |
| -} |
122 |
| - |
123 |
| -// Create a Quad shape on the XZ plane |
124 |
| -rpr_shape CreateQuad_XZ(rpr_context context, rpr_scene scene, float ax, float ay, float bx, float by, float Y, float normal) |
125 |
| -{ |
126 |
| - vertexP3N3T2 meshVertices[] = |
127 |
| - { |
128 |
| - { ax, Y, by, 0.0f, normal, 0.0f, 0.0f, 0.0f }, |
129 |
| - { bx, Y, by, 0.0f, normal, 0.0f, 1.0f, 0.0f }, |
130 |
| - { bx, Y, ay, 0.0f, normal, 0.0f, 1.0f, 1.0f }, |
131 |
| - { ax, Y, ay, 0.0f, normal, 0.0f, 0.0f, 1.0f }, |
132 |
| - }; |
133 |
| - |
134 |
| - const unsigned int meshVertices_nbOfElement = sizeof(meshVertices)/sizeof(meshVertices[0]); |
135 |
| - |
136 |
| - rpr_shape mesh = CreateQuad(context, scene, meshVertices, meshVertices_nbOfElement); |
137 |
| - return mesh; |
138 |
| -} |
139 |
| - |
140 |
| -// Create a Quad shape on the XY plane |
141 |
| -rpr_shape CreateQuad_XY(rpr_context context, rpr_scene scene, float ax, float ay, float bx, float by, float Z) |
142 |
| -{ |
143 |
| - vertexP3N3T2 meshVertices[] = |
144 |
| - { |
145 |
| - { ax, by, Z, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }, |
146 |
| - { bx, by, Z, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f }, |
147 |
| - { bx, ay, Z, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f }, |
148 |
| - { ax, ay, Z, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, |
149 |
| - }; |
150 |
| - |
151 |
| - const unsigned int meshVertices_nbOfElement = sizeof(meshVertices)/sizeof(meshVertices[0]); |
152 |
| - |
153 |
| - rpr_shape mesh = CreateQuad(context, scene, meshVertices, meshVertices_nbOfElement); |
154 |
| - return mesh; |
155 |
| -} |
156 |
| - |
157 |
| - |
158 |
| - |
159 | 74 |
|
160 | 75 | int main()
|
161 | 76 | {
|
@@ -350,35 +265,21 @@ int main()
|
350 | 265 | const float lightX1 = lightX0 + 0.8f;
|
351 | 266 | const float lightX2 = 4.0f - 0.4f - 0.8f;
|
352 | 267 | const float lightX3 = lightX2 + 0.8f;
|
353 |
| - rpr_shape roof0 = CreateQuad_XZ(context, scene, -4.0f, -2.0f , lightX0, +2.0f , roofY, -1.0f); |
354 |
| - rpr_shape roof1 = CreateQuad_XZ(context, scene, lightX0, -2.0f , lightX1 , -2.0f+0.8*2.0f , roofY, -1.0f); |
355 |
| - rpr_shape roof2 = CreateQuad_XZ(context, scene, lightX0, -2.0f+0.8*3.0f , lightX1 , +2.0f , roofY, -1.0f); |
356 |
| - rpr_shape roofLightLeft = CreateQuad_XZ(context, scene, lightX0, -2.0f+0.8*2.0f , lightX1 , -2.0f+0.8*3.0f , roofY, -1.0f); |
357 |
| - rpr_shape roof3 = CreateQuad_XZ(context, scene, lightX1, -2.0f , lightX2, +2.0f , roofY, -1.0f); |
358 |
| - rpr_shape roof4 = CreateQuad_XZ(context, scene, lightX2, -2.0f , lightX3 , -2.0f+0.8*2.0f , roofY, -1.0f); |
359 |
| - rpr_shape roof5 = CreateQuad_XZ(context, scene, lightX2, -2.0f+0.8*3.0f , lightX3 , +2.0f , roofY, -1.0f); |
360 |
| - rpr_shape roofLightRight = CreateQuad_XZ(context, scene, lightX2, -2.0f+0.8*2.0f , lightX3 , -2.0f+0.8*3.0f , roofY, -1.0f); |
361 |
| - rpr_shape roof6 = CreateQuad_XZ(context, scene, lightX3, -2.0f , 4.0f, +2.0f , roofY, -1.0f); |
362 |
| - rpr_shape floor = CreateQuad_XZ(context, scene, -4.0f, -2.0f , +4.0f, +2.0f , 0.0f, +1.0f); |
363 |
| - rpr_shape shapeWallLeft = CreateQuad_YZ(context, scene, 0.0, -2.0f , roofY, +2.0f , -4.0f); |
364 |
| - rpr_shape shapeWallRight = CreateQuad_YZ(context, scene, 0.0, -2.0f , roofY, +2.0f , +4.0f); |
365 |
| - rpr_shape shapeWallBack = CreateQuad_XY(context, scene, -4.0, 0.0, +4.0f, roofY , -2.0f); |
366 |
| - rpr_shape pictureShape = CreateQuad_XY(context, scene, 0.0, 0.3, +3.5f, roofY-0.3f , -1.9f); |
367 |
| - g_gc.GCAdd(roof0); |
368 |
| - g_gc.GCAdd(roof1); |
369 |
| - g_gc.GCAdd(roof2); |
370 |
| - g_gc.GCAdd(roofLightLeft); |
371 |
| - g_gc.GCAdd(roof3); |
372 |
| - g_gc.GCAdd(roof4); |
373 |
| - g_gc.GCAdd(roof5); |
374 |
| - g_gc.GCAdd(roofLightRight); |
375 |
| - g_gc.GCAdd(roof6); |
376 |
| - g_gc.GCAdd(floor); |
377 |
| - g_gc.GCAdd(shapeWallLeft); |
378 |
| - g_gc.GCAdd(shapeWallRight); |
379 |
| - g_gc.GCAdd(shapeWallBack); |
380 |
| - g_gc.GCAdd(pictureShape); |
381 |
| - |
| 268 | + rpr_shape roof0 = CreateQuad_XZ(g_gc, context, scene, -4.0f, -2.0f , lightX0, +2.0f , roofY, -1.0f); |
| 269 | + rpr_shape roof1 = CreateQuad_XZ(g_gc, context, scene, lightX0, -2.0f , lightX1 , -2.0f+0.8*2.0f , roofY, -1.0f); |
| 270 | + rpr_shape roof2 = CreateQuad_XZ(g_gc, context, scene, lightX0, -2.0f+0.8*3.0f , lightX1 , +2.0f , roofY, -1.0f); |
| 271 | + rpr_shape roofLightLeft = CreateQuad_XZ(g_gc, context, scene, lightX0, -2.0f+0.8*2.0f , lightX1 , -2.0f+0.8*3.0f , roofY, -1.0f); |
| 272 | + rpr_shape roof3 = CreateQuad_XZ(g_gc, context, scene, lightX1, -2.0f , lightX2, +2.0f , roofY, -1.0f); |
| 273 | + rpr_shape roof4 = CreateQuad_XZ(g_gc, context, scene, lightX2, -2.0f , lightX3 , -2.0f+0.8*2.0f , roofY, -1.0f); |
| 274 | + rpr_shape roof5 = CreateQuad_XZ(g_gc, context, scene, lightX2, -2.0f+0.8*3.0f , lightX3 , +2.0f , roofY, -1.0f); |
| 275 | + rpr_shape roofLightRight = CreateQuad_XZ(g_gc, context, scene, lightX2, -2.0f+0.8*2.0f , lightX3 , -2.0f+0.8*3.0f , roofY, -1.0f); |
| 276 | + rpr_shape roof6 = CreateQuad_XZ(g_gc, context, scene, lightX3, -2.0f , 4.0f, +2.0f , roofY, -1.0f); |
| 277 | + rpr_shape floor = CreateQuad_XZ(g_gc, context, scene, -4.0f, -2.0f , +4.0f, +2.0f , 0.0f, +1.0f); |
| 278 | + rpr_shape shapeWallLeft = CreateQuad_YZ(g_gc, context, scene, 0.0, -2.0f , roofY, +2.0f , -4.0f, 1.0f); |
| 279 | + rpr_shape shapeWallRight = CreateQuad_YZ(g_gc, context, scene, 0.0, -2.0f , roofY, +2.0f , +4.0f, 1.0f); |
| 280 | + rpr_shape shapeWallBack = CreateQuad_XY(g_gc, context, scene, -4.0, 0.0, +4.0f, roofY , -2.0f, 1.0f); |
| 281 | + rpr_shape pictureShape = CreateQuad_XY(g_gc, context, scene, 0.0, 0.3, +3.5f, roofY-0.3f , -1.9f, 1.0f); |
| 282 | + |
382 | 283 |
|
383 | 284 | // create material for the left wall
|
384 | 285 | {
|
@@ -415,6 +316,14 @@ int main()
|
415 | 316 | // This means the texture is using the sRGB color space with a gamma correction.
|
416 | 317 | CHECK( rprImageSetOcioColorspace(img , "Utility - sRGB - Texture") );
|
417 | 318 | }
|
| 319 | + else |
| 320 | + { |
| 321 | + // art.jpg image is stored in the non-linear sRGB space. |
| 322 | + // if we are not using the OCIO workflow, then we need to set the gamma for non-linear images ( like most of .png, .jpg... representing color ) |
| 323 | + // This gamma value is used to do a basic IDT operation, transforming the image from non-linear "Texture Colorspace" to a linear "Render Colorspace". |
| 324 | + // In our case: from "non-linear sRGB" to "linear sRGB" |
| 325 | + CHECK( rprImageSetGamma(img, 2.2) ); |
| 326 | + } |
418 | 327 |
|
419 | 328 | CHECK( rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_IMAGE_TEXTURE, &imgSampler));
|
420 | 329 | g_gc.GCAdd(imgSampler);
|
|
0 commit comments