From d43508ba4843801cbbf1f42a27af260d4eef5701 Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Sun, 17 Apr 2022 20:08:57 -0700 Subject: Initial work on sprites and texture system --- assets/Materials/M_BasicWalls.json | 1 + assets/Materials/M_Default.json | 2 +- assets/Materials/M_Player.json | 1 + assets/Shaders/Default.glsl | 30 ------------------ assets/Shaders/Default.json | 32 ------------------- assets/Shaders/S_Default.glsl | 38 ++++++++++++++++++++++ assets/Shaders/S_Default.json | 65 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 106 insertions(+), 63 deletions(-) create mode 100644 assets/Materials/M_BasicWalls.json create mode 100644 assets/Materials/M_Player.json delete mode 100644 assets/Shaders/Default.glsl delete mode 100644 assets/Shaders/Default.json create mode 100644 assets/Shaders/S_Default.glsl create mode 100644 assets/Shaders/S_Default.json (limited to 'assets') diff --git a/assets/Materials/M_BasicWalls.json b/assets/Materials/M_BasicWalls.json new file mode 100644 index 0000000..209dcf6 --- /dev/null +++ b/assets/Materials/M_BasicWalls.json @@ -0,0 +1 @@ +{"Name":"M_BasicWalls","ShaderName":"S_Default","Fields":[{"Name":"taint","Type":"Vector","Value":[0.37144365906715393,0.5479920506477356,0.5784313678741455,1.0]}]} \ No newline at end of file diff --git a/assets/Materials/M_Default.json b/assets/Materials/M_Default.json index 87a467f..ad09830 100644 --- a/assets/Materials/M_Default.json +++ b/assets/Materials/M_Default.json @@ -1 +1 @@ -{"Name":"M_Default","ShaderName":"Default","Fields":[]} \ No newline at end of file +{"Name":"M_Default","ShaderName":"S_Default","Fields":[{"Name":"taint","Type":"Vector","Value":[1.0,1.0,1.0,1.0]}]} \ No newline at end of file diff --git a/assets/Materials/M_Player.json b/assets/Materials/M_Player.json new file mode 100644 index 0000000..d2b126d --- /dev/null +++ b/assets/Materials/M_Player.json @@ -0,0 +1 @@ +{"Name":"M_Player","ShaderName":"S_Default","Fields":[{"Name":"taint","Type":"Vector","Value":[1.0,1.0,1.0,0.0]}]} \ No newline at end of file diff --git a/assets/Shaders/Default.glsl b/assets/Shaders/Default.glsl deleted file mode 100644 index d103102..0000000 --- a/assets/Shaders/Default.glsl +++ /dev/null @@ -1,30 +0,0 @@ -#type vertex -#version 330 core - -layout(location = 0) in vec3 pos; -layout(location = 1) in vec4 color; - -out Vertex2Fragmnet { - vec4 color; -} v2f; - -// Standard PainterHost uniform -uniform mat4 transformation; - -void main() { - gl_Position = transformation * vec4(pos, 1.0); - v2f.color = color; -} - -#type fragment -#version 330 core - -in Vertex2Fragmnet { - vec4 color; -} v2f; - -out vec4 fragColor; - -void main() { - fragColor = v2f.color; -} 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/S_Default.glsl b/assets/Shaders/S_Default.glsl new file mode 100644 index 0000000..1d93471 --- /dev/null +++ b/assets/Shaders/S_Default.glsl @@ -0,0 +1,38 @@ +#type vertex +#version 330 core + +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; + +// Autofill uniforms +uniform mat4 transformation; + +void main() { + gl_Position = transformation * vec4(pos, 1.0); + v2f.color = color; + v2f.texcoord = texcoord; +} + +#type fragment +#version 330 core + +in Vertex2Fragmnet { + vec4 color; + vec2 texcoord; +} v2f; + +out vec4 fragColor; + +// Material uniforms +uniform sampler2D textureAtlas; +uniform vec4 taint; + +void main() { + 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 -- cgit v1.2.3-70-g09d2