From 3bb3166d1c96ab3ed5fcb62aa0c29e9dfb6d8b8e Mon Sep 17 00:00:00 2001 From: Artsiom Trubchyk Date: Thu, 15 May 2025 23:26:59 +0300 Subject: [PATCH] Convert noise shader to version 1.4.0 --- material/noise/example/noise.fp | 14 ++++++++++--- material/noise/example/noise.material | 8 -------- material/noise/example/noise.vp | 29 ++++++++++++--------------- material/noise/game.project | 2 +- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/material/noise/example/noise.fp b/material/noise/example/noise.fp index cb5245a..c96d8d4 100644 --- a/material/noise/example/noise.fp +++ b/material/noise/example/noise.fp @@ -1,5 +1,13 @@ -varying mediump vec2 var_texcoord0; -uniform lowp vec4 time; +#version 140 + +in mediump vec2 var_texcoord0; + +uniform fs_uniforms +{ + mediump vec4 time; +}; + +out mediump vec4 out_fragColor; // noise shader from https://www.shadertoy.com/view/XXBcDz @@ -42,6 +50,6 @@ float fbm( vec2 p ) void main() { float n = fbm(var_texcoord0.xy); - gl_FragColor = vec4(n, n, n, 1.0); + out_fragColor = vec4(n, n, n, 1.0); } diff --git a/material/noise/example/noise.material b/material/noise/example/noise.material index ed59526..7a373b8 100644 --- a/material/noise/example/noise.material +++ b/material/noise/example/noise.material @@ -7,18 +7,10 @@ vertex_constants { name: "mtx_worldview" type: CONSTANT_TYPE_WORLDVIEW } -vertex_constants { - name: "mtx_view" - type: CONSTANT_TYPE_VIEW -} vertex_constants { name: "mtx_proj" type: CONSTANT_TYPE_PROJECTION } -vertex_constants { - name: "mtx_normal" - type: CONSTANT_TYPE_NORMAL -} fragment_constants { name: "time" type: CONSTANT_TYPE_USER diff --git a/material/noise/example/noise.vp b/material/noise/example/noise.vp index 79dedc0..c91917c 100644 --- a/material/noise/example/noise.vp +++ b/material/noise/example/noise.vp @@ -1,26 +1,23 @@ +#version 140 -// Positions can be world or local space, since world and normal -// matrices are identity for world vertex space materials. -// If world vertex space is selected, you can remove the -// normal matrix multiplication for optimal performance. +in highp vec4 position; +in mediump vec2 texcoord0; +in mediump vec3 normal; -attribute highp vec4 position; -attribute mediump vec2 texcoord0; -attribute mediump vec3 normal; - -uniform mediump mat4 mtx_worldview; -uniform mediump mat4 mtx_view; -uniform mediump mat4 mtx_proj; -uniform mediump mat4 mtx_normal; +uniform vp_uniforms +{ + mediump mat4 mtx_worldview; + mediump mat4 mtx_proj; +}; -varying highp vec4 var_position; -varying mediump vec3 var_normal; -varying mediump vec2 var_texcoord0; +out highp vec4 var_position; +out mediump vec2 var_texcoord0; void main() { - vec4 p = mtx_worldview * vec4(position.xyz, 1.0); + highp vec4 p = mtx_worldview * vec4(position.xyz, 1.0); var_texcoord0 = texcoord0; + gl_Position = mtx_proj * p; } diff --git a/material/noise/game.project b/material/noise/game.project index 0aeaef3..f696cc5 100644 --- a/material/noise/game.project +++ b/material/noise/game.project @@ -1,5 +1,5 @@ [project] -title = Defold-examples +title = material_noise version = 0.1 [bootstrap]