Search the Community
Showing results for tags 'heat air'.
-
Update 24.05.2020: New Download Links in this Post Update 05.05.2020: Download Depth Of Field 2.0 OvGME Ready - Thanks Morpheus. Update 05.08.2020: Download Heatair V2.0 OvGME Ready Update 05.11.2020: Download MotionBlur V2.0 OvGME Ready Scientific article about Boke from Zeiss [GER] Hello pilots and modders, as an owner of a film company, a problem jumped right into my eye at DCS. For some reason (the reason is: ED uses Focal Length as well as Focal Distance and Distance for calculation. That is correct. But in DCS the zoom is not controlled by the focal length, but by the zoom - equivalent to a digital zoom. But this is not considered in the formula. Would be correct in reality, but nobody zooms this far lossless digitally and let's be honest - it doesn't look cool! And they missed the distance from the Camera to the Object to be noticed) the depth of field is not really calculated correctly. As you can see in the following picture, the background gets blurred the more you increase the focal length or simply zoom in. This is true for the same aperture, of course. But currently it looks like this in DCS. (v2.5.5) Wide Normal Tele Furthermore, the further you are away from the object, the less blurred the background becomes. At this point I am really a filmmaker and not a mathematician or full-time programmer. However, with my rudimentary knowledge and a lot of time of reverse code reading I have been working on the DOF.fx. You can find it here: *DCS Installation Path*\Bazar\shaders\PostEffects\DOF.fx The formula used here is obviously correct focalWidth * abs(focalDistance-dist)/dist but various parameters seem to be identical all the time especially the focalDistance and focalWidth where the latter should be called focalLength. Therefore the maximum blur does not change when zooming, nor when changing the distance to the object. Even worse. It has the effect that the image becomes sharper when zooming in. Simply because you have more image and details at the same bokeh. First of all I tried to transfer the real values from the camera into the formula. For this purpose I read out the zoom, the target point of the camera as well as the camera position, because these values seem to remain always the same in the current DOF.fx of DCS. Strangely enough I had to leave the value focalDistance in the formula anyway. So my calculation is still far away from perfection. Unfortunately, without debugging I don't know what values and value ranges DCS spits out here. So I had to test a lot with try and error. I have edited the following lines and tried to correct the incorrect calculation. At the beginning #include "../common/samplers11.hlsl" #include "../common/states11.hlsl" #include "common/context.hlsl" //added to get access to some camera values out of the game then the function of getBlurFactor float getBlurFactor(float dist) { //get game camera values float near = gNearFarFovZoom.x; //get nearest point rendered float far = gNearFarFovZoom.y; //get farest point rendered float zoom = gNearFarFovZoom.w; //get fov value of the camera float3 camOrigin = gOrigin; //get camera origin float3 camPosition = gCameraPos; //get camera pos //calculations float focalLength = 1/zoom; //it looks like the zoom is defined from 0.0 - 1.0 where 0 is the largest zoom - with more zoom you get more bokeh - simply inverted that thing and called it like what it is in our context float clipminmax = far-near; //calc the distance between clipping - that is normaly the range where the depth map is calculated and I think the dist value is something between 0.0-1.0 float3 d = camOrigin-camPosition; //calc absolut values of x,y,z - distance float cameraDistance = sqrt((d.x * d.x)+(d.y * d.y)+(d.z * d.z)); //calc absolut direct distance aka focalDistance (Pythagorean theorem) cameraDistance = 1/clipminmax*cameraDistance; //remap the distance to something like 0.0-1.0 float aperture = 2.8;//the standard blur looks like aperture 1 - this multiplier reduces the heavy blur (https://en.wikipedia.org/wiki/Aperture) aperture = aperture*aperture; //calc the size of the bokeh with this aperture. The aperture² gives you the ammount of reducing light. Also its the ammount the bokeh decreases. For example 1 = 1. Maximum Bokeh. At Aperture 1.4 you have the half ammount of light and the half size of bokeh. //output return focalLength * abs(cameraDistance + focalDistance - dist)/dist/aperture; //default -> focalWidth * abs(focalDistance-dist)/dist; | I cannot delete focalDistance, then you see extreme blur. In theory that means that my calculation of cameraDistance is wrong. I'm pretty sure it is, but hey at this moment it works. } float getRadius(float2 uv) { #ifdef MSAA float depth = DepthMap.Load(uint2(uv*dims), 0).r; #else float depth = DepthMap.Load(uint3(uv*dims, 0)).r; #endif float4 p = mul(float4(uv*2-1, depth, 1), invProj); float f = getBlurFactor(p.z/p.w); return pow(f, 1.5); //does the boke effect really grow exponentially with distance? - but this does enlarge the area where it is sharp. Default 1.5. } and then something for the performance here #define GOLDEN_ANGLE 2.39996323 #define NUMBER 150.0 #define ITERATIONS_STEP 8 //increasing this value means more fps because of less calculations. But also the look is different. Less iterations creates smaller bokeh. There is something in the loop down. Maybe in it could prevent. #define ITERATIONS (GOLDEN_ANGLE * NUMBER) // This creates the 2D offset for the next point. // (r-1.0) is the equivalent to sqrt(0, 1, 2, 3...) float2 Sample(in float theta, inout float r) { r += 1.0 / r; return (r-1.0) * float2(cos(theta), sin(theta)) * .06; } float3 Bokeh(Texture2D tex, float2 uv, float radius, float amount) { float3 acc = float3(0,0,0); float3 div = float3(0,0,0); float2 pixel = float2(aspect, 1.0) * radius * .025; float r = 1.0; for (float j = 0.0; j < ITERATIONS; j += ITERATIONS_STEP) { //using here ITERATIONS_STEP instead of GOLDEN_ANGLE float2 s = Sample(j, r); float2 tuv = uv + pixel * s; // rebuild tuv float nr = min(getRadius(tuv), radius); tuv = uv + pixel * s * (nr/radius); float3 col = tex.Sample(ClampLinearSampler, tuv).rgb; float3 bokeh = float3(5.0, 5.0, 5.0) + pow(col, 9.0) * amount; acc += col * bokeh; div += bokeh; } return acc / div; } The code can be optimized for all cases, but is easier to understand at this stage! This is how it looks like after my tuning. Wide Normal Tele and... Wide Normal Tele I would be glad about feedback and further developments to make DCS even more beautiful. Best greetings from Germany!
- 79 replies
-
- 5
-
- depth of field
- mod
-
(and 5 more)
Tagged with: