summaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-10-09 11:51:46 +0300
committerAntti Määttä <antti.maatta@qt.io>2020-10-16 07:15:32 +0300
commita37d31d37efd9e9130354609829461635603fb40 (patch)
tree43dd6445072d4bb54ac487bcac56ace2ef5387be /res
parent9c04cb932a9c7c7a36ace729a58b5e6794ec7db9 (diff)
Convert Material library to use images
Change-Id: Ic7754a206a0c0205d71ce78bc42d90c10abbba25 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'res')
-rw-r--r--res/effectlib/customMaterial.glsllib16
-rw-r--r--res/effectlib/evalBakedShadowMap.glsllib2
-rw-r--r--res/effectlib/transformCoordinate.glsllib9
3 files changed, 16 insertions, 11 deletions
diff --git a/res/effectlib/customMaterial.glsllib b/res/effectlib/customMaterial.glsllib
index 83756ec..9f7ae77 100644
--- a/res/effectlib/customMaterial.glsllib
+++ b/res/effectlib/customMaterial.glsllib
@@ -31,23 +31,19 @@
#ifndef CUSTOM_MATERIAL_GLSLLIB
#define CUSTOM_MATERIAL_GLSLLIB 1
-vec4 getTransformedSample(sampler2D sampler, vec2 coord, vec3 transformU, vec3 transformV)
-{
- const vec3 coord3 = vec3(coord, 1.0);
- return texture(sampler, vec2(dot(transformU, coord3), dot(transformV, coord3)));
-}
-
#define SNAPPER_SAMPLER2D(samplerName, samplerNiceName, texFilter, texWrap, showUI ) \
uniform sampler2D samplerName; \
uniform vec3 samplerName##TransformU; \
uniform vec3 samplerName##TransformV; \
- vec4 samplerName##Transformed(vec2 coord) \
+ vec3 texcoordTransformed_##samplerName(vec3 coord) \
+ { \
+ return vec3(dot(samplerName##TransformU, coord), dot(samplerName##TransformV, coord), coord.z); \
+ } \
+ vec4 sampleTransformed_##samplerName(vec3 coord) \
{ \
- return getTransformedSample(samplerName, coord, samplerName##TransformU, samplerName##TransformV); \
+ return texture(samplerName, texcoordTransformed_##samplerName(coord).xy); \
}
-
-
// some useful defines
#ifndef PI
#define PI 3.14159265358979
diff --git a/res/effectlib/evalBakedShadowMap.glsllib b/res/effectlib/evalBakedShadowMap.glsllib
index a283d8a..7ea3887 100644
--- a/res/effectlib/evalBakedShadowMap.glsllib
+++ b/res/effectlib/evalBakedShadowMap.glsllib
@@ -30,7 +30,7 @@
vec4 evalBakedShadowMap( in vec3 inCoords )
{
- vec4 shadowCol = (uShadowMappingEnabled) ? texture( uBakedShadowTexture, inCoords.xy ) : vec4( 1.0, 1.0, 1.0, 1.0 );
+ vec4 shadowCol = (uShadowMappingEnabled) ? texture( uBakedShadowTexture, texcoordTransformed_uBakedShadowTexture(inCoords).xy ) : vec4( 1.0, 1.0, 1.0, 1.0 );
return shadowCol;
}
diff --git a/res/effectlib/transformCoordinate.glsllib b/res/effectlib/transformCoordinate.glsllib
index ccdf7d0..cbe20e7 100644
--- a/res/effectlib/transformCoordinate.glsllib
+++ b/res/effectlib/transformCoordinate.glsllib
@@ -40,4 +40,13 @@ texture_coordinate_info transformCoordinate( in mat4 transform, in texture_coord
return( tci );
}
+texture_coordinate_info scaleCoordinate(in vec3 scale, in texture_coordinate_info coordinate)
+{
+ texture_coordinate_info tci;
+ tci.position = scale * coordinate.position;
+ tci.tangent_u = scale * coordinate.tangent_u;
+ tci.tangent_v = scale * coordinate.tangent_v;
+ return tci;
+}
+
#endif