Skip to content

Commit

Permalink
Stable version v1.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruofeidu committed Dec 17, 2017
1 parent a64dbcc commit 56455a6
Show file tree
Hide file tree
Showing 16 changed files with 481 additions and 10 deletions.
1 change: 1 addition & 0 deletions Colors/Natural.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"../DuEngine/x64/Release/DuEngine.exe" %~n0.ini
24 changes: 24 additions & 0 deletions Colors/Natural.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://www.shadertoy.com/view/MlcGD7
// see also full black body spectrum: https://www.shadertoy.com/view/4tdGWM
// deeper in fluids: https://www.shadertoy.com/view/XldGDM

void mainImage( out vec4 O, vec2 U )
{
U /= iResolution.xy;
float y = 2.* U.y;

O =
// secret 1 for natural colors for luminous phenomena:
// - real-life color spectrum is never zero in any channel
// - intensities are 0 to infinity
// - captors (camera,eye) saturates early
y > 1. ? vec4(1,1./4.,1./16.,1) * exp(4.*U.x - 1.) // i.e. exp(T) * exp(-z)

// secret 2 for natural colors for volumetric phenomena:
// - transparency decrease as the power of distance ( T^l )
// - T value varies with frequency ( i.e. color channel )
// - real life transparency is never exactly 1 at any frequency
: pow(vec4(.1, .7, .8, 1), vec4(4.*U.x));


}
3 changes: 3 additions & 0 deletions Colors/Natural.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
shader_frag = $Name.glsl
channels_count = 1
iChannel0_type = London
1 change: 1 addition & 0 deletions Colors/_create.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python "../Scripts/_create.py"
2 changes: 1 addition & 1 deletion Distortion/_create.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"python" "../Scripts/_create.py"
python "../Scripts/_create.py"
8 changes: 4 additions & 4 deletions DuEngine/DuEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ void DuEngine::start(int argc, char* argv[]) {
m_path = new PathManager(std::string(argv[0]), m_config);

// setup the default m_window width and height
m_defaultWidth = m_config->GetIntWithDefault("window_width", m_defaultWidth);
m_defaultHeight = m_config->GetIntWithDefault("window_height", m_defaultHeight);
string _windowTitle = m_config->GetStringWithDefault("window_title", "DuRenderer | " + m_config->GetName());
m_defaultWidth = m_config->GetIntWithDefault("window_width", m_config->GetIntWithDefault("width", m_defaultWidth));
m_defaultHeight = m_config->GetIntWithDefault("window_height", m_config->GetIntWithDefault("height", m_defaultHeight));
string _windowTitle = m_config->GetStringWithDefault("window_title", m_config->GetStringWithDefault("title", "DuRenderer | " + m_config->GetName()));
m_window->init(argc, argv, m_defaultWidth, m_defaultHeight, _windowTitle);

// setup recording
m_recording = m_config->GetBoolWithDefault("recording", m_recording);
m_recording = m_config->GetBoolWithDefault("record", m_config->GetBoolWithDefault("recording", m_recording));
m_recordPath = m_config->GetStringWithDefault("record_path", m_config->GetName());
m_recordStart = m_config->GetIntWithDefault("record_start", m_recordStart);
m_recordEnd = m_config->GetIntWithDefault("record_end", m_recordEnd);
Expand Down
3 changes: 1 addition & 2 deletions DuEngine/DuScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ void DuEngine::initScene() {
auto channels_count = m_config->GetIntWithDefault(prefix + "channels_count", 0);
for (int i = 0; i < channels_count; ++i) {
string iPrefix = prefix + "iChannel" + to_string(i) + "_";
auto type = m_config->GetStringWithDefault(iPrefix + "type", "unknown");
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
auto type = toLower(m_config->GetStringWithDefault(iPrefix + "type", "unknown"));
auto fileName = m_path->getResource(iPrefix + "tex");
Texture::QueryFileNameByType(type, fileName, m_path->getPresetPath());
auto textureType = Texture::QueryType(type);
Expand Down
43 changes: 42 additions & 1 deletion DuEngine/DuUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "stdafx.h"
#include "DuUtils.h"

bool dirExists(const std::string& dirName_in) {
bool dirExists(const string& dirName_in) {
DWORD ftyp = GetFileAttributesA(dirName_in.c_str());
if (ftyp == INVALID_FILE_ATTRIBUTES)
return false; //something is wrong with your path!
Expand Down Expand Up @@ -61,6 +61,47 @@ string repeatstring(string s, int cnt) {
return res;
}

string toLower(const string & value) {
string result;
result.resize(value.size());
std::transform(value.begin(), value.end(), result.begin(), ::tolower);
return result;
}

bool toBool(const string & str) {
string value = toLower(str);
if (value == "false")
return false;
else if (value == "true")
return true;
warning("Could not parse boolean value " + str);
return false;
}

int toInt(const string & str) {
char *end_ptr = nullptr;
int result = (int)strtol(str.c_str(), &end_ptr, 10);
if (*end_ptr != '\0')
warning("Could not parse integer value \"%s\"" + str);
return result;
}

unsigned int toUInt(const string & str) {
char *end_ptr = nullptr;
unsigned int result = (int)strtoul(str.c_str(), &end_ptr, 10);
if (*end_ptr != '\0')
warning("Could not parse integer value \"%s\"" + str);
return result;
}

float toFloat(const string & str) {
char *end_ptr = nullptr;
float result = (float)strtof(str.c_str(), &end_ptr);
if (*end_ptr != '\0')
warning("Could not parse floating point value \"%s\"" + str);;
return result;
}

void onError() {
system("pause");
exit(EXIT_FAILURE);
Expand Down
8 changes: 7 additions & 1 deletion DuEngine/DuUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ void dump(char* pszFormat, ...);
void onError();

// file systems
bool dirExists(const std::string& dirName_in);
bool dirExists(const string& dirName_in);
string getTimeForFileName();

// string utilities
string repeatstring(string s, int cnt);

string toLower(const string &value);
bool toBool(const string &str);
int toInt(const string &str);
unsigned int toUInt(const string &str);
float toFloat(const string &str);

// design pattern utilities
class Singleton
{
Expand Down
2 changes: 1 addition & 1 deletion DuEngine/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const float PI = 3.14159265359f;
#define DEBUG_VIDEO 0
#define DEBUG_PATH 0
#define DEBUG_TEXTURE_DEPRECATED_FILTERING 0
#define VERBOSE_OUTPUT 1
#define VERBOSE_OUTPUT 0

#if COMPILE_WITH_SH
#include "SHUtils.h"
Expand Down
1 change: 1 addition & 0 deletions DuShaders/0-5OrdersSphericalHarmonics.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"../DuEngine/x64/Release/DuEngine.exe" %~n0.ini
Loading

0 comments on commit 56455a6

Please sign in to comment.