Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
Clojure
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Helion
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Yul (Solidity IR)
Zig
Javascript
GIMPLE
Ygen
sway
hlsl source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
AMD RGA 2.10
AMD RGA 2.11
AMD RGA 2.12
AMD RGA 2.13
AMD RGA 2.9.1
Clang (assertions trunk)
Clang (trunk)
DXC (trunk)
DXC 1.6.2112
DXC 1.7.2207
DXC 1.7.2212
DXC 1.7.2308
DXC 1.8.2306-preview
DXC 1.8.2403
DXC 1.8.2403.1
DXC 1.8.2403.2
DXC 1.8.2405
DXC 1.8.2407
DXC 1.8.2502
DXC 1.8.2505
DXC 1.8.2505.1
RGA 2.6.1 (DXC 1.6.2112)
RGA 2.6.1 (DXC 1.7.2207)
RGA 2.6.2 (DXC 1.6.2112)
RGA 2.6.2 (DXC 1.7.2207)
RGA 2.6.2 (DXC trunk)
RGA 2.9.0 (DXC trunk)
Options
Source code
// Miss Shader (.rmiss) - With Explicit Bindings // Executed when a ray doesn't hit any geometry // DATA TYPES // Scalar types // bool, int, uint, half, float, double // Vectors float3 skyColorHorizon; float3 skyColorZenith; // PARAMETERS WITH EXPLICIT BINDINGS [[vk::binding(0, 1)]] cbuffer MissParams { float4 horizonColor; float4 zenithColor; float sunIntensity; float3 sunDirection; }; // PAYLOAD struct RayPayload { float4 color; float hitT; float3 normal; float3 worldPos; uint recursionDepth; bool isShadowRay; }; // VARIABLES // Global static const float PI = 3.14159265358979323846f; // MISS SHADER ENTRY POINT [shader("miss")] void main(inout RayPayload payload) { // Local variables float3 rayDir = WorldRayDirection(); // Simple sky model float t = 0.5 * (rayDir.y + 1.0); float3 skyColor = (1.0 - t) * horizonColor.xyz + t * zenithColor.xyz; // Add sun if looking in sun direction float sunDot = max(0.0, dot(rayDir, normalize(sunDirection))); float sunHighlight = pow(sunDot, 128.0) * sunIntensity; // For shadow rays, just set a flag that nothing was hit if (payload.isShadowRay) { payload.hitT = -1.0; } else { // Regular rays get the sky color payload.color = float4(skyColor + sunHighlight, 1.0); payload.hitT = -1.0; payload.normal = float3(0, 1, 0); payload.worldPos = float3(0, 0, 0); } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree