Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/AtomicFS.glsl @ 12232

Last change on this file since 12232 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 2.3 KB
Line 
1#version 430
2
3out vec4 fragColour;
4
5uniform vec4 ColourMe[2] = vec4[](vec4(0,0,0,0),vec4(0,0,1,0));
6
7uniform bool pretty_colours;
8uniform bool image_load_store;
9
10uniform uint colour_factor[3];
11
12uniform switches
13{
14    bool awesome;
15    // float R;
16    // vec2 GB;
17};
18
19// buffer colors
20// {
21//     float R;
22//     // vec2 GB;
23// };
24uniform colors
25{
26    float R;
27    // vec2 GB;
28};
29
30uniform more_switches
31{
32    bool more_awesome;
33} moswitch;
34
35layout(binding = 0, offset = 4) uniform atomic_uint atom_counter;
36// layout(binding = 0) uniform atomic_uint atom_counter2;
37
38// layout(binding = 0, r32ui) coherent uniform uimage2D image_data;
39layout(binding = 0, rgba8) coherent uniform image2D image_data;
40
41// Pixel shader
42void main()
43{
44    // for (int i = 0; i < 3; i++) {
45    //     uint counter = atomicCounterIncrement(atom_counter[i]);
46    // }
47
48    //uint counter = atomicCounterIncrement(atom_counter);
49
50    // uint counter2 = atomicCounterIncrement(atom_counter2);
51    // uint counter4eva = atomicCounterIncrement(atom_counter[1]);
52
53    if (pretty_colours)
54    {
55        // Test basic setting integer vectors.
56        fragColour = ColourMe[0] + ColourMe[1]; // + counter / 4E9;
57    }
58    else if (image_load_store)
59    {
60        vec4 in_colour = imageLoad(image_data, ivec2(0));
61        // ivec2 frag_coord = ivec2(clamp(gl_FragCoord.x,0,256),
62        //                          clamp(gl_FragCoord.y,0,256));
63        // vec4 in_colour = imageLoad(image_data, frag_coord);
64
65        //imageStore(image_data, ivec2(0), vec4(0,0,1,1));
66
67        // Test image load/store and atomic counters.
68        //fragColour = vec4(in_colour,0,0,1);
69        fragColour = in_colour;
70    }
71    else 
72    {
73        // Test uint, bool, and atomic counters.
74        //fragColour =  counter / 4E9 + vec4(float(colour_factor[0]) / 100, float(colour_factor[1]) / 100, float(colour_factor[2]) / 100, 1);
75        if (awesome)
76        {
77            // midnight green
78            // fragColour = vec4(0, 0.28, 0.32, 1);
79            fragColour = vec4(R, 0.28, 0.32, 1);
80        }
81        else if (moswitch.more_awesome)
82        {
83            // jade
84            fragColour = vec4(0, 0.65, 0.41, 1);
85        }
86        else
87        {
88            fragColour = vec4(1,1,1,1);
89        }
90    }
91
92    // fragColour = vec4(1,1,1,1);
93    // fragColour = mycolour;
94}
Note: See TracBrowser for help on using the repository browser.