-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support primvars as user data in lights #1939 * Support light primvars in the delegate #1939 * Also support primvars on custom procedurals
- Loading branch information
1 parent
f3002b6
commit 5e7998d
Showing
8 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Support user data in lights | ||
|
||
see #1939 | ||
|
||
author: sebastien.ortega | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#usda 1.0 | ||
( | ||
endTimeCode = 1 | ||
framesPerSecond = 24 | ||
metersPerUnit = 1 | ||
startTimeCode = 1 | ||
timeCodesPerSecond = 24 | ||
upAxis = "Y" | ||
) | ||
|
||
def DomeLight "dome" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
def DistantLight "distant" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
|
||
def DiskLight "disk" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
def CylinderLight "cylinder" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
def RectLight "rect" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
|
||
def SphereLight "sphere" | ||
{ | ||
int primvars:one_value = 1 | ||
float primvars:two_value = 2.0 | ||
color3f primvars:color_value = (0, 0, 1) | ||
float primvars:arnold:intensity = 0.5 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <ai.h> | ||
|
||
#include <cstdio> | ||
#include <cstring> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
bool CheckUserData(const char *name) | ||
{ | ||
AtNode *node = AiNodeLookUpByName(nullptr, AtString(name)); | ||
if (node == nullptr) | ||
return false; | ||
|
||
const AtString s_intAttr("one_value"); | ||
const AtString s_fltAttr("two_value"); | ||
const AtString s_colorAttr("color_value"); | ||
const AtString s_intensityAttr("intensity"); | ||
|
||
if (!AiNodeLookUpUserParameter (node, s_intAttr)) | ||
return false; | ||
int intVal = AiNodeGetInt(node, s_intAttr); | ||
if (intVal != 1) | ||
return false; | ||
|
||
if (!AiNodeLookUpUserParameter (node, s_fltAttr)) | ||
return false; | ||
float fltVal = AiNodeGetFlt(node, s_fltAttr); | ||
if (fltVal != 2) | ||
return false; | ||
|
||
if (!AiNodeLookUpUserParameter (node, s_colorAttr)) | ||
return false; | ||
AtRGB colorVal = AiNodeGetRGB(node, s_colorAttr); | ||
static AtRGB blue(0.f, 0.f, 1.f); | ||
if (colorVal != blue) | ||
return false; | ||
|
||
float intensity = AiNodeGetFlt(node, s_intensityAttr); | ||
if (intensity != 0.5f) | ||
return false; | ||
|
||
|
||
return true; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
AiBegin(); | ||
AiMsgSetConsoleFlags(nullptr, AI_LOG_ALL); | ||
AtParamValueMap* params = AiParamValueMap(); | ||
AiSceneLoad(nullptr, "scene.usda", nullptr); | ||
AiSceneWrite(nullptr, "scene.ass", params); | ||
AiParamValueMapDestroy(params); | ||
AiEnd(); | ||
|
||
AiBegin(); | ||
AiSceneLoad(nullptr, "scene.ass", nullptr); | ||
|
||
bool success = true; | ||
AtNode *dome = AiNodeLookUpByName(nullptr, AtString("/dome")); | ||
|
||
success &= CheckUserData("/dome"); | ||
success &= CheckUserData("/distant"); | ||
success &= CheckUserData("/disk"); | ||
success &= CheckUserData("/rect"); | ||
success &= CheckUserData("/sphere"); | ||
success &= CheckUserData("/cylinder"); | ||
AiEnd(); | ||
return (success) ? 0 : 1; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|