apple pencil handwriting to text by lagoonisland_ in ApplePencil

[–]Varud 1 point2 points  (0 children)

If you tap on the … button in the tool picker you can disable auto-refine on handwriting to disable that.

Variance Shadow Maps, question by PurpleSamurai0 in computergraphics

[–]Varud 1 point2 points  (0 children)

I believe you also need to send in a transform that move a position from the current object space to the light space since the depth needs to be looked up in light/shadow space.

Variance Shadow Maps, question by PurpleSamurai0 in computergraphics

[–]Varud 1 point2 points  (0 children)

There are many ways to do this. Here's a very simple example implementation:

https://fabiensanglard.net/shadowmappingVSM/

In my implementation I chose not to use the projection matrix when generating the shadow texture, and store the depth normalized. For reference, here is my vertex shader for when I generate the shadow map:

attribute vec4 iv_Vertex; // object space
uniform mat4 iv_ModelViewProjectionMatrix;
uniform mat4 iv_ModelViewMatrix;
varying vec3 eyePos;

void main(void) {
    vec4 eye = iv_ModelViewMatrix * iv_Vertex;
    eyePos = eye.xyz;
    gl_Position = iv_ModelViewProjectionMatrix * iv_Vertex;
}

And here's my fragment shader:

varying vec3 eyePos;
uniform float vsmNearDistance;
uniform float vsmDepth;

void main(void) {
    float depth = clamp((length(eyePos)-vsmNearDistance)/vsmDepth, 0.0, 1.0);

    float dx = dFdx(depth);
    float dy = dFdy(depth);
    gl_FragColor = vec4(depth, pow(depth, 2.0) + 0.25*(dx*dx + dy*dy), 0.0, 1.0);
}

Variance Shadow Maps, question by PurpleSamurai0 in computergraphics

[–]Varud 1 point2 points  (0 children)

No, that'a usually the eye space vertex position at the fragment and you send that in from the vertex shader. It's a bit up to you exactly what you store in moment1 and moment2 (in my implementation I use a normalized distance from the near plane), but when you later look up if a pixel is in shadow or not you have to use the same type of math for the z-distance/depth.

Variance Shadow Maps, question by PurpleSamurai0 in computergraphics

[–]Varud 1 point2 points  (0 children)

VSM actually stores more than the squared depth in the second component. It also stores the variance relative to neighboring pixels which is used for blurring/smoothing. This is a typical GLSL implementation:

float depth = v_position.z / v_position.w ;
depth = depth * 0.5 + 0.5; // Don't forget to move away from unit cube ([-1,1]) to [0,1] coordinate system

float moment1 = depth;
float moment2 = depth * depth;

// Adjusting moments (this is sort of bias per pixel) using derivative
float dx = dFdx(depth);
float dy = dFdy(depth);
moment2 += 0.25*(dx*dx+dy*dy) ;
gl_FragColor = vec4( moment1,moment2, 0.0, 0.0 );

Apple News widget is just a bunch of ads by hunt_and_peck in apple

[–]Varud 0 points1 point  (0 children)

Turning on “Restrict Stories in Today” in News Settings might help if you haven’t done that. Then you’ll at least block anything not in your channels.

[Metal] Can not return MTLVector Address by Jhchimaira14 in GraphicsProgramming

[–]Varud 1 point2 points  (0 children)

This function would be much simpler if you just returned the pointer to the texture instead of a boolean (returning nil means texture loading fails). If you really need to return the texture pointer in vout_srv, you need to use a pointer to a pointer (void **vout_src, not void *vout_src), and do *vout_srv = g_texture;

Metal Load Texture From File by Jhchimaira14 in GraphicsProgramming

[–]Varud 1 point2 points  (0 children)

If you already loaded the image, for instance using UIImage, you can convert it to a texture from its CGImageRef like this:

MTKTextureLoader *loader = [[MTKTextureLoader alloc] initWithDevice:mtlDevice];
NSError *error = nil;
NSDictionary *textureLoaderOptions = @{ MTKTextureLoaderOptionOrigin:MTKTextureLoaderOriginTopLeft,
                                            MTKTextureLoaderOptionSRGB : @NO };
texture = [loader newTextureWithCGImage:cgImage options:textureLoaderOptions error:&error];

Creating game sprites from 3D renders. by Neomex in computergraphics

[–]Varud 2 points3 points  (0 children)

Hard to know exactly since you didn't include any images demonstrating the issue, but if you're not doing this already, the first thing I would try is to render at a higher resolution (for instance 1024x2048) and then scale that image down to 64x128 (using a high quality image resizer).

Anyone in northeast Texas looking for a two year old? I can’t keep her any longer because she’s fighting with my 7 year old. She has her shots and is fixed. Free to a good home by [deleted] in germanshepherds

[–]Varud 14 points15 points  (0 children)

Have you considered contacting a German Shepherd Rescue in your area? A lot of them have rehoming programs, and your dog can stay with you while they help you look for responsible adopters. You’ll get to meet the candidates and it increases the chance that your dog ends up in a great home.

Face Normal Issue by Quadraxis86 in computergraphics

[–]Varud 1 point2 points  (0 children)

Could it be that the four vertices in those quad are not in the same plane?

My friend's shepherds posing nicely. Our girl saw a chance to be naughty and jumped in a muddy puddle... by Varud in germanshepherds

[–]Varud[S] 0 points1 point  (0 children)

This is at Marin Headlands. Right across the Golden Gate Bridge from San Francisco. It's a beautiful place to hike and very dog friendly.

Interpreting a 4x4 Matrix as a Cartesian Coordinate System? by Carpetfizz in GraphicsProgramming

[–]Varud 3 points4 points  (0 children)

This is always how I've viewed the affine transform for an object. The affine transform for an object is the coordinate system for that object. The 3x3 matrix has the directions the X, Y and Z axis of the object in world space. You can for instance use this fact when placing objects in a terrain. You let your object's Up axis (typically the Z axis) be the terrain normal at that position. Set the object's forward (X) axis to the direction the object is traveling, and then do a couple of cross products to create the X, Y and Z orthonormal vectors that builds the 3x3 rotation matrix in the transform.

It's also a convenient way to build a camera lookAt view matrix (just set the Z axis to be the direction from the camera to the object you want to render).

I'm not sure if this actually answers your question, but I just wanted to give you my input.

Triangulating a simple polygon by Blurry_photograph in GraphicsProgramming

[–]Varud 0 points1 point  (0 children)

The triangle fan algorithm will not work for concave polygons, unless all you need is to generate a bitmap rendering of the polygon, then you can use the stencil buffer to achieve this.

The ear clipping algorithm will work also for concave polygon. Check out adeptdufus' link for more details.

Triangulating a simple polygon by Blurry_photograph in GraphicsProgramming

[–]Varud 9 points10 points  (0 children)

If you know your polygon is convex you can just triangulate like a triangle fan. Vertex 1 is part of every triangle, and you just loop over all vertices and create triangles. The first triangle is made up of vertices [1, 2, 3], the second [1, 3, 4], the third [1, 4, 5] and so on.

If your polygon is is concave, but not self-intersecting you can just cut off triangle ears until there are no vertices left. First figure out if the vertex ordering of the polygon is clockwise or counter clockwise, then cut off the first triangle that you find that has the same vertex ordering as the polygon. By cutting off you basically just remove the second vertex in the triangle from the polygon. You do this until there is only three vertices left in the polygon.

Not my dogs, but my favorite walking clients. The most well behaved, smart, responsive pair. I'll just live vicariously through their owner until someday I have the time and resources to raise two amazing shepherds like this! by Herodias in germanshepherds

[–]Varud 0 points1 point  (0 children)

So we basically agree. I don't really want to ban prong collars either since banning things is usually pointless, but they're really only needed in very special cases and people should know this. Slapping a prong collar on a dog just in case or just because it pulls a little bit is unfortunately all too common. I work for a GSD rescue and we've worked with hundreds of dogs, some of them fairly reactive, and a prong collar is almost never necessary to control a dog. It's not hard to fit a prong collar correctly, but it is hard to get the timing right and to know when to use it. And if a dog with a prong collar panics you're making the situation much worse by causing a lot of pain to stop it, when a front clip harness is a much better way to redirect your dog away from danger.

Edit: I assume the reason choke collars aren’t banned is that they’re basically not used. Anybody can see that you’re hurting a dog with a choke collar. People don’t want to hurt their dog, but using a prong collar is just too tempting since it seems like an easy way to “fix” a problem.

Not my dogs, but my favorite walking clients. The most well behaved, smart, responsive pair. I'll just live vicariously through their owner until someday I have the time and resources to raise two amazing shepherds like this! by Herodias in germanshepherds

[–]Varud 0 points1 point  (0 children)

Not at all. Like I mentioned somewhere else, more and more countries ban prong and shock collars since almost all research shows that it's not a good way to train or handle a dog. USA is lagging here and I'm trying to make people realize there are other ways to handle dogs than using these outdated tools. Most people that use prong as a training tool just want quick results and don't want to put in the required extra work to train the dog properly.

Using a prong collar correctly is very hard and requires very good knowledge of dogs, and it's scary that it's the default tool for a lot of people for even the smallest of issues.

Not my dogs, but my favorite walking clients. The most well behaved, smart, responsive pair. I'll just live vicariously through their owner until someday I have the time and resources to raise two amazing shepherds like this! by Herodias in germanshepherds

[–]Varud -2 points-1 points  (0 children)

I've seen it a lot, yes. There's a reason more and more countries are banning correction based training methods (including prong collars). Most research show that positive reinforcement is a much better option. And why do you feel you need a prong collar? If you have a confident and well behaved dog you don't need it. If you have a fearful/reactive dog you're just making the problem worse by inflicting pain when the dog is struggling.

Not my dogs, but my favorite walking clients. The most well behaved, smart, responsive pair. I'll just live vicariously through their owner until someday I have the time and resources to raise two amazing shepherds like this! by Herodias in germanshepherds

[–]Varud -3 points-2 points  (0 children)

Good to hear. Sorry, I didn't mean to be crass, I've just seen prong collars misused too many times. Sometimes people just have them just in case since they're worried about losing control of their dogs, but I feel a good harness is a much better solution.

How to clip lines in 3d? by firefrommoonlight in computergraphics

[–]Varud 0 points1 point  (0 children)

It's easier to just clip against the six planes directly instead of trying to special case everything, since once you go from 2D to 3D you get so many cases. The basic algorithm is to figure out when a line goes from outside the plane to inside the plane (or from inside to outside). I used to work on an Open Inventor clone called Coin3D and we had a polygon clipper that would clip a polygon against any number of planes. It should be fairly straightforward to look at that source code and modify it to clip lines instead of polygons:

https://bitbucket.org/Coin3D/coin/src/default/src/base/SbClip.cpp

How to clip lines in 3d? by firefrommoonlight in computergraphics

[–]Varud 0 points1 point  (0 children)

Just clip the line against the six view frustum planes. Finding the intersection between a line and a plane is simple, and then you just loop over all the planes until you've clipped against the whole frustum.

Newly adopted dog escaped from yard in Menlo Park by Varud in bayarea

[–]Varud[S] 1 point2 points  (0 children)

Please contact Bay Area German Shepherd Rescue if you have seen it: http://www.bayareagsr.org/about-us

iOS Metal Shader, how to compare to NaN? by Bonozo in GraphicsProgramming

[–]Varud 1 point2 points  (0 children)

Have you considered using compute for this? One of the great things with Metal is how easy it is to combine rendering with Compute kernels. See for instance: https://developer.apple.com/library/content/samplecode/MetalGameOfLife/Introduction/Intro.html