yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

venkataram-nvAvoiding the use of the global AST builder in DeclRefType::create (#4866)25bc5a3ad

master
560 B29 linesraw
1module environment;
2
3uint lcg(inout uint prev)
4{
5    const uint LCG_A = 1664525u;
6    const uint LCG_C = 1013904223u;
7    prev = (LCG_A * prev + LCG_C);
8    return prev & 0x00FFFFFF;
9}
10
11public float rnd(inout uint prev)
12{
13    return ((float) lcg(prev) / (float) 0x01000000);
14}
15
16public struct Environment_sample_data
17{
18    uint alias;
19    float q;
20};
21
22public float3 environment_sample(StructuredBuffer <Environment_sample_data> sample_buffer, inout int seed)
23{
24    float3 xi;
25    xi.x = rnd(seed);
26    xi.y = rnd(seed);
27    xi.z = rnd(seed);
28    return xi.z;
29}