Vladimir Sabantsev Posted 3 hours ago Posted 3 hours ago Hello, I have troubles passing texture uniform variables into a post effect. The following sample produces runtime exception "vector subscript out of range": > effect-set-uniform-texture_d.exe!std::vector<class std::map<class Leadwerks::String,struct Leadwerks::Render::RenderCameraUniformValue,struct std::less<class Leadwerks::String>,class std::allocator<struct std::pair<class Leadwerks::String const ,struct Leadwerks::Render::RenderCameraUniformValue> > >,class std::allocator<class std::map<class Leadwerks::String,struct Leadwerks::Render::RenderCameraUniformValue,struct std::less<class Leadwerks::String>,class std::allocator<struct std::pair<class Leadwerks::String const ,struct Leadwerks::Render::RenderCameraUniformValue> > > > >::operator[](unsigned __int64) Unknown effect-set-uniform-texture_d.exe!Leadwerks::Render::RenderCamera::SetUniformTexture(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>) Unknown effect-set-uniform-texture_d.exe!std::invoke<void ( Leadwerks::Render::RenderCamera::*&)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int &,class Leadwerks::String &,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &>(void ( Leadwerks::Render::RenderCamera::*&)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int &,class Leadwerks::String &,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &) Unknown effect-set-uniform-texture_d.exe!std::_Invoker_ret<struct std::_Unforced>::_Call<void ( Leadwerks::Render::RenderCamera::*&)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int &,class Leadwerks::String &,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &>(void ( Leadwerks::Render::RenderCamera::*&)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int &,class Leadwerks::String &,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &) Unknown effect-set-uniform-texture_d.exe!std::_Call_binder<struct std::_Unforced,0,1,2,3,void ( Leadwerks::Render::RenderCamera::*)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::tuple<class std::shared_ptr<class Leadwerks::Render::RenderCamera>,int,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> >,class std::tuple<> >(struct std::_Invoker_ret<struct std::_Unforced>,struct std::integer_sequence<unsigned __int64,0,1,2,3>,void ( Leadwerks::Render::RenderCamera::*&)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::tuple<class std::shared_ptr<class Leadwerks::Render::RenderCamera>,int,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> > &,class std::tuple<> &&) Unknown effect-set-uniform-texture_d.exe!std::_Binder<struct std::_Unforced,void ( Leadwerks::Render::RenderCamera::*)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int const &,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &>::operator()<>(void) Unknown effect-set-uniform-texture_d.exe!std::invoke<class std::_Binder<struct std::_Unforced,void ( Leadwerks::Render::RenderCamera::*)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int const &,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &> &>(class std::_Binder<struct std::_Unforced,void ( Leadwerks::Render::RenderCamera::*)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int const &,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &> &) Unknown effect-set-uniform-texture_d.exe!std::_Func_impl_no_alloc<class std::_Binder<struct std::_Unforced,void ( Leadwerks::Render::RenderCamera::*)(int,class Leadwerks::String const &,class std::shared_ptr<class Leadwerks::Render::RenderTexture>),class std::shared_ptr<class Leadwerks::Render::RenderCamera> &,int const &,class Leadwerks::String,class std::shared_ptr<class Leadwerks::Render::RenderTexture> &>,void>::_Do_call(void) Unknown effect-set-uniform-texture_d.exe!std::_Func_class<void>::operator()(void) Unknown effect-set-uniform-texture_d.exe!Leadwerks::Core::ThreadManager::Update(bool) Unknown effect-set-uniform-texture_d.exe!Leadwerks::Render::RenderingThreadManager::Update(bool) Unknown effect-set-uniform-texture_d.exe!Leadwerks::Core::ThreadManager::EntryPoint(class std::shared_ptr<class Leadwerks::Object>) Unknown effect-set-uniform-texture_d.exe!Leadwerks::Thread::thread_function(void *) Unknown ucrtbased.dll!00007fffe5372ec5() Unknown kernel32.dll!00007ff81359259d() Unknown ntdll.dll!00007ff8150aaf78() Unknown main.cpp #include "Leadwerks.h" namespace lwe = Leadwerks; int main(int argc, const char* argv[]) { auto displays = lwe::GetDisplays(); auto window = lwe::CreateWindow("SetUniform-Texture", 0, 0, 720, 720, displays[0], lwe::WINDOW_DEFAULT); auto framebuffer = lwe::CreateFramebuffer(window); auto world = lwe::CreateWorld(); auto camera_0 = lwe::CreateCamera(world); auto camera_1 = lwe::CreateCamera(world); auto camera_0_texture_0 = lwe::CreateTexture(lwe::TEXTURE_2D, 720, 720); auto camera_0_texture_1 = lwe::CreateTexture(lwe::TEXTURE_2D, 720, 720); auto camera_0_texbuff = lwe::CreateTextureBuffer(720, 720, 2, true); camera_0_texbuff->SetColorAttachment(camera_0_texture_0, 0); camera_0_texbuff->SetColorAttachment(camera_0_texture_1, 1); camera_0->SetRenderTarget(camera_0_texbuff); camera_0->SetOrder(0); camera_1->SetLighting(false); camera_1->SetRenderLayers(0); camera_1->SetOrder(1); auto camera_1_effect = lwe::LoadPostEffect("Shaders/BaseColorInterp.fx"); auto camera_1_effect_id = camera_1->AddPostEffect(camera_1_effect); camera_1->EnablePostEffect(camera_1_effect_id); #if 1 camera_1->SetUniform(camera_1_effect_id, "ColorBuffer0", camera_0_texture_0); camera_1->SetUniform(camera_1_effect_id, "ColorBuffer1", camera_0_texture_1); #endif while (window->Closed() == false && window->KeyDown(lwe::KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } BaseColorInterp.fx { "posteffect": { "subpasses": [ { "shader": { "float32": { "vertex": "Shaders/PostEffects/PostEffect.vert", "fragment": "Shaders/PostEffects/BaseColorInterp.frag" } } } ] } } BaseColorInterp.frag #version 450 // Uniforms layout(binding = 0) uniform sampler2DMS ColorBuffer0; layout(binding = 1) uniform sampler2DMS ColorBuffer1; layout(location = 0) uniform ivec4 DrawViewport; // Outputs layout(location = 0) out vec4 outColor; void main() { ivec2 coord = ivec2(gl_FragCoord.x, gl_FragCoord.y); outColor = texelFetch(ColorBuffer0, coord, 0) / 2.f + texelFetch(ColorBuffer1, coord, 0) / 2.f; } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.