As in the title, I’m getting a
“Fragment program ‘frag’: Unrecognized sampler ‘sampler_cameraopaquetexture’ - does not match any texture and is not a recognized inline name (should contain filter and wrap modes).” on d3d11.
For the life of me can’t figure out what I’ve done wrong.
The entire thing could be wrong and not output anything useful, I’m poking around with things I don’t really understand, but this seems like something very basic I’m missing.
Shader "Custom/SelectiveSaturationShader" {
Properties
{
_SaturationTex("SaturationTexture", 2D) = "white"{}
}
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline" }
LOD 200
ZWrite Off Cull Off
Pass
{
name "SelectiveSaturationPass"
HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
// The Blit.hlsl file provides the vertex shader (Vert),
// input structure (Attributes) and output strucutre (Varyings)
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
// Physically based Standard lighting model, and enable shadows on all light types
#pragma vertex Vert
#pragma fragment frag
TEXTURE2D(_camerOpaqueTexture);
SAMPLER(sampler_CameraOpaqueTexture);
TEXTURE2D(_SaturationTex);
SAMPLER(sampler_SaturationTex);
float Epsilon = 1e-10;
half4 Saturation( float3 In, float saturation )
{
half luma = dot(In, float3(0.2126729, 0.7151522, 0.0721750));
half3 temp = luma.xxx + saturation.xxx * (In - luma.xxx);
return half4(temp.x, temp.y, temp.z, 1);
}
half4 RGBtoHCV(in float3 RGB)
{
half4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0/3.0) : float4(RGB.gb, 0.0, -1.0/3.0);
half4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
half C = Q.x - min(Q.w, Q.y);
half H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
return half4(H, C, Q.x,1);
}
half4 frag (Varyings input) : SV_Target
{
half4 satColor = SAMPLE_TEXTURE2D(_SaturationTex, sampler_SaturationTex, input.texcoord);
half4 sat = Saturation(satColor.xyz, 0);
half4 hcva = RGBtoHCV(sat.xyz);
half4 sceneColour = SAMPLE_TEXTURE2D(_camerOpaqueTexture, sampler_CameraOpaqueTexture, input.texcoord);
half4 sceneSaturated = Saturation(satColor.xyz, hcva.z);
sceneSaturated.w = sceneColour.w;
return sceneSaturated;
}
ENDHLSL
}
}
FallBack "Diffuse"
}
I’m hoping this pulls in a texture rendered out from another camera, sets the saturation of that texture to 0, and uses that to set the screen saturation. May be wildly off on that point but if I can get rid of this error, at least I can begin fixing logic.
Thanks.