Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


coffeecup

Member Since 20 Aug 2011
Offline Last Active Feb 07 2015 06:13 AM

Posts I've Made

In Topic: texture artifacts on voxel terrain

04 February 2015 - 03:25 PM

vertexshader

 

attribute vec3 position;
uniform sampler2D texture_0;
varying vec3  my_vWorldPosition;
void main() {
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
  gl_Position = projectionMatrix * mvPosition;
  my_vWorldPosition = (modelMatrix * vec4( position, 1.0 )).xyz;     
}

fragmentshader

 
uniform sampler2D texture_0;
varying vec3 my_vWorldPosition;


vec2 computeSliceOffset(float slice, float slicesPerRow, vec2 sliceSize) {
  return sliceSize * vec2(mod(slice, slicesPerRow),floor(slice / slicesPerRow));                  
}                                                                        

vec4 sampleAs3DTexture(sampler2D tex, vec3 texCoord, float size, float numRows, float slicesPerRow) {
  float slice   = texCoord.z * size;                                             
  float sliceZ  = floor(slice);                                  
  float zOffset = fract(slice);                          
                                                                                 
  vec2 sliceSize = vec2(1.0 / slicesPerRow,             // u space of 1 slice    
                        1.0 / numRows);                 // v space of 1 slice    
                                                                                 
  vec2 slice0Offset = computeSliceOffset(sliceZ, slicesPerRow, sliceSize);       
  vec2 slice1Offset = computeSliceOffset(sliceZ + 1.0, slicesPerRow, sliceSize); 
                                                                                 
  vec2 slicePixelSize = sliceSize / size;               // space of 1 pixel      
  vec2 sliceInnerSize = slicePixelSize * (size - 1.0);  // space of size pixels  
                                                                                 
  vec2 uv = slicePixelSize * 0.5 + texCoord.xy * sliceInnerSize;                 
  vec4 slice0Color = texture2D(tex, slice0Offset + uv);                          
  vec4 slice1Color = texture2D(tex, slice1Offset + uv);                          
  //return mix(slice0Color, slice1Color, zOffset);                               
  return slice0Color;                                                            
}                                                                              
void main() {                                                                    
  vec3 vtex =  mod(my_vWorldPosition.xzy,64.0)/64.0;
  gl_FragColor = sampleAs3DTexture(texture_0,vtex,64.0,8.0,8.0);
}

In Topic: calculate position of plane in front of camera?

17 September 2014 - 12:53 PM

j5CByNa.png

 

So just to be sure I should get this value which I can plugin as Y position for the transparent plane?

I think I'm missing something.


In Topic: calculate position of plane in front of camera?

17 September 2014 - 08:19 AM

for one moment I thought it worked but I'm getting strange values, but I think i get what you are suggesting and it should work, basically with the view-projection matrix I can project my waterplane where I know Y from world space to clip space and then set the y value of the transparent plane so that it aligns with the waterplane..

 

Do I have to consider the z position of my transparent plane here ?

 

btw. is clip space the same as camera space ?


In Topic: how are this effects created?

14 April 2014 - 05:48 AM

I took the screenshot from the video here : http://www.youtube.com/watch?v=MDi9hjTfRPA#t=1047

 

Do you think that the blue shot which is comming from the right side is also a particle system?

 

I read something about creating laser beams here http://codepoke.net/2011/12/27/opengl-libgdx-laser-fx/ and I was wondering if I could use the some technique for other effects like in the youtube video.


In Topic: reconstruct depth from z/w ?

19 February 2014 - 09:18 AM

ofc, just after posting this I found another error, now I just output z/w and use it in the other shader..


PARTNERS