Advanced Effects

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

But.. You've just given me an idea..
Because I render all Specular Highlights into its own buffer before
"Adding" them to all the other passes, why cant I just "H and V Blur"
that buffer before adding it? Huh?
And another cool thing is that the Specular buffer could even be smaller
than all the others, giving us a speed advantage.. :mrgreen: :lol:

Now were cookin!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Btw.. What does this mean..

Code: Select all

 
SQL ERROR [ mysqli ]
User i74339rw already has more than 'max_user_connections' active connections [1203]
An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
 
I know how to get past it, but it is a bit annoying..
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Advanced Effects

Post by thanhle »

It looks great.
To be realistic, the light need to wrap around the surface, since the surface can be visible by the light direction.
Some of your lights stop at the edge of the surface.
You're almost there.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

You mean brighter Diffuse and no Specular?
Or falloff?
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Or just Speclar with no Diffuse?

Image
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Advanced Effects

Post by thanhle »

The issue doesn't seems to appear on the last picture.

However, if you look at the eye on the second last picture, is that the shape of the light? What type of lights are these? Spot or custom shape light?

What is the frame rate at 1000 or 2000 lights?

Looks good,

Best regards
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Thanks! The framerate would probably also depend on how many polygons there are.
If you meant the light acting on the Empty Background, then that's simple to fix by something like..

Code: Select all

 
 if (DepthLinearised < 0.9 ) 
 {gl_FragColor = vec4(Specular * 1.0, 1.0);
  // Or Diffuse..
  // I now have them in separate passes because
  // Diffuse must be MULTIPLIED and
  // Specular must be ADDED..
 }
 
Also I Multiply the final output with SSAO just for a bit of realism..

Anyhow, I'm trying to get the Near Plane worked into it too (For an even more accurate Fragpos)..
As for the speed of the whole process, well my coding ain't that great
but I'm sure that the "concept" with good coding and GPU assembly can
produce some cool framerates.. (they're better for me already)

Here's a shot of the light not acting on the backdrop..

Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

O.K. So I figured that even if the Near Plane is usually quite close to the camera, it should be fine because of the minimal
influence this would have on the final output..
Yes that was quite correct, but..

If you had to consider this near Plane then surely you'd get much closer to Perfect,
(which due to the nature of deferred rendering would still not be absolutely perfect)..

The coder would have a choice between "Reasonably Accurate" and "Extremely Accurate"..

The Near Plane as well:
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Now the code for "Reasonably Accurate" would be:

Code: Select all

 
   FragmentPosXYZ.x = CameraPosition.x + ((FarLeftDwnXYZ.x
                      + ((FarLeftUpXYZ.x - FarLeftDwnXYZ.x)  * UVCoordsXY.y)
                      + (FarRightDwnXYZ.x - FarLeftDwnXYZ.x) * UVCoordsXY.x)
                      * DepthLinearised);
   FragmentPosXYZ.y = CameraPosition.y + ((FarLeftDwnXYZ.y 
                      + ((FarLeftUpXYZ.y - FarLeftDwnXYZ.y)  * UVCoordsXY.y)
                      + (FarRightDwnXYZ.y - FarLeftDwnXYZ.y) * UVCoordsXY.x)
                      * DepthLinearised);
   FragmentPosXYZ.z = CameraPosition.z + ((FarLeftDwnXYZ.z
                      + ((FarLeftUpXYZ.z - FarLeftDwnXYZ.z)  * UVCoordsXY.y)
                      + (FarRightDwnXYZ.z - FarLeftDwnXYZ.z) * UVCoordsXY.x)
                      * DepthLinearised);
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

The code for "EXTREMELY ACCURATE" would be.. (drum-roll)..

Code: Select all

 
   FragmentPosXYZ.x = (CameraPosition.x + ((((FarLeftDwnXYZ.x + ((FarLeftUpXYZ.x - FarLeftDwnXYZ.x) * UVCoordsXY.y)
                      + (FarRightDwnXYZ.x - FarLeftDwnXYZ.x) * UVCoordsXY.x))
                      - // Minus the Near Plane Corners..
                      ((NearLeftDwnXYZ.x + ((NearLeftUpXYZ.x - NearLeftDwnXYZ.x) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.x - NearLeftDwnXYZ.x) * UVCoordsXY.x))) * DepthLinearised))
                      // Plus (Near Minus Camera)..
                      + ((((NearLeftDwnXYZ.x + ((NearLeftUpXYZ.x - NearLeftDwnXYZ.x) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.x - NearLeftDwnXYZ.x) * UVCoordsXY.x))) - CameraPosition.x );
                        
   FragmentPosXYZ.y = (CameraPosition.y + (((FarLeftDwnXYZ.y + ((FarLeftUpXYZ.y - FarLeftDwnXYZ.y) * UVCoordsXY.y)
                      + (FarRightDwnXYZ.y - FarLeftDwnXYZ.y) * UVCoordsXY.x)
                      - // Minus the Near Plane Corners..
                       ((NearLeftDwnXYZ.y + ((NearLeftUpXYZ.y - NearLeftDwnXYZ.y) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.y - NearLeftDwnXYZ.y) * UVCoordsXY.x))) * DepthLinearised))
                      // Plus (Near Minus Camera)..
                      + ((((NearLeftDwnXYZ.y + ((NearLeftUpXYZ.y - NearLeftDwnXYZ.y) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.y - NearLeftDwnXYZ.y) * UVCoordsXY.x))) - CameraPosition.y);
                      
   FragmentPosXYZ.z = (CameraPosition.z + (((FarLeftDwnXYZ.z + ((FarLeftUpXYZ.z - FarLeftDwnXYZ.z) * UVCoordsXY.y)
                      + (FarRightDwnXYZ.z - FarLeftDwnXYZ.z) * UVCoordsXY.x)                  
                      - // Minus the Near Plane Corners..
                      ((NearLeftDwnXYZ.z + ((NearLeftUpXYZ.z - NearLeftDwnXYZ.z) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.z - NearLeftDwnXYZ.z) * UVCoordsXY.x))) * DepthLinearised))
                      // Plus (Near Minus Camera)..
                      + ((((NearLeftDwnXYZ.z + ((NearLeftUpXYZ.z - NearLeftDwnXYZ.z) * UVCoordsXY.y)
                      + (NearRightDwnXYZ.z - NearLeftDwnXYZ.z) * UVCoordsXY.x))) - CameraPosition.z );  
 
 
(that was an edit..)
Last edited by Vectrotek on Sun Feb 05, 2017 10:00 pm, edited 2 times in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Now one way to see if it is really more accurate is to render the "Final Linearized Depth" in a little window
(see the Bottom Right Window) and then to set the "Near and Far" to tightly enclose the test subject, then
see if the Specular highlights still "look" right and..

(26808 Polygons at 30 fps)
Image

This works!

I'll take credit for this little formula (bar some unnecessary parenthesis and some help) thank you very much! 8)

Thanks goes out to Devsh and Mel!

(net so n' klein bietjie windgat)
Last edited by Vectrotek on Sun Feb 05, 2017 6:03 pm, edited 3 times in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Next would be Normal Maps, Tangents, Binormals, Specular and "PLAECF" Gloss Maps..
And maybe once I figure out how to access GPU Shader Parameters by INDEX rather than NAME,
even GPU Assembly. But before that I'd like to try Screen Space Reflection now that we have
all the parameters required for it ..

Cheers and thanks!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Oh.. In your loop this would obviously have to happen cyclically (if you've got my last project)..

Code: Select all

 
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("CameraPosition", CameraPosition);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("FarLeftUpXYZ", FarLeftUpXYZ);
   // MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("FarRightUpXYZ", FarRightUpXYZ); // NOT USED!!
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("FarRightDwnXYZ", FarRightDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("FarLeftDwnXYZ", FarLeftDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("NearLeftUpXYZ", NearLeftUpXYZ);
   // MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("NearRightUpXYZ", NearRightUpXYZ); // NOT USED..
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("NearRightDwnXYZ", NearRightDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S27_ACCURATE_DEFERRED_A_DIFFUSE)  ->SetFragment3FloatsByName ("NearLeftDwnXYZ", NearLeftDwnXYZ);
 
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("CameraPosition", CameraPosition);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("FarLeftUpXYZ", FarLeftUpXYZ);
  //  MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("FarRightUpXYZ", FarRightUpXYZ); // NOT USED
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("FarRightDwnXYZ", FarRightDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("FarLeftDwnXYZ", FarLeftDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("NearLeftUpXYZ", NearLeftUpXYZ);
   // MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("NearRightUpXYZ", NearRightUpXYZ); // NOT USED!!
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("NearRightDwnXYZ", NearRightDwnXYZ);
   MyCoolEffect.AccessThePPShaderCollection() ->AccessShader (S28_ACCURATE_DEFERRED_B_SPECULAR)  ->SetFragment3FloatsByName ("NearLeftDwnXYZ", NearLeftDwnXYZ);
 
Last edited by Vectrotek on Tue Feb 07, 2017 8:24 pm, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Frank Sponzappa..
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Image
Post Reply