• Advertisement

Andrey OGL_D3D

Member
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About Andrey OGL_D3D

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. DX11 Asynchronous Texture Creation DX11

    Yes, you are right. It is my mistake.
  2. 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.
  3. 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
  4. 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
  5. 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 ?
  6. 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