Quantcast
Channel: Deferred Shading and material ID - Game Development Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Justin William Stanley Bryant for Deferred Shading and material ID

$
0
0

In my renderer I have a material ID that I use to change the material settings of rendered objects that way each object can have a different roughness\metalness\Fresnel\specular color\lighting type.

You don't branch with the mat id you just load a different material and use that when you do your lighting eg.

struct RenderMaterial{uint vHighlight1Color;uint vHighlight2Color;uint vFrontColor;uint vBackColor;float fReflectivity;float vHighlight1;float vHighlight2;float ior;float pointlightspecpower;float spotlightspecpower;float sunpower;float roughness;float fresneladjust;bool  GGX;float ambientpower;};Texture2D<uint> RenderMaterialIDs; //written to in my Fill Gbuffer stageStructuredBuffer<RenderMaterial> RenderMaterials; //Filled on the CPU with all the current RenderMaterials, loaded from disk.//Loading material from bufferuint MatID;MatID = RenderMaterialIDs.Load(uint3(globalIdx.x, globalIdx.y, 0));RenderMaterial CurrentMaterial = RenderMaterials[MatID];// Using material datafloat alpha2 = CurrentMaterial.roughness* CurrentMaterial.roughness;float G = G_Smith(CurrentMaterial.roughness, nDotV, nDotL);fresnelTerm = fresnelTerm * CurrentMaterial.fresneladjust;float3 spec=CurrentMaterial.GGX ? LightingFuncGGX_OPT3 : CookTorrence

I Use a tilebased deferred renderer


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>