Code Monkey home page Code Monkey logo

Comments (11)

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024 2

I managed to fix the issue, it was an issue with how I setup my rotation Matrix and how it was applying to the model matrix. It ended up exploding everything. Thanks for helping me, even though it wasn't an issue with your codebase :)

from imgui.

PathogenDavid avatar PathogenDavid commented on June 18, 2024

This is most likely an issue on your end. You should use a graphics debugger like RenderDoc to investigate.

from imgui.

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024

@PathogenDavid Why does it start working as soon as I disable ImGui::DockSpaceOverViewport();?

from imgui.

PathogenDavid avatar PathogenDavid commented on June 18, 2024

Hard to say without debugging your app, which is why I recommended looking at a graphics debugger.

from imgui.

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024

For some reason the vs output changes depending on whether dockspace is active or not. If it is active, gl_position goes to NaN. If it is inactive, the values are correct.
No Dockspace
image
Dockspace
image

from imgui.

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024

It seems like my program doesn't allow:
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
and:
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGui::DockSpaceOverViewport();
}
to run at the same time for some reason.

from imgui.

ocornut avatar ocornut commented on June 18, 2024

It's possibly an issue in your code and you may be not sharing the relevant code.
It's ambiguous what those vertices you posted are (vertices for what?).
Try to confirm if your render-to-texture is valid in both cases.
Use Metrics/Debugger to inspect our draw calls.

from imgui.

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024

My textures are valid, it seems like my vertex positions become invalid. I'm not sure what is causing it to become invalid.
image
this is my vertex shader if it helps.

from imgui.

ocornut avatar ocornut commented on June 18, 2024

it seems like my vertex positions become invalid.

OpenGL uses a bunch of global state, so it is possible that some of the state we alter inside ImGui_ImplOpenGL3_RenderDrawData() are altering your render because it doesn't explicitly set them up.

from imgui.

ocornut avatar ocornut commented on June 18, 2024

My textures are valid, it seems like my vertex positions become invalid. I'm not sure what is causing it to become invalid.

Again, this can means different things and is very ambiguous to read without code. We still don't know how you are rendering the things that breaks.

If you have a texture working, then you can submit your framebuffer using ImGui::Image(), and then I don't understand what this shader is about because you shouldn't need one. So it seems like you are may doing something else but I cannot guess what it is.

I also don't know if by texture you are referring to the texture used as part of the render toward generating your framebuffer-rendered-to-texture, or if you are talking about your framebuffer-rendered-to-texture. Without code we can only guess.

from imgui.

Platforming-Mayhem avatar Platforming-Mayhem commented on June 18, 2024

Through testing a bunch I've found out that my model matrix is getting screwed up for some reason. Also just to give some context, I am using ImGui to display a render texture using ImGui::Image. However the part that is going wrong happens during the rendering of the render texture, and the render texture is rendering a scene that contains a gameObject with a texture that looks like this:
watermark
The GameObject's texture is being passed correctly, but the render texture isn't rendering anything.

void K::Transform::PassModelMatrix(K::Transform* parent) 
{
	K::Matrix4x4 globalModelMatrix = K::Matrix4x4::IdentityMatrix();

	if (parent == nullptr)
	{
		//World space transforms are in control
		*this->localScale = *this->scale;
		*this->localRotation = *this->rotation;
		*this->localPosition = *this->position;
		//Scaling Matrix
		globalModelMatrix.m[0][0] *= this->scale->x;
		globalModelMatrix.m[1][1] *= this->scale->y;
		globalModelMatrix.m[2][2] *= this->scale->z;
		//Rotation Matrix
		globalModelMatrix = K::Matrix4x4::Matrix_MultiplyMatrix(globalModelMatrix, *K::Quaternion::Euler(this->rotation)->QuaternionToMatrix());
		//Translation Matrix
		globalModelMatrix.m[3][0] += this->position->x;
		globalModelMatrix.m[3][1] += this->position->y;
		globalModelMatrix.m[3][2] += this->position->z;
	}
	else
	{
		if (*this->position != this->previousPosition)
		{
			*this->localPosition = *this->position;
			K::Matrix4x4 invert = K::QuickInverse(parent->modelMatrix);
			K::MultiplyMatrixVector(*this->position, *this->localPosition, invert);
		}
		if (*this->rotation != this->previousRotation)
		{
			*this->localRotation = *this->rotation - *parent->rotation;
		}
		if (*this->scale != this->previousScale)
		{
			*this->localScale = *this->scale / *parent->scale;
		}

		//Local space transforms are in control
		*this->scale = *this->localScale * *parent->scale;
		*this->rotation = *this->localRotation + *parent->rotation;
		K::MultiplyMatrixVector(*this->localPosition, *this->position, parent->modelMatrix);
		//Scaling Matrix
		globalModelMatrix.m[0][0] *= this->scale->x;
		globalModelMatrix.m[1][1] *= this->scale->y;
		globalModelMatrix.m[2][2] *= this->scale->z;
		//Rotation Matrix
		globalModelMatrix = K::Matrix4x4::Matrix_MultiplyMatrix(globalModelMatrix, *K::Quaternion::Euler(this->rotation)->QuaternionToMatrix());
		//Translation Matrix
		globalModelMatrix.m[3][0] += this->position->x;
		globalModelMatrix.m[3][1] += this->position->y;
		globalModelMatrix.m[3][2] += this->position->z;
	}

	this->modelMatrix = globalModelMatrix;

	this->previousPosition = *this->position;
	this->previousRotation = *this->rotation;
	this->previousScale = *this->scale;
}

This is the code(^) used to construct the model matrix, this->modelMatrix is the final model matrix that gets passed to the shader.

void GameObject::PassTransformationMatrix()
{
	if (this->parent == nullptr) 
		this->GetTransform()->PassModelMatrix();
	else 
		this->GetTransform()->PassModelMatrix(this->parent->GetTransform());
	glUniformMatrix4fv(glGetUniformLocation(this->material->GetShader()->shader, "modelMatrix"), 1, GL_FALSE, &this->GetTransform()->modelMatrix.m[0][0]);
}

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.