aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Rahm <joshua.rahm@colorado.edu>2014-04-19 14:50:38 -0600
committerJoshua Rahm <joshua.rahm@colorado.edu>2014-04-19 14:50:38 -0600
commit14b6f5cee8236f7c42065813c5dd6a659d4d5d65 (patch)
treed64893feea6fcfe1a1e0188f328b8d92bdc55f7a
parent491d908b52e4f2854bf844a8c393211dea041333 (diff)
downloadterralloc-14b6f5cee8236f7c42065813c5dd6a659d4d5d65.tar.gz
terralloc-14b6f5cee8236f7c42065813c5dd6a659d4d5d65.tar.bz2
terralloc-14b6f5cee8236f7c42065813c5dd6a659d4d5d65.zip
made shaders faster
-rw-r--r--shaders/basic.frag4
-rw-r--r--shaders/basic.vert4
2 files changed, 6 insertions, 2 deletions
diff --git a/shaders/basic.frag b/shaders/basic.frag
index 719137d..835efbf 100644
--- a/shaders/basic.frag
+++ b/shaders/basic.frag
@@ -20,6 +20,8 @@ in float texture_blend[8] ;
in vec2 texcoord ;
in vec4 position ;
+flat in int texidx ;
+
vec3 sample(float xc,float yc) {
vec3 color = vec3(0);
for ( int i = 0 ; i < 8 ; ++ i ) {
@@ -49,7 +51,7 @@ int dominentTexture() {
}
vec3 calNormChange( vec3 norm, vec3 down, vec3 right ) {
- int dom = dominentTexture() ;
+ int dom = texidx ;
float x00 = length(sample2(dom,-dX, dY));
float x01 = length(sample2(dom, 0, dY));
float x02 = length(sample2(dom, dX, dY));
diff --git a/shaders/basic.vert b/shaders/basic.vert
index e1abeb5..36e0c48 100644
--- a/shaders/basic.vert
+++ b/shaders/basic.vert
@@ -16,6 +16,7 @@ out vec4 position ;
out vec3 normal ;
out float texture_blend[8] ;
+flat out int texidx ;
void main() {
gl_Position = pjMatrix * (position = mvMatrix * vec4(in_position,1.0)) ;
@@ -23,5 +24,6 @@ void main() {
normal = normalMatrix * in_normal ;
for ( int i = 0 ; i < 8 ; ++ i )
texture_blend[i] = 0 ;
- texture_blend[int(clamp(round(in_color.a),0,8))] = 1.0 ;
+ texidx = int(clamp(round(in_color.a),0,8));
+ texture_blend[texidx] = 1.0 ;
}