Connect and collaborate with CRYENGINE developers in the official Forums.
Visit the Gallery to share what you have created and be inspired by what others are creating with CRYENGINE.
Originally posted by Xzero
I've also added shadows, so the lighting is even better looking.... but it does run like crud, but then again, considering the high-resolution it's being run at and the very lager shadow resolution (e_shadows_max_texture_size 2048), it's understandable.
Originally posted by Lex4art
>>Since jittering doesn't affect point lights, it didn't change my light source, and only the sun's. Then I change my tex format for shadows from 4 to 0, so that r_ShadowBlur would work, and then slightly blured it so that the jittering was less obvious.
Wow. u have pretty deep relations with engine ^^
Im also have simple solution for radiocity emulation - anyone interested? ^^
Originally posted by VinoBob
Thanks mate! I suspected that there should be a change in the rendering, not int the textures. Regarding the shader code, i suggest to dont show it to the public. if you have a good idea, it may be stolen. BTW is this SSGI the same as we saw in the CE3 presentations? It ran at a unbelievable high FPS-s, even CE2 with SSAO cannot reach that speed with those settings. Its hard to believe those results. How does your shader perform with CE2, dosent let it drop the FPS too much?
Originally posted by BloodShadow
Hi maybe you could show us your shader code?
So we can try to help you. )
Originally posted by Mocib
What frame rates are you getting?
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Grain filter technique /////////////////////////////////////////////////////////////////////////
//Number of samples.
float4 NUM_SAMPLES = 8;
//Grain sampler for grain filter.
sampler2D grainNoiseSampler = sampler_state
{
Texture = textures/defaults/vector_noise.dds;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = POINT;
AddressU = Wrap;
AddressV = Wrap;
};
sampler2D GIsum : register (s0)
{
Texture = $ZTarget;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = POINT;
AddressU = Clamp;
AddressV = Clamp;
};
sampler2D GInormal : register (s2)
{
Texture = $BackBuffer;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = POINT;
AddressU = Clamp;
AddressV = Clamp;
};
sampler2D GIcolor : register (s3)
{
Texture = $BackBuffer;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = POINT;
AddressU = Clamp;
AddressV = Clamp;
};
////////////////// structures /////////////////////
struct vtxOutGrainFilter
{
float4 HPosition : POSITION;
float4 ScreenTC : TEXCOORD0;
};
///////////////// vertex shader //////////////////
// based off BaseVS
vtxOutGrainFilter GrainFilterVS(vtxIn IN)
{
vtxOutGrainFilter OUT = (vtxOutGrainFilter)0;
float4 vPos = IN.Position;
OUT.HPosition = mul(vpMatrix, vPos);
OUT.ScreenTC.xy = IN.baseTC.xy;
// output with correct aspect ratio into wz
OUT.ScreenTC.wz = (IN.baseTC.xy -0.5 ) * float2(0.75*(ScrSize.x/ScrSize.y), 1.0) + 0.5;
return OUT;
}
//noise producing function to eliminate banding - can't get it working, will just do that after it's done.
float GIrand(float2 co)
{
return 0.5+(frac(sin(dot(co.xy, float2(12.9898,78.233))) * 43758.5453))*0.5;
}
pixout GrainFilterPS(vtxOutGrainFilter IN)
{
pixout OUT;
///////////////// grain filter //////////////////
half4 acc = 0;
float2 vNoiseTC = (IN.ScreenTC.xy ) * (PS_ScreenSize.xy/64.0) + (psParams[0].xy/PS_ScreenSize.xy);
float2 vNoise = tex2D(grainNoiseSampler, vNoiseTC)+ dot(IN.ScreenTC.xy, 1) * 65535;
vNoise = frac( vNoise );
vNoise = vNoise*2-1;
//vNoise *= 0.05;
half4 cScreen = tex2D(screenMapSampler, IN.ScreenTC);
///////////////// arkano22 SSGI //////////////////
//Calculate sampling rates.
float ratex = (1.0/1024.0);
float ratey = (1.0/768.0);
//Initialize occlusion sum and gi color.
float sum = 0.0;
float3 fcolor = float3(0,0,0);
//Far and near clip planes.
float zFar = 80.0;
float zNear = 0.5;
//Get depth at current pixel.
float prof = tex2D(GIsum, IN.ScreenTC.xy).x;
//Scale sample number with depth.
int samples = round(8/(0.5+prof));
prof = zFar * zNear / (prof * (zFar - zNear) - zFar); //linearize z sample
//Obtain normal and color at current pixel.
float3 norm = normalize(float3(tex2D(GInormal,IN.ScreenTC.xy).xyz)*2.0-float(1.0));
float3 dcolor1 = tex2D(GIcolor, IN.ScreenTC.xy);
int hf = samples/2;
//Calculate kernel steps.
float incx = ratex*30;//gi radius
float incy = ratey*30;
float incx2 = ratex*8;//ao radius
float incy2 = ratey*8;
//Do the actual calculations.
for(int i=0; i < 2; i++)
{
for(int j=0; j < 2; j++)
{
if (i != 0 || j!= 0)
{
float2 coords = float2(i*incx,j*incy)/prof;
float2 coords2 = float2(i*incx2,j*incy2)/prof;
float prof2 = tex2D(GIsum,IN.ScreenTC.xy+coords*GIrand(IN.ScreenTC)).x;
prof2 = zFar * zNear / (prof2 * (zFar - zNear) - zFar); //linearize z sample
float prof2g = tex2D(GIsum,IN.ScreenTC.xy+coords2*GIrand(IN.ScreenTC)).x;
prof2g = zFar * zNear / (prof2g * (zFar - zNear) - zFar); //linearize z sample
float3 norm2g = normalize(float3(tex2D(GInormal,IN.ScreenTC.xy+coords2*GIrand(IN.ScreenTC)).xyz)*2.0-float3(1.0,1.0,1.0));
float3 dcolor2 = tex2D(GIcolor, IN.ScreenTC.xy+coords*GIrand(IN.ScreenTC));
//OCCLUSION:
//Calculate approximate pixel distance.
float3 dist2 = float3(coords2,prof-prof2g);
//Calculate normal and sampling direction coherence.
float coherence2 = dot(normalize(-coords2),normalize(float2(norm2g.xy)));
//If there is coherence, calculate occlusion.
if (coherence2 > 0)
{
float pformfactor2 = 0.5*((1.0-dot(norm,norm2g)))/(3.1416*pow(abs(length(dist2*2)),2.0)+0.5);//el 4: depthscale
sum += clamp(pformfactor2*0.2,0.0,1.0);//ao intensity;
}
//COLOR BLEEDING:
if (length(dcolor2)>0.3)
{
//Color threshold
float3 norm2 = normalize(float3(tex2D(GInormal,IN.ScreenTC.xy+coords*GIrand(IN.ScreenTC)).xyz)*2.0-float3(1.0,1.0,1.0));
//Calculate approximate pixel distance.
float3 dist = float3(coords,abs(prof-prof2));
//Calculate normal and sampling direction coherence:
float coherence = dot(normalize(-coords),normalize(float2(norm2.xy)));
//If there is coherence, calculate bleeding.
if (coherence > 0)
{
float pformfactor = ((1.0-dot(norm,norm2)))/(3.1416*pow(abs(length(dist*2)),2.0)+0.5); //el 4: depthscale
//fcolor += dcolor2*(clamp(pformfactor,0.0,1.0));
// Brighten it up a bit.
fcolor += dcolor2*(clamp(pformfactor*4,4.0,4.0));
}
}
}
}
}
float3 bleeding = (fcolor/samples)*0.5;
float occlusion = 1.0-(sum/samples);
//Output SSGI
OUT.Color = float4(1,1,1,1);
OUT.Color = float4(float3(dcolor1*occlusion+bleeding*0.5),1.0);
// Grainfilter test output
// OUT.Color = cScreen + dot(vNoise.xy, 0.5)*psParams[0].w;
//Weaker grain as to not interfere with the image.
//OUT.Color = cScreen + dot(vNoise.xy, 0.25)*psParams[0].w;
return OUT;
}
////////////////// technique /////////////////////
technique GrainFilter
{
pass p0
{
VertexShader = compile vs_Auto GrainFilterVS();
PixelShader = compile ps_Auto GrainFilterPS();
ZEnable = false;
ZWriteEnable = false;
CullMode = None;
}
}
for(int i=0; i < 4; i++)
{
for(int j=0; j < 4; j++)
{
for(int i=-hf; i < hf; i++)
{
for(int j=-hf; j < hf; j++)
{
//Scale sample number with depth.
int samples = round(8/(0.5+prof));
prof = zFar * zNear / (prof * (zFar - zNear) - zFar); //linearize z sample
//Obtain normal and color at current pixel.
float3 norm = normalize(float3(tex2D(GInormal,IN.ScreenTC.xy).xyz)*2.0-float3(1.0,1.0,1.0));
float3 dcolor1 = tex2D(GIcolor, IN.ScreenTC.xy);-
int hf = samples/2;
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Grain filter technique /////////////////////////////////////////////////////////////////////////
sampler2D grainNoiseSampler = sampler_state
{
Texture = textures/defaults/vector_noise.dds;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = POINT;
AddressU = Wrap;
AddressV = Wrap;
};
pixout GrainFilterPS(vtxOut IN)
{
pixout OUT;
half4 acc = 0;
float2 vNoiseTC = (IN.baseTC.xy ) * (PS_ScreenSize.xy/64.0) + (psParams[0].xy/PS_ScreenSize.xy);
float2 vNoise = tex2D(grainNoiseSampler, vNoiseTC)+ dot(IN.baseTC.xy, 1) * 65535;
vNoise = frac( vNoise );
vNoise = vNoise*2-1;
//vNoise *= 0.05;
half4 cScreen = tex2D(screenMapSampler, IN.baseTC);
OUT.Color = cScreen + dot(vNoise.xy, 0.5)*psParams[0].w;
return OUT;
}
////////////////// technique /////////////////////
technique GrainFilter
{
pass p0
{
VertexShader = compile vs_Auto BaseVS();
PixelShader = compile ps_Auto GrainFilterPS();
CullMode = None;
}
}