-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
402 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <zeno/zeno.h> | ||
#include <zeno/extra/ShaderNode.h> | ||
#include <zeno/types/ShaderObject.h> | ||
|
||
namespace zeno { | ||
|
||
struct ShaderBuffer : ShaderNodeClone<ShaderBuffer> { | ||
virtual int determineType(EmissionPass *em) override { | ||
return TypeHint.at("uint64"); | ||
} | ||
|
||
virtual void emitCode(EmissionPass *em) override { | ||
|
||
auto name = get_input2<std::string>("name"); | ||
return em->emitCode("reinterpret_cast<uint64_t>("+ name + "_buffer" +")"); | ||
} | ||
}; | ||
|
||
ZENDEFNODE(ShaderBuffer, { | ||
{ | ||
{"string", "name", ""}, | ||
}, | ||
{ | ||
{"shader", "out"}, | ||
{"int", "size"}, | ||
}, | ||
{}, | ||
{"shader"}, | ||
}); | ||
|
||
struct ShaderBufferRead : ShaderNodeClone<ShaderBufferRead> { | ||
|
||
virtual int determineType(EmissionPass *em) override { | ||
|
||
em->determineType(get_input("buffer").get()); | ||
|
||
auto type = get_input2<std::string>("type"); | ||
return TypeHint.at(type); | ||
} | ||
|
||
virtual void emitCode(EmissionPass *em) override { | ||
|
||
auto buffer = get_input("buffer").get(); | ||
|
||
auto in = em->determineExpr(buffer); | ||
auto type = get_input2<std::string>("type"); | ||
auto offset = get_input2<int>("offset"); | ||
|
||
em->emitCode("buffer_read<" + type + ">("+ in + "," + std::to_string(offset) + ")" ); | ||
} | ||
}; | ||
|
||
ZENDEFNODE(ShaderBufferRead, { | ||
{ | ||
{"buffer"}, | ||
{"int", "offset", "0"}, | ||
{"enum " + ShaderDataTypeNamesString, "type", "float"}, | ||
}, | ||
{ | ||
{"out"}, | ||
}, | ||
{}, | ||
{"shader"}, | ||
}); | ||
|
||
} |
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,51 @@ | ||
#include <zeno/zeno.h> | ||
#include <zeno/extra/ShaderNode.h> | ||
#include <zeno/types/ShaderObject.h> | ||
|
||
namespace zeno { | ||
|
||
static std::string dataTypeDefaultString() { | ||
return ShaderDataTypeNames.front(); | ||
} | ||
|
||
struct ShaderTypeCast : ShaderNodeClone<ShaderTypeCast> { | ||
virtual int determineType(EmissionPass *em) override { | ||
|
||
auto obj = get_input("in").get(); | ||
em->determineType(obj); | ||
|
||
auto type = get_input2<std::string>("type:"); | ||
return TypeHint.at(type); | ||
} | ||
|
||
virtual void emitCode(EmissionPass *em) override { | ||
|
||
auto op = get_input2<std::string>("op:"); | ||
auto type = get_input2<std::string>("type:"); | ||
|
||
auto obj = get_input("in").get(); | ||
auto in = em->determineExpr(obj); | ||
|
||
if (op == "bit_cast") { | ||
em->emitCode("reinterpret_cast<"+type+"&>("+in+")"); | ||
} else { | ||
em->emitCode(type + "(" + in + ")" ); | ||
} | ||
} | ||
}; | ||
|
||
ZENDEFNODE(ShaderTypeCast, { | ||
{ | ||
{"in"} | ||
}, | ||
{ | ||
{"shader", "out"}, | ||
}, | ||
{ | ||
{"enum bit_cast data_cast ", "op", "bit_cast"}, | ||
{"enum" + ShaderDataTypeNamesString, "type", "bool"}, | ||
}, | ||
{"shader"}, | ||
}); | ||
|
||
} |
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
Oops, something went wrong.