Browse Source

uniforms grouping...

leonsal 8 years ago
parent
commit
00b2d7ed8c

+ 158 - 0
gls/uniform.go

@@ -327,6 +327,8 @@ type UniformMatrix3f struct {
 	v [9]float32
 }
 
+// NewUniformMatrix3 creates and returns a pointer to a new UniformMatrix3f
+// with the specified name
 func NewUniformMatrix3f(name string) *UniformMatrix3f {
 
 	uni := new(UniformMatrix3f)
@@ -334,26 +336,61 @@ func NewUniformMatrix3f(name string) *UniformMatrix3f {
 	return uni
 }
 
+// Init initializes this uniform the specified name
+// It is normally used when the uniform is embedded in another object.
 func (uni *UniformMatrix3f) Init(name string) {
 
 	uni.name = name
 }
 
+// SetMatrix3 sets the matrix stored by the uniform
 func (uni *UniformMatrix3f) SetMatrix3(m *math32.Matrix3) {
 
 	uni.v = *m
 }
 
+// GetMatrix3 gets the matrix stored by the uniform
 func (uni *UniformMatrix3f) GetMatrix3() math32.Matrix3 {
 
 	return uni.v
 }
 
+// SetElement sets the value of the matrix element at the specified column and row
+func (uni *UniformMatrix3f) SetElement(col, row int, v float32) {
+
+	uni.v[col*3+row] = v
+}
+
+// GetElement gets the value of the matrix element at the specified column and row
+func (uni *UniformMatrix3f) GetElement(col, row int, v float32) float32 {
+
+	return uni.v[col*3+row]
+}
+
+// Set sets the value of the matrix element by its position starting
+// from 0 for col0, row0 to 8 from col2, row2.
+// This way the matrix can be considered as a vector of 9 elements
+func (uni *UniformMatrix3f) Set(pos int, v float32) {
+
+	uni.v[pos] = v
+}
+
+// Get gets the value of the matrix element by its position starting
+// from 0 for col0, row0 to 8 from col2, row2.
+// This way the matrix can be considered as a vector of 9 elements
+func (uni *UniformMatrix3f) Get(pos int) float32 {
+
+	return uni.v[pos]
+}
+
+// Transfer transfer the uniform matrix data to the graphics library
 func (uni *UniformMatrix3f) Transfer(gl *GLS) {
 
 	gl.UniformMatrix3fv(uni.Location(gl), 1, false, &uni.v[0])
 }
 
+// TransferIdx transfer the uniform matrix data to a specified destination index
+// of an uniform array to the graphics library
 func (uni *UniformMatrix3f) TransferIdx(gl *GLS, idx int) {
 
 	gl.UniformMatrix3fv(uni.LocationIdx(gl, idx), 1, false, &uni.v[0])
@@ -400,6 +437,127 @@ func (uni *UniformMatrix4f) TransferIdx(gl *GLS, idx int) {
 	gl.UniformMatrix4fv(uni.LocationIdx(gl, idx), 1, false, &uni.v[0])
 }
 
+//
+// Type Uniform3fv is a uniform containing an array of three float32 values
+//
+type Uniform3fv struct {
+	Uniform           // embedded uniform
+	count   int       // number of groups of 3 float32 values
+	v       []float32 // array of values
+}
+
+// NewUniform3fv creates and returns an uniform array with the specified size
+// of 3 float values
+func NewUniform3fv(name string, count int) *Uniform3fv {
+
+	uni := new(Uniform3fv)
+	uni.Init(name, count)
+	return uni
+}
+
+// Init initializes an Uniform3fv object with the specified name and count of 3 float32 groups.
+// It is normally used when the uniform is embedded in another object.
+func (uni *Uniform3fv) Init(name string, count int) {
+
+	uni.name = name
+	uni.count = count
+	uni.v = make([]float32, count*3)
+}
+
+// Set sets the value of all elements of the specified group of 3 floats for this uniform array
+func (uni *Uniform3fv) Set(idx int, v0, v1, v2 float32) {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	uni.v[pos] = v0
+	uni.v[pos+1] = v1
+	uni.v[pos+2] = v2
+}
+
+// Get gets the value of all elements of the specified group of 3 floats for this uniform array
+func (uni *Uniform3fv) Get(idx int) (v0, v1, v2 float32) {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	return uni.v[pos], uni.v[pos+1], uni.v[pos+2]
+}
+
+// SetVector3 sets the value of all elements for the specified group of 3 float for this uniform array
+// from the specified Vector3 object.
+func (uni *Uniform3fv) SetVector3(idx int, v *math32.Vector3) {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	uni.v[pos] = v.X
+	uni.v[pos+1] = v.Y
+	uni.v[pos+2] = v.Z
+}
+
+// GetVector3 gets the value of all elements of the specified group of 3 float for this uniform array
+// as a Vector3 object.
+func (uni *Uniform3fv) GetVector3(idx int) math32.Vector3 {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	return math32.Vector3{uni.v[pos], uni.v[pos+1], uni.v[pos+2]}
+}
+
+// SetColor sets the value of all elements of the specified group of 3 floats for this uniform array
+// form the specified Color object.
+func (uni *Uniform3fv) SetColor(idx int, color *math32.Color) {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	uni.v[pos] = color.R
+	uni.v[pos+1] = color.G
+	uni.v[pos+2] = color.B
+}
+
+// GetColor gets the value of all elements of the specified group of 3 float for this uniform array
+// as a Color object.
+func (uni *Uniform3fv) GetColor(idx int) math32.Color {
+
+	if idx < 0 || idx >= uni.count {
+		panic("Invalid index")
+	}
+	pos := idx * 3
+	return math32.Color{uni.v[pos], uni.v[pos+1], uni.v[pos+2]}
+}
+
+// SetPos sets the value at the specified position in the uniform array.
+func (uni *Uniform3fv) SetPos(pos int, v float32) {
+
+	if pos < 0 || pos >= len(uni.v) {
+		panic("Invalid index")
+	}
+	uni.v[pos] = v
+}
+
+// GetPos gets the value at the specified position in the uniform array.
+func (uni *Uniform3fv) GetPos(pos int) float32 {
+
+	if pos < 0 || pos >= len(uni.v) {
+		panic("Invalid index")
+	}
+	return uni.v[pos]
+}
+
+// Transfer transfers the current values of this uniform to the current shader program
+func (uni *Uniform3fv) Transfer(gl *GLS) {
+
+	gl.Uniform3fv(uni.Location(gl), int32(uni.count), uni.v)
+}
+
 //
 // Type Uniform4fv is a Uniform containing an array of four float32 values
 //

+ 60 - 34
material/standard.go

@@ -11,14 +11,25 @@ import (
 
 type Standard struct {
 	Material                 // Embedded material
-	emissive  *gls.Uniform3f // Emissive color uniform
-	ambient   *gls.Uniform3f // Ambient color uniform
-	diffuse   *gls.Uniform3f // Diffuse color uniform
-	specular  *gls.Uniform3f // Specular color uniform
-	shininess *gls.Uniform1f // Shininess exponent uniform
-	opacity   *gls.Uniform1f // Opacity (alpha)uniform
+	uni      *gls.Uniform3fv // Uniform array of 3 floats with material properties
+	//ambient   *gls.Uniform3f // Ambient color uniform
+	//diffuse   *gls.Uniform3f // Diffuse color uniform
+	//specular  *gls.Uniform3f // Specular color uniform
+	//emissive  *gls.Uniform3f // Emissive color uniform
+	//shininess *gls.Uniform1f // Shininess exponent uniform
+	//opacity   *gls.Uniform1f // Opacity (alpha)uniform
 }
 
+const (
+	vAmbient   = 0              // index for Ambient color in uniform array
+	vDiffuse   = 1              // index for Diffuse color in uniform array
+	vSpecular  = 2              // index for Specular color in uniform array
+	vEmissive  = 3              // index for Emissive color in uniform array
+	pShininess = vEmissive * 4  // position for material shininess in uniform array
+	pOpacity   = pShininess + 1 // position for material opacitiy in uniform array
+	uniSize    = 5              // total count of groups 3 floats in uniform
+)
+
 // NewStandard creates and returns a pointer to a new standard material
 func NewStandard(color *math32.Color) *Standard {
 
@@ -33,83 +44,98 @@ func (ms *Standard) Init(shader string, color *math32.Color) {
 	ms.SetShader(shader)
 
 	// Creates uniforms and adds to material
-	ms.emissive = gls.NewUniform3f("MatEmissiveColor")
-	ms.ambient = gls.NewUniform3f("MatAmbientColor")
-	ms.diffuse = gls.NewUniform3f("MatDiffuseColor")
-	ms.specular = gls.NewUniform3f("MatSpecularColor")
-	ms.shininess = gls.NewUniform1f("MatShininess")
-	ms.opacity = gls.NewUniform1f("MatOpacity")
+	ms.uni = gls.NewUniform3fv("Material", uniSize)
+	//ms.emissive = gls.NewUniform3f("MatEmissiveColor")
+	//ms.ambient = gls.NewUniform3f("MatAmbientColor")
+	//ms.diffuse = gls.NewUniform3f("MatDiffuseColor")
+	//ms.specular = gls.NewUniform3f("MatSpecularColor")
+	//ms.shininess = gls.NewUniform1f("MatShininess")
+	//ms.opacity = gls.NewUniform1f("MatOpacity")
 
 	// Set initial values
-	ms.emissive.Set(0, 0, 0)
-	ms.ambient.SetColor(color)
-	ms.diffuse.SetColor(color)
-	ms.specular.Set(0.5, 0.5, 0.5)
-	ms.shininess.Set(30.0)
-	ms.opacity.Set(1.0)
+	ms.uni.SetColor(vAmbient, color)
+	ms.uni.SetColor(vDiffuse, color)
+	ms.uni.Set(vSpecular, 0.5, 0.5, 0.5)
+	ms.uni.Set(vEmissive, 0, 0, 0)
+	ms.uni.SetPos(pShininess, 30.0)
+	ms.uni.SetPos(pOpacity, 1.0)
+
+	//ms.ambient.SetColor(color)
+	//ms.diffuse.SetColor(color)
+	//ms.emissive.Set(0, 0, 0)
+	//ms.specular.Set(0.5, 0.5, 0.5)
+	//ms.shininess.Set(30.0)
+	//ms.opacity.Set(1.0)
 }
 
 // AmbientColor returns the material ambient color reflectivity.
 func (ms *Standard) AmbientColor() math32.Color {
 
-	return ms.ambient.GetColor()
+	return ms.uni.GetColor(vAmbient)
 }
 
 // SetAmbientColor sets the material ambient color reflectivity.
 // The default is the same as the diffuse color
 func (ms *Standard) SetAmbientColor(color *math32.Color) {
 
-	ms.ambient.SetColor(color)
+	ms.uni.SetColor(vAmbient, color)
 }
 
 // SetColor sets the material diffuse color and also the
 // material ambient color reflectivity
 func (ms *Standard) SetColor(color *math32.Color) {
 
-	ms.diffuse.SetColor(color)
-	ms.ambient.SetColor(color)
+	ms.uni.SetColor(vDiffuse, color)
+	ms.uni.SetColor(vAmbient, color)
+	//	ms.diffuse.SetColor(color)
+	//	ms.ambient.SetColor(color)
 }
 
 // SetEmissiveColor sets the material emissive color
 // The default is {0,0,0}
 func (ms *Standard) SetEmissiveColor(color *math32.Color) {
 
-	ms.emissive.SetColor(color)
+	ms.uni.SetColor(vEmissive, color)
+	//	ms.emissive.SetColor(color)
 }
 
 // EmissiveColor returns the material current emissive color
 func (ms *Standard) EmissiveColor() math32.Color {
 
-	return ms.emissive.GetColor()
+	return ms.uni.GetColor(vEmissive)
+	//return ms.emissive.GetColor()
 }
 
 // SetSpecularColor sets the material specular color reflectivity.
 // The default is {0.5, 0.5, 0.5}
 func (ms *Standard) SetSpecularColor(color *math32.Color) {
 
-	ms.specular.SetColor(color)
+	ms.uni.SetColor(vSpecular, color)
+	//ms.specular.SetColor(color)
 }
 
 // SetShininess sets the specular highlight factor. Default is 30.
 func (ms *Standard) SetShininess(shininess float32) {
 
-	ms.shininess.Set(shininess)
+	//ms.shininess.Set(shininess)
+	ms.uni.SetPos(pShininess, shininess)
 }
 
 // SetOpacity sets the material opacity (alpha). Default is 1.0.
 func (ms *Standard) SetOpacity(opacity float32) {
 
-	ms.opacity.Set(opacity)
+	ms.uni.SetPos(pOpacity, opacity)
+	//ms.opacity.Set(opacity)
 }
 
 func (ms *Standard) RenderSetup(gs *gls.GLS) {
 
 	ms.Material.RenderSetup(gs)
-
-	ms.emissive.Transfer(gs)
-	ms.ambient.Transfer(gs)
-	ms.diffuse.Transfer(gs)
-	ms.specular.Transfer(gs)
-	ms.shininess.Transfer(gs)
-	ms.opacity.Transfer(gs)
+	ms.uni.Transfer(gs)
+	//ms.emissive.Transfer(gs)
+	//ms.ambient.Transfer(gs)
+	//ms.diffuse.Transfer(gs)
+	//ms.specular.Transfer(gs)
+	//ms.shininess.Transfer(gs)
+	//ms.opacity.Transfer(gs)
 }

+ 18 - 11
renderer/shader/chunkMaterial.go

@@ -10,18 +10,25 @@ func init() {
 
 const chunkMaterial = `
 // Material uniforms
-uniform vec3      MatAmbientColor;
-uniform vec3      MatDiffuseColor;
-uniform vec3      MatSpecularColor;
-uniform float     MatShininess;
-uniform vec3      MatEmissiveColor;
-uniform float     MatOpacity;
+uniform vec3	Material[5];
+
+// Macros to access elements inside the Material uniform array
+#define MatAmbientColor		Material[0]
+#define MatDiffuseColor		Material[1]
+#define MatSpecularColor	Material[2]
+#define MatEmissiveColor	Material[3]
+#define MatShininess		Material[4].x
+#define MatOpacity			Material[4].y
 
 {{if .MatTexturesMax}}
-uniform sampler2D MatTexture[{{.MatTexturesMax}}];
-uniform vec2      MatTexRepeat[{{.MatTexturesMax}}];
-uniform vec2      MatTexOffset[{{.MatTexturesMax}}];
-uniform int       MatTexFlipY[{{.MatTexturesMax}}];
-uniform bool      MatTexVisible[{{.MatTexturesMax}}];
+// Textures uniforms
+uniform sampler2D	MatTexture[{{.MatTexturesMax}}];
+uniform mat3		MatTexinfo[{{.MatTexturesMax}}];
+
+// Macros to access elements inside MatTexinfo uniform
+#define MatTexOffset(a)		MatTexinfo[a][0].xy
+#define MatTexRepeat(a)		MatTexinfo[a][1].xy
+#define MatTexFlipY(a)		bool(MatTexinfo[a][2].x)
+#define MatTexVisible(a)	bool(MatTexinfo[a][2].y)
 {{ end }}
 `

+ 1 - 1
renderer/shader/shaderPanel.go

@@ -113,7 +113,7 @@ void main() {
             vec2 offset = vec2(-Panel[content][0], -Panel[content][1]);
             vec2 factor = vec2(1/Panel[content][2], 1/Panel[content][3]);
             vec2 texcoord = (FragTexcoord + offset) * factor;
-            color = texture(MatTexture[0], texcoord * MatTexRepeat[0] + MatTexOffset[0]);
+            color = texture(MatTexture[0], texcoord * MatTexRepeat(0) + MatTexOffset(0));
         {{ end }}
         if (color.a == 0) {
             discard;

+ 3 - 3
renderer/shader/shaderPhong.go

@@ -46,7 +46,7 @@ void main() {
     // Flips texture coordinate Y if requested.
     vec2 texcoord = VertexTexcoord;
     {{ if .MatTexturesMax }}
-    if (MatTexFlipY[0] > 0) {
+    if (MatTexFlipY(0)) {
         texcoord.y = 1 - texcoord.y;
     }
     {{ end }}
@@ -80,8 +80,8 @@ void main() {
     // Combine all texture colors
     vec4 texCombined = vec4(1);
     {{ range loop .MatTexturesMax }}
-    if (MatTexVisible[{{.}}] == true) {
-        vec4 texcolor = texture(MatTexture[{{.}}], FragTexcoord * MatTexRepeat[{{.}}] + MatTexOffset[{{.}}]);
+    if (MatTexVisible({{.}})) {
+        vec4 texcolor = texture(MatTexture[{{.}}], FragTexcoord * MatTexRepeat({{.}}) + MatTexOffset({{.}}));
         if ({{.}} == 0) {
             texCombined = texcolor;
         } else {

+ 1 - 1
renderer/shader/shaderPoint.go

@@ -73,7 +73,7 @@ void main() {
     {{ range loop .MatTexturesMax }}
     {
         vec2 pt = gl_PointCoord - vec2(0.5);
-        vec4 texcolor = texture(MatTexture[{{.}}], (Rotation * pt + vec2(0.5)) * MatTexRepeat[{{.}}] + MatTexOffset[{{.}}]);
+        vec4 texcolor = texture(MatTexture[{{.}}], (Rotation * pt + vec2(0.5)) * MatTexinfo[{{.}}]TexRepeat + MatTexinfo[{{.}}]TexOffset);
         if ({{.}} == 0) {
             texCombined = texcolor;
         } else {

+ 3 - 3
renderer/shader/shaderStandard.go

@@ -55,7 +55,7 @@ void main() {
     vec2 texcoord = VertexTexcoord;
     {{if .MatTexturesMax }}
     // Flips texture coordinate Y if requested.
-    if (MatTexFlipY[0] > 0) {
+    if (MatTexFlipY(0)) {
         texcoord.y = 1 - texcoord.y;
     }
     {{ end }}
@@ -92,8 +92,8 @@ void main() {
     // Use Go templates to unroll the loop because non-const
     // array indexes are not allowed until GLSL 4.00.
     {{ range loop .MatTexturesMax }}
-    if (MatTexVisible[{{.}}] == true) {
-        vec4 texcolor = texture(MatTexture[{{.}}], FragTexcoord * MatTexRepeat[{{.}}] + MatTexOffset[{{.}}]);
+    if (MatTexVisible({{.}})) {
+        vec4 texcolor = texture(MatTexture[{{.}}], FragTexcoord * MatTexRepeat({{.}}) + MatTexOffset({{.}}));
         if ({{.}} == 0) {
             texCombined = texcolor;
         } else {

+ 75 - 43
texture/texture2D.go

@@ -16,29 +16,41 @@ import (
 )
 
 type Texture2D struct {
-	gs           *gls.GLS      // Pointer to OpenGL state
-	refcount     int           // Current number of references
-	texname      uint32        // Texture handle
-	magFilter    uint32        // magnification filter
-	minFilter    uint32        // minification filter
-	wrapS        uint32        // wrap mode for s coordinate
-	wrapT        uint32        // wrap mode for t coordinate
-	iformat      int32         // internal format
-	width        int32         // texture width in pixels
-	height       int32         // texture height in pixels
-	format       uint32        // format of the pixel data
-	formatType   uint32        // type of the pixel data
-	updateData   bool          // texture data needs to be sent
-	updateParams bool          // texture parameters needs to be sent
-	genMipmap    bool          // generate mipmaps flag
-	data         interface{}   // array with texture data
-	uTexture     gls.Uniform1i // Texture unit uniform
-	uFlipY       gls.Uniform1i // Flip Y coordinate flag uniform
-	uVisible     gls.Uniform1i // Texture visible uniform
-	uOffset      gls.Uniform2f // Texture offset uniform
-	uRepeat      gls.Uniform2f // Texture repeat uniform
+	gs           *gls.GLS            // Pointer to OpenGL state
+	refcount     int                 // Current number of references
+	texname      uint32              // Texture handle
+	magFilter    uint32              // magnification filter
+	minFilter    uint32              // minification filter
+	wrapS        uint32              // wrap mode for s coordinate
+	wrapT        uint32              // wrap mode for t coordinate
+	iformat      int32               // internal format
+	width        int32               // texture width in pixels
+	height       int32               // texture height in pixels
+	format       uint32              // format of the pixel data
+	formatType   uint32              // type of the pixel data
+	updateData   bool                // texture data needs to be sent
+	updateParams bool                // texture parameters needs to be sent
+	genMipmap    bool                // generate mipmaps flag
+	data         interface{}         // array with texture data
+	uTexture     gls.Uniform1i       // Texture unit uniform
+	uTexinfo     gls.UniformMatrix3f // uniform 3x3 array with texture info
+
+	//uTexture     gls.Uniform1i // Texture unit uniform
+	//uFlipY       gls.Uniform1i // Flip Y coordinate flag uniform
+	//uVisible     gls.Uniform1i // Texture visible uniform
+	//uOffset      gls.Uniform2f // Texture offset uniform
+	//uRepeat      gls.Uniform2f // Texture repeat uniform
 }
 
+const (
+	iOffsetX = 0
+	iOffsetY = 1
+	iRepeatX = 3
+	iRepeatY = 4
+	iFlipY   = 6
+	iVisible = 7
+)
+
 func newTexture2D() *Texture2D {
 
 	t := new(Texture2D)
@@ -53,16 +65,24 @@ func newTexture2D() *Texture2D {
 	t.updateParams = true
 	t.genMipmap = true
 
+	// Initialize Uniform elements
 	t.uTexture.Init("MatTexture")
-	t.uFlipY.Init("MatTexFlipY")
-	t.uVisible.Init("MatTexVisible")
-	t.uOffset.Init("MatTexOffset")
-	t.uRepeat.Init("MatTexRepeat")
-
-	t.uRepeat.Set(1, 1)
-	t.uOffset.Set(0, 0)
-	t.uVisible.Set(1)
-	t.uFlipY.Set(1)
+	t.uTexinfo.Init("MatTexinfo")
+	t.uTexinfo.Set(iOffsetX, 0)
+	t.uTexinfo.Set(iOffsetY, 0)
+	t.uTexinfo.Set(iRepeatX, 1)
+	t.uTexinfo.Set(iRepeatY, 1)
+	t.uTexinfo.Set(iFlipY, 1)
+	t.uTexinfo.Set(iVisible, 1)
+
+	//t.uFlipY.Init("MatTexFlipY")
+	//t.uVisible.Init("MatTexVisible")
+	//t.uOffset.Init("MatTexOffset")
+	//t.uRepeat.Init("MatTexRepeat")
+	//t.uRepeat.Set(1, 1)
+	//t.uOffset.Set(0, 0)
+	//t.uVisible.Set(1)
+	//t.uFlipY.Set(1)
 
 	return t
 }
@@ -165,16 +185,16 @@ func (t *Texture2D) SetData(width, height int, format int, formatType, iformat i
 func (t *Texture2D) SetVisible(state bool) {
 
 	if state {
-		t.uVisible.Set(1)
+		t.uTexinfo.Set(iVisible, 1)
 	} else {
-		t.uVisible.Set(0)
+		t.uTexinfo.Set(iVisible, 0)
 	}
 }
 
 // Visible returns the current visibility state of the texture
 func (t *Texture2D) Visible() bool {
 
-	if t.uVisible.Get() == 0 {
+	if t.uTexinfo.Get(iVisible) == 0 {
 		return false
 	} else {
 		return true
@@ -216,34 +236,42 @@ func (t *Texture2D) SetWrapT(wrapT uint32) {
 // SetRepeat set the repeat factor
 func (t *Texture2D) SetRepeat(x, y float32) {
 
-	t.uRepeat.Set(x, y)
+	t.uTexinfo.Set(iRepeatX, x)
+	t.uTexinfo.Set(iRepeatY, y)
+	//t.uRepeat.Set(x, y)
 }
 
 // Repeat returns the current X and Y repeat factors
 func (t *Texture2D) Repeat() (float32, float32) {
 
-	return t.uRepeat.Get()
+	return t.uTexinfo.Get(iRepeatX), t.uTexinfo.Get(iRepeatY)
+	//return t.uRepeat.Get()
 }
 
 // SetOffset sets the offset factor
 func (t *Texture2D) SetOffset(x, y float32) {
 
-	t.uOffset.Set(x, y)
+	t.uTexinfo.Set(iOffsetX, x)
+	t.uTexinfo.Set(iOffsetY, y)
+	//t.uOffset.Set(x, y)
 }
 
 // Offset returns the current X and Y offset factors
 func (t *Texture2D) Offset() (float32, float32) {
 
-	return t.uOffset.Get()
+	return t.uTexinfo.Get(iOffsetX), t.uTexinfo.Get(iOffsetY)
+	//return t.uOffset.Get()
 }
 
 // SetFlipY set the state for flipping the Y coordinate
 func (t *Texture2D) SetFlipY(state bool) {
 
 	if state {
-		t.uFlipY.Set(1)
+		t.uTexinfo.Set(iFlipY, 1)
+		//t.uFlipY.Set(1)
 	} else {
-		t.uFlipY.Set(0)
+		t.uTexinfo.Set(iFlipY, 0)
+		//t.uFlipY.Set(0)
 	}
 }
 
@@ -334,8 +362,12 @@ func (t *Texture2D) RenderSetup(gs *gls.GLS, idx int) {
 	// Transfer uniforms
 	t.uTexture.Set(int32(idx))
 	t.uTexture.TransferIdx(gs, idx)
-	t.uFlipY.TransferIdx(gs, idx)
-	t.uVisible.TransferIdx(gs, idx)
-	t.uOffset.TransferIdx(gs, idx)
-	t.uRepeat.TransferIdx(gs, idx)
+	t.uTexinfo.TransferIdx(gs, idx)
+
+	//	t.uTexture.Set(int32(idx))
+	//	t.uTexture.TransferIdx(gs, idx)
+	//	t.uFlipY.TransferIdx(gs, idx)
+	//	t.uVisible.TransferIdx(gs, idx)
+	//	t.uOffset.TransferIdx(gs, idx)
+	//	t.uRepeat.TransferIdx(gs, idx)
 }