<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with texturesampling() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=texturesampling%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:02:49 +0000</pubDate>
         <description>Tagged with texturesampling() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedtexturesampling%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Problems with FX2D</title>
      <link>https://forum.processing.org/two/discussion/26055/problems-with-fx2d</link>
      <pubDate>Sun, 21 Jan 2018 00:42:27 +0000</pubDate>
      <dc:creator>grothcrafter</dc:creator>
      <guid isPermaLink="false">26055@/two/discussions</guid>
      <description><![CDATA[<p>I have some problems with FX2D.</p>

<p>It's a great renderer and its snapy as hell but some functions won't work.</p>

<p>The biggest problem I have is that 'smooth' and 'noSmooth' hase no effect.</p>

<p>In my code I scale an image for the background, it's for a 8 bit style game, but because of the anti aliasing it looks like shit.</p>

<p>Also it seems like the mouseWheel function doesn't works, thats weard to.</p>

<p>Has any body found a work around for theese problems?</p>

<p>It would be nice to be able to use FX2D for that because the framerate compared to the other renderers is just impressiv.</p>
]]></description>
   </item>
   <item>
      <title>noSmooth() isnt working in P3D :(</title>
      <link>https://forum.processing.org/two/discussion/24084/nosmooth-isnt-working-in-p3d</link>
      <pubDate>Sun, 10 Sep 2017 12:03:49 +0000</pubDate>
      <dc:creator>GeorgeJava</dc:creator>
      <guid isPermaLink="false">24084@/two/discussions</guid>
      <description><![CDATA[<p>Why is in P3D &gt; size(w,h,P3D) &lt; doesnt working noSmooth ? :/ i have pixel art and i resize image 2x. and i have noSmooth(). because isnt working... pls help, thx..</p>
]]></description>
   </item>
   <item>
      <title>Image Texture Mode strange Mapping 360</title>
      <link>https://forum.processing.org/two/discussion/22443/image-texture-mode-strange-mapping-360</link>
      <pubDate>Sun, 07 May 2017 17:23:34 +0000</pubDate>
      <dc:creator>nabr</dc:creator>
      <guid isPermaLink="false">22443@/two/discussions</guid>
      <description><![CDATA[<p>I tested this code with other frameworks/engines It works fine.</p>

<p>In processing with different images/videos etc. you can see a line going through the screen</p>

<p>I guess, it's the default texture mode. Maybe a user already got a workaround</p>

<p>Any help is much appreciated.</p>

<p>Copy +Paste press Play</p>

<pre><code>//Vertex 
String[] vertSource={"#if __VERSION__ &gt;= 150" //check backward compatible /mobile
  , "#define attribute in"
  , "#define varying out" 
  , "#endif"
  , "#ifdef GL_ES"
  , "precision mediump float;"
  , "precision mediump int;"
  , "#endif"

  //attribute
  , "in vec4 position;"
  //uniforms
  , "uniform mat3 Ry;"
  , "uniform float pitch;"
  //varying
  , "out vec3 refDir;"

  , "void main() {"
  , "gl_Position = vec4(position.xy,0, 1.);"

  //apply Rotation Matix
  , "refDir = Ry*vec4(position.xy,1.,0).xyz;"
  , "}"
};

//Fragment
String[] fragSource={"#if __VERSION__ &gt;= 150" //check backward compatible /mobile
  , "#define attribute in"
  , "#define varying out" 
  , "#define texture(a,b) texture2D(a,b)"
  , "#endif"
  , "#ifdef GL_ES"
  , "precision mediump float;"
  , "precision mediump int;"
  , "#endif"

  //attribute
  , "in vec3 refDir;"
  //uniforms
  , "uniform sampler2D envmap;"
  //varying
  , "out vec4 fragColor;"

  , "#define PI 3.14159273"

  , "void main () {"

  //map texture to sphere: &lt;a href="<a href="https://github.com/mrdoob/three.js/issues/1621" target="_blank" rel="nofollow">https://github.com/mrdoob/three.js/issues/1621</a>" target="_blank" rel="nofollow"&gt;<a href="https://github.com/mrdoob/three.js/issues/1621&lt;/a&gt" target="_blank" rel="nofollow">https://github.com/mrdoob/three.js/issues/1621&lt;/a&gt</a>;
  , "float lat = atan(refDir.z,refDir.x);"
  , "float lon = acos(refDir.y/length(refDir));"
  , "fragColor = texture(envmap,vec2(.5+lat/(2.0*PI),lon/PI));"
  , "}"
};

PShader shader;
PImage img;
PMatrix3D rotY = new PMatrix3D();

void setup() {
  //setup scene
  size(640, 360, P3D);

  //load frag/vert Source
  shader=new PShader(this, vertSource, fragSource);

  //load equirectangular Image
  //<a href="https://www.flickr.com/search/?l=commderiv&amp;q=equirectangular" target="_blank" rel="nofollow">https://www.flickr.com/search/?l=commderiv&amp;q=equirectangular</a>
  String https="https://"; //processing forum resolve links automatically - workaround to avoid it
  img = loadImage(https+"c1.staticflickr.com/8/7178/7019373941_c1f2402f06_h.jpg");
}
void draw() {

  //map mouse to a range form - to
  float p=map(mouseX, 0, width, HALF_PI, -PI);

  //uncomment for 360 rotation
  //p=(float)millis()*.001f;

  //rotation to mouse
  float s=sin(p), c=cos(p);

  //uniform Rotation Matrix
  shader.set("Ry", rotY, true);

  //reset to NULL
  rotY.reset();
  //Rotation (pitch) "<a href="http://planning.cs.uiuc.edu/node102.html/" target="_blank" rel="nofollow">http://planning.cs.uiuc.edu/node102.html/</a>
  rotY.apply(
    c, 0, s, 0, 
    0, 1, 0, 0, 
    -s, 0, c, 0, 
    0, 0, 0, 1);

  //clear
  background(0);

  //uniform texture image
  shader.set("envmap", img);

  //apply filter to scene
  filter(shader);
}
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/691/B4E3E0OA8T1M.PNG" alt="eqi-img-processing" title="eqi-img-processing" /></p>
]]></description>
   </item>
   <item>
      <title>How can I achieve noSmooth() with the P3D renderer ?</title>
      <link>https://forum.processing.org/two/discussion/21564/how-can-i-achieve-nosmooth-with-the-p3d-renderer</link>
      <pubDate>Thu, 23 Mar 2017 20:22:08 +0000</pubDate>
      <dc:creator>orgicus</dc:creator>
      <guid isPermaLink="false">21564@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'd like to render basic 3D shapes without any aliasing/smoothing with a PGraphics instance using the P3D renderer, but noSmooth() doesn't seem to work.</p>

<p>In OF I remember calling <code>setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);</code> on a texture.</p>

<p>What would be the equivalent in Processing ?</p>

<p>Thank you,
George</p>
]]></description>
   </item>
   <item>
      <title>Packing float into sampler2D</title>
      <link>https://forum.processing.org/two/discussion/20736/packing-float-into-sampler2d</link>
      <pubDate>Fri, 10 Feb 2017 18:41:04 +0000</pubDate>
      <dc:creator>bradcoleman</dc:creator>
      <guid isPermaLink="false">20736@/two/discussions</guid>
      <description><![CDATA[<p>Hi everybody,</p>

<p>Was hoping anybody here could help me with this...
For a project I want to pack data into a texture and use it in a fragment shader because it can potentially be a lot of data.
Thing is... I need the data as floats in my shader code but I can't seem to get it right.</p>

<p>I wrote a little test case below which illustrates my problem. 
The goal of this sketch is to make the left half of the screen white and the right half of the screen black. That would be the case if the data passed via the texture would be interpreted correctly.</p>

<p>Tried a lot of methods to pack/unpack data, but I'm thinking I got it wrong on the processing side of things. I also noticed that when using println(pixels[0]), the value that gets printed is NOT the same as Float.floatToIntBits gives... so something get's changed.</p>

<p>Anyway, if anybody knows the correct way of passing float values to a shader via a texture and unpacking them from vec4 to float I would be really grateful. Thanks!</p>

<p>Processing sketch:</p>

<pre><code>PShader shader;
PImage sampler;

void setup() {
  size(1280, 720, P2D);

  shader = loadShader("shader.glsl"); 
  shader.set("resolution",1280,720);

  // no texture interpolation
  ((PGraphicsOpenGL)g).textureSampling(3);

  sampler = createImage(2,1,ARGB);   
  sampler.loadPixels();
  sampler.pixels[0]=Float.floatToIntBits(5); // left half of screen &lt; 1
  sampler.pixels[1]=Float.floatToIntBits(15); // right half of screen &gt; 10
  sampler.updatePixels();

  shader.set("sampler",sampler);
}

void draw() {
  filter(shader);
}
</code></pre>

<p>Shader code:</p>

<pre><code>                uniform sampler2D sampler;
                uniform vec2 resolution;

                const vec4 bitEnc = vec4(1.,255.,65025.,16581375.);
                const vec4 bitDec = 1./bitEnc;

                float DecodeFloatRGBA (vec4 v) {
                    return dot(v, bitDec);
                }

                void main(){
                  vec4 test = texture2D(sampler,gl_FragCoord.xy/resolution);
                  float testfloat = DecodeFloatRGBA(test);

                  if (testfloat&lt;10){
                    gl_FragColor=vec4(0,0,0,1);
                  }
                  else{
                    gl_FragColor=vec4(1,1,1,1);
                  }
                }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Resize image without any smoothing</title>
      <link>https://forum.processing.org/two/discussion/21391/resize-image-without-any-smoothing</link>
      <pubDate>Tue, 14 Mar 2017 13:39:33 +0000</pubDate>
      <dc:creator>Kaggen</dc:creator>
      <guid isPermaLink="false">21391@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I'm trying to resize an image and display it without any smoothing (mipmap, bicubic, linear or other).</p>

<p>The point is i want it to stay "pixelated" (sharp pixels). See picture below...</p>

<p>I'm using P2D.</p>

<p>Any ideas?</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/754/MSI82ZARDJ4S.PNG" alt="resize" title="resize" /></p>
]]></description>
   </item>
   <item>
      <title>Grey Lines Around the Edges of Transparent Images</title>
      <link>https://forum.processing.org/two/discussion/18218/grey-lines-around-the-edges-of-transparent-images</link>
      <pubDate>Tue, 20 Sep 2016 00:34:22 +0000</pubDate>
      <dc:creator>Ystem</dc:creator>
      <guid isPermaLink="false">18218@/two/discussions</guid>
      <description><![CDATA[<p>When I draw an image with transparent edges, the renderer (I am using P3D) is drawing a thin grey line around the border of the image, which is visible despite the fact that the edges of the image are transparent. There are also some other wierd grey lines around various images. Does anyone know how to fix this?</p>

<p>I have found other posts about this issue on the processing forum:
<a rel="nofollow" href="https://forum.processing.org/one/topic/transparent-png-issue.html">https://forum.processing.org/one/topic/transparent-png-issue.html</a>
And of this and similar issues on openGl forums:
<a rel="nofollow" href="https://www.opengl.org/discussion_boards/showthread.php/167808-2D-texture-problem-lines-between-textures">https://opengl.org/discussion_boards/showthread.php/167808-2D-texture-problem-lines-between-textures</a>
<a rel="nofollow" href="https://www.opengl.org/discussion_boards/showthread.php/178038-Black-lines-at-edges-of-textures">https://opengl.org/discussion_boards/showthread.php/178038-Black-lines-at-edges-of-textures</a></p>

<p>The post on the processing forum does not have a solution (and isn't really the same problem). It seems there might be a way to fix this by adjusting OpenGL settings, but I don't know how to do that with processing.
I am using OpenGL because I have to render a very large number of pixels in 3D space every frame, and I doubt other renderers will work as well.
Here are some images (I scaled some of these up to show the problem, the lines are all exactly 1 pixel in the original (they seem to actual be one pixel on my retina display, not one processing pixel):</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/960/LUQ8JJ2VGQ2Y.png" alt="Screen Shot 2016-09-19 at 6.21.35 PM" title="Screen Shot 2016-09-19 at 6.21.35 PM" /></p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/326/FKRRPAI8LM6A.png" alt="Screen Shot 2016-09-19 at 6.31.56 PM" title="Screen Shot 2016-09-19 at 6.31.56 PM" /></p>

<p>The lines in the middle of these images are added by the renderer, they are at the edge of a partially transparent image.</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/942/HXNOSR7UD08N.png" alt="Screen Shot 2016-09-19 at 6.17.20 PM" title="Screen Shot 2016-09-19 at 6.17.20 PM" /></p>

<p>This is the border between two images (each drawn on a textured polygon, with uv mapping). The black line in the middle is not part of either image. That line is not on the edge of where the image is being drawn, but on the edge of the opaque part of an image. This image also has a line on the very edge.</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/713/BS2O46VNNKJA.png" alt="Screen Shot 2016-09-19 at 6.21.35 PM copy" title="Screen Shot 2016-09-19 at 6.21.35 PM copy" /></p>

<p>The borders between some textures without any transparency still get weird lines.</p>
]]></description>
   </item>
   </channel>
</rss>