diff options
80 files changed, 890 insertions, 486 deletions
diff --git a/examples/animated-shapes/shaders/animated-shapes.frag b/examples/animated-shapes/shaders/animated-shapes.frag index 61276842..a5c57171 100644 --- a/examples/animated-shapes/shaders/animated-shapes.frag +++ b/examples/animated-shapes/shaders/animated-shapes.frag @@ -1,5 +1,11 @@ -uniform lowp vec4 uColor; -varying lowp vec2 vCoefficient; +//@version 100 + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +}; + +INPUT lowp vec2 vCoefficient; void main() { diff --git a/examples/animated-shapes/shaders/animated-shapes.vert b/examples/animated-shapes/shaders/animated-shapes.vert index 06e6523b..5ba6c5c3 100644 --- a/examples/animated-shapes/shaders/animated-shapes.vert +++ b/examples/animated-shapes/shaders/animated-shapes.vert @@ -1,7 +1,14 @@ -attribute mediump vec3 aCoefficient; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uPosition[MAX_POINT_COUNT]; -varying lowp vec2 vCoefficient; +//@version 100 + +INPUT mediump vec3 aCoefficient; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uPosition[MAX_POINT_COUNT]; +}; + +OUTPUT lowp vec2 vCoefficient; void main() { diff --git a/examples/bezier-curve/shaders/bezier-curve.frag b/examples/bezier-curve/shaders/bezier-curve.frag index ef6b09ed..8633599c 100644 --- a/examples/bezier-curve/shaders/bezier-curve.frag +++ b/examples/bezier-curve/shaders/bezier-curve.frag @@ -1,4 +1,5 @@ -uniform lowp vec4 uColor; +//@version 100 + void main() { diff --git a/examples/bezier-curve/shaders/bezier-curve.vert b/examples/bezier-curve/shaders/bezier-curve.vert index a108a415..1f807a54 100644 --- a/examples/bezier-curve/shaders/bezier-curve.vert +++ b/examples/bezier-curve/shaders/bezier-curve.vert @@ -1,6 +1,12 @@ -attribute mediump vec2 aPosition; -uniform mediump mat4 uMvpMatrix; -uniform vec3 uSize; +//@version 100 + +INPUT mediump vec2 aPosition; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM vec3 uSize; +}; void main() { diff --git a/examples/bullet-physics/shaders/rendering-textured-shape.frag b/examples/bullet-physics/shaders/rendering-textured-shape.frag index 1f7bac25..af4064f3 100644 --- a/examples/bullet-physics/shaders/rendering-textured-shape.frag +++ b/examples/bullet-physics/shaders/rendering-textured-shape.frag @@ -1,7 +1,14 @@ -uniform sampler2D uTexture; -uniform mediump float uBrightness; -varying mediump vec2 vTexCoord; -varying mediump vec3 vIllumination; +//@version 100 + +UNIFORM sampler2D uTexture; + +UNIFORM_BLOCK VanFrag +{ +UNIFORM mediump float uBrightness; +}; + +INPUT mediump vec2 vTexCoord; +INPUT mediump vec3 vIllumination; mediump vec3 redistribute_rgb(mediump vec3 color) { @@ -23,7 +30,7 @@ mediump vec3 redistribute_rgb(mediump vec3 color) void main() { - mediump vec4 texColor = texture2D( uTexture, vTexCoord ); + mediump vec4 texColor = TEXTURE( uTexture, vTexCoord ); //mediump vec4 texColor = vec4(0.5,0.5,0.5,1.0); //gl_FragColor = vec4(texColor.rgb, 1.0); diff --git a/examples/bullet-physics/shaders/rendering-textured-shape.vert b/examples/bullet-physics/shaders/rendering-textured-shape.vert index 02b1edbd..abad5039 100644 --- a/examples/bullet-physics/shaders/rendering-textured-shape.vert +++ b/examples/bullet-physics/shaders/rendering-textured-shape.vert @@ -1,11 +1,17 @@ -attribute mediump vec3 aPosition; // DALi shader builtin -attribute mediump vec2 aTexCoord; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump mat4 uViewMatrix; // DALi shader builtin -uniform mediump mat4 uModelView; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin -varying mediump vec3 vIllumination; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump mat4 uViewMatrix; // DALi shader builtin +UNIFORM mediump mat4 uModelView; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; + +INPUT mediump vec3 aPosition; // DALi shader builtin +INPUT mediump vec2 aTexCoord; // DALi shader builtin +OUTPUT mediump vec3 vIllumination; +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/contact-cards/shaders/clipped-image.frag b/examples/contact-cards/shaders/clipped-image.frag index bde9850c..f9d80188 100644 --- a/examples/contact-cards/shaders/clipped-image.frag +++ b/examples/contact-cards/shaders/clipped-image.frag @@ -1,3 +1,5 @@ +//@version 100 + // This fragment-shader does not output anything. // It's for a control which is just going to clip as specified in the vertex shader. diff --git a/examples/contact-cards/shaders/clipped-image.vert b/examples/contact-cards/shaders/clipped-image.vert index cfe84bdd..f8c8a96e 100644 --- a/examples/contact-cards/shaders/clipped-image.vert +++ b/examples/contact-cards/shaders/clipped-image.vert @@ -1,13 +1,19 @@ +//@version 100 + // This vertex-shader mixes in the quad and circle geometry depending on the value of uDelta. // // uDelta is used to mix in the Circle and the Quad positions. // If uDelta is 0.0f, then the circle position is adopted and if it is 1.0f, then the quad position is adopted. -attribute mediump vec2 aPositionCircle; -attribute mediump vec2 aPositionQuad; -uniform mediump float uDelta; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; +INPUT mediump vec2 aPositionCircle; +INPUT mediump vec2 aPositionQuad; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump float uDelta; +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +}; void main() { diff --git a/examples/line-mesh/shaders/line-mesh.frag b/examples/line-mesh/shaders/line-mesh.frag index c9eeb01e..4f11e44e 100644 --- a/examples/line-mesh/shaders/line-mesh.frag +++ b/examples/line-mesh/shaders/line-mesh.frag @@ -1,7 +1,13 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; +//@version 100 -varying lowp vec3 vColor; +UNIFORM sampler2D sTexture; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +}; + +INPUT lowp vec3 vColor; void main() { diff --git a/examples/line-mesh/shaders/line-mesh.vert b/examples/line-mesh/shaders/line-mesh.vert index e9ff779e..98949b86 100644 --- a/examples/line-mesh/shaders/line-mesh.vert +++ b/examples/line-mesh/shaders/line-mesh.vert @@ -1,11 +1,17 @@ -attribute mediump vec2 aPosition1; -attribute mediump vec2 aPosition2; -attribute lowp vec3 aColor; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump float uMorphAmount; +//@version 100 -varying lowp vec3 vColor; +INPUT mediump vec2 aPosition1; +INPUT mediump vec2 aPosition2; +INPUT lowp vec3 aColor; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM mediump float uMorphAmount; +}; + +OUTPUT lowp vec3 vColor; void main() { diff --git a/examples/mesh-morph/shaders/mesh-morph.frag b/examples/mesh-morph/shaders/mesh-morph.frag index 93f7a013..bdd5ca04 100644 --- a/examples/mesh-morph/shaders/mesh-morph.frag +++ b/examples/mesh-morph/shaders/mesh-morph.frag @@ -1,4 +1,6 @@ -varying lowp vec4 vColor; +//@version 100 + +INPUT lowp vec4 vColor; void main() { diff --git a/examples/mesh-morph/shaders/mesh-morph.vert b/examples/mesh-morph/shaders/mesh-morph.vert index 766c88c2..222a5fd2 100644 --- a/examples/mesh-morph/shaders/mesh-morph.vert +++ b/examples/mesh-morph/shaders/mesh-morph.vert @@ -1,11 +1,18 @@ -attribute mediump vec2 aInitPos; -attribute mediump vec2 aFinalPos; -attribute mediump vec3 aColor; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump float uDelta; -uniform lowp vec4 uColor; -varying lowp vec4 vColor; +//@version 100 + +INPUT mediump vec2 aInitPos; +INPUT mediump vec2 aFinalPos; +INPUT mediump vec3 aColor; + +OUTPUT lowp vec4 vColor; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM mediump float uDelta; +UNIFORM lowp vec4 uColor; +}; void main() { diff --git a/examples/metaball-explosion/shaders/metaball-refraction.frag b/examples/metaball-explosion/shaders/metaball-refraction.frag index ad67df6d..7c3e1566 100644 --- a/examples/metaball-explosion/shaders/metaball-refraction.frag +++ b/examples/metaball-explosion/shaders/metaball-refraction.frag @@ -1,10 +1,18 @@ +//@version 100 + //Fragment shader code for metaball and background composition with refraction effect precision highp float; -varying vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sEffect; -uniform vec2 uPositionMetaball; +INPUT vec2 vTexCoord; + +UNIFORM sampler2D sTexture; +UNIFORM sampler2D sEffect; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM vec2 uPositionMetaball; +}; + void main() { vec2 zoomCoords; @@ -13,7 +21,7 @@ void main() vec3 color = vec3(1.0, 1.0, 1.0); float ambient = 0.2; - vec4 metaColor = texture2D(sEffect, vTexCoord); + vec4 metaColor = TEXTURE(sEffect, vTexCoord); vec2 adjustedCoords = vTexCoord.xy * vec2(2.0) - vec2(1.0); fakePos = adjustedCoords.xy - vec2(uPositionMetaball.x, -uPositionMetaball.y); @@ -65,7 +73,7 @@ void main() float specularFactor = max(0.0,dot(vertexToEye, lightReflect)); specularFactor = pow(specularFactor, 32.0) * 0.7; - vec4 texColor = texture2D(sTexture, zoomCoords); + vec4 texColor = TEXTURE(sTexture, zoomCoords); gl_FragColor.rgb = texColor.rgb * ambient + color.rgb * texColor.rgb * lightDiffuse + vec3(specularFactor); gl_FragColor.a = 1.0; } diff --git a/examples/metaball-explosion/shaders/metaball.frag b/examples/metaball-explosion/shaders/metaball.frag index 8411a181..095eceb6 100644 --- a/examples/metaball-explosion/shaders/metaball.frag +++ b/examples/metaball-explosion/shaders/metaball.frag @@ -1,12 +1,19 @@ +//@version 100 + // Fragment shader code for metaball precision mediump float; -varying vec2 vTexCoord; -uniform vec2 uPositionMetaball; -uniform vec2 uPositionVar; -uniform vec2 uGravityVector; -uniform float uRadius; -uniform float uRadiusVar; + +INPUT vec2 vTexCoord; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM vec2 uPositionMetaball; +UNIFORM vec2 uPositionVar; +UNIFORM vec2 uGravityVector; +UNIFORM float uRadius; +UNIFORM float uRadiusVar; +}; void main() { diff --git a/examples/metaball-explosion/shaders/metaball.vert b/examples/metaball-explosion/shaders/metaball.vert index 911e77ac..6f6dd4b1 100644 --- a/examples/metaball-explosion/shaders/metaball.vert +++ b/examples/metaball-explosion/shaders/metaball.vert @@ -1,11 +1,18 @@ +//@version 100 + //Vertex shader code for metaball -attribute mediump vec2 aPosition; -attribute mediump vec2 aTexture; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform lowp vec4 uColor; -varying mediump vec2 vTexCoord; +INPUT mediump vec2 aPosition; +INPUT mediump vec2 aTexture; + +OUTPUT mediump vec2 vTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM lowp vec4 uColor; +}; void main() { diff --git a/examples/metaball-refrac/shaders/fragment.frag b/examples/metaball-refrac/shaders/fragment.frag index 1878397b..df97aeea 100644 --- a/examples/metaball-refrac/shaders/fragment.frag +++ b/examples/metaball-refrac/shaders/fragment.frag @@ -1,10 +1,13 @@ +//@version 100 + // Fragment shader code when there's no effect precision mediump float; -varying vec2 vTexCoord; -uniform sampler2D sTexture; + +INPUT vec2 vTexCoord; +UNIFORM sampler2D sTexture; void main() { - gl_FragColor = texture2D(sTexture, vTexCoord); + gl_FragColor = TEXTURE(sTexture, vTexCoord); } diff --git a/examples/metaball-refrac/shaders/metaball-refraction.frag b/examples/metaball-refrac/shaders/metaball-refraction.frag index e84f3ea5..718ffa2f 100644 --- a/examples/metaball-refrac/shaders/metaball-refraction.frag +++ b/examples/metaball-refrac/shaders/metaball-refraction.frag @@ -1,13 +1,15 @@ +//@version 100 // Fragment shader code for metaball and background composition with refraction effect precision mediump float; -varying vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sEffect; +INPUT vec2 vTexCoord; + +UNIFORM sampler2D sTexture; +UNIFORM sampler2D sEffect; void main() { - vec4 metaColor = texture2D(sEffect, vTexCoord); + vec4 metaColor = TEXTURE(sEffect, vTexCoord); vec2 zoomCoords; float bright = 1.0; if (metaColor.r > 0.85) @@ -25,5 +27,5 @@ void main() zoomCoords = vTexCoord; } - gl_FragColor = texture2D(sTexture, zoomCoords) * bright; + gl_FragColor = TEXTURE(sTexture, zoomCoords) * bright; } diff --git a/examples/metaball-refrac/shaders/metaball.frag b/examples/metaball-refrac/shaders/metaball.frag index ed877673..2fdc2697 100644 --- a/examples/metaball-refrac/shaders/metaball.frag +++ b/examples/metaball-refrac/shaders/metaball.frag @@ -1,13 +1,19 @@ +//@version 100 + // Fragment shader for metaballs precision mediump float; -varying vec2 vTexCoord; -uniform vec2 uPositionMetaball; -uniform vec2 uPositionVar; -uniform vec2 uGravityVector; -uniform float uRadius; -uniform float uRadiusVar; -uniform float uAspect; +INPUT vec2 vTexCoord; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM vec2 uPositionMetaball; +UNIFORM vec2 uPositionVar; +UNIFORM vec2 uGravityVector; +UNIFORM float uRadius; +UNIFORM float uRadiusVar; +UNIFORM float uAspect; +}; void main() { diff --git a/examples/metaball-refrac/shaders/metaball.vert b/examples/metaball-refrac/shaders/metaball.vert index 370d8702..fd002d96 100644 --- a/examples/metaball-refrac/shaders/metaball.vert +++ b/examples/metaball-refrac/shaders/metaball.vert @@ -1,11 +1,16 @@ +//@version 100 // Vertex shader for metaballs -attribute mediump vec2 aPosition; -attribute mediump vec2 aTexture; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform lowp vec4 uColor; -varying mediump vec2 vTexCoord; +INPUT mediump vec2 aPosition; +INPUT mediump vec2 aTexture; +OUTPUT mediump vec2 vTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM lowp vec4 uColor; +}; void main() { diff --git a/examples/particles/shaders/particle-view-simple.frag b/examples/particles/shaders/particle-view-simple.frag index 942a401c..457c31b6 100644 --- a/examples/particles/shaders/particle-view-simple.frag +++ b/examples/particles/shaders/particle-view-simple.frag @@ -1,11 +1,15 @@ -#version 300 es +//@version 100 + // Shader for an unlit, unfogged, textured mesh. precision mediump float; -uniform vec4 uColor; -out vec4 oFragColor; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM vec4 uColor; +}; void main() { - oFragColor = uColor; + gl_FragColor = uColor; } diff --git a/examples/particles/shaders/particle-view-simple.vert b/examples/particles/shaders/particle-view-simple.vert index 59238621..dc472ba1 100644 --- a/examples/particles/shaders/particle-view-simple.vert +++ b/examples/particles/shaders/particle-view-simple.vert @@ -1,12 +1,18 @@ -#version 300 es +//@version 100 + // Shader for simple textured geometry. precision mediump float; -uniform mat4 uMvpMatrix;//by DALi -uniform vec3 uSize; // by DALi -in vec3 aPosition; + +UNIFORM_BLOCK VertexBlock +{ + UNIFORM mat4 uMvpMatrix; //by DALi + UNIFORM vec3 uSize; // by DALi +}; + +INPUT vec3 aPosition; void main() { - gl_Position = uMvpMatrix * vec4(aPosition * uSize, 1.f); + gl_Position = uMvpMatrix * vec4(aPosition * uSize, 1.0); } diff --git a/examples/particles/shaders/particle-view.frag b/examples/particles/shaders/particle-view.frag index 293487c3..c1c97ccc 100644 --- a/examples/particles/shaders/particle-view.frag +++ b/examples/particles/shaders/particle-view.frag @@ -1,16 +1,21 @@ -#version 300 es +//@version 100 + // Fragment shader for particles, which simulates depth of field using // a combination of procedural texturing, alpha testing and alpha blending. precision lowp float; -uniform float uAlphaTestRefValue; -uniform vec2 uFadeRange; // near, far -in vec2 vUvUnit; -flat in float vDepth; -flat in float vFocalDistance; -flat in float vOpacity; -flat in vec3 vColor; -out vec4 oFragColor; + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM float uAlphaTestRefValue; +UNIFORM vec2 uFadeRange; // near, far +}; + +INPUT vec2 vUvUnit; +INPUT flat float vDepth; +INPUT flat float vFocalDistance; +INPUT flat float vOpacity; +INPUT flat vec3 vColor; const float REF_VALUE_THRESHOLD = 1. / 64.; @@ -35,5 +40,5 @@ void main() // Fade particles out as they get close to the near and far clipping planes alpha *= smoothstep(.0f, uFadeRange.x, vDepth) * smoothstep(1.f, uFadeRange.y, vDepth); - oFragColor = vec4(vColor, alpha); + gl_FragColor = vec4(vColor, alpha); } diff --git a/examples/particles/shaders/particle-view.vert b/examples/particles/shaders/particle-view.vert index 33cc108a..d1b301d3 100644 --- a/examples/particles/shaders/particle-view.vert +++ b/examples/particles/shaders/particle-view.vert @@ -1,22 +1,29 @@ -#version 300 es +//@version 100 + // Shader for billboarded particles, where the vertices of the particles // are supplied as vec3 position (particle position) + vec2 sub-position. precision lowp float; -uniform mat4 uModelView; // DALi -uniform mat4 uProjection; // DALi -uniform vec3 uSize; // DALi -uniform vec4 uColor; // DALi - -uniform vec3 uSecondaryColor; -uniform vec2 uDepthRange; // x is zNear, y is 1.f / (zFar - zNear) -uniform float uTwinkleFrequency; -uniform float uTwinkleSizeScale; -uniform float uTwinkleOpacityWeight; -uniform float uTime; -uniform float uFocalLength; -uniform float uAperture; -uniform float uPopulation; +UNIFORM_BLOCK Vanilla +{ +UNIFORM mat4 uModelView; // DALi +UNIFORM mat4 uProjection; // DALi +UNIFORM vec3 uSize; // DALi +UNIFORM vec4 uColor; // DALi +}; + +UNIFORM_BLOCK Billboard +{ +UNIFORM vec3 uSecondaryColor; +UNIFORM vec2 uDepthRange; // x is zNear, y is 1.f / (zFar - zNear) +UNIFORM float uTwinkleFrequency; +UNIFORM float uTwinkleSizeScale; +UNIFORM float uTwinkleOpacityWeight; +UNIFORM float uTime; +UNIFORM float uFocalLength; +UNIFORM float uAperture; +UNIFORM float uPopulation; +}; struct Scatter { @@ -26,22 +33,29 @@ struct Scatter }; const int SCATTER_VARS = 6; // Must match ParticleView::mScatterProps' size. -uniform Scatter uScatter[SCATTER_VARS]; + +UNIFORM_BLOCK ScatterBlock +{ +UNIFORM Scatter uScatter[SCATTER_VARS]; +}; const int POPULATION_GRANULARITY = 128; -uniform float uOrderLookUp[POPULATION_GRANULARITY]; - -in vec3 aPosition; -in float aSeed; -in vec4 aPath; -in vec2 aSubPosition; -in float aSize; - -flat out float vDepth; -flat out float vFocalDistance; -out vec2 vUvUnit; -flat out float vOpacity; -flat out vec3 vColor; // ignore alpha +UNIFORM_BLOCK OrderLookup +{ +UNIFORM float uOrderLookUp[POPULATION_GRANULARITY]; +}; + +INPUT vec3 aPosition; +INPUT float aSeed; +INPUT vec4 aPath; +INPUT vec2 aSubPosition; +INPUT float aSize; + +OUTPUT flat float vDepth; +OUTPUT flat float vFocalDistance; +OUTPUT vec2 vUvUnit; +OUTPUT flat float vOpacity; +OUTPUT flat vec3 vColor; // ignore alpha float bezier(vec3 control, float alpha) { diff --git a/examples/perf-scroll/shaders/perf-scroll.frag b/examples/perf-scroll/shaders/perf-scroll.frag index f9eba48f..a3f24dd3 100644 --- a/examples/perf-scroll/shaders/perf-scroll.frag +++ b/examples/perf-scroll/shaders/perf-scroll.frag @@ -1,8 +1,14 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +} +UNIFORM sampler2D sTexture; + +INPUT mediump vec2 vTexCoord; void main() { - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor; + gl_FragColor = TEXTURE( sTexture, vTexCoord ) * uColor; } diff --git a/examples/perf-scroll/shaders/perf-scroll.vert b/examples/perf-scroll/shaders/perf-scroll.vert index 3cb2121b..643d96c8 100644 --- a/examples/perf-scroll/shaders/perf-scroll.vert +++ b/examples/perf-scroll/shaders/perf-scroll.vert @@ -1,8 +1,14 @@ -attribute mediump vec2 aPosition; -attribute mediump vec2 aTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -varying mediump vec2 vTexCoord; +//@version 100 + +INPUT mediump vec2 aPosition; +INPUT mediump vec2 aTexCoord; +OUTPUT mediump vec2 vTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +}; void main() { diff --git a/examples/point-mesh/shaders/point-mesh.frag b/examples/point-mesh/shaders/point-mesh.frag index 51be2396..08eb6021 100644 --- a/examples/point-mesh/shaders/point-mesh.frag +++ b/examples/point-mesh/shaders/point-mesh.frag @@ -1,13 +1,20 @@ -varying mediump vec3 vVertexColor; -varying mediump float vHue; -uniform lowp vec4 uColor; -uniform sampler2D sTexture1; -uniform sampler2D sTexture2; -uniform lowp vec4 uFadeColor; +//@version 100 + +INPUT mediump vec3 vVertexColor; +INPUT mediump float vHue; + +UNIFORM sampler2D sTexture1; +UNIFORM sampler2D sTexture2; + +UNIFORM_BLOCK FragUniforms +{ +UNIFORM lowp vec4 uColor; +UNIFORM lowp vec4 uFadeColor; +}; void main() { - mediump vec4 texCol1 = texture2D(sTexture1, gl_PointCoord); - mediump vec4 texCol2 = texture2D(sTexture2, gl_PointCoord); + mediump vec4 texCol1 = TEXTURE(sTexture1, gl_PointCoord); + mediump vec4 texCol2 = TEXTURE(sTexture2, gl_PointCoord); gl_FragColor = vec4(vVertexColor, 1.0) * ((texCol1 * vHue) + (texCol2 * (1.0 - vHue))); } diff --git a/examples/point-mesh/shaders/point-mesh.vert b/examples/point-mesh/shaders/point-mesh.vert index 6afbdb4a..4c129ee8 100644 --- a/examples/point-mesh/shaders/point-mesh.vert +++ b/examples/point-mesh/shaders/point-mesh.vert @@ -1,12 +1,21 @@ -attribute mediump vec2 aPosition; -attribute highp float aHue; -varying mediump vec2 vTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump float uPointSize; -uniform lowp vec4 uFadeColor; -varying mediump vec3 vVertexColor; -varying mediump float vHue; +//@version 100 + +INPUT mediump vec2 aPosition; +INPUT highp float aHue; +OUTPUT mediump vec2 vTexCoord; +OUTPUT mediump vec3 vVertexColor; +OUTPUT mediump float vHue; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +}; + +UNIFORM_BLOCK Custom +{ +UNIFORM mediump float uPointSize; +}; vec3 hsv2rgb(vec3 c) { diff --git a/examples/reflection-demo/reflection-example.cpp b/examples/reflection-demo/reflection-example.cpp index 77318180..68b5691d 100644 --- a/examples/reflection-demo/reflection-example.cpp +++ b/examples/reflection-demo/reflection-example.cpp @@ -78,7 +78,7 @@ Shader CreateShader(const std::string& vsh, const std::string& fsh) std::vector<char> fshShaderSource; // VSH - if(vsh[0] == '/') + if(vsh[0] == '/' && vsh[1] != '/') { std::string vshPath(DEMO_GAME_DIR); vshPath += '/'; @@ -91,7 +91,7 @@ Shader CreateShader(const std::string& vsh, const std::string& fsh) } // FSH - if(fsh[0] == '/') + if(fsh[0] == '/' && fsh[1] != '/') { std::string fshPath(DEMO_GAME_DIR); fshPath += '/'; diff --git a/examples/reflection-demo/shaders/reflection-plasma.frag b/examples/reflection-demo/shaders/reflection-plasma.frag index 47b0055c..15bf7aac 100644 --- a/examples/reflection-demo/shaders/reflection-plasma.frag +++ b/examples/reflection-demo/shaders/reflection-plasma.frag @@ -1,13 +1,20 @@ +//@version 100 + precision mediump float; -uniform sampler2D sTexture; -uniform float uTime; -uniform float uKFactor; -uniform mediump vec3 eyePos; -uniform mediump vec3 lightDir; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; -varying mediump vec2 vTexCoord; +UNIFORM sampler2D sTexture; + +UNIFORM_BLOCK Custom +{ +UNIFORM float uTime; +UNIFORM float uKFactor; +UNIFORM mediump vec3 eyePos; +UNIFORM mediump vec3 lightDir; +}; + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vPosition; +INPUT mediump vec2 vTexCoord; void main() { @@ -26,5 +33,5 @@ void main() v += sin(sqrt(c.x*c.x+c.y*c.y+1.0)+uTime); v = v/2.0; mediump vec3 col = vec3(1, sin(PI*v), cos(PI*v)); - gl_FragColor = (texture2D(sTexture, vTexCoord)) * (((col.r+col.g+col.b)/3.0)+1.0+intensity); + gl_FragColor = (TEXTURE(sTexture, vTexCoord)) * (((col.r+col.g+col.b)/3.0)+1.0+intensity); } diff --git a/examples/reflection-demo/shaders/reflection-simple.frag b/examples/reflection-demo/shaders/reflection-simple.frag index 1c813ae1..4c59193f 100644 --- a/examples/reflection-demo/shaders/reflection-simple.frag +++ b/examples/reflection-demo/shaders/reflection-simple.frag @@ -1,10 +1,17 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vPosition; +INPUT mediump vec2 vTexCoord; void main() { - gl_FragColor = texture2D(sTexture, vTexCoord) * 2.0; + gl_FragColor = TEXTURE(sTexture, vTexCoord) * 2.0; } diff --git a/examples/reflection-demo/shaders/reflection-tex.frag b/examples/reflection-demo/shaders/reflection-tex.frag index 8f792cc3..0d17642c 100644 --- a/examples/reflection-demo/shaders/reflection-tex.frag +++ b/examples/reflection-demo/shaders/reflection-tex.frag @@ -1,12 +1,19 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture0; -uniform sampler2D sTexture1; -uniform mediump vec3 eyePos; -uniform mediump vec3 lightDir; -uniform mediump vec2 uScreenSize; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM sampler2D sTexture0; +UNIFORM sampler2D sTexture1; + +UNIFORM_BLOCK Custom +{ +UNIFORM lowp vec4 uColor; +UNIFORM mediump vec3 eyePos; +UNIFORM mediump vec3 lightDir; +UNIFORM mediump vec2 uScreenSize; +}; + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vPosition; +INPUT mediump vec2 vTexCoord; mediump float rand(mediump vec2 co) { @@ -22,6 +29,6 @@ void main() mediump float factor = gl_FragCoord.y / uScreenSize.y; mediump float intensity = max(dot(n,l), 0.0); mediump vec2 uv = tx; - gl_FragColor = ((texture2D(sTexture0, vTexCoord) * factor ) + - (texture2D(sTexture1, uv))) * intensity; + gl_FragColor = ((TEXTURE(sTexture0, vTexCoord) * factor ) + + (TEXTURE(sTexture1, uv))) * intensity; } diff --git a/examples/reflection-demo/shaders/reflection-textured.frag b/examples/reflection-demo/shaders/reflection-textured.frag index 8eb60617..1c3962e8 100644 --- a/examples/reflection-demo/shaders/reflection-textured.frag +++ b/examples/reflection-demo/shaders/reflection-textured.frag @@ -1,13 +1,18 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -uniform mediump vec2 uScreenSize; +//@version 100 -uniform mediump vec3 eyePos; -uniform mediump vec3 lightDir; +UNIFORM sampler2D sTexture; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; -varying mediump vec2 vTexCoord; +UNIFORM_BLOCK Custom +{ +UNIFORM lowp vec4 uColor; +UNIFORM mediump vec2 uScreenSize; +UNIFORM mediump vec3 eyePos; +UNIFORM mediump vec3 lightDir; +}; + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vPosition; +INPUT mediump vec2 vTexCoord; void main() { @@ -15,5 +20,5 @@ void main() mediump vec3 l = normalize( lightDir ); mediump vec3 e = normalize( eyePos ); mediump float intensity = max(dot(n,l), 0.0); - gl_FragColor = texture2D(sTexture, vTexCoord) * intensity; + gl_FragColor = TEXTURE(sTexture, vTexCoord) * intensity; } diff --git a/examples/reflection-demo/shaders/reflection.frag b/examples/reflection-demo/shaders/reflection.frag index 55060a84..44a0902e 100644 --- a/examples/reflection-demo/shaders/reflection.frag +++ b/examples/reflection-demo/shaders/reflection.frag @@ -1,10 +1,17 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vPosition; +INPUT mediump vec2 vTexCoord; void main() { - gl_FragColor = texture2D(sTexture, vTexCoord) * 50.0; + gl_FragColor = TEXTURE(sTexture, vTexCoord) * 50.0; } diff --git a/examples/reflection-demo/shaders/reflection.vert b/examples/reflection-demo/shaders/reflection.vert index 872da7d4..67136505 100644 --- a/examples/reflection-demo/shaders/reflection.vert +++ b/examples/reflection-demo/shaders/reflection.vert @@ -1,13 +1,19 @@ -attribute mediump vec3 aPosition; -attribute mediump vec3 aNormal; -attribute mediump vec2 aTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump mat3 uNormalMatrix; -uniform mediump vec3 uSize; +//@version 100 -varying mediump vec2 vTexCoord; -varying mediump vec3 vNormal; -varying mediump vec3 vPosition; +INPUT mediump vec3 aPosition; +INPUT mediump vec3 aNormal; +INPUT mediump vec2 aTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump mat3 uNormalMatrix; +UNIFORM mediump vec3 uSize; +}; + +OUTPUT mediump vec2 vTexCoord; +OUTPUT mediump vec3 vNormal; +OUTPUT mediump vec3 vPosition; void main() { diff --git a/examples/refraction-effect/shaders/refraction-effect-flat.frag b/examples/refraction-effect/shaders/refraction-effect-flat.frag index f9eba48f..98aaa08d 100644 --- a/examples/refraction-effect/shaders/refraction-effect-flat.frag +++ b/examples/refraction-effect/shaders/refraction-effect-flat.frag @@ -1,8 +1,15 @@ -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM_BLOCK VanillaFrag +{ +UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; + +INPUT mediump vec2 vTexCoord; void main() { - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor; + gl_FragColor = TEXTURE( sTexture, vTexCoord ) * uColor; } diff --git a/examples/refraction-effect/shaders/refraction-effect-flat.vert b/examples/refraction-effect/shaders/refraction-effect-flat.vert index fc35d09d..148f9417 100644 --- a/examples/refraction-effect/shaders/refraction-effect-flat.vert +++ b/examples/refraction-effect/shaders/refraction-effect-flat.vert @@ -1,10 +1,16 @@ +//@version 100 + // The shader source is used when the MeshActor is not touched -attribute mediump vec3 aPosition; -attribute mediump vec3 aNormal; -attribute highp vec2 aTexCoord; -uniform mediump mat4 uMvpMatrix; -varying mediump vec2 vTexCoord; +INPUT mediump vec3 aPosition; +INPUT mediump vec3 aNormal; +INPUT highp vec2 aTexCoord; +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +}; + +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/refraction-effect/shaders/refraction-effect-refraction.frag b/examples/refraction-effect/shaders/refraction-effect-refraction.frag index 8fcf92d1..b3cf5a9d 100644 --- a/examples/refraction-effect/shaders/refraction-effect-refraction.frag +++ b/examples/refraction-effect/shaders/refraction-effect-refraction.frag @@ -1,15 +1,22 @@ +//@version 100 + precision mediump float; -uniform mediump float uEffectStrength; -uniform mediump vec3 uLightPosition; -uniform mediump vec2 uLightXYOffset; -uniform mediump vec2 uLightSpinOffset; -uniform mediump float uLightIntensity; -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec4 vVertex; -varying mediump vec3 vNormal; -varying mediump vec2 vTexCoord; -varying mediump vec2 vTextureOffset; +UNIFORM_BLOCK Custom +{ +UNIFORM mediump float uEffectStrength; +UNIFORM mediump vec3 uLightPosition; +UNIFORM mediump vec2 uLightXYOffset; +UNIFORM mediump vec2 uLightSpinOffset; +UNIFORM mediump float uLightIntensity; +UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; + +INPUT mediump vec4 vVertex; +INPUT mediump vec3 vNormal; +INPUT mediump vec2 vTexCoord; +INPUT mediump vec2 vTextureOffset; vec3 rgb2hsl(vec3 rgb) { @@ -49,7 +56,7 @@ void main() spotEffect = spotEffect * uEffectStrength; mediump float lightDiffuse = ( ( dot( vecToLight, normal )-0.75 ) *uLightIntensity ) * spotEffect; - lowp vec4 color = texture2D( sTexture, vTexCoord + vTextureOffset * spotEffect ); + lowp vec4 color = TEXTURE( sTexture, vTexCoord + vTextureOffset * spotEffect ); vec3 lightedColor = hsl2rgb( rgb2hsl(color.rgb) + vec3(0.0,0.0,lightDiffuse) ); gl_FragColor = vec4( lightedColor, color.a ) * uColor; diff --git a/examples/refraction-effect/shaders/refraction-effect-refraction.vert b/examples/refraction-effect/shaders/refraction-effect-refraction.vert index 00611230..52b5368f 100644 --- a/examples/refraction-effect/shaders/refraction-effect-refraction.vert +++ b/examples/refraction-effect/shaders/refraction-effect-refraction.vert @@ -1,11 +1,18 @@ -attribute mediump vec3 aPosition; -attribute mediump vec3 aNormal; -attribute highp vec2 aTexCoord; -uniform mediump mat4 uMvpMatrix; -varying mediump vec4 vVertex; -varying mediump vec3 vNormal; -varying mediump vec2 vTexCoord; -varying mediump vec2 vTextureOffset; +//@version 100 + +INPUT mediump vec3 aPosition; +INPUT mediump vec3 aNormal; +INPUT highp vec2 aTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +}; + +OUTPUT mediump vec4 vVertex; +OUTPUT mediump vec3 vNormal; +OUTPUT mediump vec2 vTexCoord; +OUTPUT mediump vec2 vTextureOffset; void main() { diff --git a/examples/renderer-stencil/shaders/render-stencil-textured.frag b/examples/renderer-stencil/shaders/render-stencil-textured.frag index 27c63e5c..b6b7d36e 100644 --- a/examples/renderer-stencil/shaders/render-stencil-textured.frag +++ b/examples/renderer-stencil/shaders/render-stencil-textured.frag @@ -1,9 +1,15 @@ -varying mediump vec2 vTexCoord; -varying mediump vec3 vIllumination; -uniform lowp vec4 uColor; -uniform sampler2D sTexture; +//@version 100 + +INPUT mediump vec2 vTexCoord; +INPUT mediump vec3 vIllumination; +UNIFORM_BLOCK Color +{ + UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; void main() { - gl_FragColor = vec4( texture2D( sTexture, vTexCoord ).rgb * vIllumination.rgb * uColor.rgb, uColor.a ); -} + gl_FragColor = vec4( TEXTURE( sTexture, vTexCoord ).rgb * vIllumination.rgb * uColor.rgb, uColor.a ); +}
\ No newline at end of file diff --git a/examples/renderer-stencil/shaders/render-stencil-textured.vert b/examples/renderer-stencil/shaders/render-stencil-textured.vert index 7dd59185..629da946 100644 --- a/examples/renderer-stencil/shaders/render-stencil-textured.vert +++ b/examples/renderer-stencil/shaders/render-stencil-textured.vert @@ -1,18 +1,24 @@ +//@version 100 + // Shader for basic, per-vertex lighting with texture (vertex): -attribute mediump vec3 aPosition; -attribute highp vec3 aNormal; -attribute highp vec2 aTexCoord; - -varying mediump vec2 vTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump vec3 uObjectDimensions; -varying mediump vec3 vIllumination; -uniform mediump mat4 uModelView; -uniform mediump mat4 uViewMatrix; -uniform mediump mat3 uNormalMatrix; -uniform mediump vec3 uLightPosition; +INPUT mediump vec3 aPosition; +INPUT highp vec3 aNormal; +INPUT highp vec2 aTexCoord; + +OUTPUT mediump vec3 vIllumination; +OUTPUT mediump vec2 vTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM mediump vec3 uObjectDimensions; +UNIFORM mediump mat4 uModelView; +UNIFORM mediump mat4 uViewMatrix; +UNIFORM mediump mat3 uNormalMatrix; +UNIFORM mediump vec3 uLightPosition; +}; void main() { diff --git a/examples/renderer-stencil/shaders/render-stencil.frag b/examples/renderer-stencil/shaders/render-stencil.frag index 12dd2a91..36b924a2 100644 --- a/examples/renderer-stencil/shaders/render-stencil.frag +++ b/examples/renderer-stencil/shaders/render-stencil.frag @@ -1,7 +1,14 @@ -varying mediump vec2 vTexCoord; -varying mediump vec3 vIllumination; -uniform lowp vec4 uColor; -uniform sampler2D sTexture; +//@version 100 + +INPUT mediump vec2 vTexCoord; +INPUT mediump vec3 vIllumination; + +UNIFORM_BLOCK color +{ + UNIFORM lowp vec4 uColor; +}; + +UNIFORM sampler2D sTexture; void main() { diff --git a/examples/renderer-stencil/shaders/render-stencil.vert b/examples/renderer-stencil/shaders/render-stencil.vert index 06270a9c..a48673a2 100644 --- a/examples/renderer-stencil/shaders/render-stencil.vert +++ b/examples/renderer-stencil/shaders/render-stencil.vert @@ -1,18 +1,24 @@ +//@version 100 + // Shader for basic, per-vertex lighting (vertex): -attribute mediump vec3 aPosition; -attribute highp vec3 aNormal; -attribute highp vec2 aTexCoord; - -varying mediump vec2 vTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump vec3 uObjectDimensions; -varying mediump vec3 vIllumination; -uniform mediump mat4 uModelView; -uniform mediump mat4 uViewMatrix; -uniform mediump mat3 uNormalMatrix; -uniform mediump vec3 uLightPosition; +INPUT mediump vec3 aPosition; +INPUT highp vec3 aNormal; +INPUT highp vec2 aTexCoord; + +OUTPUT mediump vec2 vTexCoord; +OUTPUT mediump vec3 vIllumination; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +UNIFORM mediump vec3 uObjectDimensions; +UNIFORM mediump mat4 uModelView; +UNIFORM mediump mat4 uViewMatrix; +UNIFORM mediump mat3 uNormalMatrix; +UNIFORM mediump vec3 uLightPosition; +}; void main() { diff --git a/examples/rendering-basic-light/shaders/rendering-basic-light.frag b/examples/rendering-basic-light/shaders/rendering-basic-light.frag index 6f561531..ce202e32 100644 --- a/examples/rendering-basic-light/shaders/rendering-basic-light.frag +++ b/examples/rendering-basic-light/shaders/rendering-basic-light.frag @@ -1,6 +1,7 @@ -varying mediump vec3 vNormal; -varying mediump vec3 vFragPos; -uniform mediump vec3 viewPos; // custom uniform +//@version 100 + +INPUT mediump vec3 vNormal; +INPUT mediump vec3 vFragPos; struct Material { @@ -16,8 +17,12 @@ struct Light mediump vec3 color; }; -uniform Material material; // custom uniform -uniform Light light; // custom uniform +UNIFORM_BLOCK CustomFrag +{ +UNIFORM mediump vec3 viewPos; // custom uniform +UNIFORM Material material; // custom uniform +UNIFORM Light light; // custom uniform +}; void main() { diff --git a/examples/rendering-basic-light/shaders/rendering-basic-light.vert b/examples/rendering-basic-light/shaders/rendering-basic-light.vert index bc5c85af..d39ec461 100644 --- a/examples/rendering-basic-light/shaders/rendering-basic-light.vert +++ b/examples/rendering-basic-light/shaders/rendering-basic-light.vert @@ -1,12 +1,18 @@ -attribute mediump vec3 aPosition; // DALi shader builtin -attribute mediump vec3 aNormal; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin -uniform mediump mat4 uModelView; // DALi shader builtin -uniform mediump mat3 uNormalMatrix; // DALi shader builtin +//@version 100 -varying mediump vec3 vNormal; -varying mediump vec3 vFragPos; +INPUT mediump vec3 aPosition; // DALi shader builtin +INPUT mediump vec3 aNormal; // DALi shader builtin + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +UNIFORM mediump mat4 uModelView; // DALi shader builtin +UNIFORM mediump mat3 uNormalMatrix; // DALi shader builtin +}; + +OUTPUT mediump vec3 vNormal; +OUTPUT mediump vec3 vFragPos; void main() { diff --git a/examples/rendering-cube/shaders/rendering-cube.frag b/examples/rendering-cube/shaders/rendering-cube.frag index 1f8954ad..67a08ab3 100644 --- a/examples/rendering-cube/shaders/rendering-cube.frag +++ b/examples/rendering-cube/shaders/rendering-cube.frag @@ -1,4 +1,6 @@ -varying mediump vec4 vColor; +//@version 100 + +INPUT mediump vec4 vColor; void main() { diff --git a/examples/rendering-cube/shaders/rendering-cube.vert b/examples/rendering-cube/shaders/rendering-cube.vert index d4a0b5c8..5c793742 100644 --- a/examples/rendering-cube/shaders/rendering-cube.vert +++ b/examples/rendering-cube/shaders/rendering-cube.vert @@ -1,9 +1,15 @@ -attribute mediump vec3 aPosition; // DALi shader builtin -attribute mediump vec3 aColor; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +//@version 100 -varying mediump vec4 vColor; +INPUT mediump vec3 aPosition; // DALi shader builtin +INPUT mediump vec3 aColor; // DALi shader builtin + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; + +OUTPUT mediump vec4 vColor; void main() { diff --git a/examples/rendering-line/shaders/rendering-line.frag b/examples/rendering-line/shaders/rendering-line.frag index b8d9d3ab..1456e4b1 100644 --- a/examples/rendering-line/shaders/rendering-line.frag +++ b/examples/rendering-line/shaders/rendering-line.frag @@ -1,4 +1,9 @@ -uniform mediump vec4 uColor; +//@version 100 + +UNIFORM_BLOCK Custom +{ +UNIFORM mediump vec4 uColor; +}; void main() { diff --git a/examples/rendering-line/shaders/rendering-line.vert b/examples/rendering-line/shaders/rendering-line.vert index 53f4a4f7..f70dabeb 100644 --- a/examples/rendering-line/shaders/rendering-line.vert +++ b/examples/rendering-line/shaders/rendering-line.vert @@ -1,6 +1,12 @@ -attribute mediump vec2 aPosition; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +//@version 100 + +INPUT mediump vec2 aPosition; // DALi shader builtin + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; void main() { diff --git a/examples/rendering-radial-progress/shaders/radial-progress-basic.frag b/examples/rendering-radial-progress/shaders/radial-progress-basic.frag index d8d62266..50cfdae3 100644 --- a/examples/rendering-radial-progress/shaders/radial-progress-basic.frag +++ b/examples/rendering-radial-progress/shaders/radial-progress-basic.frag @@ -1,3 +1,5 @@ +//@version 100 + // Fragment shader for polygon void main() diff --git a/examples/rendering-radial-progress/shaders/radial-progress-basic.vert b/examples/rendering-radial-progress/shaders/radial-progress-basic.vert index 9700c416..9c591231 100644 --- a/examples/rendering-radial-progress/shaders/radial-progress-basic.vert +++ b/examples/rendering-radial-progress/shaders/radial-progress-basic.vert @@ -1,11 +1,17 @@ +//@version 100 + // Vertex shader for polygon -attribute mediump vec3 aPosition; -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin -uniform mediump float uProgress; +INPUT mediump vec3 aPosition; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +UNIFORM mediump float uProgress; +}; -varying mediump vec2 vTexCoord; +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/rendering-radial-progress/shaders/radial-progress-textured.frag b/examples/rendering-radial-progress/shaders/radial-progress-textured.frag index 4017c033..2f9a483d 100644 --- a/examples/rendering-radial-progress/shaders/radial-progress-textured.frag +++ b/examples/rendering-radial-progress/shaders/radial-progress-textured.frag @@ -1,10 +1,12 @@ +//@version 100 + // Fragment shaderfor textured quad -uniform sampler2D uTexture; -varying mediump vec2 vTexCoord; +UNIFORM sampler2D uTexture; +INPUT mediump vec2 vTexCoord; void main() { - mediump vec4 texColor = texture2D( uTexture, vTexCoord ); + mediump vec4 texColor = TEXTURE( uTexture, vTexCoord ); gl_FragColor = texColor; } diff --git a/examples/rendering-radial-progress/shaders/radial-progress-textured.vert b/examples/rendering-radial-progress/shaders/radial-progress-textured.vert index 78aca625..deb23706 100644 --- a/examples/rendering-radial-progress/shaders/radial-progress-textured.vert +++ b/examples/rendering-radial-progress/shaders/radial-progress-textured.vert @@ -1,10 +1,15 @@ +//@version 100 // Vertex shader for textured quad -attribute mediump vec2 aPosition; -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +INPUT mediump vec2 aPosition; -varying mediump vec2 vTexCoord; +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; + +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/rendering-skybox/shaders/rendering-skybox-cube.frag b/examples/rendering-skybox/shaders/rendering-skybox-cube.frag index b8a29f58..93d84519 100644 --- a/examples/rendering-skybox/shaders/rendering-skybox-cube.frag +++ b/examples/rendering-skybox/shaders/rendering-skybox-cube.frag @@ -1,11 +1,13 @@ +//@version 100 + // Fragment shader for a textured cube -uniform sampler2D uTexture; +UNIFORM sampler2D uTexture; -varying mediump vec2 vTexCoord; +INPUT mediump vec2 vTexCoord; void main() { - mediump vec4 texColor = texture2D( uTexture, vTexCoord ); + mediump vec4 texColor = TEXTURE( uTexture, vTexCoord ); gl_FragColor = texColor; } diff --git a/examples/rendering-skybox/shaders/rendering-skybox-cube.vert b/examples/rendering-skybox/shaders/rendering-skybox-cube.vert index 621f98de..3e6bc48a 100644 --- a/examples/rendering-skybox/shaders/rendering-skybox-cube.vert +++ b/examples/rendering-skybox/shaders/rendering-skybox-cube.vert @@ -1,11 +1,16 @@ +//@version 100 // Vertex shader for a textured cube -attribute mediump vec3 aPosition; // DALi shader builtin -attribute mediump vec2 aTexCoord; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +INPUT mediump vec3 aPosition; // DALi shader builtin +INPUT mediump vec2 aTexCoord; // DALi shader builtin -varying mediump vec2 vTexCoord; +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; + +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/rendering-skybox/shaders/rendering-skybox-equirectangular.frag b/examples/rendering-skybox/shaders/rendering-skybox-equirectangular.frag index e38d7e86..4bc66fb3 100644 --- a/examples/rendering-skybox/shaders/rendering-skybox-equirectangular.frag +++ b/examples/rendering-skybox/shaders/rendering-skybox-equirectangular.frag @@ -1,9 +1,11 @@ +//@version 100 + // Fragment shader for a skybox in equirectangular projection precision mediump float; -uniform sampler2D uSkyBoxEquirectangularTexture; +UNIFORM sampler2D uSkyBoxEquirectangularTexture; -varying vec3 vTexCoord; +INPUT vec3 vTexCoord; // Take the sample direction as interpolated from the cube's local position, // and use this direction vector and the spherical to cartesian coordinate @@ -30,6 +32,6 @@ void main() // Flip the texture UVs vertically vec2 uvFlippped = vec2(uv.x, 1.0 - uv.y); - vec4 texColor = texture2D( uSkyBoxEquirectangularTexture, uvFlippped ); + vec4 texColor = TEXTURE( uSkyBoxEquirectangularTexture, uvFlippped ); gl_FragColor = texColor; } diff --git a/examples/rendering-skybox/shaders/rendering-skybox.frag b/examples/rendering-skybox/shaders/rendering-skybox.frag index c7556457..7a15616b 100644 --- a/examples/rendering-skybox/shaders/rendering-skybox.frag +++ b/examples/rendering-skybox/shaders/rendering-skybox.frag @@ -1,11 +1,13 @@ +//@version 100 + // Fragment shader for a skybox -uniform samplerCube uSkyBoxTexture; +UNIFORM samplerCube uSkyBoxTexture; -varying mediump vec3 vTexCoord; +INPUT mediump vec3 vTexCoord; void main() { - mediump vec4 texColor = textureCube( uSkyBoxTexture, vTexCoord ); + mediump vec4 texColor = TEXTURE( uSkyBoxTexture, vTexCoord ); gl_FragColor = texColor; } diff --git a/examples/rendering-skybox/shaders/rendering-skybox.vert b/examples/rendering-skybox/shaders/rendering-skybox.vert index c2ce43a9..811357f6 100644 --- a/examples/rendering-skybox/shaders/rendering-skybox.vert +++ b/examples/rendering-skybox/shaders/rendering-skybox.vert @@ -1,9 +1,16 @@ +//@version 100 + // Vertex shader for a skybox -attribute mediump vec3 aPosition; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin +INPUT mediump vec3 aPosition; // DALi shader builtin + + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +}; -varying mediump vec3 vTexCoord; +OUTPUT mediump vec3 vTexCoord; void main() { diff --git a/examples/rendering-textured-cube/shaders/rendering-textured-cube.frag b/examples/rendering-textured-cube/shaders/rendering-textured-cube.frag index 43fb27f4..96e0887e 100644 --- a/examples/rendering-textured-cube/shaders/rendering-textured-cube.frag +++ b/examples/rendering-textured-cube/shaders/rendering-textured-cube.frag @@ -1,8 +1,10 @@ -uniform sampler2D uTexture; -varying mediump vec2 vTexCoord; +//@version 100 + +UNIFORM sampler2D uTexture; +INPUT mediump vec2 vTexCoord; void main() { - mediump vec4 texColor = texture2D( uTexture, vTexCoord ); + mediump vec4 texColor = TEXTURE( uTexture, vTexCoord ); gl_FragColor = texColor; } diff --git a/examples/rendering-textured-cube/shaders/rendering-textured-cube.vert b/examples/rendering-textured-cube/shaders/rendering-textured-cube.vert index 36c0e608..787104bd 100644 --- a/examples/rendering-textured-cube/shaders/rendering-textured-cube.vert +++ b/examples/rendering-textured-cube/shaders/rendering-textured-cube.vert @@ -1,9 +1,15 @@ -attribute mediump vec3 aPosition; // DALi shader builtin -attribute mediump vec2 aTexCoord; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +//@version 100 -varying mediump vec2 vTexCoord; +INPUT mediump vec3 aPosition; // DALi shader builtin +INPUT mediump vec2 aTexCoord; // DALi shader builtin + +UNIFORM_BLOCK Vert +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; + +OUTPUT mediump vec2 vTexCoord; void main() { diff --git a/examples/rendering-triangle/shaders/rendering-triangle.frag b/examples/rendering-triangle/shaders/rendering-triangle.frag index b8d9d3ab..a452cec2 100644 --- a/examples/rendering-triangle/shaders/rendering-triangle.frag +++ b/examples/rendering-triangle/shaders/rendering-triangle.frag @@ -1,4 +1,9 @@ -uniform mediump vec4 uColor; +//@version 100 + +UNIFORM_BLOCK Custome +{ +UNIFORM mediump vec4 uColor; +}; void main() { diff --git a/examples/rendering-triangle/shaders/rendering-triangle.vert b/examples/rendering-triangle/shaders/rendering-triangle.vert index 53f4a4f7..f70dabeb 100644 --- a/examples/rendering-triangle/shaders/rendering-triangle.vert +++ b/examples/rendering-triangle/shaders/rendering-triangle.vert @@ -1,6 +1,12 @@ -attribute mediump vec2 aPosition; // DALi shader builtin -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +//@version 100 + +INPUT mediump vec2 aPosition; // DALi shader builtin + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; void main() { diff --git a/examples/sparkle/shaders/sparkle-effect.frag b/examples/sparkle/shaders/sparkle-effect.frag index 006a7d2b..e2213894 100644 --- a/examples/sparkle/shaders/sparkle-effect.frag +++ b/examples/sparkle/shaders/sparkle-effect.frag @@ -1,11 +1,13 @@ +//@version 100 + precision highp float; -uniform sampler2D sTexture; -varying vec2 vTexCoord; +UNIFORM sampler2D sTexture; -varying lowp vec4 vColor; +INPUT vec2 vTexCoord; +INPUT lowp vec4 vColor; void main() { gl_FragColor = vColor; - gl_FragColor.a *= texture2D(sTexture, vTexCoord).a; + gl_FragColor.a *= TEXTURE(sTexture, vTexCoord).a; } diff --git a/examples/sparkle/shaders/sparkle-effect.vert b/examples/sparkle/shaders/sparkle-effect.vert index 02c33df8..45689ab8 100644 --- a/examples/sparkle/shaders/sparkle-effect.vert +++ b/examples/sparkle/shaders/sparkle-effect.vert @@ -1,29 +1,32 @@ +//@version 100 precision highp float; -attribute vec2 aTexCoord; -uniform mat4 uMvpMatrix; -varying vec2 vTexCoord; +INPUT vec2 aTexCoord; +INPUT vec2 aParticlePath0; +INPUT vec2 aParticlePath1; +INPUT vec2 aParticlePath2; +INPUT vec2 aParticlePath3; +INPUT vec2 aParticlePath4; +INPUT vec2 aParticlePath5; -attribute vec2 aParticlePath0; -attribute vec2 aParticlePath1; -attribute vec2 aParticlePath2; -attribute vec2 aParticlePath3; -attribute vec2 aParticlePath4; -attribute vec2 aParticlePath5; +OUTPUT lowp vec4 vColor; +OUTPUT vec2 vTexCoord; -uniform float uPercentage; -uniform float uPercentageMarked; -uniform vec3 uParticleColors[NUM_COLOR]; -uniform float uOpacity[NUM_PARTICLE]; -uniform vec2 uTapIndices; -uniform float uTapOffset[MAXIMUM_ANIMATION_COUNT]; -uniform vec2 uTapPoint[MAXIMUM_ANIMATION_COUNT]; -uniform float uAcceleration; -uniform float uRadius; -uniform float uScale; -uniform float uBreak; - -varying lowp vec4 vColor; +UNIFORM_BLOCK Custom +{ +UNIFORM mat4 uMvpMatrix; +UNIFORM float uPercentage; +UNIFORM float uPercentageMarked; +UNIFORM vec3 uParticleColors[NUM_COLOR]; +UNIFORM float uOpacity[NUM_PARTICLE]; +UNIFORM vec2 uTapIndices; +UNIFORM float uTapOffset[MAXIMUM_ANIMATION_COUNT]; +UNIFORM vec2 uTapPoint[MAXIMUM_ANIMATION_COUNT]; +UNIFORM float uAcceleration; +UNIFORM float uRadius; +UNIFORM float uEffectScale; +UNIFORM float uBreak; +}; void main() { @@ -38,7 +41,7 @@ void main() return; } - // As the movement along the b-curve has nonuniform speed with a uniform increasing parameter 'uPercentage' + // As the movement along the b-curve has nonUNIFORM speed with a UNIFORM increasing parameter 'uPercentage' // we give different particles the different 'percentage' to make them looks more random float increment = idx / float(NUM_PARTICLE)*5.0; float percentage = mod(uPercentage +uAcceleration+increment, 1.0); @@ -75,8 +78,8 @@ void main() position = mix( position, vec2( 250.0,250.0 ),uBreak*(1.0-uOpacity[int(idx)]) ) ; // vertex position on the mesh: (sign(aTexCoord.x), sign(aTexCoord.y))*PARTICLE_HALF_SIZE - gl_Position = uMvpMatrix * vec4( position.x+sign(aTexCoord.x)*PARTICLE_HALF_SIZE/uScale, - position.y+sign(aTexCoord.y)*PARTICLE_HALF_SIZE/uScale, + gl_Position = uMvpMatrix * vec4( position.x+sign(aTexCoord.x)*PARTICLE_HALF_SIZE/uEffectScale, + position.y+sign(aTexCoord.y)*PARTICLE_HALF_SIZE/uEffectScale, 0.0, 1.0 ); // we store the color index inside texCoord attribute diff --git a/examples/sparkle/sparkle-effect-example.cpp b/examples/sparkle/sparkle-effect-example.cpp index a6c7a83c..3f7d9ebb 100644 --- a/examples/sparkle/sparkle-effect-example.cpp +++ b/examples/sparkle/sparkle-effect-example.cpp @@ -356,12 +356,12 @@ private: // prepare the animation by setting the uniform to the required value mEffect.SetProperty(mEffect.GetPropertyIndex(BREAK_UNIFORM_NAME), 1.f); mMeshActor.SetProperty(Actor::Property::SCALE, 0.01f); - mEffect.SetProperty(mEffect.GetPropertyIndex("uScale"), 0.01f); + mEffect.SetProperty(mEffect.GetPropertyIndex("uEffectScale"), 0.01f); mMeshActor.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.f, 1.f)); Animation breakAnimation = Animation::New(duration * 1.5f); breakAnimation.AnimateTo(Property(mMeshActor, Actor::Property::SCALE), Vector3(ACTOR_SCALE, ACTOR_SCALE, ACTOR_SCALE), EaseOutSquare); - breakAnimation.AnimateTo(Property(mEffect, "uScale"), ACTOR_SCALE, EaseOutSquare); + breakAnimation.AnimateTo(Property(mEffect, "uEffectScale"), ACTOR_SCALE, EaseOutSquare); breakAnimation.AnimateTo(Property(mMeshActor, Actor::Property::POSITION), ACTOR_POSITION, EaseOutSquare); breakAnimation.FinishedSignal().Connect(this, &SparkleEffectExample::OnBreakAnimationFinished); diff --git a/examples/sparkle/sparkle-effect.h b/examples/sparkle/sparkle-effect.h index 2f0247ad..2deee478 100644 --- a/examples/sparkle/sparkle-effect.h +++ b/examples/sparkle/sparkle-effect.h @@ -244,7 +244,7 @@ Shader New() handle.RegisterProperty(oss.str(), PARTICLE_COLORS[i].RGB); } handle.RegisterProperty("uRadius", 250.f); - handle.RegisterProperty("uScale", ACTOR_SCALE); + handle.RegisterProperty("uEffectScale", ACTOR_SCALE); // set the initial uniform values diff --git a/examples/styling/shaders/image-channel-control.frag b/examples/styling/shaders/image-channel-control.frag index 37bdf1c4..a717dd85 100644 --- a/examples/styling/shaders/image-channel-control.frag +++ b/examples/styling/shaders/image-channel-control.frag @@ -1,9 +1,16 @@ +//@version 100 + INPUT mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform mediump vec4 uColor; -uniform mediump vec3 uChannels; + +UNIFORM sampler2D sTexture; + +UNIFORM_BLOCK Custom +{ +UNIFORM mediump vec4 uColor; +UNIFORM mediump vec3 uChannels; +}; void main() { - OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4(uChannels, 1.0) ; + gl_FragColor = TEXTURE( sTexture, vTexCoord ) * uColor * vec4(uChannels, 1.0) ; } diff --git a/examples/textured-mesh/shaders/textured-mesh.frag b/examples/textured-mesh/shaders/textured-mesh.frag index 1edd66ec..06668b61 100644 --- a/examples/textured-mesh/shaders/textured-mesh.frag +++ b/examples/textured-mesh/shaders/textured-mesh.frag @@ -1,9 +1,16 @@ -varying mediump vec2 vTexCoord; -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -uniform lowp vec4 uFadeColor; +//@version 100 + +INPUT mediump vec2 vTexCoord; + +UNIFORM sampler2D sTexture; + +UNIFORM_BLOCK CustomColor +{ +UNIFORM lowp vec4 uColor; +UNIFORM lowp vec4 uFadeColor; +}; void main() { - gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * uFadeColor; + gl_FragColor = TEXTURE(sTexture, vTexCoord)* uColor * uFadeColor; } diff --git a/examples/textured-mesh/shaders/textured-mesh.vert b/examples/textured-mesh/shaders/textured-mesh.vert index 11931501..3c974f22 100644 --- a/examples/textured-mesh/shaders/textured-mesh.vert +++ b/examples/textured-mesh/shaders/textured-mesh.vert @@ -1,9 +1,15 @@ -attribute mediump vec2 aPosition; -attribute highp vec2 aTexCoord; -varying mediump vec2 vTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform lowp vec4 uFadeColor; +//@version 100 + +INPUT mediump vec2 aPosition; +INPUT highp vec2 aTexCoord; + +OUTPUT mediump vec2 vTexCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; +UNIFORM mediump vec3 uSize; +}; void main() { diff --git a/examples/textured-mesh/textured-mesh-example.cpp b/examples/textured-mesh/textured-mesh-example.cpp index 2423d8e2..d87fc89c 100644 --- a/examples/textured-mesh/textured-mesh-example.cpp +++ b/examples/textured-mesh/textured-mesh-example.cpp @@ -92,6 +92,7 @@ public: mRenderer = Renderer::New(mGeometry, mShader); mRenderer.SetTextures(mTextureSet1); + mRenderer[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::NONE; mMeshActor = Actor::New(); mMeshActor.AddRenderer(mRenderer); diff --git a/examples/uniform-blocks/shaders/uniform-block-alt.frag b/examples/uniform-blocks/shaders/uniform-block-alt.frag index 81cd3dfe..6e0192b6 100644 --- a/examples/uniform-blocks/shaders/uniform-block-alt.frag +++ b/examples/uniform-blocks/shaders/uniform-block-alt.frag @@ -1,12 +1,14 @@ -layout(std140) uniform FragmentBlock +//@version 100 + +UNIFORM_BLOCK FragmentBlock { - lowp vec4 uColor; - mediump vec4 uColorArray[1024]; - mediump int uColorIndex; + UNIFORM lowp vec4 uColor; + UNIFORM mediump vec4 uColorArray[1024]; + UNIFORM mediump int uColorIndex; }; void main() { // Test that the array color is the same as the actor color - fragColor = vec4(vec3(0.5, 0.5, 0.5) + vec3(uColorArray[uColorIndex].xyz-uColor.xyz)*0.5, 1.0); + gl_FragColor = vec4(vec3(0.5, 0.5, 0.5) + vec3(uColorArray[uColorIndex].xyz-uColor.xyz)*0.5, 1.0); } diff --git a/examples/uniform-blocks/shaders/uniform-block.frag b/examples/uniform-blocks/shaders/uniform-block.frag index 9e699bf9..71479353 100644 --- a/examples/uniform-blocks/shaders/uniform-block.frag +++ b/examples/uniform-blocks/shaders/uniform-block.frag @@ -1,11 +1,13 @@ -layout(std140) uniform FragmentBlock +//@version 100 + +UNIFORM_BLOCK FragmentBlock { - lowp vec4 uColor; - mediump vec4 uColorArray[1024]; - mediump int uColorIndex; +UNIFORM lowp vec4 uColor; +UNIFORM mediump vec4 uColorArray[1024]; +UNIFORM mediump int uColorIndex; }; void main() { - fragColor = uColorArray[uColorIndex]; + gl_FragColor = uColorArray[uColorIndex]; } diff --git a/examples/uniform-blocks/shaders/uniform-block.vert b/examples/uniform-blocks/shaders/uniform-block.vert index cbf8ff9d..ecdae31c 100644 --- a/examples/uniform-blocks/shaders/uniform-block.vert +++ b/examples/uniform-blocks/shaders/uniform-block.vert @@ -1,9 +1,11 @@ +//@version 100 + INPUT vec2 aPosition; -layout(std140) uniform VertexBlock +UNIFORM_BLOCK Vanilla { - highp mat4 uMvpMatrix; - highp vec3 uSize; +UNIFORM highp mat4 uMvpMatrix; +UNIFORM highp vec3 uSize; }; void main() diff --git a/examples/waves/shaders/waves.frag b/examples/waves/shaders/waves.frag index 8a496a19..2c7589b8 100644 --- a/examples/waves/shaders/waves.frag +++ b/examples/waves/shaders/waves.frag @@ -1,19 +1,25 @@ +//@version 100 + precision highp float; -uniform vec4 uColor; // DALi -uniform sampler2D uNormalMap; // DALi +UNIFORM sampler2D uNormalMap; // DALi + +UNIFORM_BLOCK CustomFrag +{ +UNIFORM vec4 uColor; // DALi -uniform vec3 uInvLightDir; -uniform vec3 uLightColorSqr; -uniform vec3 uAmbientColor; +UNIFORM vec3 uInvLightDir; +UNIFORM vec3 uLightColorSqr; +UNIFORM vec3 uAmbientColor; -uniform float uNormalMapWeight; -uniform float uSpecularity; +UNIFORM float uNormalMapWeight; +UNIFORM float uSpecularity; +}; -varying vec2 vUv; -varying vec3 vNormal; -varying vec3 vViewPos; -varying float vHeight; +INPUT vec2 vUv; +INPUT vec3 vNormal; +INPUT vec3 vViewPos; +INPUT float vHeight; float Rand(vec2 co) { @@ -30,8 +36,8 @@ void main() vec3 viewPos = normalize(vViewPos); vec2 uv2 = vUv + vViewPos.xy / vViewPos.z * vHeight + vec2(.5, 0.); - vec3 perturbNormal = texture2D(uNormalMap, vUv).rgb * 2. - 1.; - vec3 perturbNormal2 = texture2D(uNormalMap, uv2).rgb * 2. - 1.; + vec3 perturbNormal = TEXTURE(uNormalMap, vUv).rgb * 2. - 1.; + vec3 perturbNormal2 = TEXTURE(uNormalMap, uv2).rgb * 2. - 1.; vec3 normal = normalize(vNormal + perturbNormal * uNormalMapWeight); vec3 normal2 = normalize(vNormal + perturbNormal2 * uNormalMapWeight); diff --git a/examples/waves/shaders/waves.vert b/examples/waves/shaders/waves.vert index ac9af2fd..7830ec7c 100644 --- a/examples/waves/shaders/waves.vert +++ b/examples/waves/shaders/waves.vert @@ -1,32 +1,39 @@ +//@version 100 + #define FMA(a, b, c) ((a) * (b) + (c)) // fused multiply-add precision highp float; const float kTile = 1.; - const float kPi = 3.1415926535; const float kEpsilon = 1. / 32.; // DALI uniforms -uniform vec3 uSize; -uniform mat4 uModelView; -uniform mat4 uProjection; -uniform mat3 uNormalMatrix; - -// our uniforms -uniform float uTime; -uniform vec2 uScrollScale; -uniform float uWaveRate; -uniform float uWaveAmplitude; -uniform float uParallaxAmount; - -attribute vec2 aPosition; -attribute vec2 aTexCoord; - -varying vec2 vUv; -varying vec3 vViewPos; -varying vec3 vNormal; -varying float vHeight; +UNIFORM_BLOCK Vanilla +{ +UNIFORM vec3 uSize; +UNIFORM mat4 uModelView; +UNIFORM mat4 uProjection; +UNIFORM mat3 uNormalMatrix; +}; + +// our UNIFORMs +UNIFORM_BLOCK CustomVert +{ +UNIFORM float uTime; +UNIFORM vec2 uScrollScale; +UNIFORM float uWaveRate; +UNIFORM float uWaveAmplitude; +UNIFORM float uParallaxAmount; +}; + +INPUT vec2 aPosition; +INPUT vec2 aTexCoord; + +OUTPUT vec2 vUv; +OUTPUT vec3 vViewPos; +OUTPUT vec3 vNormal; +OUTPUT float vHeight; float CubicHermite(float B, float C, float t) { diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index a57abc27..eec5b21d 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 2.3.50 +Version: 2.3.51 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/shaders/raymarch_sphere_shaded.fsh b/resources/shaders/raymarch_sphere_shaded.fsh index 7e7d6b8b..1a35b93b 100644 --- a/resources/shaders/raymarch_sphere_shaded.fsh +++ b/resources/shaders/raymarch_sphere_shaded.fsh @@ -1,11 +1,16 @@ +//@version 100 + /* * Fragment shader for textured quad */ -varying mediump vec2 vTexCoord; -varying mediump vec2 vRayCastCoord; +INPUT mediump vec2 vTexCoord; +INPUT mediump vec2 vRayCastCoord; -uniform mediump float uRadius; -uniform mediump float uAdjuster; +UNIFORM_BLOCK Custom +{ +UNIFORM mediump float uRadius; +UNIFORM mediump float uAdjuster; +} #define CAMERA_Z_POSITION 1.0 // gives us a FOV of 90 degrees if Plane of projection is at Z = 0 with size 2x2 #define SPHERE_Z_POSITION -1.0 // Sphere placed behind Plane of projection diff --git a/resources/shaders/raymarch_sphere_shaded.vsh b/resources/shaders/raymarch_sphere_shaded.vsh index fcc1df33..5a41c5a8 100644 --- a/resources/shaders/raymarch_sphere_shaded.vsh +++ b/resources/shaders/raymarch_sphere_shaded.vsh @@ -1,9 +1,15 @@ -attribute mediump vec2 aPosition; -uniform mediump mat4 uMvpMatrix; // DALi shader builtin -uniform mediump vec3 uSize; // DALi shader builtin +//@version 100 + +INPUT mediump vec2 aPosition; +OUTPUT mediump vec2 vTexCoord; +OUTPUT mediump vec2 vRayCastCoord; + +UNIFORM_BLOCK Vanilla +{ +UNIFORM mediump mat4 uMvpMatrix; // DALi shader builtin +UNIFORM mediump vec3 uSize; // DALi shader builtin +}; -varying mediump vec2 vTexCoord; -varying mediump vec2 vRayCastCoord; void main() { mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0); diff --git a/resources/style/android/base-theme.json b/resources/style/android/base-theme.json index b477b966..667e2087 100644 --- a/resources/style/android/base-theme.json +++ b/resources/style/android/base-theme.json @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd + * Copyright (c) 2024 Samsung Electronics Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,20 +50,23 @@ "shader": { "fragmentShader":[ + "//@version 100", " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", - "", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", @@ -89,19 +92,21 @@ { "fragmentShader":[ " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", - "", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", diff --git a/resources/style/base-theme.json b/resources/style/base-theme.json index 12404e94..fdcb4244 100644 --- a/resources/style/base-theme.json +++ b/resources/style/base-theme.json @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd + * Copyright (c) 2024 Samsung Electronics Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,20 +50,23 @@ "shader": { "fragmentShader":[ - " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", - "", + "//@version 100", + " INPUT mediump vec2 vTexCoord;", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", @@ -88,20 +91,24 @@ "shader": { "fragmentShader":[ - " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", + "//@version 100", + " INPUT mediump vec2 vTexCoord;", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", "", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", diff --git a/resources/style/rpi/base-theme.json b/resources/style/rpi/base-theme.json index d8400b33..5c3bd62a 100644 --- a/resources/style/rpi/base-theme.json +++ b/resources/style/rpi/base-theme.json @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd + * Copyright (c) 2024 Samsung Electronics Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,20 +46,23 @@ "shader": { "fragmentShader":[ - " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", - "", + "//@version 100", + " INPUT mediump vec2 vTexCoord;", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragmentBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", @@ -84,20 +87,23 @@ "shader": { "fragmentShader":[ - " varying mediump vec2 vTexCoord;", - " uniform lowp vec4 uColor;", - " uniform sampler2D sTexture;", - " uniform mediump vec3 uCustomPosition;", - "", + "//@version 100", + " INPUT mediump vec2 vTexCoord;", + " UNIFORM sampler2D sTexture;", + " UNIFORM_BLOCK FragmentBlock", + " {", + " UNIFORM lowp vec4 uColor;", + " UNIFORM mediump vec3 uCustomPosition;", + " };", " void main()", " {", - " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )", + " if( TEXTURE( sTexture, vTexCoord ).a <= 0.0001 )", " {", " discard;", " }", "", " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );", - " mediump vec4 color = texture2D( sTexture, wrapTexCoord );", + " mediump vec4 color = TEXTURE( sTexture, wrapTexCoord );", " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;", "", " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );", |