I am trying to make a shader material using the Custom Node.
// Inputs
// uv (float2) - UV coordinates
// Tex (Texture Object) - Texture
float3 color = Tex.Sample(TexSampler, uv).rgb;
float3 blurred = float3(0.0, 0.0, 0.0);
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
blurred += Tex.Sample(TexSampler, uv + float2(i, j) * Strength).rgb;
}
}
blurred /= 25.0;
float3 edges = abs(color - Tex.Sample(TexSampler, uv + float2(0.01, 0.01)).rgb);
float edgeFactor = length(edges) * Offset;
float3 watercolor = lerp(blurred, color, edgeFactor);
// Output the watercolor color
return float4(watercolor, 1.0);
The code works good but if I switch my project to “Support Hardware Ray Tracing” the shader wont compiling anymore giving the error:
[SM6] RayTracingMaterialHitShaders.dxil:3935:28: error: Opcode Sample not valid in shader model lib_6_6(closesthit).
[SM6] note: at ‘%649 = call %dx.types.ResRet.f32 @dx.op.sample.f32(i32 60, %dx.types.Handle %622, %dx.types.Handle %624, float %647, float %648, float undef, float undef, i32 0, i32 0, i32 undef, float undef)’ in block ‘#29’ of function ‘?MaterialCHS@@YAXUFPackedMaterialClosestHitPayload@@UFRayTracingIntersectionAttributes@@@Z’.
Any idea why?