MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenShadingLanguage / get_userdata

Method get_userdata

src/testrender/simplerend.cpp:253–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252
253bool
254SimpleRenderer::get_userdata (bool derivatives, ustring name, TypeDesc type,
255 ShaderGlobals *sg, void *val)
256{
257 // Just to illustrate how this works, respect s and t userdata, filled
258 // in with the uv coordinates. In a real renderer, it would probably
259 // look up something specific to the primitive, rather than have hard-
260 // coded names.
261
262 if (name == u_s && type == TypeDesc::TypeFloat) {
263 ((float *)val)[0] = sg->u;
264 if (derivatives) {
265 ((float *)val)[1] = sg->dudx;
266 ((float *)val)[2] = sg->dudy;
267 }
268 return true;
269 }
270 if (name == u_t && type == TypeDesc::TypeFloat) {
271 ((float *)val)[0] = sg->v;
272 if (derivatives) {
273 ((float *)val)[1] = sg->dvdx;
274 ((float *)val)[2] = sg->dvdy;
275 }
276 return true;
277 }
278
279 return false;
280}
281
282
283bool

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected