Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by KarimIO

  1. Hey guys, is there a difference in performance between GL_S3TC_DXT1_RGB and GL_S3TC_DXT1_RGBA? I want to use the latter in all cases if possible because dds files have no way to check if there's an alpha bit or not.
  2. KarimIO

    STB Image

    It works great here, been using it for years.
  3. Hey guys! Three questions about uniform buffers: 1) Is there a benefit to Vulkan and DirectX's Shader State for the Constant/Uniform Buffer? In these APIs, and NOT in OpenGL, you must set which shader is going to take each buffer. Why is this? For allowing more slots? 2) I'm building an wrapper over these graphics APIs, and was wondering how to handle passing parameters. In addition, I used my own json format to describe material formats and shader formats. In this, I can describe which shaders get what uniform buffers. I was thinking of moving to support ShaderLab (Unity's shader format) instead, as this would allow people to jump over easily enough and ease up the learning curve. But ShaderLab does not support multiple Uniform Buffers at all, as I can tell, let alone what parameters go where. So to fix this, I was just going to send all Uniform Buffers to all shaders. Is this that big of a problem? 3) Do you have any references on how to organize material uniform buffers? I may be optimizing too early, but I've seen people say what a toll this can take.
  4. Sorry for the late reply, but does this mean I can just make everything RGBA without negative consequences?
  5. Okay thanks! I've built my own dds exporter and importer so I can easily modify it to support this, I was just confused most of the flags related to channels were about uncompressed ones according to the msdn. Also I'll let the question about whether or not dxt_rgb stand for curiosity's sake.
  6. Isn't that just for uncompressed data? Or for all of it?
  7. Hey guys, Are lightmaps still the best way to handle static diffuse irradiance, or is SH used for both diffuse and specular irradiance now? Also, do any modern games use direct light in lightmaps, or are all direct lighting handled by shadow maps now? Finally, how is SH usually baked? Thanks!
  8. But those issues can be mitigated by using features like parallax cubemapping and SSAO. Not fully, to be sure, but when it's the high frequency data that matters, I don't see how cramming more low-frequency data in can help all that much. And how would they even be combined? I skimmed through most of this and it's quite interesting so far. That was my thought process for the most part but I think many are able to combine lightmaps and SH quite well. Sounds interesting! I'll try this out then. Do you have any articles about this technique?
  9. Hey guys So I was wondering how modern terrain and water geometry works both with and without tesselation. Essentially: 1) Is Geoclipmapping still the best CPU tesselation technique? 2) Is Geoclipmapping still used with tesselation? 3) Is non-tesselated water just flat? Is there any other (reasonable) ways to simulate it? Do people use Geoclipmapping for that too? Thanks!
  10. I was considering only using those kinds of approaches on smaller areas, if at all (RSM, VoxelGI, and the like would be supported in volumes) because they're so expensive. But I'll check out your link, thanks
  11. Hey guys, So I'm starting to think about BSP for my engine, which so far only supports models. And I've got a couple stupid questions. How are static and dynamic models usually used with the BSP visibility side of things? As far as I'm aware, dynamic models only use the BSP tree as a way to cull before visibility culling, so i guess I can compare an OOBB to the BSP tree leaves - is this correct? How do static meshes affect the BSP tree in terms of blocking visibility? Thanks in advance!
  12. Hey guys, I'm trying to work on adding transparent objects to my deferred-rendered scene. The only issue is the z-buffer. As far as I know, the standard way to handle this is copying the buffer. In OpenGL, I can just blit it. What's the alternative for DirectX? And are there any alternatives to copying the buffer? Thanks in advance!
  13. KarimIO

    Copy Z-Buffer in DirectX

    To clarify to those finding this later, and so someone can correct me if I'm wrong, this is a good solution, but you can not use it with the default depth buffer in opengl. This can be solved by using an fbo in the middle, and simply doing something that doesn't output depth, such as post processing, at the end.
  14. KarimIO

    Copy Z-Buffer in DirectX

    Forgive me if this is marginally off topic, but with OpenGL, is that done this way? glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0); glBindFramebuffer(GL_FRAMEBUFFER, fbo2); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0);
  15. KarimIO

    Copy Z-Buffer in DirectX

    Are you suggesting sharing an image/texture (specifically the depth buffer) between two framebuffers? I had considered that but I thought it might have issues.
  16. KarimIO

    Do models go inside a BSP?

    I didn't mean frustum culling of pixels, I'm aware that happens automatically, I meant of subtrees and entire objects or areas. Awesome! Thanks! I'll check it out soon. And is this used in addition to the previously mentioned techniques, or instead of it? Thanks again, JoeJ and Hodgman!
  17. KarimIO

    Do models go inside a BSP?

    As I said, I currently use only models for geometry. I wanted to add CSG-geometry for blocking things out, as well as for people who come from the Source Engine that might find it useful. This is pretty much what I planned to do before wanting to look for more effective methods. Quick question though, should frustum culling be done before or after occlusion culling? So an optimal approach would be using the PVS for static objects and occlusion queries for dynamic ones, while checking the partitioning tree for where the dynamic objects are to reduce the amount of occlusions, correct? I know nothing of Hi-Z Pyramids, but I'll check them out!
  18. KarimIO

    Do models go inside a BSP?

    Alrighty so basically I should use CSG geometry without the BSP partitioning. PVS is an all-encompassing thing, right, not just an individual technology? But in regard to partitioning and visibility, I remember Frostbite used sphere-based partitioning. Is that still used today, or can you suggest another partition method.
  19. KarimIO

    Do models go inside a BSP?

    Thanks for responding quickly and helpfully as usual, Hodgman! Doesn't Source use BSP for practically for everything under the sun and Unreal use it for blocking? It's not just partitioning and visibility I'd like it for, but also that blocking. Yeah that makes sense, but it shouldn't be difficult to overcome. How is this done though? The only thing that comes to mind is having an interior and exterior collision mesh, so anything including the interior mesh would block other BSP elements and anything in the exterior would represent what leaf the actual model is in.
  20. I'm trying to port my engine to DirectX and I'm currently having issues with depth reconstruction. It works perfectly in OpenGL (even though I use a bit of an expensive method). Every part besides the depth reconstruction works so far. I use GLM because it's a good math library that has no need to install any dependencies or anything for the user. So basically I get my GLM matrices: struct DefferedUBO { glm::mat4 view; glm::mat4 invProj; glm::vec4 eyePos; glm::vec4 resolution; }; DefferedUBO deffUBOBuffer; // ... glm::mat4 projection = glm::perspective(engine.settings.fov, aspectRatio, 0.1f, 100.0f); // Get My Camera CTransform *transform = &engine.transformSystem.components[engine.entities[entityID].components[COMPONENT_TRANSFORM]]; // Get the View Matrix glm::mat4 view = glm::lookAt( transform->GetPosition(), transform->GetPosition() + transform->GetForward(), transform->GetUp() ); deffUBOBuffer.invProj = glm::inverse(projection); deffUBOBuffer.view = glm::inverse(view); if (engine.settings.graphicsLanguage == GRAPHICS_DIRECTX) { deffUBOBuffer.invProj = glm::transpose(deffUBOBuffer.invProj); deffUBOBuffer.view = glm::transpose(deffUBOBuffer.view); } // Abstracted so I can use OGL, DX, VK, or even Metal when I get around to it. deffUBO->UpdateUniformBuffer(&deffUBOBuffer); deffUBO->Bind()); Then in HLSL, I simply use the following: cbuffer MatrixInfoType { matrix invView; matrix invProj; float4 eyePos; float4 resolution; }; float4 ViewPosFromDepth(float depth, float2 TexCoord) { float z = depth; // * 2.0 - 1.0; float4 clipSpacePosition = float4(TexCoord * 2.0 - 1.0, z, 1.0); float4 viewSpacePosition = mul(invProj, clipSpacePosition); viewSpacePosition /= viewSpacePosition.w; return viewSpacePosition; } float3 WorldPosFromViewPos(float4 view) { float4 worldSpacePosition = mul(invView, view); return; } float3 WorldPosFromDepth(float depth, float2 TexCoord) { return WorldPosFromViewPos(ViewPosFromDepth(depth, TexCoord)); } // ... // Sample the hardware depth buffer. float depth = shaderTexture[3].Sample(SampleType[0], input.texCoord).r; float3 position = WorldPosFromDepth(depth, input.texCoord).rgb; Here's the result: This just looks like random colors multiplied with the depth. Ironically when I remove transposing, I get something closer to the truth, but not quite: You're looking at Crytek Sponza. As you can see, the green area moves and rotates with the bottom of the camera. I have no idea at all why. The correct version, along with Albedo, Specular, and Normals.
  21. In the main prepass vertex shader, I need to use this: #pragma pack_matrix( row_major ) Multiplication should be column major by default because I use GLM. Yet, for one specific file, I need to use row_major.
  22. The problem is, I'm doing no such thing. GLM outputs the same column-major matrices, but for some reason one shader requires row major and the other column major. I understand everything you're talking about, it's just DirectX likes it one way in one shader and another way in another shader.
  23. @Hodgman Sorry! Didn't see the response until now! Keep in mind as I used GLM, it's column major. Here's the code that works: //////////////////////////////////////////////////////////////////////////////// // Filename: mainVert.vs //////////////////////////////////////////////////////////////////////////////// ///////////// // GLOBALS // ///////////// #pragma pack_matrix( row_major ) cbuffer MatrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; ////////////// // TYPEDEFS // ////////////// struct VertexInputType { float3 position : POSITION; float3 normal : NORMAL; float3 tangent : TANGENT; float2 texCoord : TEXCOORD0; }; struct PixelInputType { float4 position : SV_POSITION; float3 worldPosition : POSITION; float3 normal : NORMAL; float3 tangent : TANGENT; float2 texCoord : TEXCOORD0; }; //////////////////////////////////////////////////////////////////////////////// // Vertex Shader //////////////////////////////////////////////////////////////////////////////// PixelInputType main(VertexInputType input) { float4 position; PixelInputType output; // Change the position vector to be 4 units for proper matrix calculations. position = float4(input.position, 1.0f); // Calculate the position of the vertex against the world, view, and projection matrices. position = mul(position, worldMatrix); output.worldPosition =; position = mul(position, viewMatrix); output.position = mul(position, projectionMatrix); output.normal = normalize(mul(float4(input.normal, 1.0), worldMatrix).xyz); output.tangent = normalize(mul(float4(input.tangent, 1.0), worldMatrix).xyz); output.texCoord = float2(input.texCoord.x, -input.texCoord.y); return output; } //////////////////////////////////////////////////////////////////////////////// // Filename: //////////////////////////////////////////////////////////////////////////////// #pragma pack_matrix( column_major ) #include "inc_transform.hlsl" #include "inc_light.hlsl" ////////////// // TYPEDEFS // ////////////// struct PixelInputType { float4 position : SV_POSITION; float2 texCoord : TEXCOORD0; float3 viewRay : POSITION; }; Texture2D shaderTexture[4]; SamplerState SampleType[4]; cbuffer MatrixInfoType { matrix invView; matrix invProj; float4 eyePos; float4 resolution; }; cbuffer Light { float3 lightPosition; float lightAttenuationRadius; float3 lightColor; float lightIntensity; }; //////////////////////////////////////////////////////////////////////////////// // Pixel Shader //////////////////////////////////////////////////////////////////////////////// float4 main(PixelInputType input) : SV_TARGET { float depth = shaderTexture[3].Sample(SampleType[0], input.texCoord).r; float3 Position = WorldPosFromDepth(invProj, invView, depth, input.texCoord); //return float4(position, 1.0); /*float near = 0.1; float far = 100; float ProjectionA = far / (far - near); float ProjectionB = (-far * near) / (far - near); depth = ProjectionB / ((depth - ProjectionA)); float4 position = float4(input.viewRay * depth, 1.0);*/ // Convert to World Space: // position = mul(invView, position); float3 Albedo = shaderTexture[0].Sample(SampleType[0], input.texCoord).rgb; float3 Normal = shaderTexture[1].Sample(SampleType[0], input.texCoord).rgb; float4 Specular = shaderTexture[2].Sample(SampleType[0], input.texCoord); float3 lightPow = lightColor * lightIntensity; float3 outColor = LightPointCalc(Albedo.rgb,, Specular,, lightPosition, lightAttenuationRadius, lightPow,; // hdrGammaTransform() return float4(hdrGammaTransform(outColor), 1.0f); }
  24. @Hodgman Got any idea for the question above?
  25. Okay thank you a lot, Hodgman I finally got it to work! But I do have a question, my main vertex.hlsl which takes the actual geometry and pushes it into the gbuffer requires row-major whereas the rest works fine using column major. Do you have any idea why that could be?
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!