Logo by Dinkydau - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. April 26, 2024, 01:11:20 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Background rotation  (Read 1047 times)
0 Members and 1 Guest are viewing this topic.
Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« 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]
uniform bool UseBackgroundPicture; checkbox[false]
uniform vec2 RotatePicXY;slider[(-2.0,-2.0),(0.0,0.0),(2.0,2.0)]
uniform float BackgroundExposure; slider[-3,0,3]
uniform sampler2D texture; file[Ditch-River_Env.hdr]

vec2 spherical(vec3 n) {
return vec2 (acos(n.z)/PI, atan(n.y,n.x)/(2.0*PI) );
}

vec3 getBackground( in vec3 rd ){
vec3 backColor = skyColor;
float theta = 1.57079633;
backColor = texture2D( texture, spherical(normalize(vec3(rd.x,rd.y*cos(theta)-rd.z*sin(theta), rd.y*sin(theta)+  rd.z*cos(theta) ))).yx+RotatePicXY).xyz*(-BackgroundExposure);

}
I looked at IBL-raytracer - code is very similar, and the same problem. It seems that in fact the texture is not rotated, but stretched on the sphere, and the sphere itself is not rotated.

And the question is: How fix 'rotate-mode' on y-axis for rotation with texture sphere? In other words, how to prevent such distortions:


* 1.jpg (37.29 KB, 660x440 - viewed 196 times.)

* 2.jpg (44.52 KB, 660x440 - viewed 193 times.)
Logged

Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #1 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) {
// Normalize, and lookup in equirectangular map.
dir = normalize(dir);
vec2 longlat = -vec2(atan(dir.y, dir.x) + offs.x * 2.0 * PI, acos(dir.z) + offs.y * PI) * scale * 2.0;
return texture2D(sampler, longlat / vec2(2.0 * PI, PI)).xyz;
}

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.

Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #2 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
#TexParameter textureName GL_TEXTURE_WRAP_S GL_CLAMP
#TexParameter textureName GL_TEXTURE_WRAP_T GL_CLAMP
#TexParameter textureName GL_TEXTURE_MAX_LEVEL 1000
#TexParameter textureName GL_TEXTURE_WRAP_S GL_REPEAT
#TexParameter textureName GL_TEXTURE_WRAP_T GL_REPEAT
#TexParameter textureName GL_TEXTURE_MAG_FILTER GL_LINEAR
#TexParameter textureName GL_TEXTURE_MIN_FILTER GL_LINEAR_MIPMAP_LINEAR
...are in Fragmentarium-1.0.15 now

in a frag this should create a mipmapped texture
Code:
uniform sampler2D myTexture; file[test.png]
#TexParameter myTexture GL_TEXTURE_MAX_LEVEL 1000
#TexParameter myTexture GL_TEXTURE_WRAP_S GL_REPEAT
#TexParameter myTexture GL_TEXTURE_WRAP_T GL_REPEAT
#TexParameter myTexture GL_TEXTURE_MAG_FILTER GL_LINEAR
#TexParameter myTexture GL_TEXTURE_MIN_FILTER GL_LINEAR_MIPMAP_LINEAR

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


* test-texture-1.jpg (20.9 KB, 640x360 - viewed 190 times.)

* test-texture-2.jpg (17.68 KB, 640x360 - viewed 201 times.)
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #3 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?
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« Reply #4 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...
Logged

Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #5 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!
Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #6 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 wink , 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.

Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #7 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.
« Last Edit: November 20, 2015, 01:28:51 PM by Patryk Kizny » Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #8 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);
...is how things are being done now on newer hardware GL 3.3+. Fragmentarium does not use glBindSampler but perhaps should, because it is simple to add filtering etc.
 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...
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Rotation Animation Let's collaborate on something! « 1 2 » Wel lEnTaoed 15 4072 Last post November 22, 2010, 01:53:15 PM
by Bent-Winged Angel
An Inner Rotation of the Box Images Showcase (Rate My Fractal) Chaos_Ink 0 1076 Last post September 25, 2012, 04:49:48 PM
by Chaos_Ink
The black art of rotation Help & Support Dermis 3 294 Last post January 08, 2013, 10:47:59 PM
by cKleinhuis
Spherical Rotation feature request Rowratty 0 860 Last post June 30, 2013, 07:00:27 PM
by Rowratty
Rotation Mandelbulb 3d metalion 12 3504 Last post May 20, 2017, 09:52:56 PM
by agirl_yo

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.193 seconds with 25 queries. (Pretty URLs adds 0.013s, 2q)