Sample scene:
Set left viewport to rendered shading mode and change the clipping mode in the node and the alpha settings in the properties panel.
Differential D2043
Image texture node: Enable clipping and alpha representation for GLSL viewport Authored by Ralf Hölzemer (cheleb) on May 31 2016, 10:17 PM.
Details
Sample scene: Set left viewport to rendered shading mode and change the clipping mode in the node and the alpha settings in the properties panel.
Diff Detail Event TimelineComment Actions I'm not sure if this is an appropriate place for asking a question, but would it be possible to enable clip and extension mapping modes in Blender Internal texture as well? I hope it isn't difficult to implement and it will greatly help with placing decals and other similar tasks. Comment Actions There are two issues here. First one is that clipping will cause leakage of a wrapped pixels to the border one, you will need somewhat similar trick as for extension. Second issue is that textureSize() is not currently usable on OSX, see rBcccd06e for details. I'm also not sure we want to do such things in shader itself, this is similar to an interpolation method which should be done using glTexParameteri(). Comment Actions Hey Sergey, i finally found some time to dig deeper into this.
Fixed in the new diff. Thanks for pointing that out.
That i didn't know. Proposed solution below.
Please note that i am more of an artist than a developer, so all of this could be totally wrong! :) It took me some time to get a grip on what is necessary to make things happen via glTexParameteri(). So i did a quick and dirty new function "GPU_texture_wrap_mode" in GPU_texture.c which would set a new wrap mode for img->gputexture[0] in node_shader_tex_image.c. This worked well for an image with just one user, but did not work for multiple image nodes using the same image because they (obviously) would all point to the same GPUTexture. Therefor, when the extend mode changed in one instance of an image node, all other instances would also change. I tried to come up with a nice solution for that problem but couldn't find anything satisfying. I am sure there is a nice solution, but it seems to me that it would be quite involved. As I said, I could be wrong - still learning. :) So, to keep it simple, the next patch still does everything in the shader and solves the textureSize() problem by simply querying the Image in node_shader_gpu_tex_image and pass that information down to image_texture_lookup in gpu_shader_material.glsl Comment Actions Just in case it will help with something: I have found out that there is a way to turn extend mapping in 3D viewport in Blender's UV\Image editor. I don't understand how exactly that works, but still. The problem is that this option wouldn't stay enabled after reloading so you'll have to manually turn it back on for every clamped\extended image. I was thinking about forming a bug report on this, but I'm not sure if that's supposed to work like that.
I'm using BI render, but if it will be implemented in Cycles that would be nice too. Since this function kind of works, perhaps it would be possible to make it properly clip the image, link it to image texture properties somehow and make this option stay on after reload? |