• Advertisement

Andrey OGL_D3D

Member
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

2 Neutral

1 Follower

About Andrey OGL_D3D

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Vulkan DirectX - Vulkan clip space

    Hi turanszkij, Anyway, if you have multi graphics rendering support, you should resolve any cases with different matrix/viewPort/clipping in the Rendering implementation side or in user side. For example, user should set Light Projection matrix for Shadow Map, but this matrix is different for Direct3D11/Vulkan. How to resolve this ? 1) You can add some macro definition to resolve clip cases in your shaders. 2) Call Matrix method renderInterace->CreateProjectionMatrix
  2. Vulkan DirectX - Vulkan clip space

    Hi turanszkij, I have different matrix projection methods in Matrix4x4 class: Matrix4x4::PerspectiveFovVulkan Matrix4x4::PerspectiveFovDirect3D(also can be used for OpenGL) Matrix4x4::OrthoVulkan Matrix4x4::OrthoDirect3D My implementation Direct3D11Render/VulkanRender/OpenGLRender knows wich methods of Matrix4x4 need to call.
  3. 2D DirectX 9 CreateDevice() fails

    Try to use DX Debug mode, may be it doesn't work on Windows 10
  4. DX11 ShadowMap Problem

    Yes, you should try to replace PCF filter. Ok, I think your function GetShadows should return only shadow Factor. Why did you callculated light intensity twice ?( in fuction GetShadows and in pixelShader ? Also your light direction will be received from VertexShader, Why did you callculate light direction in GetShadows? Final fuction GetShadows: float GetShadows(Pixel input) { ... //float3 lightDir = normalize(LightPosition - input.WorldPos); // your light direction will be received from VertexShader. //float lightIntensity = dot(input.Normal, lightDir); // light intensity will be calculated in pixelShader // Multiply the light intensity with the shadowFactor //lightIntensity *= shadowFactor; // Return the final lightIntensity // return lightIntensity; return shadowFactor; // return shadowFactor only. } Try to use this code, If you have incorrect result you can attach project with executable file and shaders,
  5. DX11 ShadowMap Problem

    Hi B. /, I you can to try Shadows without PCF Filter: #if 1 float shadowFactor = ShadowMap.SampleCmpLevelZero(CmpSampler, input.LightPos.xy, lightDepth); #else float shadowFactor = 0; // Perform PCF filtering on a 4 x 4 texel neighborhood for (float y = -1.5; y <= 1.5; y += 1.0) { for (float x = -1.5; x <= 1.5; x += 1.0) { float2 uvOffset = float2(x, y) * (1.0 / ShadowMapSize); shadowFactor += ShadowMap.SampleCmpLevelZero(CmpSampler, input.LightPos.xy + uvOffset, lightDepth); } } shadowFactor /= 16.0; #endif Which result will you receive ?
  6. DX11 Asynchronous Texture Creation DX11

    Yes, you are right. It is my mistake.
  7. DX11 Asynchronous Texture Creation DX11

    You can use D3D11_CREATE_DEVICE_SINGLETHREADED for creating textures from other thread, because ID3D11Device object is thread-safe, but you should synchronize manualy of creating and setting of Unity Textures.
  8. 3D Sun shafts via postprocess artefacts

    Hi all! After some modiifcation of shader i have the result for 16 samples: the result for 32 samples: also i try to change ShaftParams: const vec4 ShaftParams = vec4(0.05, 1.0, 0.1, 2.0); But i have still some artefacts. May be i should use additive blend + blur in low resolution, from turanszkij post, but can be simple to fix this implemenation. I attached the new shader. shaftsCryPS.glsl
  9. 3D Sun shafts via postprocess artefacts

    Ok, Thanks again. I will try it and check linear filter. Yes, i have separate depth scene pass without Sun, now i understand, thanks
  10. 3D Sun shafts via postprocess artefacts

    Matt_Aufderheide, turanszkij Thanks! But how to calculate of the correct number of samples ? i think we can use the dimension of Render Target for calculation of number of samples. Yes, but this is other Sun shafts technique? I think this technique are described there: here, here, also here ?
  11. Hi all! I try to use the Sun shafts effects via post process in my 3DEngine, but i have some artefacts on final image(Please see attached images). The effect contains the following passes: 1) Depth scene pass; 2) "Shafts pass" Using DepthPass Texture + RGBA BackBuffer texture. 3) Shafts pass texture + RGBA BackBuffer texture. Shafts shader for 2 pass: // uniform sampler2D FullSampler; // RGBA Back Buffer uniform sampler2D DepthSampler; varying vec2 tex; #ifndef saturate float saturate(float val) { return clamp(val, 0.0, 1.0); } #endif void main(void) { vec2 uv = tex; float sceneDepth = texture2D(DepthSampler, uv.xy).r; vec4 scene = texture2D(FullSampler, tex); float fShaftsMask = (1.0 - sceneDepth); gl_FragColor = vec4( scene.xyz * saturate(sceneDepth), fShaftsMask ); } final shader: // uniform sampler2D FullSampler; // RGBA Back Buffer uniform sampler2D BlurSampler; // shafts sampler varying vec4 Sun_pos; const vec4 ShaftParams = vec4(0.1,2.0,0.1,2.0); varying vec2 Tex_UV; #ifndef saturate float saturate(float val) { return clamp(val, 0.0, 1.0); } #endif vec4 blendSoftLight(vec4 a, vec4 b) { vec4 c = 2.0 * a * b + a * a * (1.0 - 2.0 * b); vec4 d = sqrt(a) * (2.0 * b - 1.0) + 2.0 * a * (1.0 - b); // TODO: To look in Crysis what it the shit??? //return ( b < 0.5 )? c : d; return any(lessThan(b, vec4(0.5,0.5,0.5,0.5)))? c : d; } void main(void) { vec4 sun_pos = Sun_pos; vec2 sunPosProj = sun_pos.xy; //float sign = sun_pos.w; float sign = 1.0; vec2 sunVec = sunPosProj.xy - (Tex_UV.xy - vec2(0.5, 0.5)); float sunDist = saturate(sign) * saturate( 1.0 - saturate(length(sunVec) * ShaftParams.y )); sunVec *= ShaftParams.x * sign; vec4 accum; vec2 tc = Tex_UV.xy; tc += sunVec; accum = texture2D(BlurSampler, tc); tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.875; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.75; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.625; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.5; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.375; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.25; tc += sunVec; accum += texture2D(BlurSampler, tc) * 0.125; accum *= 0.25 * vec4(sunDist, sunDist, sunDist, 1.0); accum.w += 1.0 - saturate(saturate(sign * 0.1 + 0.9)); vec4 cScreen = texture2D(FullSampler, Tex_UV.xy); vec4 cSunShafts = accum; float fShaftsMask = saturate(1.00001 - cSunShafts.w) * ShaftParams.z * 2.0; float fBlend = cSunShafts.w; vec4 sunColor = vec4(0.9, 0.8, 0.6, 1.0); accum = cScreen + cSunShafts.xyzz * ShaftParams.w * sunColor * (1.0 - cScreen); accum = blendSoftLight(accum, sunColor * fShaftsMask * 0.5 + 0.5); gl_FragColor = accum; } Demo project: Demo Project Shaders for postprocess Shaders/SunShaft/ What i do wrong ? Thanks!
  • Advertisement