您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

75 行
2.0 KiB

Shader "Debug/ReflectionProbePreview"
{
Properties
{
_Cubemap("_Cubemap", Cube) = "white" {}
_CameraWorldPosition("_CameraWorldPosition", Vector) = (1,1,1,1)
_MipLevel("_MipLevel", Range(0.0,7.0)) = 0.0
_Exposure("_Exposure", Range(-10.0,10.0)) = 0.0
}
SubShader
{
Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "Opaque" "Queue" = "Transparent" }
ZWrite On
Cull Back
Pass
{
Name "ForwardUnlit"
Tags{ "LightMode" = "Forward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "CoreRP/ShaderLibrary/common.hlsl"
#include "HDRP/ShaderVariables.hlsl"
struct appdata
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct v2f
{
float4 positionCS : SV_POSITION;
float3 normalWS : NORMAL;
float3 positionWS : TEXCOORD0;
};
TEXTURECUBE(_Cubemap);
SAMPLER(sampler_Cubemap);
float3 _CameraWorldPosition;
float _MipLevel;
float _Exposure;
v2f vert(appdata v)
{
v2f o;
// Transform local to world before custom vertex code
o.positionWS = TransformObjectToWorld(v.positionOS.xyz);
o.positionWS = GetCameraRelativePositionWS(o.positionWS);
o.positionCS = TransformWorldToHClip(o.positionWS);
o.normalWS = TransformObjectToWorldNormal(v.normalOS);
return o;
}
float4 frag(v2f i) : SV_Target
{
//float3 view = normalize(i.worldpos - _CameraWorldPosition);
float3 V = normalize(i.positionWS - GetPrimaryCameraPosition());
float3 R = reflect(V, i.normalWS);
float4 color = SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, R, _MipLevel).rgba;
color = color * exp2(_Exposure);
return float4(color);
}
ENDHLSL
}
}
}