Implement the refract
HLSL Function
#99153
Labels
backend:DirectX
backend:SPIR-V
bot:HLSL
HLSL
HLSL Language Support
metabug
Issue to collect references to a group of similar or related issues.
refract
using HLSL source inhlsl_intrinsics.h
refract
SPIR-V target built-in in clang/include/clang/Basic/BuiltinsSPIRV.tdrefract
toCheckSPIRVBuiltinFunctionCall
inclang/lib/Sema/SemaSPIRV.cpp
refract
toEmitSPIRVBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/refract.hlsl
clang/test/CodeGenSPIRV/Builtins/refract.c
clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl
clang/test/SemaSPIRV/BuiltIns/refract-errors.c
int_spv_refract
intrinsic inIntrinsicsSPIRV.td
refract
lowering and map it toint_spv_refract
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/refract.ll
DirectX
SPIR-V
Refract:
Description:
Refract
For the incident vector I and surface normal N, and the ratio of
indices of refraction eta, the result is the refraction vector. The
result is computed by
k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
if k < 0.0 the result is 0.0
otherwise, the result is eta * I - (eta * dot(N, I) +
sqrt(k)) * N
The input parameters for the incident vector I and the surface normal
N must already be normalized to get the desired results.
The type of I and N must be a scalar or vector with a floating-point
component type.
The type of eta must be a 16-bit or 32-bit floating-point scalar.
Result Type, the type of I, and the type of N must all be the same
type.
72
<id>
I
<id>
N
<id>
eta
Test Case(s)
Example 1
HLSL:
Returns a refraction vector using an entering ray, a surface normal, and a refraction index.
Parameters
Return Value
A floating-point, refraction vector. If the angle between the entering ray i and the surface normal n is too great for a given refraction index ?, the return value is (0,0,0).
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
Intrinsic Functions (DirectX HLSL)
The text was updated successfully, but these errors were encountered: