java - Simple Vertex Shader for color based on model space vertex Z coord -


I have a simple function map_color which calculates the color of the lessons for a tragic simulator in my university Shader. It seems quite simple for my first shader, but I do not know where to start from. I have seen some code samples that seem promising but are too complex and hard for me.

Let me tell you that I am using Java / Jog but I can see the details of loading Shader and it will change on itself. Most are looking for help with actual shader codes.

  Private zeros map_color (float height, float color []) {float T = (height - COLOR_MIN_HEIGHT) / (COLOR_MAX_HEIGHT - COLOR_MIN_HEIGHT); // clamping for the class, just if (T & LT; 0.0) T = 0.0F; If (t> 1.0) t = 1.0F; // brown yellow map if (t & lt; 0.5) {color [0] = 0.488 f + t * 0.836 f; Color [1] = 0.164 f + t * 0.953 f; Color [2] = 0.094 f + t * 0.172 f; } And {color [0] = 0.90 f + (t - 0.5 f) * 0.180 f; Color [1] = 0.640 f + (t - 0.5 f) * 0.680 f; Color [2] = 0.180 f + (t - 0.5 f) * 0.773 f; }} Private void drawTerrain () {// Each quad needs a different head - this implementation is disabled / should be calculated once and when the grid is loaded float [] v1 = new float [3] ; Float [] v2 = new float [3]; Float [] ideal = new float [3]; Float [] color = new float [3]; V1 [0] = Grid Horizontal Scale Factor / 5.0F; // Scale Factor A Hack v1 [1] = 0.0 F; V2 [0] = 0.0 f; V2 [1] = Grid Horizontal Scale Factor / 5.0F; // Get ready to isolate hack / content properties on hat gl.glEnable (GLLightingFunc.GL_COLOR_MATERIAL); Gl.glColorMaterial (GL.GL_FRONT_AND_BACK, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE); (Int x = 2; x & lt; latticeSizeX-1; x ++) {for (int y = 2; y & lt; latticaceae -1; y ++) {gl.glBegin (GL.GL_TRIANGLES); V1 [2] = unsafeopo gateflotate ((X + 1) * 263 + y) - Unprotected TapoGetflattate ((X-1) * 263 + Y); V2 [2] = unsafeopt.getflotate (X * 263 + (Y + 1)) - UnprotectedTopoGetflotAut (X * 263 + (Y-1)); Cross (ideal, v2, v1); Gl.glNormal3fv (ideal, 0); Map_color (unsafeTipoGateFlotAut (x * 263 + y, color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (x, y, unsafe tapo.getflatate (x * 263 + y)); Map_color (unprotected TopoGetflotAut ((X + 1) * 263 + y), color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (X + 1, Y, Unprotected TapoGetflattate ((X + 1) * 263 + y)); Map_color (unsafeTipoGetflotAut (x * 263 + (y + 1)), color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (x, y + 1, unsafe tapo.getflatate (x * 263 + (y + 1)); V1 [2] = Unprotected TapoGetflotAut ((X + 2) * 263 + Y + 1) - Unprotected TapoGetFalatite (X * 263 + (Y + 1)); V2 [2] = Unprotected TapoGetflattate ((X + 1) * 263 + y + 2) - Unprotected TapoGetflattate ((X + 1) * 263 + y); Cross (ideal, v2, v1); Map_color (unsafeTipoGateflotAtt ((X + 1) * 263 + y + 1), color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (x + 1, y + 1, unsafe top.getflattate ((x + 1) * 263 + y + 1)); Map_color (unsafeTipoGetflotAut (x * 263 + (y + 1)), color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (x, y + 1, unsafe tapo.getflatate (x * 263 + (y + 1)); Map_color (unprotected TopoGetflotAut ((X + 1) * 263 + y), color); Gl.glColor3f (color [0], color [1], color [2]); Gl.glVertex3f (X + 1, Y, Unprotected TapoGetflattate ((X + 1) * 263 + y)); Gl.glEnd (); }} Gl.glDisable (GLLightingFunc.GL_COLOR_MATERIAL); }  


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -