Directx12- Texture always returns ZERO when the texture format is UINT - graphics

Recently,I am learning the SAT(summed area table) Varinance Shadow Mapping.It is suggested in the paper that I can use uint format SAT to prevent precision loss.So I change my SAT format from DXGI_FORMAT_R32G32_FLOAT to DXGI_FORMAT_R32G32_UINT.However, with the same code and shader except the texture format is different, the float format texture works fine, but the uint format texture always returns ZERO(I find this problem by using RenderDoc pixel debugger).This problem persists when I use Sample() method , Load() method and even compute shader!
I have tried many ways but nothing works.Please help me!!!!!!!!!
And I do not show any code here,because I have no idea about which part of code to show.
I am a Rookie just like my name.
So if you need some code,please tell me.Thanks a lot!!
If possible,please tell me some possible solutions of this problem. Thank you very much for your answers!

Related

Paraview bug when displaying vtkUniformGrid?

I am displaying a vtkUNiformGrid in Paraview, which contains (besides other things) 3-component flow vector in each point. When I display the dataset with volume rendering, it displays just fines. However, when I add Arrow glyph to the very same data, they do show the same data but elsewhere, smaller and in multiple copies (9 in number). Perhaps an images shows better what I mean:
I am a bit at loss as to where to look. Did I screw something up? Other ideas?
To help you debug, open a 2nd layout window and select Spreadsheet View, and look at the source on which you are applying the glyph filter. Is the vector data that you're trying to plot under PointData? Then check in the glyph filter properties that the Vectors drop down box indicates the array that you're trying to plot.
Just for the record, the cause was actually writing data into the vtkDoubleArray in a wrong way -- the array has 3 components and the indices were actually 1/3 of what they should have been, with x/y/z values interspersed (that gives the 3x3 pattern in the lower third, as I realized); I was assuming the components were stored contiguously, which is apparently not the case.
The old code was something like this:
auto flow=vtkSmartPointer<vtkDoubleArray>::New();
flow->SetNumberOfComponents(3);
auto grid=vtkSmartPointer<vtkUniformGrid>::New();
grid->SetDimensions(...);
grid->GetPointData()->AddArray(flow);
for(int i:{0,1,2}) flow->FillComponent(i,0);
for(ijk: ... /* traverses the grid, each point potentially more than once */ ){
vtkIdType dataId=grid->ComputePointId(ijk);
// XXX: this is what caused troubles:
double* f0=flow->GetPointer(dataId);
f[0]+=dx;
f[1]+=dy;
f[2]+=dz;
}
The correct version of the loop body is:
double f[3];
flow->GetTupleValue(dataId,f); // copy the data
f[0]+=dx;
f[1]+=dy;
f[2]+=dz;
flow->SetTupleValue(dataId,f);
Both scalar and vector datasets are now matching:

Is there any way to interpolate colors when using a structure grid in VTK?

I want to make a color map on vtkstructuredgrid and I need the colors to be interpolated between cells. The other option is using point data but when ever I use
structuredgrid->PointData()->SetScalars(Floatarray);
it says I cant have a pointer to a incomplete class type.
Any help would be greatly appreciated.
Your approach should work...
However, PointData is not a method, for the vtkStructuredGrid class: you should avoid (), and that's the reason for the error (Pointer to incomplete class type is not allowed).
Moreover, PointData is protected, in the "standard" definition of vtkStructuredGrid, and you should derive the entire class to access it from your code.
Before trying that, by the way, can you try with
structuredgrid->GetPointData()->SetScalars(Floatarray);
?
It should work too (not sure about the parameter type passed to SetScalar(), BTW).

How to draw pixels for ray-tracing in C++?

I'm currently trying to learn ray-tracing in C++. I am getting help from two books: one is Ray Tracing from the Ground Up by Kevin Suffern, and the other one is Physically Based Rendering by Matt Pharr. These two books are great for learning basics and, later, advanced stuff.
I could create some basic shapes using user interface of Suffern's book. However when I tried to write all code on my own, things have gone wild. I realized that I don't even know how to open a window and fill pixels on that. Do you have any good resource to recommend that could teach me the basics of drawing in C++.
You could generate image files instead of drawing to windows. The PPM format is the simplest one to generate. Browsers usually can display PPM. Safari does.
If you want to generate PNG files use libpng.
SDL might work for you: http://www.libsdl.org/
You can allocate your own image buffer, write your pixels to it, and then save to file/draw to window as needed. I expect the Pharr book has its own version of this tucked away somewhere, courtesy of Literate Programming.
More concretely: GUI API's and image file format libraries will typically be able to read simple image buffer data, stored in row-major array order. I would recommend an RGBA pixel format, something like the following:
template<class T> class image_rgba {
unsigned m_rows, m_cols;
T *m_data;
public:
image_rgba(unsigned rows, unsigned columns)
: m_rows(rows)
, m_cols(columns)
, m_data(new T[rows*columns*4])
{}
~image_rgba() { delete[] m_data; }
typedef T pixel[4];
pixel index_pixel_ref(unsigned row, unsigned col) {
assert(row<m_rows && col<m_cols);
return m_data + (m_cols*row+col)*4;
}
}
(note that I have not tested the above -- best to treat it as pseudocode...)

Appropriate use of CCTextureCache

I'm currently creating a CCSprite like this:
CCSprite *s = [CCSprite spriteWithFile:#"image.png"];
This sprite is the background image of a CCLayer that's used relatively often. Is the following use of CCTextureCache more efficient?
CCTexture2D *t = [[CCTextureCache sharedTextureCache] addImage:#"image.png"];
CCSprite *s = [CCSprite spriteWithTexture:t];
No. Internally, all methods that use an image as a texture (not just CCSprite) will add the texture to the CCTextureCache.
The only reason why you would want to use addImage directly is when you want to pre-load certain textures so that the first appearance of a node using that texture won't cause a lag during gameplay.
First of all, if you look to the code of spriteWithFile: method, you will see that it adds image to the texture cache anyway if cannot find it there.
The second thing you must know, that if you store your art in atlases for reducing memory usage(for example, atlas 2048x2048 pixels with 20 different pictures), spriteWithTexture: will create sprite with whole huge atlas(2048x2048 pixels) texture.

How to make basic line segments in LWJGL/OpenGL

I am in the process of learning LWJGL and also OpenGL. I have done the tutorials on quads, and also succesfully drawn polygons on a display. I am trying to draw lines using the same methods, but the lines are not created, or they are made invisible, possibly with a pixel width of 0? I have googled for an answer or a tutorial, but so far all of them seems to claim that I am doing the right thing. my method is as follows:
private void drawLine(Point point, Joint Point2) {
GL11.glColor3f(0.0f, 1.0f, 0.2f);
GL11.glBegin(GL11.GL_LINE);
GL11.glVertex2d(point.getX(), point.getY());
GL11.glVertex2d(point2.getX(), point2.getY());
GL11.glEnd();
}
I also tried to put this one in the middle, but no effect.
GL11.glLineWidth(3.8f);
As stated in the comments, The answer was that GL11.GL_LINE is not accepted as a constant in this case. GL11.LINE_STRIP however works like a charm.

Resources