-
Notifications
You must be signed in to change notification settings - Fork 1
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
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/crayg/src/scene/shadingnetworks/shadingnodes/ColorToFloat.cpp
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,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
21
src/crayg/src/scene/shadingnetworks/shadingnodes/ColorToFloat.h
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,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); |