I am using a pixel shader code that uses the Sample Function. I want to use SampleGrad and hence want to calculate the derivatives in my shader code. Is there a way to do the same?
Thanks.
Found an intrinsic function ddx and ddy to do the same. Thanks.
Related
I am using ggez rust crate, trying to develop 2d game. Currently I have a problem, where I want to flip image over x axes. So for example if character is looking in right direction, it would look left after transformation. Could not find anything useful in documentation. As I see DrawParam struct does not support this. Is there any way to achieve this?
The Image struct has a method draw in where you can pass some DrawParams. DrawParams can set scaled or transformed which you could use for that.
You would just need to scale by a negative factor, something like:
image.draw(ctx, draw_params.scale(Vector2::from_slice(&[-1f32, 1f32])));
I'd like to create a mipmap chain for a 2D texture by blitting the base image into mip levels. In Vulkan, vkCmdBlitImage can be used to do this while linearly filtering the image (see another question). How can I achieve the same in D3D12?
Afaik D3D12 has no such functionality and you're supposed to generate the mip map chain with a compute shader like this one from the MiniEngine in the DX samples provided by MS.
I'm using OpenCV calibrateCamera function to extract intrinsic end extrinsic parameters of my camera. I have a big problem with the extrinsic one (rotation and translation) because the rotation matrix, that should be a 3x3 matrix, it's only a 3x1. Does someone know why I have this output or how can I use it?
Thanks in advance!
You get a vector which is actually the axis-angle representation of your rotation. You can convert that in a 3x3 rotation matrix using the Rodrigues formula:
Rodrigues on Wikipedia
Rodrigues using OpenCV
I'm trying to implement marching cube algorythm in my geometry shader. So i place my datagrid into a Texture3D. Now i want to look up the data in the geometry shader and this trows an error "cannot map expression to gs_4_0 instruction set"
This is the line of code where he trows the error
cubeVale[0] = dataFieldTex.Sample( samPoint, float3(k, j, i)).a;
I hope someone can help me out here.
ty
Sample() only works in pixel shaders, since it automatically computes the mipmap lod to use by taking derivatives of the texture coordinates, and derivatives are only available in pixel shaders.
MSDN has a list of texture object methods and the shader profiles they work in. For the gs_4_0 profile your choices are Load(), SampleLevel() or SampleGrad(). You probably want SampleLevel(), especially if your Texture3D only has one mip level.
From what I understand, taking a polygon and breaking it up into composite triangles is called "tesselation". What's the opposite process called and can anyone link me to an algorithm for it?
Essentially, I have a list of 2D triangles and I need an algorithm to recombine them into a polygon.
Thanks!
I think you need to transform your triangles as a half edge data structure, and then you should be able to easily find the half edges which have no opposite.
It's called mesh decimation. Here is some code I wrote to do this for a class. Tibur is correct that the half edge data structure makes this much more efficient.
http://www.cs.virginia.edu/~mjh7v/advgfx/proj1/
The thing that you are calling tessellation is actually called triangulation. The thing you are searching for is tessellation (you may have heard of it referred to as tiling).
If you are more specific about the problem you are trying to solve (e.g. do you know the shape of the final polygon?) I can try to recommend some more specific algorithms.