Jump to content
  • Advertisement

toto5100

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

169 Neutral

About toto5100

  • Rank
    Member
  1. When i do : length( fwidth(normalize(WorldNormal) )  ) / length( fwidth (worldPos ) ); it changes nothing. Also, i'm using Unity's Surface Shaders, which compute normals automatically. Normal map is also taken in account. I don't know how can i smooth them. It's also strange that the SSS effect works well when i do BRDF before gamma correction and looks ugly when i do gamma correction on input.   PS : You think Cook Torrance with GGX is good for skin specular or i should move to Kelemen/Szirmay-Kalos ?
  2. It's not a problem of normal : Normals are ok.   And about the curvature, i calculate it dynamically using : length( fwidth(WorldNormal)  ) / length( fwidth (worldPos ) );   I'm manually correcting gamma by doing pow(2.2) on input (Albedo) and pow(1/2.2) on output. When i remove this (so without gamma correction) it looks like it should (but its in gamma).   So i found a compromise which is i do gamma correction AFTER brdf calculations. So the code looks like this : half3 falbedo = tex2D(_MainTex,uv); float ndotl = dot(s.blurNormal,lightDir); lookUpPos.x = ndotl * 0.5 + 0.5; lookUpPos.y = curvature * lightIntensity; float3 dif = tex2D (_BRDFLookUp, lookUpPos).xyz; fAlbedo*=dif; float3 final = (pow(fAlbedo,2.2) + spec) * _LightColor0.rgb * (attenuation * 2); return float4(final,1); I know that it's not correct but i found nothing else.
  3. Hi, Now, i implemented Pre Integrated SSS, so i use curvature and BRDF lookup but i have a new problem : the SSS have ugly artifacts, and i don't know why. I tried to use a smaller mip map but it doesn't resolve the problem. You can see the SSS is pretty hard, with a "polygon" look.   After that, i tried to do a pow(2.2) on the lookupsample, and there is less artifacts but it's incorrect(the falloff is not linear). I also have some banding.
  4. I tested your half lambert, but the problem is the lighting looks flat : the falloff is very large, so it looks incorrect, especially with shadows. I tried to downscale the normal map, and the result is a little softer, but it's still very harsh. [attachment=22313:Image based Lighting Woman Harsh 2.jpg] I'll try pre integrated sss too. Someone knows where i can download the head scan all people use ? The Infinite site is down :(
  5. @Promit Yes, the falloff is very harsh, and without specular too (it stay the same). Do you know another diffuse equation i can use to have something softer ? @kauna It's because Unity Free have his inputs in Gamma Space, so i had to manually correct the gamma in shaders.   I will try Sub Surface Scaterring, but i cant' use a method in Screen Space or anything which needs a rendertexture : in free version, rendertexture are very expensive. So i'll try the Pre-Integrated Skin Shading but i have some questions : if i understood well, i need my usual textures : - Albedo, Normal map, Specular Map, Gloss Map and - Curvature Map (Baked from the mesh) and BRDF look up So this method only affect diffuse calculations right ? I can keep my Cook Torrance Specular, i just have to modify classic Diffuse Lambert to add SSS ?
  6. Hi, i implemented physically based shading, using the Cook Torrance BRDF Equation, with Trowbridge Reitz GGX for Normal Distribution, the Smith Schlick GGX for Geometric Shadowing, Schlick Approximation for Fresnel and for diffuse, Lambert. All is working in Linear Space with pow(2.33) on Input and pow(0.4545) on output, and it looks good. But the problem i have is for skin : [attachment=22294:Skin harsh.jpg] The falloff is too harsh, good for general objects, but the skin should look softer. And it looks like cell shading... So how can i make it softer like this :
  7. toto5100

    Problem with SSAO (solved)

    Yeah your SSAO looks good Where do the dot ? In my code, there is already 2 dot products in the aoFF function (functions which calculate ao contribution) : float aoFF(in half3 ddiff, in half3 cnorm, in float c1, in float c2, in float2 uv) //cnorm -> main normal and readDepthNormal(uv+half2(c1,c2).xyz -> sample normal { half3 vv = normalize(ddiff); float rd = length(ddiff);   return clamp(1.0-dot(readDepthNormal(uv+half2(c1,c2)).xyz,-vv),0.0,1.0) *             clamp(dot( cnorm,vv )-_Bias,0.0,1.0)*               (1.0 - 1.0/sqrt(1.0/(rd*rd*_scale) + 1.0)); }   Because currently, i have a little self occlusion and "grey" planes surfaces caused i think by the self occlusion (but my depth buffer is precise so it renders grey and not like lines). I can't combine ambient term with ao, i can just blend the ao on the screen because i'm using Unity Free and it doesn't allow rendertextures. So i "fake" it by using a method which is very slow so i can use just 1 grabpass because 2 or more would be too expensive. I capture both depth and normals in 1 pass.   EDIT : ok, i solved the self occlusion by my self, i just added a condition about a dot threshold and it done the job :)
  8. toto5100

    Problem with SSAO (solved)

    Ok. I did tweked a little my shader and its works well, but i have self occlusion artifacts. How can i avoid them ?
  9. toto5100

    Problem with SSAO (solved)

    Now, i have a working SSAO but i have problems : there is many black halo and the ao intensity decrease when we are near. Only the far ao can be seeing :    No one can help me ?
  10. Hi, i tried to implement the Disk to Disk SSAO method from Arkano22 (http://www.gamedev.net/topic/556187-the-best-ssao-ive-seen/) in Unity, which doesn't use GLSL but CG. The problem is : it doesn't look like SSAO at all. I really have no idea on where is the problem. Input texures seems good, and i didnt modified anything (i only ported the code), it uses the same method with the same functions (except for the position buffer reconstruction). Here is the code i use :   Shader "FXLab/PostProcessing/Bunell Disk SSAO" {     Properties { _FXDepthTexture ("Depth Texture (FXDepthTexture)", 2D) = "" {} _FXWorldNormalTexture ("World Normal Texture (FXWorldNormalTexture)", 2D) = "" {} _noiseTex ("NoiseTex", 2D) = ""{} } SubShader { //Blend One Zero Blend Zero SrcColor Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Opaque"} Lighting Off Cull Off Fog { Mode Off } ZWrite Off   Pass { CGPROGRAM   #pragma vertex vert #pragma fragment frag  #pragma target 3.0 #pragma glsl   #include "UnityCG.cginc"   #define FORCE_TEX2DLOD #include "../FXLab.cginc"   float _Bias; sampler2D noiseTex; float4 _ProjInfo; float4x4 _InvProj;   struct appdata { float4 vertex : POSITION; float4 texcoord : TEXCOORD0; float3 normal : NORMAL; };   struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0;   };   v2f vert (appdata v) { v2f o; o.pos = mul( UNITY_MATRIX_MVP, v.vertex ); o.uv = v.texcoord.xy;   return o; }   float3 posFromDepth(float2 coord) { float Depth=sampleDepth(coord); //sampleDepth return the depth value (0...1 range) float4 Pos=float4((coord.x-0.5)*2,(0.5-coord.y)*2,1,1); float4 Ray=mul(Pos,_InvProjMatrix); return Ray.xyz*Depth; }     float aoFF(in half3 ddiff, in half3 cnorm, in float c1, in float c2, in float2 uv) { half3 vv = normalize(ddiff); float rd = length(ddiff); return (1.0-clamp(dot(sampleWorldNormal(uv+half2(c1,c2)),-vv),0.0,1.0)) *             clamp(dot( cnorm,vv ),0.0,1.0)*               (1.0 - 1.0/sqrt(1.0/(rd*rd) + 1.0)); }     fixed4 frag( v2f o ) : COLOR { float dep = sampleFloat(_FXDepthTexture, o.uv); half3 n = sampleWorldNormal(o.uv); half3 p = posFromDepth(o.uv);   half2 fres = half2(_ScreenParams.x/64.0*5,_ScreenParams.y/64.0*5); half3 random = tex2D(noiseTex,o.uv*fres.xy); random = random*2.0-half3(1.0);   float ao = 0.0; float incx = 1/_ScreenParams.x*0.1; float incy = 1.0/_ScreenParams.y*0.1; float pw = incx; float ph = incy; float cdepth = sampleDepth(o.uv); for(float i=0.0; i<3.0; ++i)      {         float npw = (pw+0.0007)/cdepth;         float nph = (ph+0.0007)/cdepth;           half3 ddiff = posFromDepth(o.uv+half2(npw,nph))-p;         half3 ddiff2 = posFromDepth(o.uv+half2(npw,-nph))-p;         half3 ddiff3 = posFromDepth(o.uv+half2(-npw,nph))-p;         half3 ddiff4 = posFromDepth(o.uv+half2(-npw,-nph))-p;         half3 ddiff5 = posFromDepth(o.uv+half2(0,nph))-p;         half3 ddiff6 = posFromDepth(o.uv+half2(0,-nph))-p;         half3 ddiff7 = posFromDepth(o.uv+half2(npw,0))-p;         half3 ddiff8 = posFromDepth(o.uv+half2(-npw,0))-p;           ao+=  aoFF(ddiff,n,npw,nph,o.uv);         ao+=  aoFF(ddiff2,n,npw,-nph,o.uv);         ao+=  aoFF(ddiff3,n,-npw,nph,o.uv);         ao+=  aoFF(ddiff4,n,-npw,-nph,o.uv);         ao+=  aoFF(ddiff5,n,0,nph,o.uv);         ao+=  aoFF(ddiff6,n,0,-nph,o.uv);         ao+=  aoFF(ddiff7,n,npw,0,o.uv);         ao+=  aoFF(ddiff8,n,-npw,0,o.uv);           //increase sampling area:         pw += incx;           ph += incy;         }      ao/=24.0;   fixed3 color = saturate(1- ao);   return fixed4(color, 1); } ENDCG } }       Fallback off CustomEditor "FXMaterialEditor" }   And here is what i have : AO only : [attachment=21775:SSAO Bad.jpg] Depth Texture (8 bit): [attachment=21772:SSAO Depth.jpg] World Normal texture : [attachment=21773:SSAO Normal.jpg] Reconstructed from depth position buffer : [attachment=21774:SSAO Position.jpg]   Someone can help me ? Thanking you in advance.  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!