Jump to content

Converting a shader from shadertoy (iResolution variable)


thrice
 Share

Recommended Posts

So, I'm trying to convert a shader from shadertoy, I'm close but still can't get it working. Also in my actual scene it doesn't seem to be working at all, but it's hard to tell if it's related to the issue I am having w conversion, since I need to rotate the sphere to get it to show up to begin with. Shader is here: (it appears blank at first, but if you rotate it youll start to see the fire. The actual effect I am going for you will see only if you rotate it just right so that you see the fire starting with the white in the middle, and it filling up the sphere).

http://cyos.babylonjs.com/#M11GKA

The source shader is here:

https://www.shadertoy.com/view/lsf3RH

So the one place I was not sure how to proceed, was mapping over the iResolution variable (which shadertoy states is the viewport resolution). I played around with a bunch of different things and ended up trying the camera input, which works, but requires rotating the mesh to see it at all.

Anyone know what input would map over to viewport resolution (or how to get it), and or what I am doing wrong/missing here? 

 

Link to comment
Share on other sites

Hey there. iResolution is being used to normalize the fragment's coordinates,  to be in the range 0 to 1. You can use vUV.xy in place of (fragCoord.xy / iResolution.xy), vUV is already in the 0 to 1 range. Also you don't need the x*=x/y part since you want to fill the whole texture (you can experiment with commenting out that line on ShaderToy to see how it will fill the whole screen).

Here's a fork of your demo to show what I mean. I changed only the line that calculates p and removed the x*=x/y line.

Link to comment
Share on other sites

On 9/2/2017 at 1:12 PM, magig said:

Hey there. iResolution is being used to normalize the fragment's coordinates,  to be in the range 0 to 1. You can use vUV.xy in place of (fragCoord.xy / iResolution.xy), vUV is already in the 0 to 1 range. Also you don't need the x*=x/y part since you want to fill the whole texture (you can experiment with commenting out that line on ShaderToy to see how it will fill the whole screen).

Here's a fork of your demo to show what I mean. I changed only the line that calculates p and removed the x*=x/y line.

@magigAhhh! Thanks a ton! This shader stuff is intense, still trying to wrap my brain around it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...