diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed30eb7e08e..d56d3b394a1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1001,6 +1001,8 @@ add_library(GPU OBJECT GPU/Common/IndexGenerator.h GPU/Common/TextureDecoder.cpp GPU/Common/TextureDecoder.h + GPU/Common/PostShader.cpp + GPU/Common/PostShader.h GPU/Common/SplineCommon.h GPU/GLES/GLES_GPU.cpp GPU/GLES/GLES_GPU.h diff --git a/Core/Config.cpp b/Core/Config.cpp index acf70ca22775..561e1eb5201f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -179,7 +179,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) graphics->Get("DisableStencilTest", &bDisableStencilTest, false); graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false); graphics->Get("LowQualitySplineBezier", &bLowQualitySplineBezier, false); - graphics->Get("FXAA", &bFXAA, false); + graphics->Get("PostShader", &sPostShaderName, "Off"); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Get("Enable", &bEnableSound, true); @@ -349,7 +349,7 @@ void Config::Save() { graphics->Set("DisableStencilTest", bDisableStencilTest); graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite); graphics->Set("LowQualitySplineBezier", bLowQualitySplineBezier); - graphics->Set("FXAA", bFXAA); + graphics->Set("PostShader", sPostShaderName); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Set("Enable", bEnableSound); diff --git a/Core/Config.h b/Core/Config.h index fab4404cd74d..60ce07341249 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -94,7 +94,7 @@ struct Config { bool bDisableStencilTest; bool bAlwaysDepthWrite; bool bLowQualitySplineBezier; - bool bFXAA; + std::string sPostShaderName; // Off for off. // Sound bool bEnableSound; diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp new file mode 100644 index 000000000000..8a1f623b544e --- /dev/null +++ b/GPU/Common/PostShader.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + + +// Postprocessing shader manager + +#include +#include + +#include "base/logging.h" +#include "file/ini_file.h" +#include "file/file_util.h" +#include "file/vfs.h" + +#include "GPU/Common/PostShader.h" + +static std::vector shaderInfo; + +// Scans the directories for shader ini files and collects info about all the shaders found. +// Additionally, scan the VFS assets. (TODO) + +void LoadPostShaderInfo(std::vector directories) { + shaderInfo.clear(); + ShaderInfo off; + off.name = "Off"; + off.section = "Off"; + shaderInfo.push_back(off); + + for (size_t d = 0; d < directories.size(); d++) { + std::vector fileInfo; + getFilesInDir(directories[d].c_str(), &fileInfo, "ini:"); + if (fileInfo.size() == 0) { + // TODO: Really gotta fix the filter, now it's gonna open shaders as ini files.. + VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:"); + } + + for (size_t f = 0; f < fileInfo.size(); f++) { + IniFile ini; + bool success = false; + std::string name = fileInfo[f].fullName; + std::string path = directories[d]; + // Hack around Android VFS path bug. really need to redesign this. + if (name.substr(0, 7) == "assets/") + name = name.substr(7); + if (path.substr(0, 7) == "assets/") + path = path.substr(7); + if (!ini.LoadFromVFS(name)) { + // vsh load. meh. + } else { + success = true; + } + if (!success) + continue; + + // Alright, let's loop through the sections and see if any is a shader. + // Ignore the first section (which only consists of the comments before the first real one). + for (size_t i = 1; i < ini.Sections().size(); i++) { + IniFile::Section §ion = ini.Sections()[i]; + if (section.Exists("Fragment") && section.Exists("Vertex")) { + // Valid shader! + ShaderInfo info; + std::string temp; + info.section = section.name(); + section.Get("Name", &info.name, section.name().c_str()); + section.Get("Fragment", &temp, ""); + info.fragmentShaderFile = path + "/" + temp; + section.Get("Vertex", &temp, ""); + info.vertexShaderFile = path + "/" + temp; + shaderInfo.push_back(info); + } + } + } + } +} + +// Scans the directories for shader ini files and collects info about all the shaders found. +void LoadAllPostShaderInfo() { + std::vector directories; + directories.push_back("assets/shaders"); + LoadPostShaderInfo(directories); +} + +const ShaderInfo *GetPostShaderInfo(std::string name) { + LoadAllPostShaderInfo(); + for (size_t i = 0; i < shaderInfo.size(); i++) { + if (shaderInfo[i].section == name) + return &shaderInfo[i]; + } + return 0; +} + +const std::vector &GetAllPostShaderInfo() { + LoadAllPostShaderInfo(); + return shaderInfo; +} \ No newline at end of file diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h new file mode 100644 index 000000000000..40d0c50e03c7 --- /dev/null +++ b/GPU/Common/PostShader.h @@ -0,0 +1,41 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + + +// Postprocessing shader manager +// For FXAA, "Natural", bloom, B&W, cross processing and whatnot. + +#include +#include + +#include "file/ini_file.h" + +struct ShaderInfo { + std::string iniFile; // which ini file was this definition in? So we can write settings back later + std::string section; // ini file section. This is saved. + std::string name; // Fancy display name. TODO: Not using yet. + + std::string fragmentShaderFile; + std::string vertexShaderFile; + + // TODO: Add support for all kinds of fun options like mapping the depth buffer, + // SRGB texture reads, multiple shaders chained, etc. +}; + +const ShaderInfo *GetPostShaderInfo(std::string name); + +const std::vector &GetAllPostShaderInfo(); \ No newline at end of file diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 729ceb69568f..f28cb2d8fe52 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -29,6 +29,7 @@ #include "GPU/ge_constants.h" #include "GPU/GPUState.h" +#include "GPU/Common/PostShader.h" #include "GPU/GLES/Framebuffer.h" #include "GPU/GLES/TextureCache.h" #include "GPU/GLES/ShaderManager.h" @@ -172,23 +173,31 @@ void FramebufferManager::CompileDraw2DProgram() { glUniform1i(draw2dprogram_->sampler0, 0); SetNumExtraFBOs(0); - if (g_Config.bFXAA) { - useFXAA_ = true; - fxaaProgram_ = glsl_create("shaders/fxaa.vsh", "shaders/fxaa.fsh"); - if (!fxaaProgram_) { - ERROR_LOG(G3D, "Failed to build FXAA program"); - useFXAA_ = false; + + const ShaderInfo *shaderInfo = 0; + if (g_Config.sPostShaderName != "Off") { + shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName); + } + + if (shaderInfo) { + postShaderProgram_ = glsl_create(shaderInfo->vertexShaderFile.c_str(), shaderInfo->fragmentShaderFile.c_str()); + if (!postShaderProgram_) { + ERROR_LOG(G3D, "Failed to build post-processing program"); + usePostShader_ = false; } else { - glsl_bind(fxaaProgram_); - glUniform1i(fxaaProgram_->sampler0, 0); + glsl_bind(postShaderProgram_); + glUniform1i(postShaderProgram_->sampler0, 0); SetNumExtraFBOs(1); float u_delta = 1.0f / PSP_CoreParameter().renderWidth; float v_delta = 1.0f / PSP_CoreParameter().renderHeight; - glUniform2f(glsl_uniform_loc(fxaaProgram_, "u_texcoordDelta"), u_delta, v_delta); + int deltaLoc = glsl_uniform_loc(postShaderProgram_, "u_texcoordDelta"); + if (deltaLoc != -1) + glUniform2f(deltaLoc, u_delta, v_delta); + usePostShader_ = true; } } else { - fxaaProgram_ = 0; - useFXAA_ = false; + postShaderProgram_ = 0; + usePostShader_ = false; } glsl_unbind(); @@ -200,9 +209,9 @@ void FramebufferManager::DestroyDraw2DProgram() { glsl_destroy(draw2dprogram_); draw2dprogram_ = 0; } - if (fxaaProgram_) { - glsl_destroy(fxaaProgram_); - fxaaProgram_ = 0; + if (postShaderProgram_) { + glsl_destroy(postShaderProgram_); + postShaderProgram_ = 0; } } @@ -219,10 +228,10 @@ FramebufferManager::FramebufferManager() : drawPixelsTexFormat_(GE_FORMAT_INVALID), convBuf(0), draw2dprogram_(0), - fxaaProgram_(0), + postShaderProgram_(0), textureCache_(0), shaderManager_(0), - useFXAA_(false) + usePostShader_(false) #ifndef USING_GLES2 , pixelBufObj_(0), @@ -812,7 +821,7 @@ void FramebufferManager::CopyDisplayToOutput() { // TODO ES3: Use glInvalidateFramebuffer to discard depth/stencil data at the end of frame. // and to discard extraFBOs_ after using them. - if (useFXAA_ && extraFBOs_.size() == 1) { + if (usePostShader_ && extraFBOs_.size() == 1) { glBindTexture(GL_TEXTURE_2D, colorTexture); // An additional pass, FXAA to the extra FBO. @@ -820,7 +829,7 @@ void FramebufferManager::CopyDisplayToOutput() { int fbo_w, fbo_h; fbo_get_dimensions(extraFBOs_[0], &fbo_w, &fbo_h); glstate.viewport.set(0, 0, fbo_w, fbo_h); - DrawActiveTexture(0, 0, fbo_w, fbo_h, fbo_w, fbo_h, true, 1.0f, 1.0f, fxaaProgram_); + DrawActiveTexture(0, 0, fbo_w, fbo_h, fbo_w, fbo_h, true, 1.0f, 1.0f, postShaderProgram_); fbo_unbind(); diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 0b8d76e60b47..1022824ed697 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -216,11 +216,11 @@ class FramebufferManager { u8 *convBuf; GLSLProgram *draw2dprogram_; - GLSLProgram *fxaaProgram_; + GLSLProgram *postShaderProgram_; TextureCache *textureCache_; ShaderManager *shaderManager_; - bool useFXAA_; + bool usePostShader_; // Used by antialiasing std::vector extraFBOs_; diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 3cc20ae96315..573949a74fe7 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -157,6 +157,7 @@ + @@ -200,6 +201,7 @@ + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index 56d1d341e926..473a66fe6e52 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -147,6 +147,7 @@ Common + @@ -266,6 +267,7 @@ Common + diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5241a424dc06..df141ce1ac56 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -138,9 +138,12 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gs->T("VSync"))); graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen"))); #endif - graphicsSettings->Add(new ItemHeader(gs->T("Antialiasing"))); + + graphicsSettings->Add(new ItemHeader(gs->T("Antialiasing and postprocessing"))); + graphicsSettings->Add(new Choice(gs->T("Postprocessing shader")))->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader); + // In case we're going to add few other antialiasing option like MSAA in the future. - graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gs->T("FXAA"))); + // graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gs->T("FXAA"))); graphicsSettings->Add(new ItemHeader(gs->T("Overlay Information"))); graphicsSettings->Add(new PopupMultiChoice(&g_Config.iShowFPSCounter, gs->T("Show FPS Counter"), fpsChoices, 0, ARRAY_SIZE(fpsChoices), gs, screenManager())); graphicsSettings->Add(new CheckBox(&g_Config.bShowDebugStats, gs->T("Show Debug Statistics"))); @@ -443,6 +446,20 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn GameSettingsScreen::OnPostProcShader(UI::EventParams &e) { + I18NCategory *g = GetI18NCategory("Graphics"); + auto procScreen = new PostProcScreen(g->T("Postprocessing Shader")); + procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange); + screenManager()->push(procScreen); + return UI::EVENT_DONE; +} + +UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) { + if (gpu) { + gpu->Resized(); + } + return UI::EVENT_DONE; +} UI::EventReturn GameSettingsScreen::OnDeveloperTools(UI::EventParams &e) { screenManager()->push(new DeveloperToolsScreen()); return UI::EVENT_DONE; diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 36d06e88f1e9..1e451cda085a 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -56,6 +56,8 @@ class GameSettingsScreen : public UIDialogScreenWithBackground { // Global settings handlers UI::EventReturn OnLanguage(UI::EventParams &e); UI::EventReturn OnLanguageChange(UI::EventParams &e); + UI::EventReturn OnPostProcShader(UI::EventParams &e); + UI::EventReturn OnPostProcShaderChange(UI::EventParams &e); UI::EventReturn OnFactoryReset(UI::EventParams &e); UI::EventReturn OnDeveloperTools(UI::EventParams &e); UI::EventReturn OnChangeNickname(UI::EventParams &e); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index f36c3394bb6c..8035e08066ee 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -145,6 +145,24 @@ UI::EventReturn PromptScreen::OnNo(UI::EventParams &e) { return UI::EVENT_DONE; } +PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title) { + shaders_ = GetAllPostShaderInfo(); + std::vector items; + int selected = -1; + for (int i = 0; i < shaders_.size(); i++) { + if (shaders_[i].section == g_Config.sPostShaderName) + selected = i; + items.push_back(shaders_[i].section); + } + adaptor_ = UI::StringVectorListAdaptor(items, selected); +} + +void PostProcScreen::OnCompleted(DialogResult result) { + if (result != DR_OK) + return; + g_Config.sPostShaderName = shaders_[listView_->GetSelected()].section; +} + NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen(title) { // Disable annoying encoding warning #ifdef _MSC_VER diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 41ec4c8b584f..6b1bc99e41c8 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -24,6 +24,7 @@ #include "base/functional.h" #include "file/file_util.h" #include "ui/ui_screen.h" +#include "GPU/Common/PostShader.h" inline void NoOpVoidBool(bool) {} @@ -70,6 +71,16 @@ class NewLanguageScreen : public ListPopupScreen { std::vector langs_; }; +class PostProcScreen : public ListPopupScreen { +public: + PostProcScreen(const std::string &title); + +private: + virtual void OnCompleted(DialogResult result); + virtual bool ShowButtons() const { return true; } + std::vector shaders_; +}; + class LogoScreen : public UIScreen { public: LogoScreen(const std::string &bootFilename) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 7955a8017aab..4ab51f44ad60 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1223,13 +1223,15 @@ namespace MainWindow case ID_OPTIONS_VSYNC: g_Config.bVSync = !g_Config.bVSync; break; - + + /* TODO: Add menus for post processing case ID_OPTIONS_FXAA: g_Config.bFXAA = !g_Config.bFXAA; if (gpu) gpu->Resized(); break; - + */ + case ID_TEXTURESCALING_AUTO: setTexScalingMultiplier(TEXSCALING_AUTO); break; case ID_TEXTURESCALING_OFF: setTexScalingMultiplier(TEXSCALING_OFF); break; case ID_TEXTURESCALING_2X: setTexScalingMultiplier(TEXSCALING_2X); break; @@ -1618,7 +1620,7 @@ namespace MainWindow CHECKITEM(ID_OPTIONS_SHOWFPS, g_Config.iShowFPSCounter); CHECKITEM(ID_OPTIONS_FRAMESKIP, g_Config.iFrameSkip != 0); CHECKITEM(ID_OPTIONS_VSYNC, g_Config.bVSync); - CHECKITEM(ID_OPTIONS_FXAA, g_Config.bFXAA); + // CHECKITEM(ID_OPTIONS_FXAA, g_Config.bFXAA); TODO: Replace with list of loaded post processing shaders CHECKITEM(ID_OPTIONS_TOPMOST, g_Config.bTopMost); CHECKITEM(ID_OPTIONS_PAUSE_FOCUS, g_Config.bPauseOnLostFocus); CHECKITEM(ID_EMULATION_SOUND, g_Config.bEnableSound); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 6ed42527534a..85d5318688d7 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -419,7 +419,7 @@ BEGIN MENUITEM "Stretch to Display", ID_OPTIONS_STRETCHDISPLAY MENUITEM "Fullscreen", ID_OPTIONS_FULLSCREEN MENUITEM "VSync", ID_OPTIONS_VSYNC - MENUITEM "FXAA antialiasing", ID_OPTIONS_FXAA + MENUITEM "Postprocessing Shader", ID_OPTIONS_FXAA POPUP "Rendering Resolution" BEGIN MENUITEM "Auto", ID_OPTIONS_SCREENAUTO diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b15cb786272f..9e036d634547 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -196,6 +196,7 @@ LOCAL_SRC_FILES := \ $(SRC)/GPU/Common/IndexGenerator.cpp.arm \ $(SRC)/GPU/Common/VertexDecoderCommon.cpp.arm \ $(SRC)/GPU/Common/TextureDecoder.cpp \ + $(SRC)/GPU/Common/PostShader.cpp \ $(SRC)/GPU/GLES/Framebuffer.cpp \ $(SRC)/GPU/GLES/GLES_GPU.cpp.arm \ $(SRC)/GPU/GLES/TextureCache.cpp.arm \ diff --git a/android/jni/Application.mk b/android/jni/Application.mk index 3d8831bc214c..d5c397d4e5ff 100644 --- a/android/jni/Application.mk +++ b/android/jni/Application.mk @@ -1,6 +1,6 @@ APP_STL := gnustl_static #APP_ABI := armeabi-v7a x86 -APP_ABI := armeabi-v7a armeabi x86 -#APP_ABI := armeabi-v7a +#APP_ABI := armeabi-v7a armeabi x86 +APP_ABI := armeabi-v7a APP_GNUSTL_CPP_FEATURES := NDK_TOOLCHAIN_VERSION := 4.8 diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index 01de3b77ee2c..4873eef4391d 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -34,4 +34,4 @@ public void onStop() { public boolean overrideKeys() { return false; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini new file mode 100644 index 000000000000..60278f472235 --- /dev/null +++ b/assets/shaders/defaultshaders.ini @@ -0,0 +1,15 @@ +# You can have multiple ini files if you want, it doesn't matter. +[FXAA] +Name=FXAA Antialiasing +Author=nVidia +Fragment=fxaa.fsh +Vertex=fxaa.vsh +[Natural] +Name=Natural Look +Fragment=natural.fsh +Vertex=natural.vsh +[Grayscale] +Name=Grayscale +Author=Henrik +Fragment=grayscale.fsh +Vertex=fxaa.vsh \ No newline at end of file diff --git a/assets/shaders/grayscale.fsh b/assets/shaders/grayscale.fsh new file mode 100644 index 000000000000..f309204e12c7 --- /dev/null +++ b/assets/shaders/grayscale.fsh @@ -0,0 +1,16 @@ +// Simple grayscale shader + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; + +void main() { + vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz; + float luma = dot(rgb, vec3(0.299, 0.587, 0.114)); + gl_FragColor.rgb = vec3(luma, luma, luma); + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/natural.fsh b/assets/shaders/natural.fsh new file mode 100644 index 000000000000..642718a17a94 --- /dev/null +++ b/assets/shaders/natural.fsh @@ -0,0 +1,48 @@ +// Natural shader, GLSL code adapted from: +// http://forums.ngemu.com/showthread.php?t=76098 + + +uniform sampler2D sampler0; + +const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212, + 0.587,-0.275,-0.523, + 0.114,-0.321, 0.311); + +const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0, + 0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523, + 0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); + +const vec3 val00 = vec3( 1.2, 1.2, 1.2); + +void main() +{ +vec3 c0,c1; + +c0 = texture2D(sampler0,gl_TexCoord[0].xy).xyz; +c0+=(texture2D(sampler0,gl_TexCoord[0].zy).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[0].xw).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[0].zw).xyz)*0.125; + +c0+= texture2D(sampler0,gl_TexCoord[1].xy).xyz; +c0+=(texture2D(sampler0,gl_TexCoord[1].zy).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[1].xw).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[1].zw).xyz)*0.125; + +c0+= texture2D(sampler0,gl_TexCoord[2].xy).xyz; +c0+=(texture2D(sampler0,gl_TexCoord[2].zy).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[2].xw).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[2].zw).xyz)*0.125; + +c0+= texture2D(sampler0,gl_TexCoord[3].xy).xyz; +c0+=(texture2D(sampler0,gl_TexCoord[3].zy).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[3].xw).xyz)*0.25; +c0+=(texture2D(sampler0,gl_TexCoord[3].zw).xyz)*0.125; +c0*=0.153846153846; + +c1=RGBtoYIQ*c0; + +c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz); + +gl_FragColor.xyz=YIQtoRGB*c1; + +} diff --git a/assets/shaders/natural.vsh b/assets/shaders/natural.vsh new file mode 100644 index 000000000000..9a0be066a700 --- /dev/null +++ b/assets/shaders/natural.vsh @@ -0,0 +1,14 @@ +attribute vec4 a_position; +attribute vec2 a_texcoord0; +uniform mat4 u_viewproj; +varying vec2 v_texcoord0; +void main() +{ +gl_Position=u_viewproj * a_position; + +gl_TexCoord[0]=a_texcoord0.xyxy; +gl_TexCoord[1]=a_texcoord0.xyxy; +gl_TexCoord[2]=a_texcoord0.xyxy; +gl_TexCoord[3]=a_texcoord0.xyxy; + +} \ No newline at end of file diff --git a/native b/native index b16b67d8b6e2..5a4dec927289 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit b16b67d8b6e2fd5127f9b84ec9f5496d8f782e71 +Subproject commit 5a4dec927289eb93fafc7bbd7facaee0c982accc