Skip to content

Commit

Permalink
missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Latios96 committed Nov 11, 2024
1 parent bd1fc0f commit 403349d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/crayg/src/scene/shadingnetworks/shadingnodes/ColorToFloat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "ColorToFloat.h"

namespace crayg {

std::string ColorToFloat::getType() const {
return "ColorToFloat";
}

ShadingNodeOutputType ColorToFloat::getOutputType() {
return ShadingNodeOutputType::FLOAT;
}

float ColorToFloat::evaluateFloat(const SurfaceInteraction &surfaceInteraction) {
const Color evaluatedColor = colorInput.evaluate(surfaceInteraction);
switch (colorToFloatMode) {
case ColorToFloatMode::R:
return evaluatedColor.r;
case ColorToFloatMode::G:
return evaluatedColor.g;
case ColorToFloatMode::B:
return evaluatedColor.b;
default:
return 0;
}
}
} // crayg
21 changes: 21 additions & 0 deletions src/crayg/src/scene/shadingnetworks/shadingnodes/ColorToFloat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include "scene/shadingnetworks/ShadingNode.h"

namespace crayg {

enum class ColorToFloatMode { R, G, B };

class ColorToFloat : public ShadingNode {
public:
float evaluateFloat(const SurfaceInteraction &surfaceInteraction) override;
std::string getType() const override;
ShadingNodeOutputType getOutputType() override;

ColorShadingNodeInput colorInput;
ColorToFloatMode colorToFloatMode;
};

}

CRAYG_FMT_ENUM_FORMATTER(crayg::ColorToFloatMode);

0 comments on commit 403349d

Please sign in to comment.