Pryme8

Members
  • Content count

    1,447
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by Pryme8

  1. had to change: #ifdef LAYERS uniform highp sampler2DArray layers[LAYERS]; #endif to #ifdef LAYERS uniform sampler2D layers[LAYERS]; #endif >_<.... sometimes I feel dumb...
  2. So what is the correct syntax to sample from a texture array? The equivalent to: vec4 tile = texture2D(sampler, texCoord); but for an Array not a single sampler2d. I have tried : vec4 tile = texture3D(sampler, vec3(texCoord.xy, 0); and the webGL 2.0 version... vec4 tile = texture(sampler, vec3(texCoord.xy, 0); But I keep dropping: 'texture' : no matching overloaded function found ERROR: 0:37: '=' : dimension mismatch ERROR: 0:37: '=' : cannot convert from 'const mediump float' to 'highp 4-component vector of float'
  3. Ok I can sample it just fine now, but it seems to drop an error reguardless: vec4 tile = texture(layers[0], texCoord); works, but drops the error: [15:11:42]: Error: ERROR: 0:37: 'texture' : no matching overloaded function found ERROR: 0:37: '=' : dimension mismatch ERROR: 0:37: '=' : cannot convert from 'const mediump float' to 'highp 4-component vector of float' Which is the same error as: http://www.babylonjs-playground.com/#NJRT3#4 Which was an example @Deltakosh put together to test texture arrays.
  4. Texture Scale

    You just need to construct your own cube then and have the uv’s aligned in the manor that will work for you.
  5. Texture Scale

    http://www.babylonjs-playground.com/#XJHNXG Your camera is just aligned wrong.
  6. Texture not Binding to Shader?

    I am having trouble assigning a texture array: I have tried: uniform sampler2DArray sprites; and uniform sampler2DArray sprites[4]; But I keep getting: 1 #version 300 es 2 #define LAYERS 0 3 #define NUM_BONE_INFLUENCERS 0 4 precision highp float; 5 #define pU 0.00392156862 6 7 uniform float time; 8 uniform float fps; 9 uniform vec2 viewOffset; 10 uniform vec2 viewportSize; 11 uniform float spriteSize; 12 13 uniform sampler2DArray sprites; 14 uniform sampler2DArray layers; 15 16 in vec3 vPosition; 17 in vec2 vUV; 18 in vec2 pixelCoord; 19 in vec2 texCoord; 20 21 22 out vec4 glFragColor; 23 void main(){ 24 vec2 spriteCoord = mod(pixelCoord, spriteSize); 25 vec3 color = vec3(spriteCoord.x,1.0,spriteCoord.y); 26 if((texCoord.x > 1.0 || texCoord.x < 0.0 || texCoord.y > 1.0 || texCoord.y < 0.0)){color = vec3(0.0); } 27 float alpha = 1.0; 28 29 glFragColor = vec4(color, alpha); 30 } 31 'sampler2DArray' : No precision specified ERROR: 0:14: 'sampler2DArray' : No precision specified No clue what I am doing wrong... Is it because "precision highp float;" is not the first line? **EDIT* uniform highp sampler2DArray sprites[4]; ^^ got it
  7. Ok so I have my little animated atlas shader and I am to the point where I want to add 'sub-layers' or overlays to each plane with the shader on it. So everything works, except the texture bound to the overlayA does not ever seem to display the correct data. If I just try to output the overlayA as well it just seems to load up the atlas texture which I do not understand at all! Here is the working example with no overlay added https://pryme8.github.io/TileMaster/dev/demo.html Then here is the one with the overlay added: https://pryme8.github.io/TileMaster/dev/demo_broke.html As far as I can tell I am handling the textures the same way. Maybe Im missing something... https://github.com/Pryme8/TileMaster/blob/gh-pages/dev/demo.html ^Source. There may be some bugs and things because I have been tearing down and re arranging the code trying to figure out what the heck is going on.
  8. Shader Texture Atlas Support

    With a solid color like that you would never need mips, effectively you could get away with a 4px by 4px image to do what your demonstrating above. I would recommend just turning off mips for now and continuing development with the NEAREST and no mips method. The whole point of the mip maps is for getting rid of texture artifacts and sharpness at a distance (and to save memory) but if you use like a fog pass or some secondary pass you can clean up the "choas" on the texture at a distance. Just move on and worry about it more once your really finishing stuff up.
  9. Shader Texture Atlas Support

    It will generate as many steps as it’s needed to reduce the image to a 1x1
  10. Shader Texture Atlas Support

    https://mtnphil.wordpress.com/2011/09/26/terrain-texture-atlas-construction/ see how it uses a "buffer" of data around the actual texture, its kinda a oddball thing to wrap your head around but this explains it decently. and here is some discussion on to mip or not to mip https://blogs.msdn.microsoft.com/shawnhar/2009/09/14/texture-filtering-mipmaps/
  11. that was a rhetorical question.
  12. Shader Texture Atlas Support

    lame, yeah you would need to do a buffer around them. Its a little more complicated but doable. I would recommend reading up on stuff like this: https://gamedev.stackexchange.com/questions/46963/how-to-avoid-texture-bleeding-in-a-texture-atlas
  13. Shader Texture Atlas Support

    No it was the sampling mode was just creating artifacts, try some of the other ones that include MIP in its sampling mode, and see what happens. These are just quick fixes the real fix is a good amount of glsl scripting, but for the most part if you get the sample mode correct most of your problems should be fixed.
  14. Shader Texture Atlas Support

    Its automatically handled in the gl pipeline when you bind a texture. Just bind the texture and set the noMipmaps to false (or its default) and the GPU creates the mipmaps and stores them in the memory. If you have the flag set to true it does not generate them, and thats when you will have to use NEAREST_SAMPLING for it to work, it will only be if you need the texture to soften up some that you will want to generate the mips and then mess with the sampling mode until you find one that gets rid of the artifacts.
  15. Shader Texture Atlas Support

    https://faculty.kaust.edu.sa/sites/markushadwiger/Documents/CS380_spring2015_lecture_12.pdf#page=4 ok what mipMaps are is basically an octree representation of the texture embeded into to memory. so it turns the texture into something like this: This is for performance/bottle necking there is no reason to display or calculate the full texture if its way far away basically. The system handles this on its own, and is a part of just the gl pipeline. When you do not generate mips it keeps the texture as is no matter what the LOD step is. Which can create artifacts and is not the most efficient, but is the simplest to wrap your head around. Now the sampling modes will need to change only if you generate mips this is because when it samples if it does nearest it will mess things up as the LOD level changes because you will want to sample from the same mip region as the the texture LOD.
  16. Shader Texture Atlas Support

    https://en.wikipedia.org/wiki/Texture_filtering Depends on if you are generating the mipmaps or not. I was looking for this one article I had seen that explained all the sample modes and where they sample from, but I cant seem to find it right now.
  17. Shader Texture Atlas Support

    So I think we fixed it then right? Your Other Option is to generate mips but set the sampling mode to do NEAREST_NEAREST_MIPLINEAR and if that sample mode does not work, try the others that include Mip sampling and Nearest until you get the look your going for, but that is if you need the mipmaps (which is pretty default to include)
  18. Shader Texture Atlas Support

    did you try: "new BabylonTexture { name = atlasLabel, noMipmap = true, samplingMode = BabylonTexture.SamplingMode.NEAREST_SAMPLINGMODE}"
  19. Shader Texture Atlas Support

    new Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format); and NEAREST_SAMPLINGMODE so: new BABYLON.Texture(url, scene, true, false, 1); or using your method I would assume: new BabylonTexture { name = atlasLabel, noMipmap = true, samplingMode = BabylonTexture.SamplingMode.NEAREST_SAMPLINGMODE} I am saying to make these changes just to see how it effects the tiling for the moment. Ideally there would be 'padding' between each texture that we could sample but that's a different method and takes a little more scripting. Once I see how this effects the results I can help more.
  20. Shader Texture Atlas Support

    what is your sampling mode? Set it to nearest, and see if that fixes the seams. Also turn of Mips for now.
  21. Low fps even with very simple scene

    remake this on: https://www.babylonjs-playground.com/ and people will help, not many are guru enough to just read through script and know whats happening.
  22. Couldn't this be done more dynamically with a shader/postEffect? Like raymarch the fog and then do a depth test and discard anything that is "covered/out of range" https://bartwronski.files.wordpress.com/2014/08/bwronski_volumetric_fog_siggraph2014.pdf
  23. Texture not Binding to Shader?

    is there a better way to do this: var defines = [] defines.push("#define LAYERS"+this.layers.length); In the setting up of the defines and then in the shader: #ifdef LAYERS0 const int layerCount = 0; #endif #ifdef LAYERS1 const int layerCount = 1; uniform sampler2d sprites[1]; #endif #ifdef LAYERS2 const int layerCount = 2; uniform sampler2d sprites[2]; #endif #ifdef LAYERS3 const int layerCount = 3; uniform sampler2d sprites[3]; #endif #ifdef LAYERS4 const int layerCount = 4; uniform sampler2d sprites[4]; #endif
  24. Texture not Binding to Shader?

    That would prolly be it, I was just under the impression it was a string from what delta said on prior posts. But I’ll give wrapping it as a single item array a shot.