小编Ego*_*rov的帖子

如何引用用于SCNTechnique的任意id <MTLTexture>?

TL; DR:

如何引用“不在磁盘上” sampler2D符号并将其传递给SCNTechnique?如果我从捆绑中引用图像,则我的技术有效,但如果不引用,则无法找到将现有id<MTLTexture>技术传递给我的技术已设置的采样器符号的方法。

长:

我有一个有效的工作SCNTechnique,它使用自定义的sampler2D符号作为金属碎片通道的输入。我试图传入id<MTLTexture>从硬件传感器获得的外部(不是来自Scenekit)作为后期处理过程中的输入。

跟随SCNShadable状态为docs的文档id<MTLTexture>可以通过SCNMaterialProperty具有正确内容集的an作为着色器输入传递。此100%可在着色器修改器传递中使用-但失败了SCNTecnique

let texture = CVMetalTextureGetTexture(textureRef!)

if self.material == nil
{
    self.material = SCNMaterialProperty(contents:texture)
}
else
{
    self.material?.contents = texture
}

self.currentTechnique?.setObject(self.material, forKeyedSubscript: "myTextureSamplerSymbol" as NSCopying)
Run Code Online (Sandbox Code Playgroud)

对于a SCNTechnique,我得到了错误日志,指示“纹理没有存储”,Metal GPU帧捕获指示为采样器设置了默认的4x4像素白色纹理(大概是从SCNTecnique?开始)。但是,我已经能够验证我的自定义设置id<MTLTexture>是否有效并且调试器中是否包含内容-其格式,宽度,高度和内容均符合预期,我只是似乎无法在场景工具包技术中引用任意纹理正确通过。

如果我在SCNTechniqueplist文件中声明我的符号以引用如下图像:

<dict>
    <key>type</key>
    <string>sampler2D</string>
    <key>image</key>
    <string>star.png</string>
</dict>
Run Code Online (Sandbox Code Playgroud)

我的通行证输入如下:

<dict>
    <key>colorSampler</key>
    <string>COLOR</string>
    <key>depthSampler</key>
    <string>DEPTH</string>
    <key> myTextureSampler</key>
    <dict>
        <key>target</key>
        <string> myTextureSamplerSymbol </string>
    </dict>
</dict>
Run Code Online (Sandbox Code Playgroud)

然后,我的通行证开始工作,并且引用了star.png纹理。 …

3d shader scenekit metal

5
推荐指数
1
解决办法
153
查看次数

特征3 - 切割MatrixXd以反转列顺序

我需要使用RcppEigen来反转MatrixXd的列的顺序.

R我只想做

> M = matrix(1:9, ncol = 3)
> M
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> M = M[, 3:1]
> M
     [,1] [,2] [,3]
[1,]    7    4    1
[2,]    8    5    2
[3,]    9    6    3
Run Code Online (Sandbox Code Playgroud)

C++使用Eigen时我可以用循环来做

Eigen::MatrixXd m1(3, 3);
Eigen::MatrixXd m2(3, 3);
m1 << 1, 4, 7,
      2, 5, 8,
      3, 6, 9;

for (int i = 0; i < 3; i++){
    m2.col(i) …
Run Code Online (Sandbox Code Playgroud)

c++ r rcpp eigen3

3
推荐指数
1
解决办法
1191
查看次数

How to import Metal in objective-c?

I tried to use metal_stdlib, or import MetalKit, but it shows metal_stdlib file not found, and MetalKit didn't get rid of any error such as

Unknown type name 'MTLDevice'; did you mean 'GDevice'?
Run Code Online (Sandbox Code Playgroud)

So how can import Metal framework? I also want to use MPSMatrix.

objective-c metal

3
推荐指数
1
解决办法
645
查看次数

如何将可变数量的纹理绑定到金属着色器?

MTLTexture在 CPU 上,我正在收集要发送到片段着色器的对象数组。在任何给定时刻可以有任意数量的这些纹理。如何将MTLTextures 的可变长度数组发送到片段着色器?

示例。)CPU:

var txrs: [MTLTexture] = []
for ... {
   txrs.append(...)
}
// Send array of textures to fragment shader.
Run Code Online (Sandbox Code Playgroud)

图形处理器:

fragment half4 my_fragment(Vertex v [[stage_in]], <array of textures>, ...) {
   ...
   for(int i = 0; i < num_textures; i++) {
      texture2d<half> txr = array_of_textures[i];
   }
   ...
}
Run Code Online (Sandbox Code Playgroud)

graphics ios swift metal metalkit

3
推荐指数
1
解决办法
1046
查看次数

调用 StreamReader.ReadLineAsync 后 Stream.Position 不会更改

当我创建尝试读取这样的行时,Stream.Position 在第一次调用 StreamReader.ReadLineAsync 后会更改一次,然后在多次调用后不会更改。

var stream = new FileStream(
filename,
FileMode.Open, FileAccess.Read, FileShare.Read,
bufferSize: 4096, useAsync: true);

using (var sr = new StreamReader(stream))
{
    while(stream.Position <= stream.Length)
    {
        var pos = stream.Position;
        var line = sr.ReadLineAsync().Result;
        Console.WriteLine("{0}: {1}", pos, line);
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行这个时,给定输入

1 2 3
4 5 6
7 8 9
10 11 12
Run Code Online (Sandbox Code Playgroud)

它给了我输出

0: 1 2 3
29: 4 5 6
29: 7 8 9
29: 10 11 12
29: 
29: 
Run Code Online (Sandbox Code Playgroud)

等等。

.net c# asynchronous stream

2
推荐指数
1
解决办法
957
查看次数

整数或双精度1.0和1

我想读取一个双精度数字并确定输入是Integer还是double。问题是当我输入1.00(是双精度)时,我得到的结果是整数

double a;
cin >> a;
if (a == int(a))
    cout << "Integer";
else
    cout << "Double";
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
157
查看次数

编译器忽略运算符的新分配

我在C ++中编写一个512位整数。对于整数,我使用new关键字从堆中分配内存,但是编译器(MINGW上的g ++版本8.1)似乎错误地对其进行了优化。即编译器命令是:

g++ -Wall -fexceptions -Og -g -fopenmp -std=c++14 -c main.cpp -o main.o

g++ -o bin\Debug\cs.exe obj\Debug\main.o -O0 -lgomp

码:

#include <iostream>
#include <cstdint>
#include <omp.h>

constexpr unsigned char arr_size = 16;
constexpr unsigned char arr_size_half = 8;
void exit(int);

struct uint512_t{
    uint32_t * bytes;
    uint512_t(uint32_t num){
        //The line below is either (wrongfully) ignored or (wrongfully) optimized out
        bytes = new(std::nothrow) uint32_t[arr_size];
        if(!bytes){
            std::cerr << "Error - not enough memory available.";
            exit(-1);
        }
        *bytes = num;
        for(uint32_t …
Run Code Online (Sandbox Code Playgroud)

c++ g++ new-operator

0
推荐指数
2
解决办法
61
查看次数

标签 统计

c++ ×3

metal ×3

.net ×1

3d ×1

asynchronous ×1

c# ×1

eigen3 ×1

g++ ×1

graphics ×1

ios ×1

metalkit ×1

new-operator ×1

objective-c ×1

r ×1

rcpp ×1

scenekit ×1

shader ×1

stream ×1

swift ×1