patriciogonzalezvivo / glslViewer

Console-based GLSL Sandbox for 2D/3D shaders
BSD 3-Clause "New" or "Revised" License
4.62k stars 350 forks source link

How to render a single frame? #274

Closed AyushKoul00 closed 2 years ago

AyushKoul00 commented 2 years ago

Like shadertoy, I just want to run my fragment shader and render a single frame (in shadertoy, I can just hit pause). Can I do something like that in this?

gschian0 commented 2 years ago

Pay attention to the number on the time step and just enter it instead of using the time variable for now... I'm sure there is a non hack way too 😎 but I'm not familiar.

AyushKoul00 commented 2 years ago

@gschian0 could you write the command of what you mean? I am sorry I am new to this

gschian0 commented 2 years ago

Instead of using "u_time" variable enter any floating decimal number with the decimal point. ... "0.0" to start?

gschian0 commented 2 years ago

If you're using sin...

sin(2.* 3.1415 + (u_time));

To..

sin(2. * 3.1415 + 0.0);

patriciogonzalezvivo commented 2 years ago

Yes, probably you want to check the test examples:

cd examples/2D/00_test
glslViewer test.frag in.png -e screenshot,screenshot.png

This will run the example and create a screenshot.png image of the first frame. Like @gschian0 said, if you don't use u_time or any other time dependent variable your image will be static. You can always use the screenshot,image.png command on the console interface to make a new screenshot.

Cheers!

AyushKoul00 commented 2 years ago

@patriciogonzalezvivo you mentioned that if i dont use time in my code, it will be static. But internally, will the shader still run each frame? The reason i am asking is, i am trying to create a ray tracer and i only want it to render once because making it render each frame will be very slow. So even if the scene is static, if my shader is called each frame internally, then it still would be slow

patriciogonzalezvivo commented 2 years ago

If there is no u_time, u_mouse or u_data on your code or videos loaded, glslViewer don't render all the time.