Deferred Engine Playground - download

i had read ur approached on point light shadow. You r using 2d texture instead of cubemap, can i know which 1 is better? how about capture environment map in 2d texture is better thn cubemap?

well I pretty much covered that in the article. Both are the same 6 textures, either as an array (cubemap) or on one large canvas. With them being combined I can do custom filtering, so itā€™s better for me.

hello kosmonautgames,

i am working on your code and like to share how i shorten the shaders.cs file in your code.

I would like to upload but i see that only image files are uploadable. I also dont know how to set the text as code. Sorry

The following text seems like a mess, but in vs2015 it was well formatet. If you want write a comment and i send the original perfectly formated file to you.

As you see i dont like to reference each shader parameter twice.

  1. make it a member of the static class
  2. set the value in the load routine

With the following code you simply define the static class members an directly pass the value to it in one step

If you like it yout cope and past. Nothing else has to be changed then the following:

make a static class:

public static class Globals
{
public static ContentManager content;
}

in the ScreenManager.load method just before calling the Shaders.Load method you set the content to the Globals member

Globals.content = content;
Shaders.Load(content);

using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using DeferredEngine.Logic;

namespace DeferredEngine.Recources
{
public static class Shaders
{
//A static file which contains all shaders
//Born out of need for quick thoughtless shader building
//I am working on making seperate shading modules instead and will slowly shorten this one.

    //Depth Reconstruction
    public static Effect           ReconstructDepth = Globals.content.Load<Effect>("Shaders/ScreenSpace/ReconstructDepth");
    public static EffectParameter  ReconstructDepthParameter_DepthMap       = ReconstructDepth.Parameters["DepthMap"];
    public static EffectParameter  ReconstructDepthParameter_Projection     = ReconstructDepth.Parameters["Projection"];
    public static EffectParameter  ReconstructDepthParameter_FarClip        = ReconstructDepth.Parameters["FarClip"];
    public static EffectParameter  ReconstructDepthParameter_FrustumCorners = ReconstructDepth.Parameters["FrustumCorners"];

    //Id Generator
    public static Effect           IdRenderEffect = Globals.content.Load<Effect>("Shaders/Editor/IdRender");
    public static EffectParameter  IdRenderEffectParameterWorldViewProj = IdRenderEffect.Parameters["WorldViewProj"];
    public static EffectParameter  IdRenderEffectParameterColorId       = IdRenderEffect.Parameters["ColorId"];
    public static EffectParameter  IdRenderEffectParameterOutlineSize   = IdRenderEffect.Parameters["OutlineSize"];
    public static EffectParameter  IdRenderEffectParameterWorld         = IdRenderEffect.Parameters["World"];

    public static EffectPass       IdRenderEffectDrawId = IdRenderEffect.Techniques["DrawId"].Passes[0];
    public static EffectPass       IdRenderEffectDrawOutline = IdRenderEffect.Techniques["DrawOutline"].Passes[0];

    //Billboard Renderer
    public static Effect           BillboardEffect = Globals.content.Load<Effect>("Shaders/Editor/BillboardEffect");

    public static EffectParameter  BillboardEffectParameter_WorldViewProj = BillboardEffect.Parameters["WorldViewProj"];
    public static EffectParameter  BillboardEffectParameter_WorldView     = BillboardEffect.Parameters["WorldView"];
    public static EffectParameter  BillboardEffectParameter_AspectRatio   = BillboardEffect.Parameters["AspectRatio"];
    public static EffectParameter  BillboardEffectParameter_FarClip       = BillboardEffect.Parameters["FarClip"];
    public static EffectParameter  BillboardEffectParameter_Texture       = BillboardEffect.Parameters["Texture"];
    public static EffectParameter  BillboardEffectParameter_DepthMap      = BillboardEffect.Parameters["DepthMap"];
    public static EffectParameter  BillboardEffectParameter_IdColor       = BillboardEffect.Parameters["IdColor"];

    public static EffectTechnique  BillboardEffectTechnique_Billboard     = BillboardEffect.Techniques["Billboard"];
    public static EffectTechnique  BillboardEffectTechnique_Id            = BillboardEffect.Techniques["Id"];

     //Lines
    public static Effect           LineEffect = Globals.content.Load<Effect>("Shaders/Editor/LineEffect");
    public static EffectParameter  LineEffectParameter_WorldViewProj = LineEffect.Parameters["WorldViewProj"];

    //Temporal AntiAliasing

    
    //Vignette and CA
    public static Effect           PostProcessing = Globals.content.Load<Effect>("shaders/postprocessing/postprocessing");
    public static EffectParameter  PostProcessingParameter_ScreenTexture               = PostProcessing.Parameters["ScreenTexture"];
    public static EffectParameter  PostProcessingParameter_ChromaticAbberationStrength = PostProcessing.Parameters["ChromaticAbberationStrength"];
    public static EffectParameter  PostProcessingParameter_SCurveStrength              = PostProcessing.Parameters["SCurveStrength"];
    public static EffectParameter  PostProcessingParameter_WhitePoint                  = PostProcessing.Parameters["WhitePoint"];
    public static EffectParameter  PostProcessingParameter_PowExposure                 = PostProcessing.Parameters["PowExposure"];
    public static EffectTechnique  PostProcessingTechnique_VignetteChroma              = PostProcessing.Techniques["VignetteChroma"];
    public static EffectTechnique  PostProcessingTechnique_Base                        = PostProcessing.Techniques["Base"];


    //Hologram Effect
    public static Effect           HologramEffect = Globals.content.Load<Effect>("Shaders/Hologram/HologramEffect");
    public static EffectParameter  HologramEffectParameter_World          = HologramEffect.Parameters["World"];
    public static EffectParameter  HologramEffectParameter_WorldViewProj  = HologramEffect.Parameters["WorldViewProj"];

    //Emissive Effect
    public static Effect           EmissiveEffect = Globals.content.Load<Effect>("Shaders/Emissive/EmissiveDraw");
    public static EffectParameter  EmissiveEffectParameter_World               = EmissiveEffect.Parameters["World"];
    public static EffectParameter  EmissiveEffectParameter_ViewProj            = EmissiveEffect.Parameters["ViewProjection"];
    public static EffectParameter  EmissiveEffectParameter_WorldViewProj       = EmissiveEffect.Parameters["WorldViewProj"];
    public static EffectParameter  EmissiveEffectParameter_InvertViewProj      = EmissiveEffect.Parameters["InvertViewProjection"];
    public static EffectParameter  EmissiveEffectParameter_Origin              = EmissiveEffect.Parameters["Origin"];
    public static EffectParameter  EmissiveEffectParameter_CameraPosition      = EmissiveEffect.Parameters["CameraPosition"];
    public static EffectParameter  EmissiveEffectParameter_Size                = EmissiveEffect.Parameters["Size"];
    public static EffectParameter  EmissiveEffectParameter_NormalMap           = EmissiveEffect.Parameters["NormalMap"];
    public static EffectParameter  EmissiveEffectParameter_DepthMap            = EmissiveEffect.Parameters["DepthMap"];
    public static EffectParameter  EmissiveEffectParameter_EmissiveMap         = EmissiveEffect.Parameters["EmissiveMap"];
    public static EffectParameter  EmissiveEffectParameter_Resolution          = EmissiveEffect.Parameters["Resolution"];
    public static EffectParameter  EmissiveEffectParameter_EmissiveColor       = EmissiveEffect.Parameters["EmissiveColor"];
    public static EffectParameter  EmissiveEffectParameter_EmissiveStrength    = EmissiveEffect.Parameters["EmissiveStrength"];
    public static EffectParameter  EmissiveEffectParameter_Time                = EmissiveEffect.Parameters["Time"];

    public static EffectTechnique  EmissiveEffectTechnique_DrawEmissiveBuffer         = EmissiveEffect.Techniques["DrawEmissiveBuffer"];
    public static EffectTechnique  EmissiveEffectTechnique_DrawEmissiveSpecularEffect = EmissiveEffect.Techniques["DrawEmissiveSpecularEffect"];
    public static EffectTechnique  EmissiveEffectTechnique_DrawEmissiveDiffuseEffect  = EmissiveEffect.Techniques["DrawEmissiveDiffuseEffect"];

    
    //ScreenSpaceReflection Effect

    public static Effect           ScreenSpaceReflectionEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/ScreenSpaceReflections");

    public static EffectParameter  ScreenSpaceReflectionParameter_DepthMap       = ScreenSpaceReflectionEffect.Parameters["DepthMap"];
    public static EffectParameter  ScreenSpaceReflectionParameter_NormalMap      = ScreenSpaceReflectionEffect.Parameters["NormalMap"];
    public static EffectParameter  ScreenSpaceReflectionParameter_TargetMap      = ScreenSpaceReflectionEffect.Parameters["TargetMap"];
    public static EffectParameter  ScreenSpaceReflectionParameter_Resolution     = ScreenSpaceReflectionEffect.Parameters["resolution"];
    public static EffectParameter  ScreenSpaceReflectionParameter_Projection     = ScreenSpaceReflectionEffect.Parameters["Projection"];
    public static EffectParameter  ScreenSpaceReflectionParameter_Time           = ScreenSpaceReflectionEffect.Parameters["Time"];
    public static EffectParameter  ScreenSpaceReflectionParameter_FrustumCorners = ScreenSpaceReflectionEffect.Parameters["FrustumCorners"];
    public static EffectParameter  ScreenSpaceReflectionParameter_FarClip        = ScreenSpaceReflectionEffect.Parameters["FarClip"];
    public static EffectParameter  ScreenSpaceReflectionParameter_NoiseMap       = ScreenSpaceReflectionEffect.Parameters["NoiseMap"];

    public static EffectTechnique  ScreenSpaceReflectionTechnique_Default        = ScreenSpaceReflectionEffect.Techniques["Default"];
    public static EffectTechnique  ScreenSpaceReflectionTechnique_Taa            = ScreenSpaceReflectionEffect.Techniques["TAA"];


    //Screen Space Ambient Occlusion Effect

    public static Effect           ScreenSpaceEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/ScreenSpaceAO");
    
    public static EffectParameter  ScreenSpaceEffectParameter_SSAOMap               = ScreenSpaceEffect.Parameters["SSAOMap"];
    public static EffectParameter  ScreenSpaceEffectParameter_NormalMap             = ScreenSpaceEffect.Parameters["NormalMap"];
    public static EffectParameter  ScreenSpaceEffectParameter_DepthMap              = ScreenSpaceEffect.Parameters["DepthMap"];
    public static EffectParameter  ScreenSpaceEffectParameter_CameraPosition        = ScreenSpaceEffect.Parameters["CameraPosition"];
    public static EffectParameter  ScreenSpaceEffectParameter_InverseViewProjection = ScreenSpaceEffect.Parameters["InverseViewProjection"];
    public static EffectParameter  ScreenSpaceEffectParameter_Projection            = ScreenSpaceEffect.Parameters["Projection"];
    public static EffectParameter  ScreenSpaceEffectParameter_ViewProjection        = ScreenSpaceEffect.Parameters["ViewProjection"];

    public static EffectParameter  ScreenSpaceEffect_FalloffMin                     = ScreenSpaceEffect.Parameters["FalloffMin"];
    public static EffectParameter  ScreenSpaceEffect_FalloffMax                     = ScreenSpaceEffect.Parameters["FalloffMax"];
    public static EffectParameter  ScreenSpaceEffect_Samples                        = ScreenSpaceEffect.Parameters["Samples"];
    public static EffectParameter  ScreenSpaceEffect_Strength                       = ScreenSpaceEffect.Parameters["Strength"];
    public static EffectParameter  ScreenSpaceEffect_SampleRadius                   = ScreenSpaceEffect.Parameters["SampleRadius"];
    public static EffectParameter  ScreenSpaceEffectParameter_InverseResolution     = ScreenSpaceEffect.Parameters["InverseResolution"];
    public static EffectParameter  ScreenSpaceEffectParameter_FrustumCorners        = ScreenSpaceEffect.Parameters["FrustumCorners"];

    public static EffectTechnique  ScreenSpaceEffectTechnique_SSAO                  = ScreenSpaceEffect.Techniques["SSAO"];
    public static EffectTechnique  ScreenSpaceEffectTechnique_BlurHorizontal        = ScreenSpaceEffect.Techniques["BilateralHorizontal"];
    public static EffectTechnique  ScreenSpaceEffectTechnique_BlurVertical          = ScreenSpaceEffect.Techniques["BilateralVertical"];


    //Gaussian Blur
    public static Effect           GaussianBlurEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/GaussianBlur");
    public static EffectParameter  GaussianBlurEffectParameter_InverseResolution    = GaussianBlurEffect.Parameters["InverseResolution"];
    public static EffectParameter  GaussianBlurEffectParameter_TargetMap            = GaussianBlurEffect.Parameters["TargetMap"];


    //DeferredCompose

    public static Effect           DeferredCompose = Globals.content.Load<Effect>("Shaders/Deferred/DeferredCompose");

    public static EffectParameter  DeferredComposeEffectParameter_ColorMap          = DeferredCompose.Parameters["colorMap"];
    public static EffectParameter  DeferredComposeEffectParameter_diffuseLightMap   = DeferredCompose.Parameters["diffuseLightMap"];
    public static EffectParameter  DeferredComposeEffectParameter_specularLightMap  = DeferredCompose.Parameters["specularLightMap"];
    public static EffectParameter  DeferredComposeEffectParameter_volumeLightMap    = DeferredCompose.Parameters["volumeLightMap"];
    public static EffectParameter  DeferredComposeEffectParameter_HologramMap       = DeferredCompose.Parameters["HologramMap"];
    public static EffectParameter  DeferredComposeEffectParameter_SSAOMap           = DeferredCompose.Parameters["SSAOMap"];
    public static EffectParameter  DeferredComposeEffectParameter_LinearMap         = DeferredCompose.Parameters["LinearMap"];
    public static EffectParameter  DeferredComposeEffectParameter_SSRMap            = DeferredCompose.Parameters["SSRMap"];
    public static EffectParameter  DeferredComposeEffectParameter_UseSSAO           = DeferredCompose.Parameters["useSSAO"];

    public static EffectTechnique  DeferredComposeTechnique_NonLinear  = DeferredCompose.Techniques["TechniqueNonLinear"];
    public static EffectTechnique  DeferredComposeTechnique_Linear     = DeferredCompose.Techniques["TechniqueLinear"];

    //DeferredClear
    public static Effect           DeferredClear = Globals.content.Load<Effect>("Shaders/Deferred/DeferredClear");

    //Directional light

    public static Effect           deferredDirectionalLight = Globals.content.Load<Effect>("Shaders/Deferred/DeferredDirectionalLight");

    public static EffectTechnique  deferredDirectionalLightUnshadowed   = deferredDirectionalLight.Techniques["Unshadowed"];
    public static EffectTechnique  deferredDirectionalLightSSShadowed   = deferredDirectionalLight.Techniques["SSShadowed"];
    public static EffectTechnique  deferredDirectionalLightShadowed     = deferredDirectionalLight.Techniques["Shadowed"];
    public static EffectTechnique  deferredDirectionalLightShadowOnly   = deferredDirectionalLight.Techniques["ShadowOnly"];

    public static EffectParameter  deferredDirectionalLightParameterViewProjection        = deferredDirectionalLight.Parameters["ViewProjection"];
    public static EffectParameter  deferredDirectionalLightParameterFrustumCorners        = deferredDirectionalLight.Parameters["FrustumCorners"];
    public static EffectParameter  deferredDirectionalLightParameterCameraPosition        = deferredDirectionalLight.Parameters["cameraPosition"];
    public static EffectParameter  deferredDirectionalLightParameterInverseViewProjection = deferredDirectionalLight.Parameters["InvertViewProjection"];
    public static EffectParameter  deferredDirectionalLightParameterLightViewProjection   = deferredDirectionalLight.Parameters["LightViewProjection"];
    public static EffectParameter  deferredDirectionalLightParameterLightView             = deferredDirectionalLight.Parameters["LightView"];
    public static EffectParameter  deferredDirectionalLightParameterLightFarClip          = deferredDirectionalLight.Parameters["LightFarClip"];
    
    public static EffectParameter  deferredDirectionalLightParameter_LightColor           = deferredDirectionalLight.Parameters["lightColor"];
    public static EffectParameter  deferredDirectionalLightParameter_LightIntensity       = deferredDirectionalLight.Parameters["lightIntensity"];
    public static EffectParameter  deferredDirectionalLightParameter_LightDirection       = deferredDirectionalLight.Parameters["LightVector"];
    public static EffectParameter  deferredDirectionalLightParameter_ShadowFiltering      = deferredDirectionalLight.Parameters["ShadowFiltering"];
    public static EffectParameter  deferredDirectionalLightParameter_ShadowMapSize        = deferredDirectionalLight.Parameters["ShadowMapSize"];

    public static EffectParameter  deferredDirectionalLightParameter_AlbedoMap            = deferredDirectionalLight.Parameters["AlbedoMap"];
    public static EffectParameter  deferredDirectionalLightParameter_NormalMap            = deferredDirectionalLight.Parameters["NormalMap"];
    public static EffectParameter  deferredDirectionalLightParameter_DepthMap             = deferredDirectionalLight.Parameters["DepthMap"];
    public static EffectParameter  deferredDirectionalLightParameter_ShadowMap            = deferredDirectionalLight.Parameters["ShadowMap"];
    public static EffectParameter  deferredDirectionalLightParameter_SSShadowMap          = deferredDirectionalLight.Parameters["SSShadowMap"];


    //Point Light
    public static Effect           deferredPointLight = Globals.content.Load<Effect>("Shaders/Deferred/DeferredPointLight");

    public static EffectTechnique  deferredPointLightUnshadowed                    = deferredPointLight.Techniques["Unshadowed"];
    public static EffectTechnique  deferredPointLightUnshadowedVolumetric          = deferredPointLight.Techniques["UnshadowedVolume"];
    public static EffectTechnique  deferredPointLightShadowed                      = deferredPointLight.Techniques["Shadowed"];
    public static EffectTechnique  deferredPointLightShadowedVolumetric            = deferredPointLight.Techniques["ShadowedVolume"];
    public static EffectTechnique  deferredPointLightWriteStencil                  = deferredPointLight.Techniques["WriteStencilMask"];
        
    public static EffectParameter  deferredPointLightParameterShadowMap            = deferredPointLight.Parameters["ShadowMap"];

    public static EffectParameter  deferredPointLightParameterResolution           = deferredPointLight.Parameters["Resolution"];
    public static EffectParameter  deferredPointLightParameter_WorldView           = deferredPointLight.Parameters["WorldView"];
    public static EffectParameter  deferredPointLightParameter_WorldViewProjection = deferredPointLight.Parameters["WorldViewProj"];
    public static EffectParameter  deferredPointLightParameter_InverseView         = deferredPointLight.Parameters["InverseView"];
        
    public static EffectParameter  deferredPointLightParameter_LightPosition       = deferredPointLight.Parameters["lightPosition"];
    public static EffectParameter  deferredPointLightParameter_LightColor          = deferredPointLight.Parameters["lightColor"];
    public static EffectParameter  deferredPointLightParameter_LightRadius         = deferredPointLight.Parameters["lightRadius"];
    public static EffectParameter  deferredPointLightParameter_LightIntensity      = deferredPointLight.Parameters["lightIntensity"];
    public static EffectParameter  deferredPointLightParameter_ShadowMapSize       = deferredPointLight.Parameters["ShadowMapSize"];
    public static EffectParameter  deferredPointLightParameter_ShadowMapRadius     = deferredPointLight.Parameters["ShadowMapRadius"];
    public static EffectParameter  deferredPointLightParameter_Inside              = deferredPointLight.Parameters["inside"];
    public static EffectParameter  deferredPointLightParameter_Time                = deferredPointLight.Parameters["Time"];
    public static EffectParameter  deferredPointLightParameter_FarClip             = deferredPointLight.Parameters["FarClip"];
    public static EffectParameter  deferredPointLightParameter_LightVolumeDensity  = deferredPointLight.Parameters["lightVolumeDensity"];
        
    public static EffectParameter  deferredPointLightParameter_NoiseMap            = deferredPointLight.Parameters["NoiseMap"];
    public static EffectParameter  deferredPointLightParameter_AlbedoMap           = deferredPointLight.Parameters["AlbedoMap"];
    public static EffectParameter  deferredPointLightParameter_NormalMap           = deferredPointLight.Parameters["NormalMap"];
    public static EffectParameter  deferredPointLightParameter_DepthMap            = deferredPointLight.Parameters["DepthMap"];

    
    public static void Load(ContentManager content)
    {
    }
}

}

You can wrap the code in triple backticks for nice formatting.

// Looks like this
private void niceHighlighting()
{
}

I donā€™t actually use shaders.cs any more for new things, and I am working on outsourcing the shader files into separate classes, I have done that for a few things now, but there is still lots to go.

Itā€™s just something that was useful when it was a really simple program to have all the shaders accessible as globals.

however, thanks for the headsup, I think this is a great improvement in general and it makes stuff a lot easier if you only access this once.

I have taken your code and pushed it to the live version, should be much easier to use now.

I wasnā€™t aware that static class members are loaded only after the static class is accessed the first time. Interesting.

I guess the whole Load / Initialize separation should probably also be removed, itā€™s something I got used to from xnaā€¦ but in most cases both want to be executed at the same time. Often times even as a constructor.

can we turn the cubemap of point light shadow into this form rather thn 2d texture strip. if possible, how it work? and how to calculate reflection vector?

Sure itā€™s just another form of storing the cubemaps.

I donā€™t remember the exact name of this projection but you can google different projections and find it. There is lots of info on conversion on the net, you should be able to implement that

Itā€™s latitude-longitude panorama. :slight_smile:
http://gl.ict.usc.edu/hdrshop/tutorial/tutorial04.php

1 Like

hello kosmonautgames,

i have worked several hours on your code this weekend because i want fully understand it and eventually implement it in my own engine.

My great compliment to you. The more i dig into the code the more i feel astonished abhout this much effort you share with us.

Now my question about the deferred light shaders.

At the moment there is no possibility to apply a light to a special intity.

For example pointlight number 5 of the pointlight collection shall only be applied to Entity xyz.

For example a rim light shall only be applied to my character and nothing else in the scene. In a forward shader i know exactly how to handle.
But how is this handled BEST in a deferred renderer.

Before i try this and that would you please be so kind and give me a hint howto do ?

Here my Idea:

  1. In des GBuffer creation shader we need a additional rendertarget or a free channel in a existing rendertarget. In this channel will be stored the ID of the entity.
    This will be a shaderparameter in the draw call

  2. After all entites are written, only the visible pixels of each entity will remain in the map ID channel

  3. The light shaders get the ID of the entity as a shaderparameter

  4. In the light shaders the ID channel of the map is parsed before doing something.
    Only the pixels with the coressponding ID will be manipulated.

What do you think ?

Hey,

you can pass a material ID already, and I used that for a few things before, like the holograms for example, or emissive materials.
Check out how I did that in the DeferredCompose.fx

        //Emissive Material
	//If the material is emissive (matType == 3) we store the factor inside metalness. We simply output the emissive material and do not compose with lighting
	if (abs(materialType - 3) < 0.1f)
	{
		// Optional: 2 << metalness*8, pow(2, m*8) etc.
		return float4(diffuseColor.rgb * metalness * 8 + volumetrics, 1);
	}

But the range was very limited afaik, from 0 to 8 basically, if I remember correctly, since I store both metalness and materialtype in one channel, and itā€™s in a very primitive fashion (back then I had no idea what I was doing). I might rework that soon to use bitmasks.

However, you can look at the BufferSetup.dgml and see that the normal map still has one free channel in theory.
This channel is even half-precision, so you can store large values that are not limited to 0ā€¦1, but rather 0ā€¦2048 (for further reference https://en.wikipedia.org/wiki/Half-precision_floating-point_format)

If you want I can show you how to make use of the free normal channel, or you can take a look at the commented out lines (encode and decode) in the Common/helper.fx shader file. These convert from a float3 to float2 and back.

    hello kosmonautgames,

now i understand the channels of the texture maps are coded for the intention of less texture fetches an memory saving where higher precission is not needed.
Therefore are the following function which i couldnĀ“t understand.

    float decodeMetalness(float input)        
    {
      	input *= 10;
    	return frac(input) * 2;
    }
  
    float decodeMattype(float input)
    {
          	input *= 10;
          	return trunc(input);
    }

But i think the ID should be checked in the light shaders and not in the DeferredCompose.fx
Did you implicitely mean this. Is my assumtion correct ?

I meant the normal decode functions, where you store the normals. These ones you posted are for the material ID, you can use them too.

yeah you can use these in the light shader, you would need to read the albedo channel then, since itā€™s stored in alpha.

But you can also save your ids in the blue channel in normal if you use the other decodes.

Maybe I could have worded that better.
Either way - right now I have 3 encoded things - normals, mattype and metalness.

Normals right now are super simple, I simply convert from [-1, 1] to [0, 1] space, so the encode function is very simple along the lines of (n + 1) / 2.
But because I use view space normals the z-component always looks in the direction of the camera and itā€™s length can be inferred from the other two components, so in theory normals only need 2 channels to store.
You could use the third one for unique Ids.

In the albedo alpha channel I store material id and metalness, and you can get these by calling DecodeMetalness(albedo.a) for example.
These are very low precision though, only a few values are permitted since itā€™s an 8bit integer used for 2 things. The decoding / encoding is done in a super bad way, for some reason it worked better than bit-flags when I set it up. I need to check that again.

Ideally I would move this to the normal blue channel, I might just do so later today.

I moved the g-buffer set up around a bit so now it uses normal.b as a storage space for mattype and metalness.

This allows both to be relatively precise and you can possibly have hundreds of unique Ids.

In your light shader you can access the mattype by
using this line

float mattype = decodeMattype(normalData.b);

sharing a technique i found to improve existing directional light. but seem like the source code link is expired.

hello kosmonautgames,

many, many thanks for your explanation. The Diagramm has helped me a lot.

I have a graphics card with 2 GByte Ram so i did not even think to code the different channels for optimized performance.

I always had in mind, that the coding and decoding costs calculation performance an so it would be better to be generous with the rendertarget textures.

hello it is me again,

i tried to upload a portion of source code i have edited to share with you an tried to code how it was said in ā€œin triple backticksā€ but sorry i am obviously too stupid.

i tried ((( my text ))), {{{ my text }}} then i realised it means not brackest but backticks. ( i am german :-)) )

So i tried ā€˜ā€™ā€™ my text ā€˜ā€™ā€™ even Ā“Ā“Ā“ my text Ā“Ā“Ā“ but nothing helps ??

Would you be so kind to help me ?

in the reply window you can mark your text and select the </> icon to format code

hello kosmonaut,

in the following i have taken all shaders and reorganized them in the format that they can be used as global static classes. For me its important, that i can find all references / uses parameters of a effect by just one mouse click in visual studio.

Everyone has his own style i like to take them in one file. Others will like to place each definition in the coresponding rendermodule file.

If it helps you i would enjoy. If not there is absolutely no problem. It took me several hous to shorten the param strings and extract many shaders from within the rendermodule files.

In the folowing i will post some rendermodule files to show how clean an readable the code becomes because of the syntax highlighting it is always obvious when a shaderparam is manipulated over all the code.

because the body in the forum is limited to size of characters it will be two portions.

using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace DeferredEngine.Recources
{
 
    public static class Globals
    {
        public static ContentManager content;
    }
 
    public static class ReconstructDepthShader
    {
        public static readonly Effect ReconstructDepth = Globals.content.Load<Effect>("Shaders/ScreenSpace/ReconstructDepth");

        public static readonly EffectParameter DepthMap       = ReconstructDepth.Parameters["DepthMap"];
        public static readonly EffectParameter Projection     = ReconstructDepth.Parameters["Projection"];
        public static readonly EffectParameter FarClip        = ReconstructDepth.Parameters["FarClip"];
        public static readonly EffectParameter FrustumCorners = ReconstructDepth.Parameters["FrustumCorners"];
    }
 
    public static class IdRenderShader
    {
 
        //Id Generator
        public static readonly Effect IdRenderEffect = Globals.content.Load<Effect>("Shaders/Editor/IdRender");

        public static readonly EffectParameter WorldViewProj    = IdRenderEffect.Parameters["WorldViewProj"];
        public static readonly EffectParameter ColorId          = IdRenderEffect.Parameters["ColorId"];
        public static readonly EffectParameter OutlineSize      = IdRenderEffect.Parameters["OutlineSize"];
        public static readonly EffectParameter World            = IdRenderEffect.Parameters["World"];

        public static readonly EffectPass      DrawId_Pass      = IdRenderEffect.Techniques["DrawId"].Passes[0];
        public static readonly EffectPass      DrawOutline_Pass = IdRenderEffect.Techniques["DrawOutline"].Passes[0];
 
    }
 
    public static class BillboardShader
    {
        //Billboard Renderer
        public static readonly Effect BillboardEffect = Globals.content.Load<Effect>("Shaders/Editor/BillboardEffect");

        public static readonly EffectParameter WorldViewProj       = BillboardEffect.Parameters["WorldViewProj"];
        public static readonly EffectParameter WorldView           = BillboardEffect.Parameters["WorldView"];
        public static readonly EffectParameter AspectRatio         = BillboardEffect.Parameters["AspectRatio"];
        public static readonly EffectParameter FarClip             = BillboardEffect.Parameters["FarClip"];
        public static readonly EffectParameter Texture             = BillboardEffect.Parameters["Texture"];
        public static readonly EffectParameter DepthMap            = BillboardEffect.Parameters["DepthMap"];
        public static readonly EffectParameter IdColor             = BillboardEffect.Parameters["IdColor"];

        public static readonly EffectTechnique Billboard_Technique = BillboardEffect.Techniques["Billboard"];
        public static readonly EffectTechnique Id_Technique        = BillboardEffect.Techniques["Id"];
 
    }
 
    public static class LineShader
    {
        //Lines
        public static readonly Effect          LineEffect          = Globals.content.Load<Effect>("Shaders/Editor/LineEffect");

        public static readonly EffectParameter WorldViewProj       = LineEffect.Parameters["WorldViewProj"];
    }
 
    public static class PostProcessShader
    {
 
        //Vignette and CA
        public static readonly Effect PostProcessing = Globals.content.Load<Effect>("shaders/postprocessing/postprocessing");
 
        public static readonly EffectParameter ScreenTexture               = PostProcessing.Parameters["ScreenTexture"];
        public static readonly EffectParameter ChromaticAbberationStrength = PostProcessing.Parameters["ChromaticAbberationStrength"];
        public static readonly EffectParameter SCurveStrength              = PostProcessing.Parameters["SCurveStrength"];
        public static readonly EffectParameter WhitePoint                  = PostProcessing.Parameters["WhitePoint"];
        public static readonly EffectParameter PowExposure                 = PostProcessing.Parameters["PowExposure"];
        public static readonly EffectTechnique VignetteChroma_Technique    = PostProcessing.Techniques["VignetteChroma"];
        public static readonly EffectTechnique Base_Technique              = PostProcessing.Techniques["Base"];
 
    }
 
    public static class HologramShader
    {
        //Hologram Effect
        public static readonly Effect HologramEffect = Globals.content.Load<Effect>("Shaders/Hologram/HologramEffect");

        public static readonly EffectParameter World                      = HologramEffect.Parameters["World"];
        public static readonly EffectParameter WorldViewProj              = HologramEffect.Parameters["WorldViewProj"];
    }
 
    public static class EmissiveShader
    {
 
        //Emissive Effect
        public static readonly Effect EmissiveEffect = Globals.content.Load<Effect>("Shaders/Emissive/EmissiveDraw");

        public static readonly EffectParameter World                 = EmissiveEffect.Parameters["World"];
        public static readonly EffectParameter ViewProj              = EmissiveEffect.Parameters["ViewProjection"];
        public static readonly EffectParameter WorldViewProj         = EmissiveEffect.Parameters["WorldViewProj"];
        public static readonly EffectParameter InvertViewProj        = EmissiveEffect.Parameters["InvertViewProjection"];
        public static readonly EffectParameter Origin                = EmissiveEffect.Parameters["Origin"];
        public static readonly EffectParameter CameraPosition        = EmissiveEffect.Parameters["CameraPosition"];
        public static readonly EffectParameter Size                  = EmissiveEffect.Parameters["Size"];
        public static readonly EffectParameter NormalMap             = EmissiveEffect.Parameters["NormalMap"];
        public static readonly EffectParameter DepthMap              = EmissiveEffect.Parameters["DepthMap"];
        public static readonly EffectParameter EmissiveMap           = EmissiveEffect.Parameters["EmissiveMap"];
        public static readonly EffectParameter Resolution            = EmissiveEffect.Parameters["Resolution"];
        public static readonly EffectParameter EmissiveColor         = EmissiveEffect.Parameters["EmissiveColor"];
        public static readonly EffectParameter EmissiveStrength      = EmissiveEffect.Parameters["EmissiveStrength"];
        public static readonly EffectParameter Time                  = EmissiveEffect.Parameters["Time"];

        public static readonly EffectTechnique DrawEmissiveBuffer_Technique          = EmissiveEffect.Techniques["DrawEmissiveBuffer"];
        public static readonly EffectTechnique DrawEmissiveSpecularEffect__Technique = EmissiveEffect.Techniques["DrawEmissiveSpecularEffect"];
        public static readonly EffectTechnique DrawEmissiveDiffuseEffect__Technique  = EmissiveEffect.Techniques["DrawEmissiveDiffuseEffect"];
 
    }
 
    public static class ScreenSpaceReflectionShader
    {
        //ScreenSpaceReflection Effect
 
        public static readonly Effect ScreenSpaceReflectionEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/ScreenSpaceReflections");

        public static readonly EffectParameter DepthMap         = ScreenSpaceReflectionEffect.Parameters["DepthMap"];
        public static readonly EffectParameter NormalMap        = ScreenSpaceReflectionEffect.Parameters["NormalMap"];
        public static readonly EffectParameter TargetMap        = ScreenSpaceReflectionEffect.Parameters["TargetMap"];
        public static readonly EffectParameter Resolution       = ScreenSpaceReflectionEffect.Parameters["resolution"];
        public static readonly EffectParameter Projection       = ScreenSpaceReflectionEffect.Parameters["Projection"];
        public static readonly EffectParameter Time             = ScreenSpaceReflectionEffect.Parameters["Time"];
        public static readonly EffectParameter FrustumCorners   = ScreenSpaceReflectionEffect.Parameters["FrustumCorners"];
        public static readonly EffectParameter FarClip          = ScreenSpaceReflectionEffect.Parameters["FarClip"];
        public static readonly EffectParameter NoiseMap         = ScreenSpaceReflectionEffect.Parameters["NoiseMap"];
        public static readonly EffectParameter SecondarySamples = ScreenSpaceReflectionEffect.Parameters["SecondarySamples"];
        public static readonly EffectParameter minThickness     = ScreenSpaceReflectionEffect.Parameters["MinimumThickness"];
        public static readonly EffectParameter Samples          = ScreenSpaceReflectionEffect.Parameters["Samples"];

        public static readonly EffectTechnique Default_Technique = ScreenSpaceReflectionEffect.Techniques["Default"];
        public static readonly EffectTechnique Taa_Technique     = ScreenSpaceReflectionEffect.Techniques["TAA"];
    }
 
    public static class ScreenSpaceAOShader
    {
        //Screen Space Ambient Occlusion Effect
        public static readonly Effect ScreenSpaceEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/ScreenSpaceAO");

        public static readonly EffectParameter SSAOMap                  = ScreenSpaceEffect.Parameters["SSAOMap"];
        public static readonly EffectParameter NormalMap                = ScreenSpaceEffect.Parameters["NormalMap"];
        public static readonly EffectParameter DepthMap                 = ScreenSpaceEffect.Parameters["DepthMap"];
        public static readonly EffectParameter CameraPosition           = ScreenSpaceEffect.Parameters["CameraPosition"];
        public static readonly EffectParameter InverseViewProjection    = ScreenSpaceEffect.Parameters["InverseViewProjection"];
        public static readonly EffectParameter Projection               = ScreenSpaceEffect.Parameters["Projection"];
        public static readonly EffectParameter ViewProjection           = ScreenSpaceEffect.Parameters["ViewProjection"];

        public static readonly EffectParameter FalloffMin               = ScreenSpaceEffect.Parameters["FalloffMin"];
        public static readonly EffectParameter FalloffMax               = ScreenSpaceEffect.Parameters["FalloffMax"];
        public static readonly EffectParameter Samples                  = ScreenSpaceEffect.Parameters["Samples"];
        public static readonly EffectParameter Strength                 = ScreenSpaceEffect.Parameters["Strength"];
        public static readonly EffectParameter SampleRadius             = ScreenSpaceEffect.Parameters["SampleRadius"];
        public static readonly EffectParameter InverseResolution        = ScreenSpaceEffect.Parameters["InverseResolution"];
        public static readonly EffectParameter FrustumCorners           = ScreenSpaceEffect.Parameters["FrustumCorners"];

        public static readonly EffectTechnique SSAO_Technique           = ScreenSpaceEffect.Techniques["SSAO"];
        public static readonly EffectTechnique BlurHorizontal_Technique = ScreenSpaceEffect.Techniques["BilateralHorizontal"];
        public static readonly EffectTechnique BlurVertical_Technique   = ScreenSpaceEffect.Techniques["BilateralVertical"];
 
    }
 
    public static class GaussianBlurShader
    {
        //Gaussian Blur
        public static readonly Effect GaussianBlurEffect = Globals.content.Load<Effect>("Shaders/ScreenSpace/GaussianBlur");

        public static readonly EffectParameter InverseResolution  = GaussianBlurEffect.Parameters["InverseResolution"];
        public static readonly EffectParameter TargetMap          = GaussianBlurEffect.Parameters["TargetMap"];
        public static readonly EffectPass      horizontalPass     = GaussianBlurEffect.Techniques["GaussianBlur"].Passes["Horizontal"];
        public static readonly EffectPass      verticalPass       = GaussianBlurEffect.Techniques["GaussianBlur"].Passes["Vertical"];
 
    }
 
    public static class DeferredComposeShader
    {
        //DeferredCompose
        public static readonly Effect DeferredCompose = Globals.content.Load<Effect>("Shaders/Deferred/DeferredCompose");

        public static readonly EffectParameter ColorMap            = DeferredCompose.Parameters["colorMap"];
        public static readonly EffectParameter diffuseLightMap     = DeferredCompose.Parameters["diffuseLightMap"];
        public static readonly EffectParameter specularLightMap    = DeferredCompose.Parameters["specularLightMap"];
        public static readonly EffectParameter volumeLightMap      = DeferredCompose.Parameters["volumeLightMap"];
        public static readonly EffectParameter HologramMap         = DeferredCompose.Parameters["HologramMap"];
        public static readonly EffectParameter SSAOMap             = DeferredCompose.Parameters["SSAOMap"];
        public static readonly EffectParameter LinearMap           = DeferredCompose.Parameters["LinearMap"];
        public static readonly EffectParameter SSRMap              = DeferredCompose.Parameters["SSRMap"];
        public static readonly EffectParameter useSSAO             = DeferredCompose.Parameters["useSSAO"];

        public static readonly EffectTechnique NonLinear_Technique = DeferredCompose.Techniques["TechniqueNonLinear"];
        public static readonly EffectTechnique Linear_Technique    = DeferredCompose.Techniques["TechniqueLinear"];
    }
 
 
    public static class deferredDirectionalLightShader
    {
        //Directional light
 
        public static readonly Effect deferredDirectionalLight = Globals.content.Load<Effect>("Shaders/Deferred/DeferredDirectionalLight");

        public static readonly EffectTechnique Unshadowed_Technique   = deferredDirectionalLight.Techniques["Unshadowed"];
        public static readonly EffectTechnique SSShadowed_Technique   = deferredDirectionalLight.Techniques["SSShadowed"];
        public static readonly EffectTechnique Shadowed_Technique     = deferredDirectionalLight.Techniques["Shadowed"];
        public static readonly EffectTechnique ShadowOnly_Technique   = deferredDirectionalLight.Techniques["ShadowOnly"];

        public static readonly EffectParameter ViewProjection         = deferredDirectionalLight.Parameters["ViewProjection"];
        public static readonly EffectParameter FrustumCorners         = deferredDirectionalLight.Parameters["FrustumCorners"];
        public static readonly EffectParameter CameraPosition         = deferredDirectionalLight.Parameters["cameraPosition"];
        public static readonly EffectParameter InverseViewProjection  = deferredDirectionalLight.Parameters["InvertViewProjection"];
        public static readonly EffectParameter LightViewProjection    = deferredDirectionalLight.Parameters["LightViewProjection"];
        public static readonly EffectParameter LightView              = deferredDirectionalLight.Parameters["LightView"];
        public static readonly EffectParameter LightFarClip           = deferredDirectionalLight.Parameters["LightFarClip"];

        public static readonly EffectParameter LightColor             = deferredDirectionalLight.Parameters["lightColor"];
        public static readonly EffectParameter LightIntensity         = deferredDirectionalLight.Parameters["lightIntensity"];
        public static readonly EffectParameter LightDirection         = deferredDirectionalLight.Parameters["LightVector"];
        public static readonly EffectParameter ShadowFiltering        = deferredDirectionalLight.Parameters["ShadowFiltering"];
        public static readonly EffectParameter ShadowMapSize          = deferredDirectionalLight.Parameters["ShadowMapSize"];

        public static readonly EffectParameter AlbedoMap              = deferredDirectionalLight.Parameters["AlbedoMap"];
        public static readonly EffectParameter NormalMap              = deferredDirectionalLight.Parameters["NormalMap"];
        public static readonly EffectParameter DepthMap               = deferredDirectionalLight.Parameters["DepthMap"];
        public static readonly EffectParameter ShadowMap              = deferredDirectionalLight.Parameters["ShadowMap"];
        public static readonly EffectParameter SSShadowMap            = deferredDirectionalLight.Parameters["SSShadowMap"];
    }
 
    public static class deferredPointLightShader
    {
        //Point Light
        public static readonly Effect deferredPointLight = Globals.content.Load<Effect>("Shaders/Deferred/DeferredPointLight");

        public static readonly EffectTechnique Unshadowed_Technique           = deferredPointLight.Techniques["Unshadowed"];
        public static readonly EffectTechnique UnshadowedVolume_Technique     = deferredPointLight.Techniques["UnshadowedVolume"];
        public static readonly EffectTechnique Shadowed_Technique             = deferredPointLight.Techniques["Shadowed"];
        public static readonly EffectTechnique ShadowedVolume_Technique       = deferredPointLight.Techniques["ShadowedVolume"];
        public static readonly EffectTechnique WriteStencil_Technique         = deferredPointLight.Techniques["WriteStencilMask"];

        public static readonly EffectParameter ShadowMap                      = deferredPointLight.Parameters["ShadowMap"];

        public static readonly EffectParameter Resolution                     = deferredPointLight.Parameters["Resolution"];
        public static readonly EffectParameter WorldView                      = deferredPointLight.Parameters["WorldView"];
        public static readonly EffectParameter WorldViewProjection            = deferredPointLight.Parameters["WorldViewProj"];
        public static readonly EffectParameter InverseView                    = deferredPointLight.Parameters["InverseView"];

        public static readonly EffectParameter LightPosition                  = deferredPointLight.Parameters["lightPosition"];
        public static readonly EffectParameter LightColor                     = deferredPointLight.Parameters["lightColor"];
        public static readonly EffectParameter LightRadius                    = deferredPointLight.Parameters["lightRadius"];
        public static readonly EffectParameter LightIntensity                 = deferredPointLight.Parameters["lightIntensity"];
        public static readonly EffectParameter ShadowMapSize                  = deferredPointLight.Parameters["ShadowMapSize"];
        public static readonly EffectParameter ShadowMapRadius                = deferredPointLight.Parameters["ShadowMapRadius"];
        public static readonly EffectParameter Inside                         = deferredPointLight.Parameters["inside"];
        public static readonly EffectParameter Time                           = deferredPointLight.Parameters["Time"];
        public static readonly EffectParameter FarClip                        = deferredPointLight.Parameters["FarClip"];
        public static readonly EffectParameter LightVolumeDensity             = deferredPointLight.Parameters["lightVolumeDensity"];

        public static readonly EffectParameter NoiseMap                       = deferredPointLight.Parameters["NoiseMap"];
        public static readonly EffectParameter AlbedoMap                      = deferredPointLight.Parameters["AlbedoMap"];
        public static readonly EffectParameter NormalMap                      = deferredPointLight.Parameters["NormalMap"];
        public static readonly EffectParameter DepthMap                       = deferredPointLight.Parameters["DepthMap"];
        }
 
    public static class DeferredClearShader
    {
        //DeferredClear
        public static readonly Effect DeferredClear = Globals.content.Load<Effect>("Shaders/Deferred/DeferredClear");
    }
 
    public static class BloomShader
    {
        //BloomShader
        public static readonly Effect bloomEffect = Globals.content.Load<Effect>("Shaders/BloomFilter/Bloom");

        public static readonly EffectParameter InverseResolution     = bloomEffect.Parameters["InverseResolution"];
        public static readonly EffectParameter Radius                = bloomEffect.Parameters["Radius"];
        public static readonly EffectParameter Strength              = bloomEffect.Parameters["Strength"];
        public static readonly EffectParameter StreakLength          = bloomEffect.Parameters["StreakLength"];
        public static readonly EffectParameter Threshold             = bloomEffect.Parameters["Threshold"];
        public static readonly EffectParameter ScreenTexture         = bloomEffect.Parameters["ScreenTexture"];

        public static readonly EffectPass      Extract_Pass          = bloomEffect.Techniques["Extract"].Passes[0];
        public static readonly EffectPass      ExtractLuminance_Pass = bloomEffect.Techniques["ExtractLuminance"].Passes[0];
        public static readonly EffectPass      Downsample_Pass       = bloomEffect.Techniques["Downsample"].Passes[0];
        public static readonly EffectPass      Upsample_Pass         = bloomEffect.Techniques["Upsample"].Passes[0];
    }
 
    public static class decalShader
    {
        //decalShader
        public static readonly Effect decalEffect = Globals.content.Load<Effect>("Shaders/Deferred/DeferredDecal");
 
        public static readonly EffectParameter DecalMap             = decalEffect.Parameters["DecalMap"];
        public static readonly EffectParameter WorldView            = decalEffect.Parameters["WorldView"];
        public static readonly EffectParameter WorldViewProj        = decalEffect.Parameters["WorldViewProj"];
        public static readonly EffectParameter InverseWorldView     = decalEffect.Parameters["InverseWorldView"];
        public static readonly EffectParameter DepthMap             = decalEffect.Parameters["DepthMap"];
        public static readonly EffectParameter FarClip              = decalEffect.Parameters["FarClip"];
 
        public static readonly EffectPass      Pass_Decal           = decalEffect.Techniques["Decal"].Passes[0];
        public static readonly EffectPass      Pass_Outline         = decalEffect.Techniques["Outline"].Passes[0];
       
    }
 
    public static class deferredEnvironmentShader
    {
        //deferredEnvironmentShader
        public static readonly Effect deferredEnvironmentEffect = Globals.content.Load<Effect>("Shaders/Deferred/DeferredEnvironmentMap");
 
        public static readonly EffectParameter AlbedoMap            = deferredEnvironmentEffect.Parameters["AlbedoMap"];
        public static readonly EffectParameter NormalMap            = deferredEnvironmentEffect.Parameters["NormalMap"];
        public static readonly EffectParameter SSRMap               = deferredEnvironmentEffect.Parameters["ReflectionMap"];
        public static readonly EffectParameter FrustumCorners       = deferredEnvironmentEffect.Parameters["FrustumCorners"];
        public static readonly EffectParameter ReflectionCubeMap    = deferredEnvironmentEffect.Parameters["ReflectionCubeMap"];
        public static readonly EffectParameter Resolution           = deferredEnvironmentEffect.Parameters["Resolution"];
        public static readonly EffectParameter FireflyReduction     = deferredEnvironmentEffect.Parameters["FireflyReduction"];
        public static readonly EffectParameter FireflyThreshold     = deferredEnvironmentEffect.Parameters["FireflyThreshold"];
        public static readonly EffectParameter TransposeView        = deferredEnvironmentEffect.Parameters["TransposeView"];
        public static readonly EffectParameter SpecularStrength     = deferredEnvironmentEffect.Parameters["EnvironmentMapSpecularStrength"];
        public static readonly EffectParameter SpecularStrengthRcp  = deferredEnvironmentEffect.Parameters["EnvironmentMapSpecularStrengthRcp"];
        public static readonly EffectParameter DiffuseStrength      = deferredEnvironmentEffect.Parameters["EnvironmentMapDiffuseStrength"];
        public static readonly EffectPass      Pass_Basic           = deferredEnvironmentEffect.Techniques["Basic"].Passes[0];
        public static readonly EffectPass      Pass_Sky             = deferredEnvironmentEffect.Techniques["Sky"].Passes[0];
        
    }
1 Like

here the second portion

        public static class ShadowMapShader
        {
            //ShadowMapShader
            public static readonly Effect ShadowMapEffect = Globals.content.Load<Effect>("Shaders/Shadow/ShadowMap");
     
            public static readonly EffectParameter WorldViewProj       = ShadowMapEffect.Parameters["WorldViewProj"];
            public static readonly EffectParameter WorldView           = ShadowMapEffect.Parameters["WorldView"];
            public static readonly EffectParameter World               = ShadowMapEffect.Parameters["World"];
            public static readonly EffectParameter LightPositionWS     = ShadowMapEffect.Parameters["LightPositionWS"];
            public static readonly EffectParameter FarClip             = ShadowMapEffect.Parameters["FarClip"];
            public static readonly EffectParameter SizeBias            = ShadowMapEffect.Parameters["SizeBias"];
            public static readonly EffectParameter MaskTexture         = ShadowMapEffect.Parameters["MaskTexture"];
            //Linear = VS Depth -> used for directional lights
            public static readonly EffectPass      Pass_linear         = ShadowMapEffect.Techniques["DrawLinearDepth"].Passes[0];
            //Distance = distance(pixel, light) -> used for omnidirectional lights
            public static readonly EffectPass      Pass_distance       = ShadowMapEffect.Techniques["DrawDistanceDepth"].Passes[0];
            public static readonly EffectPass      Pass_distanceAlpha  = ShadowMapEffect.Techniques["DrawDistanceDepthAlpha"].Passes[0];
     
          
        }
     
        public static class GBufferShader
        {
            // GBufferShader
            public static readonly Effect          gbufferEffect = Globals.content.Load<Effect>("Shaders/GbufferSetup/Gbuffer");
     
            public static readonly EffectParameter WorldView                         = gbufferEffect.Parameters["WorldView"];
            public static readonly EffectParameter WorldViewProj                     = gbufferEffect.Parameters["WorldViewProj"];
            public static readonly EffectParameter WorldViewIT                       = gbufferEffect.Parameters["WorldViewIT"];
            public static readonly EffectParameter Camera                            = gbufferEffect.Parameters["Camera"];
            public static readonly EffectParameter FarClip                           = gbufferEffect.Parameters["FarClip"];
     
            public static readonly EffectParameter Material_Metallic                 = gbufferEffect.Parameters["Metallic"];
            public static readonly EffectParameter Material_MetallicMap              = gbufferEffect.Parameters["MetallicMap"];
            public static readonly EffectParameter Material_DiffuseColor             = gbufferEffect.Parameters["DiffuseColor"];
            public static readonly EffectParameter Material_Roughness                = gbufferEffect.Parameters["Roughness"];
            public static readonly EffectParameter Material_MaskMap                  = gbufferEffect.Parameters["Mask"];
            public static readonly EffectParameter Material_Texture                  = gbufferEffect.Parameters["Texture"];
            public static readonly EffectParameter Material_NormalMap                = gbufferEffect.Parameters["NormalMap"];
            public static readonly EffectParameter Material_DisplacementMap          = gbufferEffect.Parameters["DisplacementMap"];
            public static readonly EffectParameter Material_RoughnessMap             = gbufferEffect.Parameters["RoughnessMap"];
            public static readonly EffectParameter Material_MaterialType             = gbufferEffect.Parameters["MaterialType"];
     
            public static readonly EffectTechnique DrawTextureDisplacement_Technique           = gbufferEffect.Techniques["DrawTextureDisplacement"];
            public static readonly EffectTechnique DrawTextureSpecularNormalMask_Technique     = gbufferEffect.Techniques["DrawTextureSpecularNormalMask"];
            public static readonly EffectTechnique DrawTextureNormalMask_Technique             = gbufferEffect.Techniques["DrawTextureNormalMask"];
            public static readonly EffectTechnique DrawTextureSpecularMask_Technique           = gbufferEffect.Techniques["DrawTextureSpecularMask"];
            public static readonly EffectTechnique DrawTextureMask_Technique                   = gbufferEffect.Techniques["DrawTextureMask"];
            public static readonly EffectTechnique DrawTextureSpecularNormalMetallic_Technique = gbufferEffect.Techniques["DrawTextureSpecularNormalMetallic"];
            public static readonly EffectTechnique DrawTextureSpecularNormal_Technique         = gbufferEffect.Techniques["DrawTextureSpecularNormal"];
            public static readonly EffectTechnique DrawTextureNormal_Technique                 = gbufferEffect.Techniques["DrawTextureNormal"];
            public static readonly EffectTechnique DrawTextureSpecular_Technique               = gbufferEffect.Techniques["DrawTextureSpecular"];
            public static readonly EffectTechnique DrawTextureSpecularMetallic_Technique       = gbufferEffect.Techniques["DrawTextureSpecularMetallic"];
            public static readonly EffectTechnique DrawTexture_Technique                       = gbufferEffect.Techniques["DrawTexture"];
            public static readonly EffectTechnique DrawBasic_Technique                         = gbufferEffect.Techniques["DrawBasic"];
     
        }
     
        public static class ClearGBufferShader
        {
            public static readonly Effect     ClearGBufferEffect   = Globals.content.Load<Effect>("Shaders/GbufferSetup/ClearGBuffer"); 
     
            public static readonly EffectPass Pass_clearGBuffer    = ClearGBufferEffect.Techniques["Clear"].Passes[0];
        }
     
     
        public static class taaShader
        {
            public static readonly Effect taaEffect = Globals.content.Load<Effect>("Shaders/TemporalAntiAliasing/TemporalAntiAliasing");
     
            public static readonly EffectParameter DepthMap           = taaEffect.Parameters["DepthMap"];
            public static readonly EffectParameter AccumulationMap    = taaEffect.Parameters["AccumulationMap"];
            public static readonly EffectParameter UpdateMap          = taaEffect.Parameters["UpdateMap"];
            public static readonly EffectParameter CurrentToPrevious  = taaEffect.Parameters["CurrentToPrevious"];
            public static readonly EffectParameter Resolution         = taaEffect.Parameters["Resolution"];
            public static readonly EffectParameter FrustumCorners     = taaEffect.Parameters["FrustumCorners"];
            public static readonly EffectParameter UseTonemap         = taaEffect.Parameters["UseTonemap"];
     
            public static readonly EffectPass      Pass_taa           = taaEffect.Techniques["TemporalAntialiasing"].Passes[0];
            public static readonly EffectPass      Pass_invTonemap    = taaEffect.Techniques["InverseTonemap"].Passes[0];
        }
     
    }