Some changes
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"generator": "Ninja Multi-Config",
|
"generator": "Ninja",
|
||||||
"intelliSenseMode": "windows-msvc-x64",
|
"intelliSenseMode": "windows-msvc-x64",
|
||||||
"inheritEnvironments": [ "msvc_x64" ],
|
"inheritEnvironments": [ "msvc_x64" ],
|
||||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||||
|
|||||||
Binary file not shown.
+18
-18
@@ -1,23 +1,5 @@
|
|||||||
import Common;
|
import Common;
|
||||||
|
|
||||||
struct GlyphInstanceData
|
|
||||||
{
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float width;
|
|
||||||
float height;
|
|
||||||
uint glyphIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TextData
|
|
||||||
{
|
|
||||||
StructuredBuffer<GlyphInstanceData> glyphs;
|
|
||||||
SamplerState glyphSampler;
|
|
||||||
Texture2D<float> glyphTextures[];
|
|
||||||
};
|
|
||||||
ParameterBlock<TextData> pText;
|
|
||||||
|
|
||||||
struct VertexInput
|
struct VertexInput
|
||||||
{
|
{
|
||||||
uint vertexId : SV_VertexID;
|
uint vertexId : SV_VertexID;
|
||||||
@@ -31,6 +13,24 @@ struct VertexOutput
|
|||||||
uint glyphIndex : GLYPHINDEX;
|
uint glyphIndex : GLYPHINDEX;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GlyphInstanceData
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
uint glyphIndex;
|
||||||
|
};
|
||||||
|
struct TextData
|
||||||
|
{
|
||||||
|
StructuredBuffer<GlyphInstanceData> glyphs;
|
||||||
|
SamplerState glyphSampler;
|
||||||
|
Texture2D<float> glyphTextures[];
|
||||||
|
};
|
||||||
|
ParameterBlock<TextData> pText;
|
||||||
|
|
||||||
|
|
||||||
[shader("vertex")]
|
[shader("vertex")]
|
||||||
VertexOutput vertexMain(VertexInput input)
|
VertexOutput vertexMain(VertexInput input)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ struct LightEnv
|
|||||||
layout(set=3)
|
layout(set=3)
|
||||||
ParameterBlock<LightEnv> pLightEnv;
|
ParameterBlock<LightEnv> pLightEnv;
|
||||||
|
|
||||||
|
[Differentiable]
|
||||||
|
float polynomial(float a, float b, float c, float x) {
|
||||||
|
return a * x * x + b * x + c;
|
||||||
|
}
|
||||||
|
|
||||||
interface IBRDF
|
interface IBRDF
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ int main() {
|
|||||||
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
||||||
.filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
.filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
||||||
});
|
});
|
||||||
|
AssetImporter::importTexture(TextureImportArgs{.filePath = sourcePath / "import" / "texture" / "Dirt.png", .importPath = ""});
|
||||||
|
|
||||||
|
|
||||||
getThreadPool().waitIdle();
|
getThreadPool().waitIdle();
|
||||||
vd->commitMeshes();
|
vd->commitMeshes();
|
||||||
|
|||||||
@@ -157,8 +157,7 @@ void BasePass::render() {
|
|||||||
vertexData->getInstanceDataSet()->updateBuffer(VertexData::CULLINGDATA_NAME, 0, cullingBuffer);
|
vertexData->getInstanceDataSet()->updateBuffer(VertexData::CULLINGDATA_NAME, 0, cullingBuffer);
|
||||||
vertexData->getInstanceDataSet()->writeChanges();
|
vertexData->getInstanceDataSet()->writeChanges();
|
||||||
permutation.setVertexData(vertexData->getTypeName());
|
permutation.setVertexData(vertexData->getTypeName());
|
||||||
const auto& materials = vertexData->getMaterialData();
|
for (const auto& materialData : vertexData->getMaterialData()) {
|
||||||
for (const auto& materialData : materials) {
|
|
||||||
// material not used for any active meshes, skip
|
// material not used for any active meshes, skip
|
||||||
if (materialData.instances.size() == 0)
|
if (materialData.instances.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -139,11 +139,9 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
|||||||
|
|
||||||
slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef());
|
slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef());
|
||||||
CHECK_DIAGNOSTICS();
|
CHECK_DIAGNOSTICS();
|
||||||
//std::cout << info.name << std::endl;
|
|
||||||
for (uint32 i = 0; i < signature->getParameterCount(); ++i) {
|
for (uint32 i = 0; i < signature->getParameterCount(); ++i) {
|
||||||
auto param = signature->getParameterByIndex(i);
|
auto param = signature->getParameterByIndex(i);
|
||||||
layout->addMapping(param->getName(), param->getBindingIndex());
|
layout->addMapping(param->getName(), param->getBindingIndex());
|
||||||
//std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround
|
// workaround
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "Math/Math.h"
|
#include "Math/Math.h"
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
enum class ExpressionType {
|
enum class ExpressionType {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
@@ -184,6 +183,9 @@ struct SwizzleExpression : public ShaderExpression {
|
|||||||
StaticArray<int32, 4> comp = {-1, -1, -1, -1};
|
StaticArray<int32, 4> comp = {-1, -1, -1, -1};
|
||||||
SwizzleExpression() {}
|
SwizzleExpression() {}
|
||||||
SwizzleExpression(StaticArray<int32, 4> comp) : comp(std::move(comp)) {}
|
SwizzleExpression(StaticArray<int32, 4> comp) : comp(std::move(comp)) {}
|
||||||
|
SwizzleExpression(std::string key, std::string target, StaticArray<int32, 4> comp) : ShaderExpression(key) {
|
||||||
|
inputs["target"].source = target;
|
||||||
|
}
|
||||||
virtual ~SwizzleExpression() {}
|
virtual ~SwizzleExpression() {}
|
||||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||||
@@ -194,6 +196,11 @@ DEFINE_REF(SwizzleExpression)
|
|||||||
struct SampleExpression : public ShaderExpression {
|
struct SampleExpression : public ShaderExpression {
|
||||||
static constexpr uint64 IDENTIFIER = 0x16;
|
static constexpr uint64 IDENTIFIER = 0x16;
|
||||||
SampleExpression() {}
|
SampleExpression() {}
|
||||||
|
SampleExpression(std::string key, std::string texture, std::string sampler, std::string texCoords) : ShaderExpression(key) {
|
||||||
|
inputs["texture"].source = texture;
|
||||||
|
inputs["sampler"].source = sampler;
|
||||||
|
inputs["texCoords"].source = texCoords;
|
||||||
|
}
|
||||||
virtual ~SampleExpression() {}
|
virtual ~SampleExpression() {}
|
||||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||||
@@ -205,8 +212,6 @@ DEFINE_REF(SampleExpression)
|
|||||||
struct MaterialNode {
|
struct MaterialNode {
|
||||||
std::string profile;
|
std::string profile;
|
||||||
Map<std::string, std::string> variables;
|
Map<std::string, std::string> variables;
|
||||||
MaterialNode() {}
|
|
||||||
~MaterialNode() {}
|
|
||||||
void save(ArchiveBuffer& buffer) const;
|
void save(ArchiveBuffer& buffer) const;
|
||||||
void load(ArchiveBuffer& buffer);
|
void load(ArchiveBuffer& buffer);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ MeshUpdater::MeshUpdater(PScene scene) : ComponentSystem<Component::Transform, C
|
|||||||
|
|
||||||
MeshUpdater::~MeshUpdater() {}
|
MeshUpdater::~MeshUpdater() {}
|
||||||
|
|
||||||
void MeshUpdater::update(entt::entity, Component::Transform& transform, Component::Mesh& comp) {
|
void MeshUpdater::update(entt::entity id, Component::Transform& transform, Component::Mesh& comp) {
|
||||||
|
scene->accessComponent<Component::Camera>(id);
|
||||||
if (comp.meshletOffsets.empty()) {
|
if (comp.meshletOffsets.empty()) {
|
||||||
for (uint32 i = 0; i < comp.asset->meshes.size(); ++i) {
|
for (uint32 i = 0; i < comp.asset->meshes.size(); ++i) {
|
||||||
comp.meshletOffsets.add(comp.asset->meshes[i]->vertexData->addCullingMapping(comp.asset->meshes[i]->id));
|
comp.meshletOffsets.add(comp.asset->meshes[i]->vertexData->addCullingMapping(comp.asset->meshes[i]->id));
|
||||||
|
|||||||
@@ -16,3 +16,11 @@ print(positions)
|
|||||||
print(indices)
|
print(indices)
|
||||||
|
|
||||||
|
|
||||||
|
# Create a tensor with attached grads from a numpy array
|
||||||
|
# Note: We pass zero=True to initialize the grads to zero on allocation
|
||||||
|
x = spy.Tensor.numpy(device, np.array([1, 2, 3, 4], dtype=np.float32)).with_grads(zero=True)
|
||||||
|
|
||||||
|
# Evaluate the polynomial and ask for a tensor back
|
||||||
|
# Expecting result = 2x^2 + 8x - 1
|
||||||
|
result: spy.Tensor = module.polynomial(a=2, b=8, c=-1, x=x, _result='tensor')
|
||||||
|
print(result.to_numpy())
|
||||||
Reference in New Issue
Block a user