Jump to content

Posteffect: VolumetricLighting


klepto2
 Share

Recommended Posts

Download: VolumetricLighting0_9_5.zip

This is a small but powerful posteffect with "real" VolumetricLighting for all lighttypes.

It shows some basic powerful features of the UltraEngine pipeline:

  • Performance
  • Accesibility (you can get nearly everything in a shader at every time)

The shader itself features Volumetric lighting based on the included shadowmap lookups and performs some calculations more or less like the screenspace godrays, but not depenfing on the backbuffer colors, but real shadow casting. It also features calculates only 1/16th of a buffer (plus out of scope pixels) per frame and reprojects the result of the previous buffer if possible.

The shader itself is currently more or less for demonstration usage only, because there are no volumetric settings for lights available and adding these would require some kind of lua or cpp backend.

image.thumb.png.d8bd6d28dcb82ce585fe9a2c76cf8cd7.png

  • Like 4
  • Upvote 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

I just tried this in game and it looks awesome, albeit a bit bright at the moment (might be my settings, not sure).\

VolumeLight_Tests.thumb.png.1ab44ca5a695aa41bc8e2ada0a08541d.png

Also it didn't work with the environment maps set.  Should it work with this you think?

 auto specmap = LoadTexture("Materials/Environment/Default/specular.dds");
 auto diffmap = LoadTexture("Materials/Environment/Default/diffuse.dds");

 world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR);
 world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE);

 

  • Like 2
Link to comment
Share on other sites

You can try to change the exposure and gamma corection parameters in the fragment shader:

const float G_SCATTERING_DEFAULT = 0.7f;
const float G_SCATTERING_DIRECTIONAL = 0.1f;
const float exposure = 20.0;
const float gamma = 1.1;

also the function writetopixel in the fragment shader (i added a return true for the editor):

bool writeToPixel(vec2 fragCoord)
{
//return true;
    ivec2 iFragCoord = ivec2(fragCoord);
    uint index = CurrentFrame % BAYER_LIMIT;
    return (((iFragCoord.x + BAYER_LIMIT_H * iFragCoord.y) % BAYER_LIMIT)
            == bayerFilter_[index]);	
}

 comment it out to use the reprojection, should be a bit faster.

  • Like 1
  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

also it should work with the environemnt, it might be that it interfears with your atmosphere shader. it uses a sphere if i remember correctly.

  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

  • 3 weeks later...

I think it might be a good idea to render point and spot lights in this manner using a sphere or cone mesh with a special shader. You would need the material set to use blending, and the mesh would have to reference the light it belongs to. That would save you from stepping through a lot of empty space.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...