浏览代码

Set values of legacy built-in uniforms

/main
Evgenii Golubev 8 年前
当前提交
34315214
共有 4 个文件被更改,包括 20 次插入7 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  2. 6
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
  3. 17
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader
  4. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs

2
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyRenderer.cs


m_ProceduralSkyMaterial.SetVector("_SkyParam", new Vector4(param.exposure, param.multiplier, param.rotation, 0.0f));
m_ProceduralSkyMaterial.SetMatrix("_ViewProjMatrix", builtinParams.viewProjMatrix);
m_ProceduralSkyMaterial.SetMatrix("_InvViewProjMatrix", builtinParams.invViewProjMatrix);
m_ProceduralSkyMaterial.SetVector("_CameraPosWS", builtinParams.cameraPosWS);
m_ProceduralSkyMaterial.SetVector("_ScreenSize", builtinParams.screenSize);
m_ProceduralSkyMaterial.SetInt("_AtmosphericsDebugMode", (int)param.debugMode);

6
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl


void VolundTransferScatter(float3 worldPos, out float4 coords1, out float4 coords2, out float4 coords3) {
const float3 scaledWorldPos = WorldScale(worldPos);
const float3 worldCamPos = WorldScale(_WorldSpaceCameraPos.xyz);
const float3 worldCamPos = WorldScale(_CameraPosWS.xyz);
const float c_MieScaleHeight = 1200.f;
const float worldRayleighDensity = 1.f;

const float worldVecLen = length(worldVec);
const float3 worldDir = worldVec / worldVecLen;
const float3 worldDirUnscaled = normalize(worldPos - _WorldSpaceCameraPos.xyz);
const float3 worldDirUnscaled = normalize(worldPos - _CameraPosWS.xyz);
const float viewSunCos = dot(worldDirUnscaled, _SunDirection);
const float rayleighPh = min(1.f, RayleighPhase(viewSunCos) * 12.f);

#if defined(UNITY_PASS_FORWARDBASE)
return pos;
#else
return pos / _ScreenParams.xy;
return pos * _ScreenSize.zw;
#endif
}

17
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader


#include "Color.hlsl"
#include "Common.hlsl"
#include "CommonLighting.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#define IS_RENDERING_SKY
#include "AtmosphericScattering.hlsl"
float4 _SkyParam; // x exposure, y multiplier, z rotation
// x exposure, y multiplier, z rotation
float4 _SkyParam;
// x = width, y = height, z = 1.0/width, w = 1.0/height
float4 _ScreenSize;
float4 _CameraPosWS;
float4x4 _InvViewProjMatrix;
float4x4 _ViewProjMatrix;
#define IS_RENDERING_SKY
#include "AtmosphericScattering.hlsl"
struct Attributes
{

2
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs


{
public Matrix4x4 viewProjMatrix;
public Matrix4x4 invViewProjMatrix;
public Vector3 cameraPosWS;
public Vector4 screenSize;
public Mesh skyMesh;
public RenderLoop renderLoop;

m_BuiltinParameters.sunLight = sunLight;
m_BuiltinParameters.invViewProjMatrix = camera.invViewProjectionMatrix;
m_BuiltinParameters.viewProjMatrix = camera.viewProjectionMatrix;
m_BuiltinParameters.cameraPosWS = camera.camera.transform.position;
m_BuiltinParameters.screenSize = camera.screenSize;
m_BuiltinParameters.skyMesh = BuildSkyMesh(camera.camera.GetComponent<Transform>().position, m_BuiltinParameters.invViewProjMatrix, false);
m_BuiltinParameters.colorBuffer = colorBuffer;

正在加载...
取消
保存