Closed USSRcoder closed 2 years ago
Works like this:
after GenRay() wrote:
vec3 d = GenRay();
o = vec3(uModel vec4(o,1));
d = vec3(uModel vec4(d,0));
its apply uModel matrix transforms;
For not rewriting prevous model draw - if (hit) oFragColor = vec4( uViewType == 0 ? color : normal * 0.5f + 0.5f, 1 ); else discard;
p.s. iteration mode view only for last model draw.
Hello, Adam. Please help transform octtrees correctly and render multiple octrees (GL version).
To rotate/transform octtree with "model" matrix uniform, i try multiple matrix like this - return normalize(mat3(inverse(uView)) inverse(mat3(uModel)) (inverse(uProjection) * vec4(coord, 1, 1) ).xyz); in vec3 GenRay() function;
But i think, it rotate camera, instest of model; Also - try to render second octtree, with some translation. if my multiply wrong, and i move the camera instead of the object, then I will not be able to see the 2nd object.
here is code to render two objects: glm::mat4 model = glm::mat4(1.0); model = glm::rotate(model, (float)glfwGetTime(), glm::vec3(0,0,1)); m_shader.SetMat4(m_shader.GetUniform("uModel"), (GLfloat*)(&model)); m_shader.SetInt(m_unif_view_type, (GLint)m_view_type); m_shader.SetInt(m_unif_beam_enable, (GLint)m_beam_enable); quad.Render();
beam opt. is disabled ofcourse;
Also disable black color if !hit: main() { ... if(uViewType == 2) oFragColor = vec4( vec3(iter / 64.0f), 1 ); else //if (!hit) discard; // no effect //oFragColor = vec4( hit ? ( uViewType == 0 ? color : normal 0.5f + 0.5f ) : vec3(0), 1 ); if (hit) oFragColor = vec4( uViewType == 0 ? color : normal 0.5f + 0.5f, 1 ); ... }