Carna Version 3.3.3
Loading...
Searching...
No Matches
mr.frag
1#version 330
2
3/*
4 * Copyright (C) 2021 Leonid Kostrykin
5 *
6 */
7
8uniform sampler3D mask;
9uniform mat4 modelTexture;
10uniform bool ignoreColor;
11uniform vec4 color;
12
13in vec4 modelSpaceCoordinates;
14
15layout( location = 0 ) out vec4 _gl_FragColor;
16
17
18// ----------------------------------------------------------------------------------
19// Fragment Procedure
20// ----------------------------------------------------------------------------------
21
22void main()
23{
24 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
25 {
26 discard;
27 }
28
29 vec4 textureCoordinates = modelTexture * modelSpaceCoordinates;
30 float intensity = texture( mask, textureCoordinates.xyz ).r;
31 if( intensity > 0 )
32 {
33 if( ignoreColor )
34 {
35 _gl_FragColor = vec4( intensity, 0, 0, 1.0 );
36 }
37 else
38 {
39 _gl_FragColor = vec4( color );
40 }
41 }
42 else
43 {
44 discard;
45 }
46}