라벨이 Unity_Shader인 게시물 표시

GPU Instancing

이미지
 https://docs.unity3d.com/Manual/GPUInstancing.html GPU instancing GPU instancing is a  draw call optimization  method that renders multiple copies of a  mesh  with the same material in a single draw call. Each copy of the mesh is called an instance. This is useful for drawing things that appear multiple times in a  scene , for example, trees or bushes. GPU instancing renders identical meshes in the same draw call. To add variation and reduce the appearance of repetition, each instance can have different properties, such as  Color  or  Scale . Draw calls that render multiple instances appear in the  Frame Debugger  as  Draw Mesh (instanced) . Requirements and compatibility This section includes information about the platform, render pipeline, and SRP Batcher compatibility of GPU instancing. Platform compatibility GPU instancing is available on every platform except  WebGL  1.0. Render pipeline compatibility Feature Bu...

SRP Batcher

 https://docs.unity3d.com/kr/2019.4/Manual/SRPBatcher.html 렌더링 성능을 극대화하려면 이러한 배치의 크기가 커야 합니다. 이를 위해 동일한 셰이더가 포함된 다른 머티리얼을 최대한 많이 사용할 수 있지만, 가능한 한 소수의 셰이더 배리언트로 사용해야 합니다. 렌더 루프 동안 Unity가 새 머티리얼을 감지하면 CPU는 모든 프로퍼티를 수집하고 GPU 메모리에 다양한 상수 버퍼를 설정합니다. GPU 버퍼 수는 셰이더가 CBUFFER를 선언하는 방법에 따라 다릅니다. 씬이 서로 다른 머티리얼을 많이 사용하는 반면 셰이더 배리언트는 아주 소수만 사용하는 경우 속도 최적화를 위해 SRP는 GPU 데이터 지속성 등과 같은 패러다임을 네이티브 방식으로 통합합니다. SRP 배처는 머티리얼 데이터가 GPU 메모리에 지속하도록 만드는 저레벨 렌더 루프입니다. 머티리얼 콘텐츠가 변하지 않으면 SRP 배처는 설정하거나 버퍼를 GPU 메모리에 업로드할 필요가 없습니다. 대신에 SRP 배처는 전용 코드 경로를 사용하여 대형 GPU 버퍼로 Unity 엔진 프로퍼티를 빠르게 업데이트합니다.

Shadow study SampleShadowmapFilteredTEXTURE2D_SHADOW_PARAM(ShadowMap, sampler_ShadowMap), float4 shadowCoord, ShadowSamplingData samplingData)

이미지
 https://github.com/Unity-Technologies/SimpleUIDemo/blob/master/Tiny3D/Library/PackageCache/com.unity.render-pipelines.core%407.1.6/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl float fetchesWeights[9]; float2 fetchesUV[9]; SampleShadow_ComputeSamples_Tent_5x5(samplingData.shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV); sum = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture, float3(fetchesUV[0].xy, shadowCoord.z));

Universial render pipeline shadow calc

 https://github.com/Unity-Technologies/Graphics/blob/4ad03e7975af24c8e60c974edb24c696e74e39b3/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl#L158 https://cyangamedev.wordpress.com/2020/09/22/custom-lighting/ real SampleShadowmapFiltered ( TEXTURE2D_SHADOW_PARAM (ShadowMap, sampler_ShadowMap), float4 shadowCoord, ShadowSamplingData samplingData) { real attenuation; #if defined (SHADER_API_MOBILE) || defined (SHADER_API_SWITCH) // 4-tap hardware comparison real4 attenuation4; attenuation4.x = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset0.xyz); attenuation4.y = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset1.xyz); attenuation4.z = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset2.xyz); attenuation4.w = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingDa...