Title: Background rotation Post by: Crist-JRoger on November 17, 2015, 09:10:10 PM I use IBL images for background. It looks like sphere but inside. No seams, solid sphere - so you know that.
There is part of code in global illumination-raytracer for rotate images/textures: Code: uniform vec3 skyColor;color[0.67,1,1] And the question is: How fix 'rotate-mode' on y-axis for rotation with texture sphere? In other words, how to prevent such distortions: Title: Re: Background rotation Post by: Patryk Kizny on November 18, 2015, 12:06:28 AM First of all, your maps need to be equirectangular AND 2:1 aspect ratio.
Not sure if it helps, but that's what I am using for mapping: Code: vec3 equirectangularMapOffsSc(sampler2D sampler, vec3 dir, vec2 offs, vec2 scale) {scale should be 0...1 offset also 0...1 equirectangularMapOffsSc(BgMap,dir,BgMapOffset, BgMapScale); This works nicely in a horizontal mode, but I am not sure about whether vertical offset is absolutely OK. Title: Re: Background rotation Post by: 3dickulus on November 18, 2015, 04:39:14 AM I have implemented some extra GL texture parameters...
Code: #TexParameter textureName GL_TEXTURE_MAG_FILTER GL_NEAREST in a frag this should create a mipmapped texture Code: uniform sampler2D myTexture; file[test.png] at some point I would like to make the rest of these selectable in the gui Edit->insert command maybe if someone can test this and determine that it is desirable but first you might want to get familiar with this http://www.informit.com/articles/article.aspx?p=770639&seqNum=4 these are all the texture parameters/options that should be available GL_TEXTURE_ENV GL_TEXTURE_ENV_MODE GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER GL_TEXTURE_ENV_COLOR GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_TEXTURE_GEN_R GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_MODE GL_TEXTURE_BORDER_COLOR GL_TEXTURE_WIDTH GL_TEXTURE_HEIGHT GL_TEXTURE_BORDER GL_TEXTURE_COMPONENTS GL_TEXTURE_RED_SIZE GL_TEXTURE_GREEN_SIZE GL_TEXTURE_BLUE_SIZE GL_TEXTURE_ALPHA_SIZE GL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_INTENSITY_SIZE GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR GL_OBJECT_LINEAR GL_OBJECT_PLANE GL_EYE_LINEAR GL_EYE_PLANE GL_SPHERE_MAP GL_DECAL GL_MODULATE GL_NEAREST GL_REPEAT GL_CLAMP GL_S GL_T GL_R GL_Q the pics... 1) when the viewer (Eye) is on the same side as surface normal direction, above looking down at floor surface normal = up 2) when the viewer (Eye) is on the back side of surface normal direction, below looking up at floor surface normal = up Title: Re: Background rotation Post by: 3dickulus on November 18, 2015, 08:17:40 AM I mention this here because I think there is a lot that can be done by GL in hardware that won't require valuable fragment code space like texture coordinate generation/mapping.
Are there any parameters, not already in Fragmentarium, that stand out as "needed" ? GL_TEXTURE_CUBE_MAP ? GL_SPHERE_MAP ? GL_TEXTURE_ENV ? @Crist-JRoger would they be helpful with the distortion problem? Title: Re: Background rotation Post by: Crist-JRoger on November 18, 2015, 08:55:30 AM 3dickulus, i appreciate your help. I'll try all that i can. But i tired to say again and again... very very sorry - i am not a programmer, i know in glsl only very primitive basics (min/max +- etc...) and i can change code for some manipulations. I have some imagination how it works )))
Unfortunately i just wait for workable code... Title: Re: Background rotation Post by: Patryk Kizny on November 18, 2015, 04:39:43 PM @3dickulus - I think that GL_TEXTURE_CUBE_MAP / GL_SPHERE_MAP / GL_TEXTURE_ENV would be extremely useful to deal with background and IBL maps!
Thanks for posting the information above! Title: Re: Background rotation Post by: 3dickulus on November 19, 2015, 03:13:29 AM Ok, I will add the (related) parameters and options to the parser for cube, sphere, env and add them to the Edit->Insert command menu, if you can test these it would be great!
Very simple examples in that link I posted above, Object Linear, Eye Linear, Sphere Map and Cube Map are intended for GL primitives like a quad or a sphere, I'm not sure exactly how (or if) this will work on fractal objects, but, I think a vertex location in a GL primitive has all the same attributes as in GLSL, xyz, depth, color etc. so it should work? Cube map will be tricky as it uses 6 separate images and needs GL_REFLECTION_MAP or GL_NORMAL_MAP too... after some testing? I'm thinking 4 menu items, Object Linear, Eye Linear, Sphere Map and Cube Map that insert the required texture parameter and option lines using the name of the sampler widget when you select the "Load Texture" button, for cube map the filename would be a basename for 6 files. Another thing is what to map on, I think there are only 3 things to possibly map, floor, sky and fractal object, if floor and object are reflective then there is only one thing to map, sky (env). I don't know if there is any reason this wouldn't work, perhaps some of the more knowledgeable GL hackers can weigh in on this. So, will start simple with an easy one, test, then move on, cube map will be last, I will let you know when I have something in beta for you to try ;) , in the mean time brush up on how these parameters and options work together, it's not as simple as using one parameter with an option, like flipping a switch, it's a combination of the right stuff re: mipmap parameters described above uses 5 lines + the sampler definition. Title: Re: Background rotation Post by: Patryk Kizny on November 20, 2015, 12:25:38 PM If you're already on this, it would be cool to add ability to dynamically load textures w/out recompiling (not sure if it's doable at all).
Also, if there's any chance to hardware blur the map, it would be very useful for IBL diffuse maps - since in most cases they would be same as specular but blurred for performance. Title: Re: Background rotation Post by: 3dickulus on November 20, 2015, 03:42:20 PM recompile is required afaik. I am finding that (of course) this is mostly legacy stuff, fixed pipeline, and this... Code: glBindSampler(0, linearFiltering); So continue building on legacy GL or start thinking about moving to the newer stuff, that means some work to rewrite QGLWidget to QOpenGLWidget to take advantage of newer feartures. bit off more than I can chew, may need a larger cranial cavity... |