diff options
author | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | 5424a1d5434e3ddd911a504719918c2df027e2fd (patch) | |
tree | 6275aab13140d81dcc46c8290e73ac9a8bbb5605 /assets/Shaders | |
parent | afcac59c7d04f4337d6b04ebed8cac7e871ccc50 (diff) |
Changeset: 8 Initial work on sprites and texture system
Diffstat (limited to 'assets/Shaders')
-rw-r--r-- | assets/Shaders/Default.json | 32 | ||||
-rw-r--r-- | assets/Shaders/S_Default.glsl (renamed from assets/Shaders/Default.glsl) | 12 | ||||
-rw-r--r-- | assets/Shaders/S_Default.json | 65 |
3 files changed, 75 insertions, 34 deletions
diff --git a/assets/Shaders/Default.json b/assets/Shaders/Default.json deleted file mode 100644 index d294372..0000000 --- a/assets/Shaders/Default.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "Inputs": [ - { - "Semantic": "Position", - "Name": "pos", - "ScalarType": "float", - "Width": 1, - "Height": 3, - "ArrayLength": 1, - "OpenGLLocation": 0 - }, - { - "Semantic": "Color1", - "Name": "color", - "ScalarType": "float", - "Width": 1, - "Height": 4, - "ArrayLength": 1, - "OpenGLLocation": 1 - } - ], - "Outputs": [ - { - "Name": "fragColor", - "ScalarType": "float", - "Width": 1, - "Height": 4, - "ArrayLength": 1, - "OpenGLLocation": 0 - } - ] -}
\ No newline at end of file diff --git a/assets/Shaders/Default.glsl b/assets/Shaders/S_Default.glsl index d103102..1d93471 100644 --- a/assets/Shaders/Default.glsl +++ b/assets/Shaders/S_Default.glsl @@ -3,17 +3,20 @@ layout(location = 0) in vec3 pos; layout(location = 1) in vec4 color; +layout(location = 2) in vec2 texcoord; out Vertex2Fragmnet { vec4 color; + vec2 texcoord; } v2f; -// Standard PainterHost uniform +// Autofill uniforms uniform mat4 transformation; void main() { gl_Position = transformation * vec4(pos, 1.0); v2f.color = color; + v2f.texcoord = texcoord; } #type fragment @@ -21,10 +24,15 @@ void main() { in Vertex2Fragmnet { vec4 color; + vec2 texcoord; } v2f; out vec4 fragColor; +// Material uniforms +uniform sampler2D textureAtlas; +uniform vec4 taint; + void main() { - fragColor = v2f.color; + fragColor = texture(textureAtlas, v2f.texcoord) * v2f.color * taint; } diff --git a/assets/Shaders/S_Default.json b/assets/Shaders/S_Default.json new file mode 100644 index 0000000..df37792 --- /dev/null +++ b/assets/Shaders/S_Default.json @@ -0,0 +1,65 @@ +{ + "Inputs": [ + { + "Semantic": "Position", + "Name": "pos", + "ScalarType": "float", + "Width": 1, + "Height": 3, + "OpenGLLocation": 0 + }, + { + "Semantic": "TexCoords1", + "Name": "texcoord", + "ScalarType": "float", + "Width": 1, + "Height": 2, + "OpenGLLocation": 1 + }, + { + "Semantic": "Color1", + "Name": "color", + "ScalarType": "float", + "Width": 1, + "Height": 4, + "OpenGLLocation": 2 + } + ], + "Outputs": [ + { + "Name": "fragColor", + "ScalarType": "float", + "Width": 1, + "Height": 4, + "OpenGLLocation": 0 + } + ], + "Uniforms": [ + { + "Type": "Math", + "AutoFill": true, + "Value": { + "Name": "transformation", + "ScalarType": "float", + "Width": 4, + "Height": 4 + } + }, + { + "Type": "Math", + "Value": { + "Name": "taint", + "Semantic": "Color1", + "ScalarType": "float", + "Width": 1, + "Height": 4 + } + }, + { + "Type": "Sampler", + "Value": { + "Name": "textureAtlas" + } + } + ] +}
\ No newline at end of file |