Finalizing render

This commit is contained in:
Vladislav Khorev 2018-10-30 02:03:42 +05:00
parent 3f567533bf
commit ac296727de
6 changed files with 71 additions and 31 deletions

View File

@ -1,42 +1,42 @@
{
"ices": [
{
"position": [ -20, 0, -50 ],
"position": [ -20, 0.8, -50 ],
"scale": 1,
"angle": 0,
"type": 1,
"texture": 1
},
{
"position": [ 30, 0, 30 ],
"position": [ 30, 0.7, 30 ],
"scale": 0.3,
"angle": 0,
"type": 2,
"texture": 2
},
{
"position": [ -10, 0, 50 ],
"position": [ -10, 0.7, 50 ],
"scale": 0.1,
"angle": 0,
"type": 3,
"texture": 3
},
{
"position": [ 0, 0, 50 ],
"position": [ 0, 0.7, 50 ],
"scale": 0.1,
"angle": 0,
"type": 4,
"texture": 1
},
{
"position": [ 30, 0, 30 ],
"position": [ 30, 0.7, 30 ],
"scale": 0.2,
"angle": 0,
"type": 5,
"texture": 2
},
{
"position": [ 50, 0, -50 ],
"position": [ 50, 0.7, -50 ],
"scale": 2,
"angle": 0,
"type": 6,

View File

@ -5,6 +5,7 @@ uniform sampler2D NormalMap;
uniform vec3 LightDirection;
uniform float TimeOfDayCoef1;
uniform float TimeOfDayCoef2;
uniform float invCoef;
uniform vec3 TimeOfDayColor;
varying vec2 texCoord;
@ -24,4 +25,10 @@ void main()
//gl_FragColor = vec4(((texture2D(Texture, texCoord).rgb + vec3(0.0, 0.1, 0.2)) * (0.4)), 1.0);
gl_FragColor = vec4(((texture2D(Texture, texCoord).rgb + TimeOfDayColor) * (cosf * TimeOfDayCoef1 + TimeOfDayCoef2)), 1.0);
if (posVec.y < 0.0)
{
discard;
//gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}

View File

@ -4,6 +4,7 @@ attribute vec3 Tangent;
attribute vec3 Binormal;
attribute vec2 vTexCoord;
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform vec3 CamPos;
@ -29,5 +30,5 @@ void main()
normVec = Normal;
posVec = vPosition;
posVec = vPosition.xyz;
}

View File

@ -21,7 +21,7 @@ extern float lastOffsetX;
#ifdef TARGET_WIN32
int TimeOfDayPref = 0;
bool SnowPref = false;
bool SnowPref = true;
#else
extern int TimeOfDayPref;
@ -94,7 +94,14 @@ void TAndroidApplication::LoadModels()
Vector3f size = objData.models[0].maxCorner - objData.models[0].minCorner;
float radius = myMax(size[0], myMax(size[1], size[2])) / 2;
mountainTransformation = Affine3f(Scaling(cameraDistance / radius * 0.25f)).matrix();
SE::MoveDataTriangleList(mountain.second.Data, Vector3f(0, -10.0, 0));
mountain.second.RefreshBuffer();
mountainTransformation = Affine3f(Scaling(cameraDistance / radius * 0.5f)).matrix();
//mountainTransformation = Affine3f(Translation3f(0, -size[1] * 0.02f, 0)).matrix() * mountainTransformation;
//mountainTransformation = Affine3f(Translation3f(0, -size[1] / 20 * cameraDistance / radius * 0.25f, 0)).matrix() * mountainTransformation;
//Matrix3f rotation(Quaternionf(0, 1 * sin(pi / 8 + pi / 2), 0, 1 * cos(pi / 8 + pi / 2)).toRotationMatrix());
//mountainTransformation = Affine3f(rotation).matrix() * mountainTransformation;
@ -104,6 +111,13 @@ void TAndroidApplication::LoadModels()
{
objData = loadObjFile("ice/ice" + std::to_string(i) + ".obj", "");
ices[i - 1] = ObjDataToRenderPairs(objData)[0][0].second;
//SE::MoveDataTriangleList(ices[i - 1].Data, Vector3f(0, 0.1f, 0));
ices[i - 1].RefreshBuffer();
}
size = objData.models[0].maxCorner - objData.models[0].minCorner;
@ -130,7 +144,9 @@ void TAndroidApplication::LoadModels()
iceParams.push_back(params);
Matrix4f iceTransformation = Affine3f(Translation3f(centerShift)).matrix();
iceTransformation = Affine3f(Scaling(cameraDistance / radius * 0.1f * scale)).matrix() * iceTransformation;
//iceTransformation = Affine3f(Scaling(cameraDistance / radius * 0.1f * scale)).matrix() * iceTransformation;
//Matrix3f rotation(Quaternionf(0, cos(angle*pi / 360.f), 0, sin(angle*pi / 360.f)).toRotationMatrix());
//iceTransformation = Affine3f(rotation).matrix() * iceTransformation;
iceTransformation = Affine3f(Translation3f(position)).matrix() * iceTransformation;
@ -155,7 +171,6 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
Renderer->PushProjectionMatrix(1,1);
Renderer->LoadIdentity();
//Renderer->PushSpecialMatrix(Matrix4f::Identity());
if (inv)
{
@ -169,13 +184,13 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky.png"]);
}
Renderer->DrawRect(Vector2f(0.0f, 0.56f), Vector2f(1.f, 0.f), Vector2f(0.5f + SkyTexShift, 0.f), Vector2f(1.f + SkyTexShift, 1.f));
Renderer->DrawRect(Vector2f(0.0f, 0.55f), Vector2f(1.f, 0.f), Vector2f(0.5f + SkyTexShift, 0.f), Vector2f(1.f + SkyTexShift, 1.f));
if (TimeOfDayPref == 1)
{
glClear(GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["final_cloud.png"]);
Renderer->DrawRect(Vector2f(0.0f, 0.56f), Vector2f(4.f, 0.f), Vector2f(0.0f + SkyTexShift + CloudTimer, 0.f), Vector2f(1.f + SkyTexShift + CloudTimer, 0.5f));
Renderer->DrawRect(Vector2f(0.0f, 0.55f), Vector2f(4.f, 0.f), Vector2f(0.0f + SkyTexShift + CloudTimer, 0.f), Vector2f(1.f + SkyTexShift + CloudTimer, 0.5f));
}
}
else
@ -188,13 +203,13 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky.png"]);
}
Renderer->DrawRect(Vector2f(0.0f, 0.54f), Vector2f(1.f, 1.f), Vector2f(0.5f + SkyTexShift, 0.f), Vector2f(1.f + SkyTexShift, 1.f));
Renderer->DrawRect(Vector2f(0.0f, 0.55f), Vector2f(1.f, 1.f), Vector2f(0.5f + SkyTexShift, 0.f), Vector2f(1.f + SkyTexShift, 1.f));
if (TimeOfDayPref == 1)
{
glClear(GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["final_cloud.png"]);
Renderer->DrawRect(Vector2f(0.0f, 0.54f), Vector2f(4.f, 1.f), Vector2f(0.0f + SkyTexShift + CloudTimer, 0.f), Vector2f(1.f + SkyTexShift + CloudTimer, 0.5f));
Renderer->DrawRect(Vector2f(0.0f, 0.55f), Vector2f(4.f, 1.f), Vector2f(0.0f + SkyTexShift + CloudTimer, 0.f), Vector2f(1.f + SkyTexShift + CloudTimer, 0.5f));
}
}
@ -226,15 +241,31 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
if (inv)
{
//Renderer->PushMatrix();
Renderer->TranslateMatrix(Vector3f(0,0.1f,0));
Renderer->TranslateMatrix(Vector3f(0, 0.0f, 0));
Renderer->ScaleMatrix(Vector3f(1, -1, 1));
}
else
{
Renderer->TranslateMatrix(Vector3f(0, 0.0f, 0));
}
Renderer->PushShader("SimplelightShader");
RenderUniform3fv("LightDirection", Vector3f(1, 1, 1).data());
if (inv)
{
RenderUniform1f("invCoef", -1.0f);
RenderUniform1f("extraSpace", 2.0f);
}
else
{
RenderUniform1f("invCoef", 1.0f);
RenderUniform1f("extraSpace", 0.0f);
}
Vector3f dayColor = Vector3f(0,0,0);
Vector3f nightColor = Vector3f(0, 0.1f, 0.2f);
@ -322,8 +353,8 @@ void TAndroidApplication::DrawSnow()
void TAndroidApplication::DrawAllScene(bool toScreen)
{
glClearColor(1.f, 0.f, 1.f, 1.0f);
//glClearColor(1.f, 1.f, 1.f, 1.0f);
//glClearColor(1.f, 0.f, 1.f, 1.0f);
glClearColor(0.9f, 0.9f, 1.f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Renderer->PushMatrix();
@ -332,6 +363,8 @@ void TAndroidApplication::DrawAllScene(bool toScreen)
Renderer->PushShader("ClipShader");
Renderer->SwitchToFrameBuffer("WaterFrame");
Renderer->SetGLCamView();
Renderer->ScaleMatrix(Vector3f(1, -1, 1));
@ -376,12 +409,13 @@ void TAndroidApplication::DrawAllScene(bool toScreen)
Renderer->SetFrameViewport("ScreenshotFrame");
}
Renderer->DrawFramePartScreen("WaterFrame", Vector2f(0, 0), Vector2f(1.f, 0.54f));
Renderer->DrawFramePartScreen("WaterFrame", Vector2f(0, 0), Vector2f(1.f, 0.55f));
glActiveTexture(GL_TEXTURE0); // return back
Renderer->PopShader();
glClear(GL_DEPTH_BUFFER_BIT);
Renderer->SetGLCamView();
@ -393,10 +427,10 @@ void TAndroidApplication::DrawAllScene(bool toScreen)
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["snow.png"]);
//if (SnowPref)
//{
// DrawSnow();
//}
if (SnowPref)
{
DrawSnow();
}
Renderer->PopShader();
@ -455,7 +489,6 @@ void TAndroidApplication::InnerInit()
boost::get<TPanoramicCamera>(Renderer->Camera).MovePhi(pi / 360.f * 5);
mCamera.MovePhi(pi / 360.f * 5);
if (Renderer->GetScreenWidth() > Renderer->GetScreenHeight())
{
boost::get<TPanoramicCamera>(Renderer->Camera).MoveDist(150.f);

View File

@ -24,7 +24,6 @@
#include "boost/shared_ptr.hpp"
#include "boost/thread/thread.hpp"
#include "boost/asio.hpp"
#include "boost/signal.hpp"
#include "boost/assign.hpp"
#include "boost/variant.hpp"
#include "boost/function.hpp"

View File

@ -96,7 +96,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../jni/;../../../boost_1_67_0;../../../eigen-3.3.4;../../../tes-engine;../../../libs/jpeg-9;../../../libs/jpeg-9/vc10;../../../libs/lpng1510;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../jni/;../../../boost_1_67_0;../../../eigen;../../../tes-engine;../../../libs/jpeg-9;../../../libs/jpeg-9/vc10;../../../libs/lpng1510;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>Sync</ExceptionHandling>
<PreprocessorDefinitions>TARGET_WIN32;DEBUG;_WIN32_WINNT=0x0600;EIGEN_DONT_ALIGN_STATICALLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
@ -114,7 +114,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../jni/;../../../boost_1_67_0;../../../eigen-3.3.4;../../../tes-engine;../../../libs/jpeg-9;../../../libs/jpeg-9/vc10;../../../libs/lpng1510;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../jni/;../../../boost_1_67_0;../../../eigen;../../../tes-engine;../../../libs/jpeg-9;../../../libs/jpeg-9/vc10;../../../libs/lpng1510;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>TARGET_WIN32;NDEBUG;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>