Logo by reallybigname - 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: Visit us on facebook
 
*
Welcome, Guest. Please login or register. April 20, 2024, 06:49:49 AM


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: Frag / GLSL newbie questions  (Read 1244 times)
0 Members and 1 Guest are viewing this topic.
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« on: July 19, 2015, 11:12:20 AM »

I am trying to integrate imported camera movements into frag.
I am using array-structured data accessed via time variable. Seems easy.
Now I have a few newbie questions as I don't have any deeper GLSLS knowledge.

- I found that things which sit in #vertex section are somewhat isolated - i.e. If any variables are defined elsewhere I can't seem to be able to access it.  So it looks like there's a #vertex part and everything else. Can one let me know something more about it?

- Also it looks like I am unable to use #ifdef inside of #vertex. Can one explain?

- I'd like to understand more in what order the code executed and what are best places to put statements that I want to be executed on entering a new frame (that's what I need for camera and some other things). Is there any documentation for what is the order

→ when exactly are init() parts executed?
→ how often and when are main() executed?
→ when are unbound statements executed? I mean bits of code which are not sitting within any functions body? Like declaring a variable and assigning it a value.

How much of it is general GLSL and which are the parts that are specific to fragmentarium?

Finally, when I messed a bit with within the #vertex part in 3D.frag I am getting warnings that I have used too many temp constants and it may negatively affect performance.

If any of it is general GLSL that I can google for, please save your time and don't elaborate.

Thank you for your help.




Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #1 on: July 19, 2015, 02:01:48 PM »

So, for once, just google glsl tutorial and use the lighthouse3d tutorial

some hints:

vertex shader code is executed before pixel shader, there is some kind of mahic going on, because the vertex shader is just executed for every vertex, w.g. the four sides of a quad, everything that is returned is then beeing interpolated, e.g. the texture coordinates are different for every pixel

The main() function is the entry point for both, pixel and vertex

code is not executed, but calculated wink everything outside of functions is global and evaluated before the code is executed

uniform variables - if defined in both shaders -are accessible in not, uniforms are outside inputs to a shader

a varying variable can be used to communicate between vertex pixel shader

glsl has basic directives like define and ifdef

the include statement is provided by fragmentarium

Logged

---

divide and conquer - iterate and rule - chaos is No random!
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #2 on: July 24, 2015, 02:28:57 PM »

In general if I need to do a lot of calculations that I need to feed later to Vertex shader, how should I approach it?
Can I call functions outside of #vertex from inside? What would be a recommended workflow?
I already have a bit of overkill on the vertex side so wanted to optimize it as much as possible.
Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #3 on: July 25, 2015, 12:23:49 AM »

It is a good question - this has been discussed before, and I don't think there is an easy way. I'm actually surprised you could even store all the camera data in the vertex shader source. You could of course do calculations on the C++ side (or from the Qt JavaScript interface), and send them to shader using uniforms (or uniform buffers), but that is tedious, since you will miss the nice matrix/vector syntax in GLSL.
Logged
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #4 on: July 25, 2015, 02:26:09 AM »

Yeah, ideally would be on a C++ side, but I never coded in C++ and it would take me ages to learn it and learn how frag is written.
Ideally you'd load a text file into interface to grab the camera from it.

So probably I'll stick to #vertex consts (which DO NOT compile on some machines as reported above) or switch to JS.
Logged

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



WWW
« Reply #5 on: July 25, 2015, 05:02:47 AM »

all variables that get created in the fragment source that are also in the variable editor GUI like sliders etc. are available for reading and writing in Fragmentarium Qt Script a.k.a. "fqs", a hybrid of Qt + javascript + app functions smiley
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
Orbit Trap in GI frag Fragmentarium « 1 2 3 » vinz 38 7419 Last post June 20, 2013, 07:48:01 PM
by vinz
Frag to GPU asm dump Fragmentarium « 1 2 3 » 3dickulus 30 7034 Last post June 16, 2015, 02:02:23 AM
by 3dickulus
Mandelbulber 2.06 Newbie questions about settings files Help & Support Phil J 9 763 Last post March 07, 2016, 12:49:42 AM
by cKleinhuis
Mandelbulber 2.06/2.07 newbie questions about creating animations Help & Support Phil J 2 392 Last post April 25, 2016, 01:51:45 AM
by Phil J
Abox minR2 tweaking frag Amazing Box, Amazing Surf and variations mclarekin 0 2411 Last post July 26, 2017, 03:18:00 PM
by mclarekin

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.229 seconds with 25 queries. (Pretty URLs adds 0.011s, 2q)