summaryrefslogtreecommitdiffstats
path: root/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp')
-rw-r--r--src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp b/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
index 9f867b3..fdab6d4 100644
--- a/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
+++ b/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
@@ -1254,9 +1254,13 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
// uniform sampler2D propName; \
// uniform int flag##propName; \
// uniform vec4 propName##Info; \
+ // uniform vec3 propName##TransformU; \
+ // uniform vec3 propName##TransformV; \
// vec4 texture2D_##propName(vec2 uv) \
// { \
- // return GetTextureValue( propName, uv, propName##Info.z ); \
+ // vec3 tuv(uv, 1.0); \
+ // vec2 uv2(dot(propName##TransformU, tuv), dot(propName##TransformV, tuv)); \
+ // return GetTextureValue( propName, uv2, propName##Info.z ); \
// }
//
// #define SNAPPER_SAMPLER2DWITHDEFAULT(propName, propNiceName, texFilter, texWrap, defaultPath, showUI ) \
@@ -1272,22 +1276,31 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
QString snapperSamplerCube = QStringLiteral("SNAPPER_SAMPLERCUBE(");
QString endingBracket = QStringLiteral(")");
+ const auto insertSnapperStr = [](const QString &parameter) {
+ QString insertStr;
+ QTextStream stream(&insertStr);
+ stream << "uniform sampler2D " << parameter << ";\n";
+ stream << "uniform int flag" << parameter << ";\n";
+ stream << "uniform vec4 " << parameter << "Info;\n";
+ stream << "uniform vec3 " << parameter << "TransformU;\n";
+ stream << "uniform vec3 " << parameter << "TransformV;\n";
+ stream << "vec2 transformCoord" << parameter << "(vec2 uv) { return vec2(dot("
+ << parameter << "TransformU, vec3(uv, 1.0)), dot("
+ << parameter << "TransformV, vec3(uv, 1.0))); }\n";
+ stream << "vec4 texture2D_" << parameter << "(vec2 uv) "
+ << "{ return GetTextureValue( " << parameter
+ << ", transformCoord" << parameter << "(uv), "
+ << parameter << "Info.z ); }\n";
+ return insertStr;
+ };
+
while ((beginIndex = str.indexOf(snapperSampler, beginIndex)) >= 0) {
int endIndex = str.indexOf(endingBracket, beginIndex);
const QStringList list = getParameters(str, beginIndex + snapperSampler.length(),
endIndex);
str.remove(beginIndex, endIndex - beginIndex + 1);
- if (list.size() == 5) {
- QString insertStr;
- QTextStream stream(&insertStr);
- stream << "uniform sampler2D " << list[0] << ";\n";
- stream << "uniform int flag" << list[0] << ";\n";
- stream << "vec4 " << list[0] << "Info;\n";
- stream << "vec4 texture2D_" << list[0] << "(vec2 uv) "
- << "{ return GetTextureValue( " << list[0] << ", uv, "
- << list[0] <<"Info.z ); }\n";
- str.insert(beginIndex, insertStr);
- }
+ if (list.size() == 5)
+ str.insert(beginIndex, insertSnapperStr(list[0]));
}
beginIndex = 0;
while ((beginIndex = str.indexOf(snapperSamplerDefault, beginIndex)) >= 0) {
@@ -1295,17 +1308,8 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
const QStringList list = getParameters(str, beginIndex + snapperSamplerDefault.length(),
endIndex);
str.remove(beginIndex, endIndex - beginIndex + 1);
- if (list.size() == 5) {
- QString insertStr;
- QTextStream stream(&insertStr);
- stream << "uniform sampler2D " << list[0] << ";\n";
- stream << "uniform int flag" << list[0] << ";\n";
- stream << "vec4 " << list[0] << "Info;\n";
- stream << "vec4 texture2D_" << list[0] << "(vec2 uv) "
- << "{ return GetTextureValue( " << list[0] << ", uv, "
- << list[0] <<"Info.z ); }\n";
- str.insert(beginIndex, insertStr);
- }
+ if (list.size() == 5)
+ str.insert(beginIndex, insertSnapperStr(list[0]));
}
beginIndex = 0;
while ((beginIndex = str.indexOf(snapperSamplerCube, beginIndex)) >= 0) {
@@ -1372,11 +1376,9 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
if (strstr(inProgramSource, "SNAPPER_SAMPLER")) {
QString programSource(inProgramSource);
insertSnapperDirectives(programSource);
- QByteArray data = programSource.toLatin1();
- const char *source = data.constData();
- m_VertShader.append(source);
- m_FragShader.append(source);
+ m_VertShader.append(programSource);
+ m_FragShader.append(programSource);
} else {
m_VertShader.append(inProgramSource);
m_FragShader.append(inProgramSource);