HLSL中Texture的操作函式

2021-09-02 16:49:40 字數 1005 閱讀 1603

最常用的乙個函式是sample

sample( sampler_state s, float location [, int offset] );

sampler_state 可以從外部的buffer傳過來,也可以是hlsl內定義,一般情況下都選擇從外部設定進行共享。

location應該穿入的是uv資料,不同的型別有不同的uv型別

texture-object type	parameter type

texture1d float

texture1darray, texture2d float2

texture2darray, texture3d, texturecube float3

texturecubearray float4

offset是可選引數,不填則是預設的0,0

texture-object type	parameter type

texture1d, texture1darray int

texture2d, texture2darray int2

texture3d int3

texturecube, texturecubearray //

not supported

// object declarations

texture2d g_meshtexture;

// color texture for mesh

samplerstate meshtexturesampler

;struct vs_output

;vs_output in;

// pixel shader函式體..

. output.rgbcolor = g_meshtexture.

sample

(meshtexturesampler, in.textureuv)

* in.diffuse;

Ogre中控制HLSL引數

首先在定義hlsl材質檔案中新增需要控制的引數,如 cpp view plain copy fragment program test fs hlsl 然後在hlsl檔案中宣告這個引數,如 cpp view plain copy uniform float testparam 最後在應用程式中修改這...

unity 中Texture大小與占用記憶體關係

例子1 使用rgba 32bit真彩 truecolor 占用記憶體 4bytes 512 512 1mb 例子2 使用rgb etc 4bit壓縮,占用記憶體 0.5bytes 512 512 128kb。即8位 bit 的圖 占用記憶體 1bytes 大小 那麼 乙個1024 1024大小 32...

HLSL有關的基礎知識

主要是最近在學習xna中有關一些效果的東西,發現了官網上的2d的一些fx效果相當好。其 給出如下鏈結 然後就查了一下hlsl這個範例裡面的fx還都不算太難,可以理解。乙個簡單的hlsl程式,返回乙個材質的各點的顏色。sampler s0 register s0 float4 main float2 ...