Giter VIP home page Giter VIP logo

Comments (7)

Dimev avatar Dimev commented on May 13, 2024

How exactly does it break? does it just disappear?

from realistic-atmosphere-godot-and-ue4.

arraybercov avatar arraybercov commented on May 13, 2024

Hey Dimev,

Yes. I can tell you exactly how.

I get a SM5 Ray tracing closest hit shaders cannot read from the SceneTexturesStruct error in the Stats tab in the material graph (I'm looking at the non-post version.

The issue is in your Get Max Distance custom expression node. Any ideas how we could re-write that Texture2DSampleLevel function to not need this struct? Maybe we can add an input to Get Max Distance to replace that or just try and do it all with nodes?

float3 Forward = mul(float3(0.00000000,0.00000000,1.00000000), ResolvedView.ViewToTranslatedWorld);
float DeviceZ = Texture2DSampleLevel(SceneTexturesStruct.SceneDepthTexture, SceneTexturesStruct.SceneDepthTextureSampler, ScreenAlignedPosition(GetScreenPosition(Parameters)), 0).r;

float Depth = DeviceZ * View.InvDeviceZToWorldZTransform[0] + View.InvDeviceZToWorldZTransform[1] + 1.0f / (DeviceZ * View.InvDeviceZToWorldZTransform[2] - (View.InvDeviceZToWorldZTransform[3] + 0.00000001));

return Depth / abs(dot(Forward, Parameters.CameraVector));

from realistic-atmosphere-godot-and-ue4.

Dimev avatar Dimev commented on May 13, 2024

Someone else also had this issue in the 4.25 preview

The code I'm using here essentially makes sure the distance returned by the depth buffer is correct, because using the scene depth node divided by the dot product of the forward and camera vector directly results in the depth not being 100% accurate at large distances.

I assume the issue has something to do with the material being involved in raytracing. maybe it can be fixed by somehow making the material not a closest hit shader, but I'll have to look at it, and maybe a different workaround of the max distance thing.

from realistic-atmosphere-godot-and-ue4.

arraybercov avatar arraybercov commented on May 13, 2024

If you have any ideas I may be able to implement, happy to try. If there is any way to do it without HLSL that'd be safer of course.

from realistic-atmosphere-godot-and-ue4.

Dimev avatar Dimev commented on May 13, 2024

The weird depth thing is because the ue4 devs added a very small value to DeviceZToWorldZ to avoid dividing by 0 in one shader in the engine (which is a stupid hack, just do proper divide by zero checking), causing the depth to be inaccurate, and needing this workaround (written by Dexyfex, not me)

There's probably a way to get around this with only nodes, but that needs investigation. Probably dividing the resulting depth by some values using nodes may work, but I haven't had success with that so far

from realistic-atmosphere-godot-and-ue4.

Dimev avatar Dimev commented on May 13, 2024

I found a fix for the issue, I'll soon upload a 4.25 version of the project and close this.
The new code for the Get Max Distance node is this:

float3 Forward = mul(float3(0.00000000,0.00000000,1.00000000), ResolvedView.ViewToTranslatedWorld);
float DeviceZ = LookupDeviceZ(ScreenAlignedPosition(GetScreenPosition(Parameters))).r;

float Depth = DeviceZ * View.InvDeviceZToWorldZTransform[0] + View.InvDeviceZToWorldZTransform[1] + 1.0f / (DeviceZ * View.InvDeviceZToWorldZTransform[2] - (View.InvDeviceZToWorldZTransform[3] + 0.00000001));

return Depth / abs(dot(Forward, Parameters.CameraVector));

from realistic-atmosphere-godot-and-ue4.

Dimev avatar Dimev commented on May 13, 2024

I uploaded the version with the fix, should work now

from realistic-atmosphere-godot-and-ue4.

Related Issues (8)

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.