Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textures #29

Open
weepy opened this issue Jan 23, 2018 · 10 comments
Open

textures #29

weepy opened this issue Jan 23, 2018 · 10 comments

Comments

@weepy
Copy link

weepy commented Jan 23, 2018

Is it possible to import image textures ?

@ChronoAndross
Copy link

Well from the looks of it, it looks like texture2D is supported within the editor, but currently can't be used for anything since there is no option to import image textures. I think on the main page of glslEditor, there is a request to create a texture editor, so I can look into this from my end and see what I can do.

@weepy
Copy link
Author

weepy commented Jan 29, 2018

that'd be awesome.

@weepy weepy closed this as completed Jan 29, 2018
@weepy weepy reopened this Jan 29, 2018
@patriciogonzalezvivo
Copy link
Owner

Hi! GlslEditor supports textures... you just have to write the URL as a comment next to texture uniform. http://editor.thebookofshaders.com/?log=180130173243

Also watch out for CORS!

@weepy
Copy link
Author

weepy commented Jan 30, 2018 via email

@ChronoAndross
Copy link

Hey @patriciogonzalezvivo ,

I noticed that this feature was not known to many, myself included. To rectify this, I am currently writing some code that clearly shows to the user that you can import images via an "Import" button. The "Import" button contains two dropdowns, one says "Import Image URL..." and the other says "Import Image from Local Storage..." Once the image is imported, the image will have a texture uniform of "u_tex" + whatever number of image that is imported into the scene.

Is it okay if I maintain my course in writing this code and submit a pull request for this? I will need a couple more hours to fully implement this feature.

Thanks for your hard work!

@weepy
Copy link
Author

weepy commented Feb 1, 2018 via email

@patriciogonzalezvivo
Copy link
Owner

@weepy yes... any format that the browser can transform into a texture is supported
@ChronoAndross sounds great! Would like to sync on the UI when you have a moment. How do you imagine? At the end of the day should be pass as a comment next the uniforms. So the glslCanvas can open it even in "player" mode.

@ChronoAndross
Copy link

@patriciogonzalezvivo I can post the UI when I get home (just leaving work now) but yes, if the file can be opened successfully, it should be placed as a comment next to the uniform named "utex_(#texture)", the newly created texture based on the user's imported image.

And then your code will run as usual.

@patriciogonzalezvivo
Copy link
Owner

sounds great

@ChronoAndross
Copy link

@patriciogonzalezvivo

Here's what the new page will look like with my new code:
screen shot 2018-02-03 at 4 46 05 pm

Notice the new "Import" button at the top there. It contains a drop down which contains 2 new options: "Import Image URL..." and "Import Local Image..." After pressing "Import Local Image...", the user will see the following:
screen shot 2018-02-03 at 4 46 58 pm

After the user selects an image, it will load it into the current shader with the name "u_tex" + the number of the active texture. The first texture that is loaded should be 0, so textures should be numbered from 0 -> n number of textures that are loaded.

If it notices "u_tex + the number of the active texture" is already in the shader, it will replace the comment that is already there for convenience. Here what my image looked like after I loaded it with my option:
screen shot 2018-02-03 at 4 46 25 pm

When loading an image via a URL, the user is prompted to insert an image:
screen shot 2018-02-03 at 4 46 43 pm

There's one problem with it I'm seeing thus far: I'm currently not catching the CORS failures if they happen since they get rejected way far down into the code. I can probably fix this bug if you want me to. But otherwise, I think it's ready.

Do you want me to submit a pull request for my changes to prepare to merge?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants