• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Hashbrown
      My light is positioned at vec3(0, 0, 2) which is in front of an object at vec3(0, 0, 0). If I don't rotate the object, everything seems to look fine:

      The problem occurs when I rotate the object, the object's lit area seems to rotate with the object. Instead of just shining the faces looking at the light.

      I can't seem to figure out what the problem is with my shader. I even tried calculating the normal matrix in glsl, just in case my implementation was wrong, but I get the same results:
      nrms = mat3(transpose(inverse(model))) * normals; // and nrms = normalMat * normals; // both get same results. I really don't think it has to do with the normals, the light calculations visually seem okay, as long as I don't rotate the object though.
      In fact, I can translate and rotate the camera and the lighting is still good, again, as long as I don't rotate the object. By the way, camera rotation is not considered in the calculations since I'm passing the camera.transform.position vec3 to calculate the toCam vector I use in my lighting calculations.
      There's clearly something I'm doing wrong
      Hopefully somebody can identify what it is though, I'll share the vertex and frag shaders below, thanks a lot!
      #version 300 es #ifdef GL_ES precision mediump float; #endif layout (location= 0) in vec3 vertex; layout (location= 1) in vec3 normals; layout (location= 2) in vec2 uv; layout (location= 3) in vec3 colors; out vec3 fragPos; out vec3 baseColors; out vec3 nrms; out vec3 camPosition; uniform vec3 camera; uniform mat3 normalMat; uniform mat4 model; uniform mat4 projection; uniform mat4 view; uniform mat4 mvp; void main() { // nrms = mat3(transpose(inverse(model))) * normals; baseColors = colors; nrms = normalMat * normals; fragPos = vec3(model * vec4(vertex, 1.0)); camPosition = camera; gl_Position = mvp * vec4(fragPos, 1.0); }  
      #version 300 es #ifdef GL_ES precision mediump float; #endif #define PI 3.14159265359 #define TWO_PI 6.28318530718 #define NUM_LIGHTS 2 in vec3 fragPos; in vec3 baseColors; in vec3 nrms; in vec3 camPosition; out vec4 color; struct Light { vec3 position; vec3 intensities; float attenuation; float ambient; }; Light light; void main () { light.position.x = 0.0; light.position.y = 0.0; light.position.z = 2.0; light.intensities.r = 1.0; light.intensities.g = 1.0; light.intensities.b = 1.0; light.ambient = 0.005; vec4 base = vec4(baseColors, 1.0); vec3 normals = normalize(nrms); vec3 toLight = normalize(light.position - fragPos); vec3 toCamera = normalize(camPosition - fragPos); // Ambient vec3 ambient = light.ambient * base.rgb * light.intensities; // Diffuse float diffuseBrightness = max(0.0, dot(normals, toLight)); vec3 diffuse = diffuseBrightness * base.rgb * light.intensities; // Composition vec3 linearColor = ambient + (diffuse); vec3 gamma = vec3(1.0 / 2.2); color = vec4( pow(linearColor, gamma), base.a); }  
    • By ZachBethel
      Hey all,
      I'm looking into building a streaming system for mipped images. I'm referencing the DirectX sample for memory management here: https://github.com/Microsoft/DirectX-Graphics-Samples/tree/master/TechniqueDemos/D3D12MemoryManagement
      I have a couple related questions to this.
      I'm leaning towards also utilizing tiled resources for mips, mainly because it allows me to avoid invalidating my pre-cooked descriptor tables any time an image updates, since I would effectively have to create a new ID3D12Resource with more / fewer mip levels when a stream / trim event occurs, respectively. Has anyone had success using tiled resources or noticed any potential performance impact related to having the page table indirection?
      Also, I noticed that tiled resource tier 1 doesn't support mip clamping. Are there workarounds (in the shader, for example), or limiting the mip level in cases where we don't have a mip resident? Or am I required to create a new view mapped to the resident subset. This would also require that I rebake my descriptor tables, which I would like to avoid.
      My second question is how to handle the actual updates. I would like to utilize a copy queue to stream contents up to the GPU. I have a couple approaches here:
      Create a device-local staging image and run my async copy job to upload to it. This happens in parallel with the current frame using the existing image. At the beginning of the next frame (on the graphics queue) I blit from the staging memory to the newly resident mip, and then use the full mip chain for rendering. Utilize sub-resource transitions to put part of the image into an SRV state and the other part into a Copy Destination state. The async copy queue uploads to the more-detailed mip levels while the current frame renders using the SRV subresources. This approach seems a bit more complicated due to having to manage sub-resource transitions, but it avoids a copy in the process. My question here is whether I need to specify the D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS bit on my resource, even though the transitions and accesses are occurring between different sub-resources. If so, do you know what kind of performance repercussions I could expect from this? Would I still be able to store my images in BCn formats, for example? Thanks much,
    • By AndyCo
      I`m looking for some project to boost up my portfolio, I`m not a pro but I`m not bad at all.
      Feel free to contact me.
    • By lucky6969b
      I want to calculate the position of the camera, but I always get a vector of zeros.

      D3DXMATRIX viewMat; pDev->GetTransform(D3DTS_VIEW, &viewMat); D3DXMatrixInverse(&viewMat, NULL, &viewMat); D3DXVECTOR3 camPos(viewMat._41, viewMat._42, viewMat._43); log->Write( L"Camera Position: %f %f %f\n", camPos.x, camPos.y, camPos.z);

      Could anyone please shed some lights on this?
    • By bsudheer
      Leap Leap Leap! is a fast-paced, endless running game where you leap from rooftop to rooftop in a computer simulated world.

      This is a free run game and get excited by this fabulous computer simulated world of skyscrapers and surreal colors in parallax effect. On your way, collect cubes and revival points as many as you can to make a long run.

      Features of Leap Leap Leap:
      -Option of two themes: Black or White.
      -Simple one touch gameplay.
      -Attractive art.
      -Effective use of parallax.
      To Download the game:
      Playstore: https://play.google.com/store/apps/details?id=com.avakaigames.leap
      Appstore: https://itunes.apple.com/us/app/leap-leap-leap/id683764406?mt=8

  • Advertisement
  • Advertisement

3D Diligent Engine - A Modern Cross-Platform Low-Level Graphics Library

Recommended Posts

13 minutes ago, Trylz Engine said:

Awesome just awesome  

Do  you support some kind of global illumination ?

Thanks :)

As of right now, this is a low-level graphics library, so it can "only" draw triangles and run shaders. I am thinking about adding higher-level functionality (scene graph, PBR shaders, shadows, etc.) but did not decide which way to go yet.

Share this post

Link to post
Share on other sites

Good work, I've seen your few topics about this engine in the past and it helped me taking decisions on how to build my own abstraction layer in my project. It's not only a nice project but also a good source of information.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement