//------------------------------------------------------------------------------------- // Fill SurfaceData/Builtin data function //------------------------------------------------------------------------------------- #include "../MaterialUtilities.hlsl" void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData) { ApplyDoubleSidedFlipOrMirror(input); // Apply double sided flip on the vertex normal // NEWLITTODO: // For now, just use the interpolated vertex normal. This has been normalized in the initial fragment interpolators unpacking. // Eventually, we want to share all the LitData LayerTexCoord (and surface gradient frame + uv, planar, triplanar, etc.) logic, also // spread in LitDataIndividualLayer and LitDataMeshModification. surfaceData.normalWS = input.worldToTangent[2].xyz; float2 baseColorMapUv = TRANSFORM_TEX(input.texCoord0, _BaseColorMap); surfaceData.baseColor = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, baseColorMapUv).rgb * _BaseColor.rgb; float alpha = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, baseColorMapUv).a * _BaseColor.a; #ifdef _ALPHATEST_ON //NEWLITTODO: Once we include those passes in the main StackLit.shader, add handling of CUTOFF_TRANSPARENT_DEPTH_PREPASS and _POSTPASS // and the related properties (in the .shader) and uniforms (in the StackLitProperties file) _AlphaCutoffPrepass, _AlphaCutoffPostpass DoAlphaTest(alpha, _AlphaCutoff); #endif #if defined(DEBUG_DISPLAY) if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) { surfaceData.color = GetTextureDataDebug(_DebugMipMapMode, baseColorMapUv, _BaseColorMap, _BaseColorMap_TexelSize, _BaseColorMap_MipInfo, surfaceData.color); } #endif // Builtin Data // NEWLITTODO: for all BuiltinData, might need to just refactor and use a comon function like that // contained in LitBuiltinData.hlsl builtinData.opacity = alpha; builtinData.bakeDiffuseLighting = float3(0.0, 0.0, 0.0); // Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity builtinData.emissiveIntensity = _EmissiveIntensity; builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive); #ifdef _EMISSIVE_COLOR_MAP builtinData.emissiveColor *= SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, TRANSFORM_TEX(input.texCoord0, _EmissiveColorMap)).rgb; #endif builtinData.velocity = float2(0.0, 0.0); //NEWLITTODO: shader feature SHADOWS_SHADOWMASK not there yet. builtinData.shadowMask0 = 0.0; builtinData.shadowMask1 = 0.0; builtinData.shadowMask2 = 0.0; builtinData.shadowMask3 = 0.0; #if (SHADERPASS == SHADERPASS_DISTORTION) || defined(DEBUG_DISPLAY) float3 distortion = SAMPLE_TEXTURE2D(_DistortionVectorMap, sampler_DistortionVectorMap, input.texCoord0).rgb; distortion.rg = distortion.rg * _DistortionVectorScale.xx + _DistortionVectorBias.xx; builtinData.distortion = distortion.rg * _DistortionScale; builtinData.distortionBlur = clamp(distortion.b * _DistortionBlurScale, 0.0, 1.0) * (_DistortionBlurRemapMax - _DistortionBlurRemapMin) + _DistortionBlurRemapMin; #else builtinData.distortion = float2(0.0, 0.0); builtinData.distortionBlur = 0.0; #endif builtinData.depthOffset = 0.0; }