View unanswered posts | View active topics
Forum › CryENGINE 2 › Showcase Gallery › Misc › CryEngine2 Global Illumination (Lights, SSGI, Vertex Paint)
|
|
|
 |
VinoBob  |
Uber Modder | Member since: 11.03.2009, 19:43 | Posts: 1697 | Location: in da hood |
Likes: 1 |
| |
|
Post Topic: Posted 12.09.2009, 00:40 |
Nice. How did you make the pix that are without textures( or white texture ). It seems to me that you can enable that render mode somehow, am i right?
"I gots to talk. I gotta tell what I feel."
|
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 12.09.2009, 01:01 |
There's a console command for it.
e_default_material
Set it to 1, and the renderer replaces all the materals with the default one. It has no effect on your level whatsoever, so don't worry about it replacing textures - it's purely a render thing.
|
|
|
|
|
|
|
 |
Lex4art  |
Skilled Modder | Member since: 15.04.2008, 13:25 | Posts: 627 | Location: Russian federation, Moskow |
Likes: 0 |
| |
|
Post Topic: Posted 12.09.2009, 12:09 |
>>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? ^^
i5 2500K @4.7Ghz; 16Gb DDR3 @1866Mhz; GTX660Ti 2Gb @1260/7000Mhz; ASUS P8Z77-M PRO; dual monitors.
|
|
|
|
|
|
|
 |
BloodShadow  |
Trainee | Member since: 01.07.2008, 21:49 | Posts: 197 | Location: Germany |
Likes: 0 |
| |
|
Post Topic: Posted 12.09.2009, 12:48 |
Hi maybe you could show us your shader code? So we can try to help you.  )
|
|
|
|
|
|
|
 |
VinoBob  |
Uber Modder | Member since: 11.03.2009, 19:43 | Posts: 1697 | Location: in da hood |
Likes: 1 |
| |
|
Post Topic: Posted 12.09.2009, 14:05 |
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?
"I gots to talk. I gotta tell what I feel."
|
|
|
|
|
|
|
 |
Mocib  |
Trained Modder | Member since: 08.03.2006, 18:37 | Posts: 330 |
Likes: 0 |
| |
|
Post Topic: Posted 12.09.2009, 18:51 |
Quote: Originally posted by XzeroI'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.  What frame rates are you getting?
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 12.09.2009, 22:43 |
Quote: 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? ^^ I'm very interested  Quote: 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? The shader is an adapted version of an already existing method. The very method in that SSGI video. The code was released by the author, so it being "stolen" from can't happen, as it itself is "stolen" (not really as he was sharing, but you get the idea). Quote: Originally posted by BloodShadowHi maybe you could show us your shader code? So we can try to help you.  ) I'll post the code in a bit. I'm going to tweak it some, add some comments, etc. I'll also again in adding it to a current shader. Quote: Originally posted by Mocib What frame rates are you getting? I'd have to check the performances, but in general I think it's something like this: Shadows off, 20 - 30 FPS Shadows on, 8 - 20 FPS Remember that's at 1920x900 in an unoptimized state. I'm sure at 1280x720 I'd get much better frames. Heck, lowering to 1600x900 gives me a boost of 4 - 6 FPS. The performance depends on shadow size, but with shadows blurred, even 256x256 shadow maps look fantastic, if not somehow more realistic for the internal lighting. The real kick in performance isn't the shadows though, it's the mass amounts of lights I have in the scene. Each light increases the polycount by... I'm not sure how much, but with all them together it doubles the polycount. Deffered lighting would be nice right now.. What I'd like to do is have sun shadows unblurred, while point-light shadows fully blured, to give an ambient lighting look to it. It really would look fantastic! If anyone has any ideas on how to do this, please let me know. Finding the blur code in the shaders is harder than I thought it'd be. lol Anyway, off to the SSGI shader
Last edited by Cry-Styves on 12.09.2009, 22:50, edited 5 times in total.
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 13.09.2009, 01:17 |
Okay, here's the code. It currently replaces the PostEffects.cfx Grain Filter technique, for testing purposes. It should be error free, as the grain still works, but I'm getting no results. Something's wrong somewhere, but I have no idea where. Code: //////////////////////////////////////////////////////////////////////////////////////////////////// /// 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; } } On the bright side, I managed to find a way to blur the point lights shadows, without blurring the sun shadows.  Edit: Turns out that the performance lost isn't caused by lights, but by the floor reflections. Edit: Updated code.
Last edited by Cry-Styves on 14.09.2009, 00:54, edited 13 times in total.
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 13.09.2009, 07:28 |
I think I found a problem with the shader. It seems the for loop doesn't work. This is what I had to change it to in order to get the grain and shader to work again. Changing the 4 to a 2 makes the screen black when removing grain filter. Code: for(int i=0; i < 4; i++) { for(int j=0; j < 4; j++) { But in order for the shader to actually work correctly, it needs to be this: Code: for(int i=-hf; i < hf; i++) { for(int j=-hf; j < hf; j++) { However, that causes the shader to stop working. It seems that the for loop can't function properly with hf in it, which is really confusing. hf is defined a few lines up: Code: //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;
Any help here would be hot. Not sure if it's the only problem, but I hope so.
Last edited by Cry-Styves on 13.09.2009, 07:46, edited 3 times in total.
|
|
|
|
|
|
|
 |
Lex4art  |
Skilled Modder | Member since: 15.04.2008, 13:25 | Posts: 627 | Location: Russian federation, Moskow |
Likes: 0 |
| |
|
Post Topic: Posted 13.09.2009, 09:13 |
To Xzero - ok, here it: Default lightning:  "Radiocity" emulation (overused for better notice):  How: i just make tricky small 16x16 px cubemap and use on target materials. Here it is: http://www.sendspace.com/file/vd9dmz (6 kbytes) The point of this cubemap - then i make it in sandbox2 i use specific ToD settings (strong black fog that covers all far objects to pitch black). Then cubemap applying to object - the black color is not affect material - so, only not black pixels makes something like radiocity. This metod have a limitations but i like it - one cubemap can be used on a lot of objects; fast (fast to use and fast to render - no perfomance lost) and not bad radiocity effect. Oh, my english is ... not perfect  .
i5 2500K @4.7Ghz; 16Gb DDR3 @1866Mhz; GTX660Ti 2Gb @1260/7000Mhz; ASUS P8Z77-M PRO; dual monitors.
Last edited by Lex4art on 13.09.2009, 09:17, edited 2 times in total.
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 13.09.2009, 09:50 |
Dude, awesome. I'll take a look at it for sure!
I don't exactly understand how to use it though.
On another note, I've been thinking of a way to recreate something like CE3's Light Propagation volumes. No luck yet though. I'm thinking maybe playing with the fogvolumes and tweak the color to be the scene colors. Who knows.
Edit: I managed to get some results. They're not great, but it's something. I still need to fix the problem above, as the samples aren't scaling with distance as they should be.
Last edited by Cry-Styves on 13.09.2009, 12:42, edited 8 times in total.
|
|
|
|
|
|
|
 |
Lex4art  |
Skilled Modder | Member since: 15.04.2008, 13:25 | Posts: 627 | Location: Russian federation, Moskow |
Likes: 0 |
| |
|
Post Topic: Posted 13.09.2009, 12:51 |
Thanks ^^ Using: 1)Select target material 2)Use this cubemap texture in "Environment" field. 3)Then shader generation params enable "Specular EnvCM" 4)"Specular color" set "255,255,255" or whatever you need for colored radiocity (default is "0,0,0" - with that zero values nothing will work). 5)Adjust power of cubemap in "Shader params" http://img12.imageshack.us/img12/1107/lex4artcubemapapply.jpg for sample And - how i can try your shader (im not a coder - i cant compile it)? Or this is early demo and no way to use at this time?
i5 2500K @4.7Ghz; 16Gb DDR3 @1866Mhz; GTX660Ti 2Gb @1260/7000Mhz; ASUS P8Z77-M PRO; dual monitors.
Last edited by Lex4art on 13.09.2009, 12:57, edited 2 times in total.
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 13.09.2009, 13:06 |
Extract PostEffects.cfx from Shaders.pak and place it in your Game/Shaders/HWScripts/CryFX folder, and then open it in notepad or Visual C++ Then go to the bottom and copy/paste my shader code over the following code: Code: //////////////////////////////////////////////////////////////////////////////////////////////////// /// 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; } } Then add the flowgraph node "Image:GrainFilter" to your map and make it start on startup (make sure amount is set to 1). Just a note though: It's really buggy. It doesn't actually give you anything other than slight double vision in the behavior of SSAO. lol
|
|
|
|
|
|
|
 |
Black Rainbow  |
Has no life | Member since: 21.01.2008, 11:28 | Posts: 6198 | Location: 52°21'25.06"N 4°56'48.42"E |
Likes: 0 |
| |
|
Post Topic: Posted 13.09.2009, 13:06 |
Xzero, this is looking awesome, but I think the effect is too great. Especially in the pic with the Raptor team sitting in the room, for instance it looks as if Jester has a light bulb aimed at his face. The colours are very nice, but it brightens the entire scene too much.
|
|
|
|
|
|
|
 |
Cry-Styves  |
THE Shader Guy | Member since: 11.09.2008, 21:08 | Posts: 3011 | Location: Frankfurt |
Likes: 9 |
| |
|
Post Topic: Posted 13.09.2009, 13:11 |
Thanks for the input Black Rainbow, but I don't see what you mean lol I will be posting some shots with shadows enabled, which lowers the overall brightness that I think you're talking about. I'll post them up sometime and you can tell me if I fixed it.
|
|
|
|
|
|