commit d132060e19927440ebc0611d2b0eae08b41d851b Author: Vladislav Khorev Date: Thu Jun 6 16:25:38 2024 +0300 Resurrection diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22a3976 --- /dev/null +++ b/.gitignore @@ -0,0 +1,400 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +.svn/ \ No newline at end of file diff --git a/Template.sln b/Template.sln new file mode 100644 index 0000000..88e4486 --- /dev/null +++ b/Template.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template\Template.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|x64.ActiveCfg = Debug|x64 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|x64.Build.0 = Debug|x64 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|x64.ActiveCfg = Release|x64 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Template/Template.vcxproj b/Template/Template.vcxproj new file mode 100644 index 0000000..7a280d8 --- /dev/null +++ b/Template/Template.vcxproj @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {0080A3E1-DFBF-4557-B198-E6D5D7724393} + Template + + + + Application + true + NotSet + v143 + + + Application + true + NotSet + v143 + + + Application + false + true + NotSet + v143 + + + Application + false + true + NotSet + v143 + + + + + + + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(LibraryPath) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + + Level3 + Disabled + C:\Work\OldProjects\engine;C:\Work\OldProjects\engine\include;C:\Boost\include\boost-1_84;..\..\lpng1510;..\..\jpeg-9;..\..\jpeg-9\vc10 + TARGET_WIN32;NOSOUND;TARGET_WIN32;SALMON_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + opengl32.lib;glu32.lib;shell32.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(CoreLibraryDependencies);Salmon Engine.lib;zlib.lib;libpng15.lib;%(AdditionalDependencies) + C:\Work\OldProjects\engine\Salmon Engine\Debug;C:\Boost\lib;C:\Work\OldProjects\lpng1510\projects\vstudio\Debug Library + + + + + Level3 + Disabled + C:\Work\OldProjects\engine;C:\Work\OldProjects\engine\include;C:\Boost\include\boost-1_84;..\..\lpng1510;..\..\jpeg-9;..\..\jpeg-9\vc10 + NOSOUND;TARGET_WIN32;SALMON_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + opengl32.lib;glu32.lib;shell32.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(CoreLibraryDependencies);Salmon Engine.lib;zlib.lib;libpng15.lib;%(AdditionalDependencies) + C:\Work\OldProjects\engine\Salmon Engine\Debug;C:\Boost\lib;C:\Work\OldProjects\lpng1510\projects\vstudio\Debug Library + + + + + Level3 + MaxSpeed + true + true + MultiThreaded + $(SalmonEnginePath);$(LibsPath)\boost_1_47_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;SALMON_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_47_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library + + + + + Level3 + MaxSpeed + true + true + MultiThreaded + $(SalmonEnginePath);$(LibsPath)\boost_1_47_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;SALMON_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_47_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Template/Template.vcxproj.filters b/Template/Template.vcxproj.filters new file mode 100644 index 0000000..82eefed --- /dev/null +++ b/Template/Template.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Файлы исходного кода + + + Файлы исходного кода + + + + + Заголовочные файлы + + + Заголовочные файлы + + + \ No newline at end of file diff --git a/Template/gameMap.cpp b/Template/gameMap.cpp new file mode 100644 index 0000000..15559e5 --- /dev/null +++ b/Template/gameMap.cpp @@ -0,0 +1,247 @@ +#include "gameMap.h" + +using namespace SE; + +TMapCharacter::TMapCharacter() : + Pos(ZeroVec3), + RotationMatrix(IdentityMatrix), + Direction(vec3(0.0f, 0.0f, 1.0f)), + Destination(ZeroVec3), + VectorToDestination(ZeroVec3), + Velocity(0.0f) +{ +} + +void TMapCharacter::SetPos(vec3& pos) +{ + Pos = pos; +} + +void TMapCharacter::GoToDestination(vec3& dest) +{ + Destination = vec3(dest.v[0], 0.0f, dest.v[2]); + Velocity = 0.002f; +} + +void TMapCharacter::Update(cardinal timer) +{ + const float CONST_DISTANCE_SLOW_DOWN = 1.0f; + const float CONST_DISTANCE_STOP = 0.1f; + const float CONST_ROTATION_ANGLE_STEP = pi/200; + + VectorToDestination = (Destination - Pos); + VectorToDestination.v[1] = 0.0f; + VectorToDestination = Normalize(VectorToDestination); + + if (!IsFloatEqual(Velocity, 0.0f)) + { + float cosa = DotProduct(VectorToDestination, Direction); + + float alpha = acosf(cosa); + + if (alpha <= CONST_ROTATION_ANGLE_STEP * timer) + { + Direction = VectorToDestination; + } + else + { + vec3 n = Normalize(CrossProduct(Direction, VectorToDestination)); + + float sinb = sinf(CONST_ROTATION_ANGLE_STEP * timer / 2.0f); + float cosb = cosf(CONST_ROTATION_ANGLE_STEP * timer / 2.0f); + + vec4 q; + q.v[0] = n.v[0] * sinb; + q.v[1] = n.v[1] * sinb; + q.v[2] = n.v[2] * sinb; + q.v[3] = cosb; + mat3 rmat = mat3(q); + RotationMatrix *= rmat; + Direction = rmat * Direction; + + } + } + + if (!(Pos == Destination)) + { + + float dist = sqrtf((Pos.v[0] - Destination.v[0])*(Pos.v[0] - Destination.v[0]) + + (Pos.v[1] - Destination.v[1])*(Pos.v[1] - Destination.v[1]) + + (Pos.v[2] - Destination.v[2])*(Pos.v[2] - Destination.v[2])); + + if (dist > CONST_DISTANCE_SLOW_DOWN) + { + Pos = Pos + timer*Velocity*Direction; + } + else if (dist > CONST_DISTANCE_STOP && dist <= CONST_DISTANCE_SLOW_DOWN) + { + Pos = Pos + 0.5f*timer*Velocity*Direction; + } + else + { + Pos = Destination; + Velocity = 0.0f; + VectorToDestination = ZeroVec3; + + } + + } +} + +vec3 TMapCharacter::GetPos() +{ + return Pos; +} + +mat3 TMapCharacter::GetRotationMatrix() +{ + return RotationMatrix; +} + +void TGameMap::LoadMap() +{ + Land = new TSimpleLandClass; + Land->LoadFromFile(std::string("landscapes/out.ls1")); + Land->SetTexture(std::string("landscapes/out.bmp")); + Land->Scale(0.005f); + + StaticModelArr.reserve(1); + StaticModelArr.resize(1); + StaticModelArr[0].LoadModel("bt_box_yellow.lm1"); + //StaticModelArr[0].SetShaderTranslateVector(vec3(-1.0f, 0.23f, 6.3f)); + + PlayerChar = new TLiteModel; + PlayerChar->LoadModel("bt_cone.lm1"); + + AnimModel = new TAnimModel; + AnimModel->LoadModel("bonemodel.lm1"); + + animSeq = 0; + //AnimModel->ApplySequence("bonemodel.an1", animSeq); + + GirlText = new TAnimModel; + GirlText->LoadModel("girl.lm1"); + //GirlText->ScaleModel(0.1f); + //GirlText->MoveModel(vec3(0,4,0)); + //GirlText->UpdateVBO(); + //GirlText->ApplySequence("girl.an1", 0); + + MapChar.SetPos(vec3(0.0f, 0.0f, 10.0f)); + + +} + +void TGameMap::FreeMap() +{ + if (Land) + { + delete Land; + Land = NULL; + } + + + if (PlayerChar) + { + delete PlayerChar; + PlayerChar = NULL; + } + + if (AnimModel) + { + delete AnimModel; + AnimModel = NULL; + } + + if (GirlText) + { + delete GirlText; + GirlText = NULL; + } + + StaticModelArr.clear(); +} + +TSimpleLandClass* TGameMap::GetLand() +{ + return Land; +} + +void TGameMap::DrawVBO() +{ + + Renderer->PushShader("Simple3D"); + Land->DrawVBO(); + Renderer->PopShader(); + //Land->DrawImmediate(); + + for (TLiteModelArr::iterator i = StaticModelArr.begin(); i != StaticModelArr.end(); ++i) + { + //i->DrawImmediate(); + i->DrawVBO(); + } + + //PlayerChar->DrawVBO(); + + //AnimModel->DrawVBO(); + + //GirlText->DrawVBO(); + +} + +cardinal timeForSeq = 0; + +void TGameMap::Update(cardinal timer) +{ + + MapChar.Update(timer); + + + vec3 vecFrom, vecTo; + vec3 pos = Land->CalcVerticalCrossing(MapChar.GetPos()); + + PlayerChar->SetShaderTranslateVector(pos); + PlayerChar->SetShaderRotateMatrix(MapChar.GetRotationMatrix()); + + timeForSeq += timer; + + if (timeForSeq >= 2000) + { + timeForSeq = 0; + + if (animSeq != 12) + { + animSeq = 12; + //animSeq+= 1; + + + if (animSeq >= 100) + { + animSeq = 0; + } + + //GirlText->ApplySequence("girl.an1", animSeq); + //GirlText->UpdateVBO(); + } + } + + + + + + //AnimModel->ApplySequence("bonemodel.an1", animSeq); + //AnimModel->UpdateVBO(); + + +} + +void TGameMap::PlayerClicked(int x, int y) +{ + /* + vec3 vecFrom, vecTo; + SalmonRender->GetVectorOutOfCursor(x, y, vecFrom, vecTo); + + vec3 r = Land->CalcCrossing(vecFrom, vecTo); + + MapChar.GoToDestination(r); + */ +} \ No newline at end of file diff --git a/Template/gameMap.h b/Template/gameMap.h new file mode 100644 index 0000000..1ea8948 --- /dev/null +++ b/Template/gameMap.h @@ -0,0 +1,66 @@ +#pragma once + +#include "SalmonEngineWindows.h" +#include +using namespace SE; + +typedef std::vector TLiteModelArr; + +class TMapCharacter +{ +protected: + + //Do not change them directly: + vec3 Pos; // y=0 here + + mat3 RotationMatrix; + vec3 Direction; // y=0 here + vec3 Destination; // y=0 here + vec3 VectorToDestination; + + float Velocity; + +public: + TMapCharacter(); + ~TMapCharacter() { } + + void SetPos(vec3& pos); + void GoToDestination(vec3& dest); + void Update(cardinal timer); + + vec3 GetPos(); + mat3 GetRotationMatrix(); + +}; + +class TGameMap +{ +protected: + TSimpleLandClass* Land; + + TLiteModelArr StaticModelArr; + + TLiteModel* PlayerChar; + TMapCharacter MapChar; + + + +public: + TGameMap() : Land(NULL), PlayerChar(NULL), AnimModel(NULL), GirlText(NULL) {}; + ~TGameMap() { FreeMap(); }; + + void LoadMap(); + void FreeMap(); + + TSimpleLandClass* GetLand(); + + void DrawVBO(); + void Update(cardinal timer); + + void PlayerClicked(int x, int y); + + TAnimModel* AnimModel; + TAnimModel* GirlText; + int animSeq; + +}; \ No newline at end of file diff --git a/Template/log.txt b/Template/log.txt new file mode 100644 index 0000000..bf536ec --- /dev/null +++ b/Template/log.txt @@ -0,0 +1,102 @@ +2024-Jun-06 15:57:24: Log started +2024-Jun-06 15:57:25: OpenGL Window created +2024-Jun-06 15:57:25: Script manager ready +2024-Jun-06 15:57:25: Render::OpenGL glVersion = 4.6.0 - Build 31.0.101.4887 +2024-Jun-06 15:57:25: Render::OpenGL glVersion above 2.0 ok +2024-Jun-06 15:57:25: Render::OpenGL GL_ARB_framebuffer_object supported ok +2024-Jun-06 15:57:25: Render::OpenGL GL_ARB_uniform_buffer_object supported ok +2024-Jun-06 15:57:25: Prepare to add shader GUI +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 3 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: GUI +2024-Jun-06 15:57:25: Prepare to add shader Parallax +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing +WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20 +WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20 +WARNING: 0:27: 'assign' : implicit type conversion allowed +2024-Jun-06 15:57:25: Shader program is - 6 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Parallax +2024-Jun-06 15:57:25: Prepare to add shader Directlight +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 9 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Directlight +2024-Jun-06 15:57:25: Prepare to add shader Env +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 12 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Env +2024-Jun-06 15:57:25: Prepare to add shader Water +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing +WARNING: 0:20: 'assign' : implicit type conversion allowed from GLSL 1.20 + + +2024-Jun-06 15:57:25: Shader program is - 15 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Water +2024-Jun-06 15:57:25: Prepare to add shader Frame +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 18 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Frame +2024-Jun-06 15:57:25: Prepare to add shader Lightview +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:5: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 21 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Lightview +2024-Jun-06 15:57:25: Prepare to add shader Simple3D +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing + + +2024-Jun-06 15:57:25: Shader program is - 24 +2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader +2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Simple3D +2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_box_yellow.bmp with id = 1 +2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_box_norm.bmp32 with id = 2 +2024-Jun-06 15:57:25: Lite model added successfully: models/bt_box_yellow.lm1 +2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_cone.bmp with id = 3 +2024-Jun-06 15:57:25: Lite model added successfully: models/bt_cone.lm1 +2024-Jun-06 15:57:25: Lite model added successfully: models/girl.lm1 +2024-Jun-06 15:57:25: Lite model added successfully: models/bonemodel.lm1 +2024-Jun-06 15:57:26: ResourceManager::TexList Texture added: out.bmp with id = 4 +2024-Jun-06 15:57:26: FrameManager:: frame buffer added: Skybox +2024-Jun-06 15:57:26: ResourceManager::TexList Texture added: normalmap.bmp with id = 6 +2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ScreenBlur +2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ShadowBufferGlobal +2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ShadowBufferLocal diff --git a/Template/main.cpp b/Template/main.cpp new file mode 100644 index 0000000..03539f9 --- /dev/null +++ b/Template/main.cpp @@ -0,0 +1,302 @@ +#include "main.h" + + +float CONST_CAM_ALPHA_MOUSE_SENSITIVETY = 0.005f; +float CONST_CAM_PHI_MOUSE_SENSITIVETY = 0.005f; + +float CONST_CAM_ZOOM_SENSITIVITY = 1.0f/120.0f; + +cardinal CONST_CUBEMAP_UPDATE_INTERVAL = 5000; + +void TMyApplication::DrawToCubemap() +{ + Renderer->PushShader("Directlight"); + + Renderer->SwitchToCubemapBuffer("Skybox",0); + Renderer->SetGlPosXView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToCubemapBuffer("Skybox",1); + Renderer->SetGlNegXView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToCubemapBuffer("Skybox",2); + Renderer->SetGlPosYView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToCubemapBuffer("Skybox",3); + Renderer->SetGlNegYView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToCubemapBuffer("Skybox",4); + Renderer->SetGlPosZView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToCubemapBuffer("Skybox",5); + Renderer->SetGlNegZView(); + DrawSceneWithoutWater(); + + Renderer->SwitchToScreen(); + + Renderer->PopShader(); +} + +void TMyApplication::DrawToShadowMap() +{ + + Renderer->PushShader("Lightview"); + + Renderer->BeginDrawToDepthBufferGlobal(std::string("ShadowBufferGlobal")); + DrawSceneWithoutWater(); + Renderer->BeginDrawToDepthBufferLocal(std::string("ShadowBufferLocal")); + DrawSceneWithoutWater(); + Renderer->EndDrawToDepthBuffer(); + + Renderer->PopShader(); +} + +void TMyApplication::DrawSceneWithoutWater() +{ + GameMap.DrawVBO(); +} + +void TMyApplication::DrawWaterSurface() +{ + + Renderer->PushShader("Water"); + + RenderUniform1f("WaterTimer", WaterTimer); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["normalmap.bmp"]); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_CUBE_MAP, ResourceManager->FrameManager.GetFrameTexture("Skybox")); + + glBegin(GL_POLYGON); + glTexCoord2f(2, 2); + glVertex3f(20, 0, 20); + glTexCoord2f(2, 0); + glVertex3f(20, 0, -20); + glTexCoord2f(0, 0); + glVertex3f(-20, 0, -20); + glTexCoord2f(0, 2); + glVertex3f(-20, 0, 20); + glEnd(); + + Renderer->PopShader(); +} + +//What to do on init +void TMyApplication::InnerInit() +{ + ResourceManager->PathToResources = "C:\\Work\\OldProjects\\ho3\\resources\\"; + + + ResourceManager->ShaderManager.AddShader("GUI", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment"); + ResourceManager->ShaderManager.AddShader("Parallax", "shaders/directlight_parallax_shadow.vertex", "shaders/directlight_parallax_shadow.fragment"); + ResourceManager->ShaderManager.AddShader("Directlight", "shaders/directlight.vertex", "shaders/directlight.fragment"); + ResourceManager->ShaderManager.AddShader("Env", "shaders/env.vertex", "shaders/env.fragment"); + ResourceManager->ShaderManager.AddShader("Water", "shaders/water.vertex", "shaders/water.fragment"); + ResourceManager->ShaderManager.AddShader("Frame", "shaders/frame.vertex", "shaders/frame.fragment"); + ResourceManager->ShaderManager.AddShader("Lightview", "shaders/lightview.vertex", "shaders/lightview.fragment"); + ResourceManager->ShaderManager.AddShader("Simple3D", "shaders/simple3d.vertex", "shaders/simple3d.fragment"); + + Renderer->SetBackgroundShader("Env"); + + Renderer->PushShader("Parallax"); + //Renderer->PushShader("GUI"); + + + ResourceManager->ModelManager.AddLiteModel("models/bt_box_yellow.lm1"); + ResourceManager->ModelManager.AddLiteModel("models/bt_cone.lm1"); + + ResourceManager->ModelManager.AddLiteModel("models/girl.lm1"); + ResourceManager->ModelAnimManager.AddAnimationToModel("girl.lm1","models/girl.bn2"); + ResourceManager->ModelAnimManager["girl.lm1"]->LoadAnimSequenceFromFileAn1("models/girl.an1"); + + ResourceManager->ModelManager.AddLiteModel("models/bonemodel.lm1"); + ResourceManager->ModelAnimManager.AddAnimationToModel("bonemodel.lm1","models/bonemodel.bn2"); + ResourceManager->ModelAnimManager["bonemodel.lm1"]->LoadAnimSequenceFromFileAn1("models/bonemodel.an1"); + + GameMap.LoadMap(); + + Renderer->SetLandToCalcCollision(GameMap.GetLand()); + + Renderer->MoveDist(15.0f); + Renderer->MovePhi(pi/6); + + + float len = 50.0f; + + //ResourceManager->LightManager.SetLightPos(0, vec4(-len * cos(pi/4), len * sin(pi/4), 0.0f, 0.0f)); + + ResourceManager->FrameManager.AddCubemapBuffer("Skybox",256,256); + + Renderer->SetBackgroundCubemap(ResourceManager->FrameManager.GetFrameTexture("Skybox")); + + ResourceManager->TexList.AddTexture("../resources/normalmap.bmp"); + + ResourceManager->FrameManager.AddFrameRenderBuffer("ScreenBlur", 512, 512); + ResourceManager->FrameManager.AddDepthBuffer("ShadowBufferGlobal", 512, 512); + + ResourceManager->FrameManager.AddDepthBuffer("ShadowBufferLocal", 1024, 1024); + + + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, ResourceManager->FrameManager.GetFrameTexture("ShadowBufferGlobal")); + glActiveTexture(GL_TEXTURE3); + glBindTexture(GL_TEXTURE_2D, ResourceManager->FrameManager.GetFrameTexture("ShadowBufferLocal")); + glActiveTexture(GL_TEXTURE0); + + glClearColor(0.2f, 0.5f, 1.0f, 1.0f); + + //Renderer->SetShadowClampValue(0.3f); + Renderer->SetShadowClampValue(0.0f); + + +} + + +//What to do on deinit +void TMyApplication::InnerDeinit() +{ + GameMap.FreeMap(); + ResourceManager->FrameManager.DeleteFrameRenderBuffer("Skybox"); +} + +//What to do on draw +void TMyApplication::InnerDraw() +{ + Renderer->SwitchToScreen(); + glClearColor(0.0f, 1.0f, 0.0f, 1.0f); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + + Renderer->PushShader("GUI"); + DrawSceneWithoutWater(); + Renderer->PopShader(); + + /* + DrawToCubemap(); + + DrawToShadowMap(); + + Renderer->SwitchToFrameBuffer(std::string("ScreenBlur")); + + DrawSceneWithoutWater(); + DrawWaterSurface(); + + + Renderer->SwitchToScreen(); + + Renderer->PushShader("Frame"); + Renderer->DrawFrameFullScreen(std::string("ScreenBlur")); + Renderer->PopShader();*/ + + + + /* + Renderer->SwitchToFrameBuffer(std::string("ScreenBlur")); + + Renderer->PushShader("GUI"); + DrawSceneWithoutWater(); + Renderer->PopShader(); + + Renderer->SwitchToScreen(); + + Renderer->PushShader("Frame"); + Renderer->DrawFrameFullScreen(std::string("ScreenBlur")); + Renderer->PopShader();*/ + + + +} + +//What to do on update. timer means how many ms passed since last update +void TMyApplication::InnerUpdate(cardinal timer) +{ + WaterTimer += 0.001f * timer; + + GameMap.Update(timer); + +} + +void TMyApplication::UpdateQuick() +{ + if (GetKeyState(VK_UP) >> 15) + { + Renderer->MoveForward(); + } + + if (GetKeyState(VK_DOWN) >> 15) + { + Renderer->MoveBackward(); + } + + if (GetKeyState(VK_LEFT) >> 15) + { + Renderer->MoveLeft(); + } + + if (GetKeyState(VK_RIGHT) >> 15) + { + Renderer->MoveRight(); + } +} + +void TMyApplication::OnMouseMove(TMouseState& mouseState) +{ + if (MouseRightButtonPressed) + { + int dx = mouseState.X - MouseX0; + int dy = mouseState.Y - MouseY0; + + MouseX0 = mouseState.X; + MouseY0 = mouseState.Y; + + Renderer->MoveAlpha(dx * CONST_CAM_ALPHA_MOUSE_SENSITIVETY); + Renderer->MovePhi(dy * CONST_CAM_PHI_MOUSE_SENSITIVETY); + } +} + +void TMyApplication::OnMouseDown(TMouseState& mouseState) +{ + if (mouseState.RightButtonPressed) + { + MouseRightButtonPressed = true; + MouseX0 = mouseState.X; + MouseY0 = mouseState.Y; + } + + if (mouseState.LeftButtonPressed) + { + MouseLeftButtonPressed = true; + } +} + +void TMyApplication::OnMouseUp(TMouseState& mouseState) +{ + + + MouseRightButtonPressed = false; + if (MouseLeftButtonPressed) + { + MouseLeftButtonPressed = false; + GameMap.PlayerClicked(mouseState.X, mouseState.Y); + } +} + +void TMyApplication::OnMouseWheel(short int delta) +{ + Renderer->MoveDist(-CONST_CAM_ZOOM_SENSITIVITY * delta); +} + + +int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, + LPSTR lpszCmdLine, int nCmdShow) +{ + //Create application + TMyApplication Application; + + //Start application + return MainLoop(Application); +} \ No newline at end of file diff --git a/Template/main.h b/Template/main.h new file mode 100644 index 0000000..d460324 --- /dev/null +++ b/Template/main.h @@ -0,0 +1,70 @@ +#pragma once + +/* Path to the engine */ +#include "SalmonEngineWindows.h" +#include "gameMap.h" + +using namespace SE; + +//Application class +class TMyApplication : public SE::TApplication +{ + /* + TLiteModel* lm; + TSimpleLandClass* TestLand; + glmat3 LiteModelRotateMatrix; + glmat3 LiteModelDeltaRotateMatrix; + cardinal LiteModelUpdateTimer; + */ + TGameMap GameMap; + + bool MouseRightButtonPressed; + //Rotate camera on mouse right button pressed + + bool MouseLeftButtonPressed; + + int MouseX0, MouseY0; + //Mouse pos caught on right button click + + float WaterTimer; + + void DrawSceneWithoutWater(); + + void DrawToCubemap(); + + void DrawToShadowMap(); + + void DrawWaterSurface(); + +public: + + //Constructor + TMyApplication() : MouseRightButtonPressed(false), MouseLeftButtonPressed(false), WaterTimer(0) { } + + virtual void InnerInit(); + //What to do on init + + virtual void InnerDeinit(); + //What to do on deinit + + virtual void InnerDraw(); + //What to do on draw + + virtual void InnerUpdate(cardinal timer); + //What to do on update. timer means how many ms passed since last update + + virtual void UpdateQuick(); + //To process input - this method is called more frequently than Update() + + virtual void OnMouseMove(TMouseState& mouseState); + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseDown(TMouseState& mouseState); + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseUp(TMouseState& mouseState); + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseWheel(short int delta); + //To do on mouse wheel move +}; \ No newline at end of file diff --git a/resources/landscapes/out.bmp b/resources/landscapes/out.bmp new file mode 100644 index 0000000..0251b4c Binary files /dev/null and b/resources/landscapes/out.bmp differ diff --git a/resources/landscapes/out.ls1 b/resources/landscapes/out.ls1 new file mode 100644 index 0000000..9ec435b Binary files /dev/null and b/resources/landscapes/out.ls1 differ diff --git a/resources/models/bonemodel.an1 b/resources/models/bonemodel.an1 new file mode 100644 index 0000000..d6b27d3 Binary files /dev/null and b/resources/models/bonemodel.an1 differ diff --git a/resources/models/bonemodel.bn1 b/resources/models/bonemodel.bn1 new file mode 100644 index 0000000..525c558 Binary files /dev/null and b/resources/models/bonemodel.bn1 differ diff --git a/resources/models/bonemodel.bn2 b/resources/models/bonemodel.bn2 new file mode 100644 index 0000000..21208b5 Binary files /dev/null and b/resources/models/bonemodel.bn2 differ diff --git a/resources/models/bonemodel.lm1 b/resources/models/bonemodel.lm1 new file mode 100644 index 0000000..97422fc Binary files /dev/null and b/resources/models/bonemodel.lm1 differ diff --git a/resources/models/bonemodel_.an1 b/resources/models/bonemodel_.an1 new file mode 100644 index 0000000..f680018 Binary files /dev/null and b/resources/models/bonemodel_.an1 differ diff --git a/resources/models/bt_box_norm.bmp32 b/resources/models/bt_box_norm.bmp32 new file mode 100644 index 0000000..86f1dba Binary files /dev/null and b/resources/models/bt_box_norm.bmp32 differ diff --git a/resources/models/bt_box_yellow.bmp b/resources/models/bt_box_yellow.bmp new file mode 100644 index 0000000..b7a2d6f Binary files /dev/null and b/resources/models/bt_box_yellow.bmp differ diff --git a/resources/models/bt_box_yellow.lm1 b/resources/models/bt_box_yellow.lm1 new file mode 100644 index 0000000..da0d955 Binary files /dev/null and b/resources/models/bt_box_yellow.lm1 differ diff --git a/resources/models/bt_cone.bmp b/resources/models/bt_cone.bmp new file mode 100644 index 0000000..9d1a3fd Binary files /dev/null and b/resources/models/bt_cone.bmp differ diff --git a/resources/models/bt_cone.lm1 b/resources/models/bt_cone.lm1 new file mode 100644 index 0000000..9e70996 Binary files /dev/null and b/resources/models/bt_cone.lm1 differ diff --git a/resources/models/girl.an1 b/resources/models/girl.an1 new file mode 100644 index 0000000..91efc85 Binary files /dev/null and b/resources/models/girl.an1 differ diff --git a/resources/models/girl.bn2 b/resources/models/girl.bn2 new file mode 100644 index 0000000..efd0f56 Binary files /dev/null and b/resources/models/girl.bn2 differ diff --git a/resources/models/girl.lm1 b/resources/models/girl.lm1 new file mode 100644 index 0000000..743cd63 Binary files /dev/null and b/resources/models/girl.lm1 differ diff --git a/resources/normalmap.bmp b/resources/normalmap.bmp new file mode 100644 index 0000000..e5e9142 Binary files /dev/null and b/resources/normalmap.bmp differ diff --git a/resources/shaders/Frame.fragment b/resources/shaders/Frame.fragment new file mode 100644 index 0000000..96d9b75 --- /dev/null +++ b/resources/shaders/Frame.fragment @@ -0,0 +1,23 @@ +uniform sampler2D Texture; + + +varying vec2 texCoord; + +void main() +{ + float xstep = 0.5f/800.0f; + float ystep = 0.5f/600.0f; + + vec4 texColor = + vec4(texture2D(Texture,texCoord).rgb,1.0) * 0.2 + + vec4(texture2D(Texture, vec2(texCoord.x+xstep, texCoord.y+ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x-xstep, texCoord.y+ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x-xstep, texCoord.y-ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x+xstep, texCoord.y-ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x, texCoord.y+2.0*ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x, texCoord.y-2.0*ystep)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x-2.0*xstep, texCoord.y)).rgb,1.0) * 0.1 + + vec4(texture2D(Texture, vec2(texCoord.x+2.0*xstep, texCoord.y)).rgb,1.0) * 0.1; + + gl_FragColor = texColor; +} diff --git a/resources/shaders/Frame.vertex b/resources/shaders/Frame.vertex new file mode 100644 index 0000000..08e1ab9 --- /dev/null +++ b/resources/shaders/Frame.vertex @@ -0,0 +1,7 @@ +varying vec2 texCoord; + +void main() +{ + gl_Position = ftransform(); + texCoord = gl_MultiTexCoord0.st; +} \ No newline at end of file diff --git a/resources/shaders/NIU/directlight_bump.fragment b/resources/shaders/NIU/directlight_bump.fragment new file mode 100644 index 0000000..a272935 --- /dev/null +++ b/resources/shaders/NIU/directlight_bump.fragment @@ -0,0 +1,38 @@ +uniform sampler2D Texture; +uniform sampler2D NormalMap; +uniform int NormalMapExists; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +void main() +{ + vec3 norm; + + vec4 ambient; + vec4 diffuse; + vec4 specular; + + vec3 TexRGB = texture2D(Texture, texCoord.st).rgb; + + vec3 cVec = normalize(camVec); + + if (NormalMapExists == 0) + { + norm = vec3(0.0,0.0,1.0); + } + else + { + norm = (texture2D(NormalMap, texCoord.st).rgb - 0.5) * 2.0; + } + + float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); + + ambient = gl_LightSource[0].ambient; + diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * max( dot(lightVec,norm),0.0); + specular = gl_LightSource[0].specular * shineFactor; + + gl_FragColor = vec4(TexRGB,1.0)*ambient+(vec4(TexRGB,1.0)*diffuse+specular); + +} diff --git a/resources/shaders/NIU/directlight_bump.vertex b/resources/shaders/NIU/directlight_bump.vertex new file mode 100644 index 0000000..5af98cd --- /dev/null +++ b/resources/shaders/NIU/directlight_bump.vertex @@ -0,0 +1,35 @@ +/* +Bump mapping shader without parallax mapping for single directional light source +The fastest shader for bump mapping + +*/ + +uniform vec3 CamPos; +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +attribute vec3 Tangent; +attribute vec3 Binormal; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0); + texCoord = gl_MultiTexCoord0.st; + + vec3 lVec = normalize(gl_LightSource[0].position.xyz); + vec3 cVec = (CamPos - gl_Vertex.xyz); + + mat3 rot; + rot[0] = Tangent; + rot[1] = Binormal; + rot[2] = gl_Normal.xyz; + + rot = ModelRotateMatrix * rot; + + lightVec = lVec * rot; + camVec = cVec * rot; +} \ No newline at end of file diff --git a/resources/shaders/NIU/directlight_bump_simple_shadow.fragment b/resources/shaders/NIU/directlight_bump_simple_shadow.fragment new file mode 100644 index 0000000..5221038 --- /dev/null +++ b/resources/shaders/NIU/directlight_bump_simple_shadow.fragment @@ -0,0 +1,72 @@ +/* +Bump mapping shader without parallax mapping but with shadows for single directional light source +*/ + +uniform sampler2D Texture; +uniform sampler2D NormalMap; +uniform int NormalMapExists; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +//For shadows +uniform sampler2D ShadowMap; +uniform float ShadowDepth; + +varying vec4 vPos; +varying vec4 gPos; + +float shadowCoef() +{ + + vec4 shadow_coord = gl_TextureMatrix[2]*vPos; + + shadow_coord.w = shadow_coord.z; + + // get the stored depth + float shadow_d = texture2D(ShadowMap, shadow_coord.xy).x; + + // get the difference of the stored depth and the distance of this fragment to the light + float diff = min(shadow_d - shadow_coord.z,0.0); + + float shadow_coef = clamp( 20*ShadowDepth*diff + 1.0, 0.0, 1.0); //[0..1] + + return shadow_coef; +} + +void main() +{ + + vec3 norm; + + vec4 ambient; + vec4 diffuse; + vec4 specular; + + vec3 TexRGB = texture2D(Texture, texCoord.st).rgb; + + vec3 cVec = normalize(camVec); + + if (NormalMapExists == 0) + { + norm = vec3(0.0,0.0,1.0); + } + else + { + norm = (texture2D(NormalMap, texCoord.st).rgb - 0.5) * 2.0; + } + + float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); + + float shadow_coef = shadowCoef(); + + ambient = gl_LightSource[0].ambient; + diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * min( max(dot(lightVec,norm),0.0),shadow_coef); + specular = gl_LightSource[0].specular * min(shineFactor,shadow_coef); + + + gl_FragColor = vec4(TexRGB,1.0)*max(ambient,diffuse)+specular; + + +} diff --git a/resources/shaders/NIU/directlight_bump_simple_shadow.vertex b/resources/shaders/NIU/directlight_bump_simple_shadow.vertex new file mode 100644 index 0000000..ae71eca --- /dev/null +++ b/resources/shaders/NIU/directlight_bump_simple_shadow.vertex @@ -0,0 +1,44 @@ +/* +Bump mapping shader without parallax mapping but with shadows for single directional light source +*/ + +uniform vec3 CamPos; +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +attribute vec3 Tangent; +attribute vec3 Binormal; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +//for fragment shader +varying vec4 vPos; +varying vec4 gPos; + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0); + gl_Position = gl_ModelViewProjectionMatrix * realVertexPos; + + texCoord = gl_MultiTexCoord0.st; + + vec3 lVec = normalize(gl_LightSource[0].position.xyz); + vec3 cVec = (CamPos - gl_Vertex.xyz); + + mat3 rot; + rot[0] = Tangent; + rot[1] = Binormal; + rot[2] = gl_Normal.xyz; + + rot = ModelRotateMatrix * rot; + + lightVec = lVec * rot; + camVec = cVec * rot; + + //For shadows + vPos = realVertexPos; + gPos = gl_ProjectionMatrix * gl_Position; + gl_TexCoord[0] = gl_MultiTexCoord0; +} \ No newline at end of file diff --git a/resources/shaders/NIU/directlight_parallax_simple_shadow.fragment b/resources/shaders/NIU/directlight_parallax_simple_shadow.fragment new file mode 100644 index 0000000..8d84267 --- /dev/null +++ b/resources/shaders/NIU/directlight_parallax_simple_shadow.fragment @@ -0,0 +1,78 @@ +uniform sampler2D Texture; +uniform sampler2D NormalMap; +uniform int NormalMapExists; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +//For shadows +uniform sampler2D ShadowMap; +uniform float ShadowDepth; + +varying vec4 vPos; +varying vec4 gPos; + +float shadowCoef() +{ + + vec4 shadow_coord = gl_TextureMatrix[2]*vPos; + + shadow_coord.w = shadow_coord.z; + + // get the stored depth + float shadow_d = texture2D(ShadowMap, shadow_coord.xy).x; + + // get the difference of the stored depth and the distance of this fragment to the light + float diff = min(shadow_d - shadow_coord.z,0.0); + + float shadow_coef = clamp( 20*ShadowDepth*diff + 1.0, 0.0, 1.0); //[0..1] + + return shadow_coef; +} + +void main() +{ + vec3 lVec = lightVec; + vec3 cVec = normalize(camVec); + + vec4 ambient; + vec4 diffuse; + vec4 specular; + + float parallax = 0.035; + + //double refinement + float height = texture2D(NormalMap, texCoord.xy).a; + float offset = parallax * (2.0 * height - 1.0); + vec2 parallaxTexCoord = texCoord.xy + offset * cVec.xy; + height += texture2D(NormalMap, parallaxTexCoord).a; + + offset = parallax * (height - 1.0); + + parallaxTexCoord = texCoord.xy + offset * cVec.xy; + + //go-go-go + vec3 TexRGB = texture2D(Texture, parallaxTexCoord).xyz; + vec3 norm; + if (NormalMapExists == 0) + { + norm = vec3(0.0,0.0,1.0); + } + else + { + norm = texture2D(NormalMap, parallaxTexCoord).xyz * 2.0 - 1.0; + } + + float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); + + float shadow_coef = shadowCoef(); + + ambient = gl_LightSource[0].ambient; + diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * min( max(dot(lightVec,norm),0.0),shadow_coef); + specular = gl_LightSource[0].specular * min(shineFactor,shadow_coef); + + + gl_FragColor = vec4(TexRGB,1.0)*max(ambient,diffuse)+specular; + +} \ No newline at end of file diff --git a/resources/shaders/NIU/directlight_parallax_simple_shadow.vertex b/resources/shaders/NIU/directlight_parallax_simple_shadow.vertex new file mode 100644 index 0000000..5eb16f8 --- /dev/null +++ b/resources/shaders/NIU/directlight_parallax_simple_shadow.vertex @@ -0,0 +1,46 @@ +/* +Bump/parallax mapping shader for single directional light source +The fastest shader for bump/bump mapping + +*/ + +uniform vec3 CamPos; +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +attribute vec3 Tangent; +attribute vec3 Binormal; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; + +//for fragment shader +varying vec4 vPos; +varying vec4 gPos; + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0); + gl_Position = gl_ModelViewProjectionMatrix * realVertexPos; + + texCoord = gl_MultiTexCoord0.st; + + vec3 lVec = normalize(gl_LightSource[0].position.xyz); + vec3 cVec = (CamPos - gl_Vertex.xyz); + + mat3 rot; + rot[0] = Tangent; + rot[1] = Binormal; + rot[2] = gl_Normal.xyz; + + rot = ModelRotateMatrix * rot; + + lightVec = lVec * rot; + camVec = cVec * rot; + + //For shadows + vPos = realVertexPos; + gPos = gl_ProjectionMatrix * gl_Position; + gl_TexCoord[0] = gl_MultiTexCoord0; +} diff --git a/resources/shaders/NIU/lightview.fragment b/resources/shaders/NIU/lightview.fragment new file mode 100644 index 0000000..fbaeb2f --- /dev/null +++ b/resources/shaders/NIU/lightview.fragment @@ -0,0 +1,4 @@ +void main() +{ + gl_FragColor = vec4(1.0,1.0,1.0,1.0); +} \ No newline at end of file diff --git a/resources/shaders/NIU/lightview.vertex b/resources/shaders/NIU/lightview.vertex new file mode 100644 index 0000000..9da8095 --- /dev/null +++ b/resources/shaders/NIU/lightview.vertex @@ -0,0 +1,12 @@ +/* Shader to draw nothing. This shader is used when render scene to depth buffer only + For example, to make depth texture from light source position +*/ + +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0); + gl_Position = gl_ModelViewProjectionMatrix * realVertexPos; +} \ No newline at end of file diff --git a/resources/shaders/NIU/multilight_bump.fragment b/resources/shaders/NIU/multilight_bump.fragment new file mode 100644 index 0000000..0be610c --- /dev/null +++ b/resources/shaders/NIU/multilight_bump.fragment @@ -0,0 +1,43 @@ +uniform sampler2D Texture; +uniform sampler2D NormalMap; +uniform int NormalMapExists; + +varying vec2 texCoord; +varying int activeLightCount; +varying vec3 camVec; +varying vec3 lightVec[8]; + +void main() +{ + vec3 norm; + + vec4 ambient; + vec4 diffuse; + vec4 specular; + + vec3 cVec = normalize(camVec); + vec3 lVec; + + vec3 TexRGB = texture2D(Texture, texCoord.st).rgb; + if (NormalMapExists == 0) + { + norm = vec3(0.0,0.0,1.0); + } + else + { + norm = (texture2D(NormalMap, texCoord.st).rgb - 0.5) * 2.0; + } + float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); + + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + + for (int i=0; i 1.0 + || shadow_coord.y < 0.0 || shadow_coord.y > 1.0) + { + shadow_coord = gl_TextureMatrix[2]*vPos; + + shadow_coord.w = shadow_coord.z; + + pcf = CalcPCFGlobal(shadow_coord); + + } + + else + { + shadow_coord.w = shadow_coord.z; + + pcf = CalcPCFLocal(shadow_coord); + } + return clamp(1.0 - pcf, ShadowClampValue, 1.0); +} + +float CalcPCFGlobal(vec4 shadowCoord) +{ + float diff; + float shadow_d; + vec3 shadow_coord = shadowCoord.xyz; + + shadow_d = texture2D(ShadowMapGlobal, shadow_coord.xy).x; + diff = clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.x += 0.001; + shadow_d = texture2D(ShadowMapGlobal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x -= 0.001; + shadow_d = texture2D(ShadowMapGlobal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.y += 0.001; + shadow_d = texture2D(ShadowMapGlobal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.y -= 0.001; + shadow_d = texture2D(ShadowMapGlobal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + return diff*0.2; +} + +float CalcPCFLocal(vec4 shadowCoord) +{ + float diff; + float shadow_d; + vec3 shadow_coord; + shadow_coord = shadowCoord.xyz; + + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff = clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x += 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x -= 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.y += 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.y -= 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x += 0.001; + shadow_coord.y += 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x -= 0.001; + shadow_coord.y += 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x += 0.001; + shadow_coord.y -= 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + shadow_coord.xy = shadowCoord.xy; + shadow_coord.x -= 0.001; + shadow_coord.y -= 0.001; + shadow_coord.xy = shadow_coord.xy + myrand2(shadow_coord.xy)*0.004; + shadow_d = texture2D(ShadowMapLocal, shadow_coord.xy).x; + diff += clamp(60000*(shadow_d - shadow_coord.z+0.004), 0.0, 1.0); + + return diff*0.11; +} + +void main() +{ + vec3 lVec = lightVec; + vec3 cVec = normalize(camVec); + + float parallax = 0.035; + + //double refinement + float height; + float offset; + vec2 parallaxTexCoord; + if (NormalMapExists != 0) + { + height = texture2D(NormalMap, texCoord.xy).a; + offset = parallax * (2.0 * height - 1.0); + parallaxTexCoord = texCoord.xy + offset * cVec.xy; + height += texture2D(NormalMap, parallaxTexCoord).a; + + offset = parallax * (height - 1.0); + + parallaxTexCoord = texCoord.xy + offset * cVec.xy; + } + else + { + parallaxTexCoord = texCoord.xy; + } + + //go-go-go + vec3 TexRGB = texture2D(Texture, parallaxTexCoord).xyz; + + vec3 norm; + + norm = (1-NormalMapExists) * vec3(0.0,0.0,1.0) + NormalMapExists*(texture2D(NormalMap, parallaxTexCoord).xyz * 2.0 - 1.0); + + float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); + + float light_coef; + + if (lightVec.z <= 0.2) + { + light_coef = 1.0; + } + else + { + light_coef = 1.0 - shadowCoef(); + } + + vec4 ambient = gl_LightSource[0].ambient; + vec4 diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * min( max(dot(lVec,norm),0.0), light_coef); + vec4 specular = gl_LightSource[0].specular * min(shineFactor, light_coef); + + float fogFactor = min(max(max(abs(vertexPos.x)-FogBeginDistance, abs(vertexPos.z)-FogBeginDistance),0.0)/(FogEndDistance - FogBeginDistance),1.0); + + gl_FragColor = mix(vec4(TexRGB,1.0)*ambient+(vec4(TexRGB,1.0)*diffuse+specular), FogColor, fogFactor); + +} \ No newline at end of file diff --git a/resources/shaders/directlight_parallax_shadow.vertex b/resources/shaders/directlight_parallax_shadow.vertex new file mode 100644 index 0000000..59d6215 --- /dev/null +++ b/resources/shaders/directlight_parallax_shadow.vertex @@ -0,0 +1,48 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; + +uniform vec3 CamPos; +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +uniform mat4 ProjectionMatrix; +uniform mat4 ProjectionMatrix1; + +attribute vec3 Tangent; +attribute vec3 Binormal; + +varying vec2 texCoord; +varying vec3 camVec; +varying vec3 lightVec; +varying vec3 vertexPos; + +//For shadows +varying vec4 vPos; +varying vec4 gPos; + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0); + gl_Position = ProjectionMatrix * realVertexPos; + + texCoord = gl_MultiTexCoord0.st; + + vec3 lVec = normalize(gl_LightSource[0].position.xyz); + vec3 cVec = (CamPos - vPosition.xyz); + + vertexPos = vPosition.xyz; + + mat3 rot; + rot[0] = normalize(Tangent); + rot[1] = normalize(Binormal); + rot[2] = normalize(gl_Normal.xyz); + + rot = ModelRotateMatrix * rot; + + lightVec = lVec * rot; + camVec = cVec * rot; + + //For shadows + vPos = realVertexPos; + gPos = ProjectionMatrix1 * vec4(vPosition.xyz, 1.0); +} \ No newline at end of file diff --git a/resources/shaders/env.fragment b/resources/shaders/env.fragment new file mode 100644 index 0000000..13b5a62 --- /dev/null +++ b/resources/shaders/env.fragment @@ -0,0 +1,8 @@ +uniform samplerCube Env; + +varying vec3 dir; + +void main(){ + gl_FragColor = textureCube(Env, dir); + +} \ No newline at end of file diff --git a/resources/shaders/env.vertex b/resources/shaders/env.vertex new file mode 100644 index 0000000..fc565c8 --- /dev/null +++ b/resources/shaders/env.vertex @@ -0,0 +1,7 @@ +varying vec3 dir; + +void main(){ + gl_Position = ftransform(); + + dir = gl_Vertex.xyz; +} \ No newline at end of file diff --git a/resources/shaders/gui_transparent.fragment b/resources/shaders/gui_transparent.fragment new file mode 100644 index 0000000..96b6642 --- /dev/null +++ b/resources/shaders/gui_transparent.fragment @@ -0,0 +1,10 @@ +uniform sampler2D Texture; + +varying vec2 texCoord; + +void main() +{ + vec4 texColor = texture2D(Texture,texCoord).rgba; + gl_FragColor = vec4(texColor.rgb,gl_FrontMaterial.diffuse.a * texColor.a); + +} diff --git a/resources/shaders/gui_transparent.vertex b/resources/shaders/gui_transparent.vertex new file mode 100644 index 0000000..069716f --- /dev/null +++ b/resources/shaders/gui_transparent.vertex @@ -0,0 +1,11 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; + +uniform mat4 ProjectionMatrix; + +void main() +{ + gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); + texCoord = vTexCoord.st; +} \ No newline at end of file diff --git a/resources/shaders/lightview.fragment b/resources/shaders/lightview.fragment new file mode 100644 index 0000000..fbaeb2f --- /dev/null +++ b/resources/shaders/lightview.fragment @@ -0,0 +1,4 @@ +void main() +{ + gl_FragColor = vec4(1.0,1.0,1.0,1.0); +} \ No newline at end of file diff --git a/resources/shaders/lightview.vertex b/resources/shaders/lightview.vertex new file mode 100644 index 0000000..024ebdc --- /dev/null +++ b/resources/shaders/lightview.vertex @@ -0,0 +1,17 @@ +/* Shader to draw nothing. This shader is used when render scene to depth buffer only + For example, to make depth texture from light source position +*/ + +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +attribute vec3 vPosition; + +uniform mat4 ProjectionMatrix; + + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0); + gl_Position = ProjectionMatrix * realVertexPos; +} \ No newline at end of file diff --git a/resources/shaders/simple3d.fragment b/resources/shaders/simple3d.fragment new file mode 100644 index 0000000..6a7f564 --- /dev/null +++ b/resources/shaders/simple3d.fragment @@ -0,0 +1,10 @@ +uniform sampler2D Texture; + +varying vec2 texCoord; + +void main() +{ + vec4 texColor = texture2D(Texture,texCoord).rgba; + gl_FragColor = vec4(texColor.rgb, 1.0); + +} diff --git a/resources/shaders/simple3d.vertex b/resources/shaders/simple3d.vertex new file mode 100644 index 0000000..808ca2e --- /dev/null +++ b/resources/shaders/simple3d.vertex @@ -0,0 +1,16 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; + +uniform mat4 ProjectionMatrix; +uniform mat3 ModelRotateMatrix; +uniform vec3 ModelTranslateVector; + +void main() +{ + vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0); + gl_Position = ProjectionMatrix * realVertexPos; + + texCoord = vTexCoord.st; + +} \ No newline at end of file diff --git a/resources/shaders/texonly.fragment b/resources/shaders/texonly.fragment new file mode 100644 index 0000000..96b6642 --- /dev/null +++ b/resources/shaders/texonly.fragment @@ -0,0 +1,10 @@ +uniform sampler2D Texture; + +varying vec2 texCoord; + +void main() +{ + vec4 texColor = texture2D(Texture,texCoord).rgba; + gl_FragColor = vec4(texColor.rgb,gl_FrontMaterial.diffuse.a * texColor.a); + +} diff --git a/resources/shaders/texonly.vertex b/resources/shaders/texonly.vertex new file mode 100644 index 0000000..069716f --- /dev/null +++ b/resources/shaders/texonly.vertex @@ -0,0 +1,11 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; + +uniform mat4 ProjectionMatrix; + +void main() +{ + gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); + texCoord = vTexCoord.st; +} \ No newline at end of file diff --git a/resources/shaders/water.fragment b/resources/shaders/water.fragment new file mode 100644 index 0000000..6ac22f2 --- /dev/null +++ b/resources/shaders/water.fragment @@ -0,0 +1,45 @@ +uniform samplerCube Env; +uniform sampler2D NormalMap; +uniform vec3 CamPos; +uniform float WaterTimer; + + +varying vec3 camVec; + + +void main() +{ + vec2 texCoord = gl_TexCoord[0].st; + + mat3 rot; + + rot[0] = vec3(0.0,0.0,1.0); + rot[1] = vec3(1.0,0.0,0.0); + rot[2] = vec3(0.0,1.0,0.0); + + float sinx = 0.025*sin(WaterTimer+texCoord.x*5); + + vec3 NVec1 = texture2D(NormalMap, vec2(-WaterTimer*0.04 + texCoord.x + sinx, -WaterTimer*0.04 + texCoord.y - sinx)).rgb; + vec3 NVec2 = texture2D(NormalMap, vec2( WaterTimer*0.04 + texCoord.y - sinx, -WaterTimer*0.04 + (1.0-texCoord.x) + sinx)).rgb; + + NVec1 = (NVec1 -0.5) * 2.0; + NVec2 = (NVec2 -0.5) * 2.0; + + vec3 NVec = NVec1 + NVec2; + vec3 NVecReflect = normalize(rot * (NVec1 + NVec2) + vec3(0,8,0)); + vec3 NVecRefract = normalize(rot * (NVec1 + NVec2)); + + vec3 dir1 = reflect((camVec),NVecReflect); + //vec3 dir2 = refract((camVec),NVecRefract,0.9); + vec3 dir2 = reflect((camVec),NVecReflect); + dir2.y = - dir2.y; + + vec4 reflectColor = textureCube(Env, dir1); + vec4 refractColor = textureCube(Env, dir2); + + vec4 texColor = reflectColor*0.2 + refractColor*0.8; + + gl_FragColor = vec4(texColor.xyz, 1.0f); + + +} \ No newline at end of file diff --git a/resources/shaders/water.vertex b/resources/shaders/water.vertex new file mode 100644 index 0000000..75111d6 --- /dev/null +++ b/resources/shaders/water.vertex @@ -0,0 +1,13 @@ +uniform vec3 CamPos; + +varying vec3 camVec; + +void main() +{ + gl_Position = ftransform(); + + gl_TexCoord[0] = gl_MultiTexCoord0; + + camVec = (gl_Vertex.xyz - CamPos); + +} \ No newline at end of file