Jump to content
  • Advertisement

lGuy

Member
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About lGuy

  • Rank
    Newbie

Personal Information

  • Role
    Amateur / Hobbyist
  • Interests
    Design
    DevOps
    Programming
    QA
  1. Hi, I've recently been trying to implement screen space reflections into my engine, however, it is extremely buggy. I'm using this tutorial : http://imanolfotia.com/blog/update/2017/03/11/ScreenSpaceReflections.html The reflections look decent when I am close to the ground (first image), however when I get further away from the ground (the surface that is reflecting stuff), the reflections become blocky and strange (second image). I have a feeling that it has something to do with the fact that the further the rays travel in view space, the more scattered they get -> therefore the reflected image is less detailed hence the blockiness. However I really am not sure about this and if this is the case, I don't know how to fix it. It would be great if anyone had any suggestions around how to debug or sort this thing out. Thanks. Here is the code for the ray casting vec4 ray_cast(inout vec3 direction, inout vec3 hit_coord, out float depth_difference, out bool success) { vec3 original_coord = hit_coord; direction *= 0.2; vec4 projected_coord; float sampled_depth; for (int i = 0; i < 20; ++i) { hit_coord += direction; projected_coord = projection_matrix * vec4(hit_coord, 1.0); projected_coord.xy /= projected_coord.w; projected_coord.xy = projected_coord.xy * 0.5 + 0.5; // view_positions store the view space coordinates of the objects sampled_depth = textureLod(view_positions, projected_coord.xy, 2).z; if (sampled_depth > 1000.0) continue; depth_difference = hit_coord.z - sampled_depth; if ((direction.z - depth_difference) < 1.2) { if (depth_difference <= 0) { vec4 result; // binary search for more detailed sample result = vec4(binary_search(direction, hit_coord, depth_difference), 1.0); success = true; return result; } } } return vec4(projected_coord.xy, sampled_depth, 0.0); } Here is the code just before this gets called float ddepth; vec3 jitt = mix(vec3(0.0), vec3(hash33(view_position)), 0.5); vec3 ray_dir = reflect(normalize(view_position), normalize(view_normal)); ray_dir = ray_dir * max(0.2, -view_position.z); /* ray cast */ vec4 coords = ray_cast(ray_dir, view_position, ddepth);
  2. Wow that's actually really cool haha. How would you store the shaders though ? Cause some models will probably use the same shader right? So there would need to be some way to map the shaders to certain models. - Sorry for all these questions...
  3. Thanks for your reply . I have a question, how does your shader know whether it should compute the color of the fragment with a texture of just a color given through attributes?
  4. Hello, I was just wondering whether it was a thing to use a component-based architecture to handle models in OpenGL much like in a entity component system. This structure has especially helped me in cases where I have models that need different resources. By that I mean, some models need a texture and texture coordinate data to go with it, others just need some color data (vec3). Some have a normals buffer whereas others just get their normals calculated on the fly (geometry shader). Some have an index buffer (rendered with glDrawElements) whereas others don't and get rendered using glDrawArrays etc... Instead of branching off into complicated hierarchies to create models that have only certain resources, or coming up with strange ways resolve certain problems concerning checking which resources some models have, I just attach components to each model such as a vertex buffer or texture coordinate buffer or index buffer etc... So, I was just wondering if I was using the other version of model handling wrong or whether this style of programming is a viable option and whether there are flaws that I am unable to foresee?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!