summaryrefslogtreecommitdiff
path: root/shaders/tesseract/538.shader_test
blob: daed8fe4e223a3c8f5cecb11070af15814f4ae55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
[require]
GLSL >= 1.10

[vertex shader]
#version 120
#extension GL_ARB_texture_rectangle : enable
#define flat
#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
attribute vec4 vvertex, vtangent;
        attribute vec2 vtexcoord0;
        
        attribute vec4 vboneweight, vboneindex; 
        #pragma CUBE2_uniform animdata
        uniform vec4 animdata[192];
    
        uniform mat4 modelmatrix;
        uniform mat3 modelworld;
        uniform vec2 texscroll;
        varying vec2 texcoord0;
        varying vec3 nvec;
        void main(void)
        {
            
        int index = int(vboneindex.x);
        
            vec4 dqreal = animdata[index] * vboneweight.x;
            vec4 dqdual = animdata[index+1] * vboneweight.x;
            index = int(vboneindex.y);
            dqreal += animdata[index] * vboneweight.y;
            dqdual += animdata[index+1] * vboneweight.y;
            
                index = int(vboneindex.z);
                dqreal += animdata[index] * vboneweight.z;
                dqdual += animdata[index+1] * vboneweight.z;
            
            
            float len = length(dqreal);
            dqreal /= len;
            dqdual /= len;
        

        vec4 mpos = vec4((cross(dqreal.xyz, cross(dqreal.xyz, vvertex.xyz) + vvertex.xyz*dqreal.w + dqdual.xyz) + dqdual.xyz*dqreal.w - dqreal.xyz*dqdual.w)*2.0 + vvertex.xyz, vvertex.w);

        
            vec4 mquat = vec4(cross(dqreal.xyz, vtangent.xyz) + dqreal.xyz*vtangent.w + vtangent.xyz*dqreal.w, dqreal.w*vtangent.w - dot(dqreal.xyz, vtangent.xyz));
            
        vec3 mnormal = cross(mquat.xyz, vec3(mquat.y, -mquat.x, mquat.w))*2.0 + vec3(0.0, 0.0, 1.0);
    
        
    

            gl_Position = modelmatrix * mpos;

            texcoord0 = vtexcoord0 + texscroll;

            nvec = modelworld * mnormal;
        }
    
[fragment shader]
#version 120
#extension GL_ARB_texture_rectangle : enable
#define flat
#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
#define fragdata(loc, name, type)
#define gcolor gl_FragData[0]
#define gnormal gl_FragData[1]
varying vec2 texcoord0;
        varying vec3 nvec;
        uniform vec4 colorscale;
        uniform float alphatest;
        uniform vec3 rsmdir;
        uniform sampler2D tex0;
        fragdata(0, gcolor, vec4)
        fragdata(1, gnormal, vec4)
        void main(void)
        {
            vec4 diffuse = texture2D(tex0, texcoord0);
            
                if(diffuse.a <= alphatest)
                    discard;
            
            vec3 normal = normalize(nvec);
            
            gcolor = vec4(dot(normal, rsmdir)*diffuse.rgb*colorscale.rgb, 1.0);
            gnormal = vec4(normal*0.5+0.5, 0.0);
        }